Skip to content

Commit 0790844

Browse files
Merge pull request #1122 from acamacho82/issues1117
Two PCIe items can be added at order time
2 parents 8bd5e0a + 05b9723 commit 0790844

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

SoftLayer/managers/ordering.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,8 @@ def get_price_id_list(self, package_keyname, item_keynames, core=None):
340340
items = self.list_items(package_keyname, mask=mask)
341341

342342
prices = []
343-
gpu_number = -1
343+
category_dict = {"gpu0": -1, "pcie_slot0": -1}
344+
344345
for item_keyname in item_keynames:
345346
try:
346347
# Need to find the item in the package that has a matching
@@ -356,15 +357,17 @@ def get_price_id_list(self, package_keyname, item_keynames, core=None):
356357
# because that is the most generic price. verifyOrder/placeOrder
357358
# can take that ID and create the proper price for us in the location
358359
# in which the order is made
359-
if matching_item['itemCategory']['categoryCode'] != "gpu0":
360+
item_category = matching_item['itemCategory']['categoryCode']
361+
if item_category not in category_dict:
360362
price_id = self.get_item_price_id(core, matching_item['prices'])
361363
else:
362-
# GPU items has two generic prices and they are added to the list
363-
# according to the number of gpu items added in the order.
364-
gpu_number += 1
364+
# GPU and PCIe items has two generic prices and they are added to the list
365+
# according to the number of items in the order.
366+
category_dict[item_category] += 1
367+
category_code = item_category[:-1] + str(category_dict[item_category])
365368
price_id = [p['id'] for p in matching_item['prices']
366369
if not p['locationGroupId']
367-
and p['categories'][0]['categoryCode'] == "gpu" + str(gpu_number)][0]
370+
and p['categories'][0]['categoryCode'] == category_code][0]
368371

369372
prices.append(price_id)
370373

0 commit comments

Comments
 (0)