Skip to content

Commit 8056e81

Browse files
author
Fernando Ojeda
committed
Refactored suspend cloud server order
1 parent f5da2d6 commit 8056e81

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

SoftLayer/managers/ordering.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ def get_preset_by_key(self, package_keyname, preset_keyname, mask=None):
322322

323323
return presets[0]
324324

325-
def get_price_id_list(self, package_keyname, item_keynames, core):
325+
def get_price_id_list(self, package_keyname, item_keynames, core=None):
326326
"""Converts a list of item keynames to a list of price IDs.
327327
328328
This function is used to convert a list of item keynames into
@@ -377,12 +377,13 @@ def get_price_id_list(self, package_keyname, item_keynames, core):
377377
def get_item_price_id(core, price, price_id):
378378
"""get item price id"""
379379
category_code = []
380-
if 'capacityRestrictionMinimum' not in price:
380+
capacity_min = int(price.get('capacityRestrictionMinimum', -1))
381+
capacity_max = int(price.get('capacityRestrictionMaximum', -1))
382+
if capacity_min is -1:
381383
if price['categories'][0]['categoryCode'] not in category_code:
382384
category_code.append(price['categories'][0]['categoryCode'])
383385
price_id = price['id']
384-
elif int(price['capacityRestrictionMinimum']) <= int(core) <= int(
385-
price['capacityRestrictionMaximum']):
386+
elif capacity_min <= int(core) <= capacity_max:
386387
if price['categories'][0]['categoryCode'] not in category_code:
387388
category_code.append(price['categories'][0]['categoryCode'])
388389
price_id = price['id']

0 commit comments

Comments
 (0)