Skip to content

Commit d7aec15

Browse files
Merge pull request #1196 from FernandoOjeda/fo_quote_file_storage
Fix quote file storage.
2 parents 4c341bf + 2274cf0 commit d7aec15

File tree

2 files changed

+42
-5
lines changed

2 files changed

+42
-5
lines changed

SoftLayer/managers/ordering.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,9 @@ def get_item_price_id(core, prices):
405405
price_id = price['id']
406406
# this check is mostly to work nicely with preset configs
407407
elif capacity_min <= int(core) <= capacity_max:
408-
price_id = price['id']
408+
if "STORAGE" in price.get("capacityRestrictionType") or "CORE" in price.get(
409+
"capacityRestrictionType"):
410+
price_id = price['id']
409411
return price_id
410412

411413
def get_item_capacity(self, items, item_keynames):
@@ -417,6 +419,9 @@ def get_item_capacity(self, items, item_keynames):
417419
if "GUEST_CORE" in item["keyName"]:
418420
item_capacity = item['capacity']
419421
break
422+
if "TIER" in item["keyName"]:
423+
item_capacity = item['capacity']
424+
break
420425
return item_capacity
421426

422427
def get_preset_prices(self, preset):

tests/managers/ordering_tests.py

Lines changed: 36 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -640,12 +640,27 @@ def test_get_item_price_id_without_capacity_restriction(self):
640640

641641
self.assertEqual(1234, price_id)
642642

643-
def test_get_item_price_id_with_capacity_restriction(self):
643+
def test_get_item_price_id_core_with_capacity_restriction(self):
644644
category1 = {'categoryCode': 'cat1'}
645645
price1 = [{'id': 1234, 'locationGroupId': '', "capacityRestrictionMaximum": "16",
646-
"capacityRestrictionMinimum": "1", 'categories': [category1]},
646+
"capacityRestrictionMinimum": "1", "capacityRestrictionType": "CORE",
647+
'categories': [category1]},
647648
{'id': 2222, 'locationGroupId': '', "capacityRestrictionMaximum": "56",
648-
"capacityRestrictionMinimum": "36", 'categories': [category1]}]
649+
"capacityRestrictionMinimum": "36", "capacityRestrictionType": "CORE",
650+
'categories': [category1]}]
651+
652+
price_id = self.ordering.get_item_price_id("8", price1)
653+
654+
self.assertEqual(1234, price_id)
655+
656+
def test_get_item_price_id_storage_with_capacity_restriction(self):
657+
category1 = {'categoryCode': 'cat1'}
658+
price1 = [{'id': 1234, 'locationGroupId': '', "capacityRestrictionMaximum": "16",
659+
"capacityRestrictionMinimum": "1", "capacityRestrictionType": "STORAGE_SPACE",
660+
'categories': [category1]},
661+
{'id': 2222, 'locationGroupId': '', "capacityRestrictionMaximum": "56",
662+
"capacityRestrictionMinimum": "36", "capacityRestrictionType": "STORAGE_SPACE",
663+
'categories': [category1]}]
649664

650665
price_id = self.ordering.get_item_price_id("8", price1)
651666

@@ -696,7 +711,7 @@ def test_clean_quote_verify(self):
696711
self.assertNotIn('testProperty', order_container)
697712
self.assertNotIn('reservedCapacityId', order_container)
698713

699-
def test_get_item_capacity(self):
714+
def test_get_item_capacity_core(self):
700715

701716
items = [{
702717
"capacity": "1",
@@ -712,3 +727,20 @@ def test_get_item_capacity(self):
712727
item_capacity = self.ordering.get_item_capacity(items, ['GUEST_CORE_1_DEDICATED', 'OS_RHEL_7_X_LAMP_64_BIT'])
713728

714729
self.assertEqual(1, int(item_capacity))
730+
731+
def test_get_item_capacity_storage(self):
732+
733+
items = [{
734+
"capacity": "1",
735+
"id": 6131,
736+
"keyName": "STORAGE_SPACE_FOR_2_IOPS_PER_GB",
737+
},
738+
{
739+
"capacity": "1",
740+
"id": 10201,
741+
"keyName": "READHEAVY_TIER",
742+
}]
743+
744+
item_capacity = self.ordering.get_item_capacity(items, ['READHEAVY_TIER', 'STORAGE_SPACE_FOR_2_IOPS_PER_GB'])
745+
746+
self.assertEqual(1, int(item_capacity))

0 commit comments

Comments
 (0)