Skip to content

Commit 1c7efeb

Browse files
sudorandomKevin McDonald
authored andcommitted
Two Bug Fixes
Fixes key error when vlans don't have datacenters Gives a better error for when a price can't be found for iscsi. Resolves softlayer#549 and softlayer#552
1 parent 8f4629a commit 1c7efeb

2 files changed

Lines changed: 10 additions & 3 deletions

File tree

SoftLayer/CLI/vlan/list.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import SoftLayer
55
from SoftLayer.CLI import environment
66
from SoftLayer.CLI import formatting
7+
from SoftLayer import utils
78

89

910
import click
@@ -43,7 +44,7 @@ def cli(env, sortby, datacenter, number, name):
4344
table.add_row([
4445
vlan['id'],
4546
vlan['vlanNumber'],
46-
vlan['primaryRouter']['datacenter']['name'],
47+
utils.lookup(vlan, 'primaryRouter', 'datacenter', 'name'),
4748
vlan.get('name') or formatting.blank(),
4849
vlan['totalPrimaryIpAddressCount'],
4950
len(vlan['hardware']),

SoftLayer/managers/iscsi.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
66
:license: MIT, see LICENSE for more details.
77
"""
8+
from SoftLayer import exceptions
89
from SoftLayer import utils
910

1011

@@ -28,8 +29,13 @@ def _find_item_prices(self, size, categorycode=''):
2829
'categories': {
2930
'categoryCode': {'operation': categorycode}
3031
}}})
31-
item_price = item_prices[0]['prices'][0]['id']
32-
return item_price
32+
33+
for item_price in item_prices:
34+
for price in item_price['prices']:
35+
return price['id']
36+
37+
raise exceptions.SoftLayerError(
38+
"Could not find a valid price with for the given size")
3339

3440
def _build_order(self, item_price, location):
3541
"""Returns a dict appropriate for Product_Order::placeOrder()."""

0 commit comments

Comments
 (0)