Skip to content

Commit 31c1dad

Browse files
author
Fernando Ojeda
committed
Refactor order place quantity option.
1 parent ee8fe37 commit 31c1dad

File tree

2 files changed

+5
-8
lines changed

2 files changed

+5
-8
lines changed

SoftLayer/CLI/order/place.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
help="Flag denoting whether or not to only verify the order, not place it")
2626
@click.option('--quantity',
2727
type=int,
28+
default=1,
2829
help="The quantity of the item being ordered")
2930
@click.option('--billing',
3031
type=click.Choice(['hourly', 'monthly']),

SoftLayer/managers/ordering.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,7 @@ def get_item_prices(self, package_id):
415415
return prices
416416

417417
def verify_order(self, package_keyname, location, item_keynames, complex_type=None,
418-
hourly=True, preset_keyname=None, extras=None, quantity=None):
418+
hourly=True, preset_keyname=None, extras=None, quantity=1):
419419
"""Verifies an order with the given package and prices.
420420
421421
This function takes in parameters needed for an order and verifies the order
@@ -446,7 +446,7 @@ def verify_order(self, package_keyname, location, item_keynames, complex_type=No
446446
return self.order_svc.verifyOrder(order)
447447

448448
def place_order(self, package_keyname, location, item_keynames, complex_type=None,
449-
hourly=True, preset_keyname=None, extras=None, quantity=None):
449+
hourly=True, preset_keyname=None, extras=None, quantity=1):
450450
"""Places an order with the given package and prices.
451451
452452
This function takes in parameters needed for an order and places the order.
@@ -509,7 +509,7 @@ def place_quote(self, package_keyname, location, item_keynames, complex_type=Non
509509
return self.order_svc.placeQuote(order)
510510

511511
def generate_order(self, package_keyname, location, item_keynames, complex_type=None,
512-
hourly=True, preset_keyname=None, extras=None, quantity=None):
512+
hourly=True, preset_keyname=None, extras=None, quantity=1):
513513
"""Generates an order with the given package and prices.
514514
515515
This function takes in parameters needed for an order and generates an order
@@ -545,6 +545,7 @@ def generate_order(self, package_keyname, location, item_keynames, complex_type=
545545
# 'domain': 'softlayer.com'}]}
546546
order.update(extras)
547547
order['packageId'] = package['id']
548+
order['quantity'] = quantity
548549
order['location'] = self.get_location_id(location)
549550
order['useHourlyPricing'] = hourly
550551

@@ -561,11 +562,6 @@ def generate_order(self, package_keyname, location, item_keynames, complex_type=
561562
raise exceptions.SoftLayerError("A complex type must be specified with the order")
562563
order['complexType'] = complex_type
563564

564-
if not quantity:
565-
order['quantity'] = 1
566-
else:
567-
order['quantity'] = quantity
568-
569565
price_ids = self.get_price_id_list(package_keyname, item_keynames, preset_core)
570566
order['prices'] = [{'id': price_id} for price_id in price_ids]
571567

0 commit comments

Comments
 (0)