Skip to content

Commit a3f2c58

Browse files
committed
previous issues were fixed, now the place quote method creates a quote with pending status
1 parent e7f4f57 commit a3f2c58

File tree

3 files changed

+50
-48
lines changed

3 files changed

+50
-48
lines changed
Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,39 @@
1-
"""Save an order as quote"""
1+
"""Place quote"""
22
# :license: MIT, see LICENSE for more details.
33

44
import json
55

66
import click
77

88
from SoftLayer.CLI import environment
9-
from SoftLayer.CLI import exceptions
109
from SoftLayer.CLI import formatting
1110
from SoftLayer.managers import ordering
1211

13-
COLUMNS = ['keyName',
14-
'description',
15-
'cost', ]
1612

1713
@click.command()
1814
@click.argument('package_keyname')
1915
@click.argument('location')
2016
@click.option('--preset',
2117
help="The order preset (if required by the package)")
2218
@click.option('--name',
23-
help="Quote name (optional)")
19+
help="A custom name to be assigned to the quote (optional)")
2420
@click.option('--send-email',
2521
is_flag=True,
26-
help="Quote will be sent to the email address")
22+
help="The quote will be sent to the email address associated.")
2723
@click.option('--complex-type', help=("The complex type of the order. This typically begins"
2824
" with 'SoftLayer_Container_Product_Order_'."))
2925
@click.option('--extras',
3026
help="JSON string denoting extra data that needs to be sent with the order")
3127
@click.argument('order_items', nargs=-1)
3228
@environment.pass_env
33-
def cli(env, package_keyname, location, preset, name, email, complex_type,
29+
def cli(env, package_keyname, location, preset, name, send_email, complex_type,
3430
extras, order_items):
35-
"""Save an order as quote.
31+
"""Place a quote.
3632
37-
This CLI command is used for saving an order in quote of the specified package in
33+
This CLI command is used for placing a quote of the specified package in
3834
the given location (denoted by a datacenter's long name). Orders made via the CLI
3935
can then be converted to be made programmatically by calling
40-
SoftLayer.OrderingManager.place_order() with the same keynames.
36+
SoftLayer.OrderingManager.place_quote() with the same keynames.
4137
4238
Packages for ordering can be retrieved from `slcli order package-list`
4339
Presets for ordering can be retrieved from `slcli order preset-list` (not all packages
@@ -49,9 +45,9 @@ def cli(env, package_keyname, location, preset, name, email, complex_type,
4945
5046
\b
5147
Example:
52-
# Order an hourly VSI with 4 CPU, 16 GB RAM, 100 GB SAN disk,
48+
# Place quote a VSI with 4 CPU, 16 GB RAM, 100 GB SAN disk,
5349
# Ubuntu 16.04, and 1 Gbps public & private uplink in dal13
54-
slcli order quote --name " My quote name" --email CLOUD_SERVER DALLAS13 \\
50+
slcli order place-quote --name " My quote name" --send-email CLOUD_SERVER DALLAS13 \\
5551
GUEST_CORES_4 \\
5652
RAM_16_GB \\
5753
REBOOT_REMOTE_CONSOLE \\
@@ -78,16 +74,18 @@ def cli(env, package_keyname, location, preset, name, email, complex_type,
7874
kwargs = {'preset_keyname': preset,
7975
'extras': extras,
8076
'quantity': 1,
81-
'quoteName': name,
82-
'sendQuoteEmailFlag': email,
77+
'quote_name': name,
78+
'send_email': send_email,
8379
'complex_type': complex_type}
8480

85-
order = manager.save_quote(*args, **kwargs)
81+
order = manager.place_quote(*args, **kwargs)
8682

8783
table = formatting.KeyValueTable(['name', 'value'])
8884
table.align['name'] = 'r'
8985
table.align['value'] = 'l'
90-
table.add_row(['id', order['orderId']])
86+
table.add_row(['id', order['quote']['id']])
87+
table.add_row(['name', order['quote']['name']])
9188
table.add_row(['created', order['orderDate']])
92-
table.add_row(['status', order['placedOrder']['status']])
93-
env.fout(table)
89+
table.add_row(['expires', order['quote']['expirationDate']])
90+
table.add_row(['status', order['quote']['status']])
91+
env.fout(table)

SoftLayer/CLI/routes.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,7 @@
210210
('order:place', 'SoftLayer.CLI.order.place:cli'),
211211
('order:preset-list', 'SoftLayer.CLI.order.preset_list:cli'),
212212
('order:package-locations', 'SoftLayer.CLI.order.package_locations:cli'),
213+
('order:place-quote', 'SoftLayer.CLI.order.place_quote:cli'),
213214

214215
('rwhois', 'SoftLayer.CLI.rwhois'),
215216
('rwhois:edit', 'SoftLayer.CLI.rwhois.edit:cli'),

SoftLayer/managers/ordering.py

Lines changed: 32 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -430,36 +430,39 @@ def place_order(self, package_keyname, location, item_keynames, complex_type=Non
430430
extras=extras, quantity=quantity)
431431
return self.order_svc.placeOrder(order)
432432

433-
def save_quote(self, package_keyname, location, item_keynames, complex_type=None,
434-
preset_keyname=None, extras=None, quantity=1):
435-
436-
"""Save an order as Quote with the given package and prices.
437-
438-
This function takes in parameters needed for an order and places the order.
439-
440-
:param str package_keyname: The keyname for the package being ordered
441-
:param str location: The datacenter location string for ordering (Ex: DALLAS13)
442-
:param list item_keynames: The list of item keyname strings to order. To see list of
443-
possible keynames for a package, use list_items()
444-
(or `slcli order item-list`)
445-
:param str complex_type: The complex type to send with the order. Typically begins
446-
with `SoftLayer_Container_Product_Order_`.
447-
:param string preset_keyname: If needed, specifies a preset to use for that package.
448-
To see a list of possible keynames for a package, use
449-
list_preset() (or `slcli order preset-list`)
450-
:param dict extras: The extra data for the order in dictionary format.
451-
Example: A VSI order requires hostname and domain to be set, so
452-
extras will look like the following:
453-
{'virtualGuests': [{'hostname': 'test', domain': 'softlayer.com'}]}
454-
:param int quantity: The number of resources to order
455-
456-
"""
457-
order = self.generate_order(package_keyname, location, item_keynames,
458-
complex_type=complex_type, hourly=False,
459-
preset_keyname=preset_keyname,
460-
extras=extras, quantity=quantity)
461-
return self.order_svc.placeOrder(order, True)
433+
def place_quote(self, package_keyname, location, item_keynames, complex_type=None,
434+
preset_keyname=None, extras=None, quantity=1, quote_name=None, send_email=False):
435+
436+
"""Place a quote with the given package and prices.
437+
438+
This function takes in parameters needed for an order and places the quote.
439+
440+
:param str package_keyname: The keyname for the package being ordered
441+
:param str location: The datacenter location string for ordering (Ex: DALLAS13)
442+
:param list item_keynames: The list of item keyname strings to order. To see list of
443+
possible keynames for a package, use list_items()
444+
(or `slcli order item-list`)
445+
:param str complex_type: The complex type to send with the order. Typically begins
446+
with `SoftLayer_Container_Product_Order_`.
447+
:param string preset_keyname: If needed, specifies a preset to use for that package.
448+
To see a list of possible keynames for a package, use
449+
list_preset() (or `slcli order preset-list`)
450+
:param dict extras: The extra data for the order in dictionary format.
451+
Example: A VSI order requires hostname and domain to be set, so
452+
extras will look like the following:
453+
{'virtualGuests': [{'hostname': 'test', domain': 'softlayer.com'}]}
454+
:param int quantity: The number of resources to order
455+
:param string quote_name: A custom name to be assigned to the quote (optional).
456+
:param bool send_email: This flag indicates that the quote should be sent to the email
457+
address associated with the account or order.
458+
"""
459+
order = self.generate_order(package_keyname, location, item_keynames, complex_type=complex_type,
460+
hourly=False, preset_keyname=preset_keyname, extras=extras, quantity=quantity)
461+
462+
order['quoteName'] = quote_name
463+
order['sendQuoteEmailFlag'] = send_email
462464

465+
return self.order_svc.placeQuote(order)
463466

464467
def generate_order(self, package_keyname, location, item_keynames, complex_type=None,
465468
hourly=True, preset_keyname=None, extras=None, quantity=1):

0 commit comments

Comments
 (0)