Skip to content

Commit fe4a2f6

Browse files
author
Fernando Ojeda
committed
Add functionality to order a hw for capacityRestrictionType PROCCESOR.
1 parent 5a0a8f3 commit fe4a2f6

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

SoftLayer/managers/ordering.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ def get_item_price_id(core, prices):
396396
capacity_min = int(price.get('capacityRestrictionMinimum', -1))
397397
capacity_max = int(price.get('capacityRestrictionMaximum', -1))
398398
# return first match if no restirction, or no core to check
399-
if capacity_min == -1 or core is None:
399+
if capacity_min == -1 or core is None or "PROCESSOR" in price.get("capacityRestrictionType"):
400400
price_id = price['id']
401401
# this check is mostly to work nicely with preset configs
402402
elif capacity_min <= int(core) <= capacity_max:

tests/managers/ordering_tests.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -666,6 +666,16 @@ def test_get_item_price_id_storage_with_capacity_restriction(self):
666666

667667
self.assertEqual(1234, price_id)
668668

669+
def test_get_item_price_id_processor_with_capacity_restriction(self):
670+
category1 = {'categoryCode': 'cat1'}
671+
price1 = [{'id': 1234, 'locationGroupId': '', "capacityRestrictionMaximum": "1",
672+
"capacityRestrictionMinimum": "1", "capacityRestrictionType": "PROCESSOR",
673+
'categories': [category1]}]
674+
675+
price_id = self.ordering.get_item_price_id("8", price1)
676+
677+
self.assertEqual(1234, price_id)
678+
669679
def test_issues1067(self):
670680
# https://github.com/softlayer/softlayer-python/issues/1067
671681
item_mock = self.set_mock('SoftLayer_Product_Package', 'getItems')

0 commit comments

Comments
 (0)