Skip to content

Commit 51f7869

Browse files
#1038 allowed 'NONE' to be used as a location if needed
1 parent e3a1337 commit 51f7869

3 files changed

Lines changed: 25 additions & 31 deletions

File tree

SoftLayer/CLI/order/place.py

Lines changed: 18 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -42,40 +42,26 @@ def cli(env, package_keyname, location, preset, verify, billing, complex_type,
4242
quantity, extras, order_items):
4343
"""Place or verify an order.
4444
45-
This CLI command is used for placing/verifying an order of the specified package in
46-
the given location (denoted by a datacenter's long name). Orders made via the CLI
47-
can then be converted to be made programmatically by calling
48-
SoftLayer.OrderingManager.place_order() with the same keynames.
49-
50-
Packages for ordering can be retrieved from `slcli order package-list`
51-
Presets for ordering can be retrieved from `slcli order preset-list` (not all packages
52-
have presets)
53-
54-
Items can be retrieved from `slcli order item-list`. In order to find required
55-
items for the order, use `slcli order category-list`, and then provide the
56-
--category option for each category code in `slcli order item-list`.
57-
45+
\b
46+
1. Find the package keyName from `slcli order package-list`
47+
2. Find the location from `slcli order package-locations PUBLIC_CLOUD_SERVER`
48+
If the package does not require a location, use 'NONE' instead.
49+
3. Find the needed items `slcli order item-list PUBLIC_CLOUD_SERVER`
50+
Some packages, like PUBLIC_CLOUD_SERVER need presets, `slcli order preset-list PUBLIC_CLOUD_SERVER`
51+
4. Find the complex type from https://sldn.softlayer.com/reference
52+
5. Use that complex type to fill out any --extras
5853
5954
Example::
6055
61-
# Order an hourly VSI with 4 CPU, 16 GB RAM, 100 GB SAN disk,
62-
# Ubuntu 16.04, and 1 Gbps public & private uplink in dal13
63-
slcli order place --billing hourly CLOUD_SERVER DALLAS13 \\
64-
GUEST_CORES_4 \\
65-
RAM_16_GB \\
66-
REBOOT_REMOTE_CONSOLE \\
67-
1_GBPS_PUBLIC_PRIVATE_NETWORK_UPLINKS \\
68-
BANDWIDTH_0_GB_2 \\
69-
1_IP_ADDRESS \\
70-
GUEST_DISK_100_GB_SAN \\
71-
OS_UBUNTU_16_04_LTS_XENIAL_XERUS_MINIMAL_64_BIT_FOR_VSI \\
72-
MONITORING_HOST_PING \\
73-
NOTIFICATION_EMAIL_AND_TICKET \\
74-
AUTOMATED_NOTIFICATION \\
75-
UNLIMITED_SSL_VPN_USERS_1_PPTP_VPN_USER_PER_ACCOUNT \\
76-
NESSUS_VULNERABILITY_ASSESSMENT_REPORTING \\
77-
--extras '{"virtualGuests": [{"hostname": "test", "domain": "softlayer.com"}]}' \\
78-
--complex-type SoftLayer_Container_Product_Order_Virtual_Guest
56+
slcli order place --verify --preset B1_2X8X100 --billing hourly
57+
--complex-type SoftLayer_Container_Product_Order_Virtual_Guest
58+
--extras '{"virtualGuests": [{"hostname": "test", "domain": "ibm.com"}]}'
59+
PUBLIC_CLOUD_SERVER DALLAS13
60+
BANDWIDTH_0_GB_2 MONITORING_HOST_PING NOTIFICATION_EMAIL_AND_TICKET
61+
OS_DEBIAN_9_X_STRETCH_LAMP_64_BIT 1_IP_ADDRESS 1_IPV6_ADDRESS
62+
1_GBPS_PUBLIC_PRIVATE_NETWORK_UPLINKS REBOOT_REMOTE_CONSOLE
63+
AUTOMATED_NOTIFICATION UNLIMITED_SSL_VPN_USERS_1_PPTP_VPN_USER_PER_ACCOUNT
64+
NESSUS_VULNERABILITY_ASSESSMENT_REPORTING
7965
8066
"""
8167
manager = ordering.OrderingManager(env.client)
@@ -118,3 +104,4 @@ def cli(env, package_keyname, location, preset, verify, billing, complex_type,
118104
table.add_row(['created', order['orderDate']])
119105
table.add_row(['status', order['placedOrder']['status']])
120106
env.fout(table)
107+

SoftLayer/managers/ordering.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -634,6 +634,9 @@ def get_location_id(self, location):
634634

635635
if isinstance(location, int):
636636
return location
637+
# Some orders dont require a location, just use 0
638+
if location.upper() == "NONE":
639+
return 0
637640
mask = "mask[id,name,regions[keyname]]"
638641
if match(r'[a-zA-Z]{3}[0-9]{2}', location) is not None:
639642
search = {'name': {'operation': location}}

tests/managers/ordering_tests.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -594,6 +594,10 @@ def test_get_location_id_int(self):
594594
dc_id = self.ordering.get_location_id(1234)
595595
self.assertEqual(1234, dc_id)
596596

597+
def test_get_location_id_NONE(self):
598+
dc_id = self.ordering.get_location_id("NONE")
599+
self.assertEqual(0, dc_id)
600+
597601
def test_location_group_id_none(self):
598602
# RestTransport uses None for empty locationGroupId
599603
category1 = {'categoryCode': 'cat1'}

0 commit comments

Comments
 (0)