Skip to content

Conversation

FernandoOjeda
Copy link
Contributor

@FernandoOjeda FernandoOjeda commented Mar 20, 2019

Fix order place quantity option #1116.

>slcli order place --help

Options:
  --preset TEXT                         The order preset (if required by the package)
  --verify                              Flag denoting whether or not to only verify the order, not place it
  --quantity INTEGER                    The quantity of the item being ordered
  --billing [hourly|monthly]            Billing rate  [default: hourly]
  --complex-type TEXT                   The complex type of the order. This typically begins with                                                       'SoftLayer_Container_Product_Order_'.
  --extras TEXT                         JSON string denoting extra data that needs to be sent with the order
  -h, --help                            Show this message and exit.

Example1:
>slcli order place --quantity 2 --billing monthly VIRTUAL_ROUTER_APPLIANCE_1_GPBS DALLAS05 INTEL_INTEL_XEON_E31270_V6_3_80 OS_JUNIPER_VSRX_15_X_UP_TO_1GBPS_STANDARD RAM_32_GB_DDR4_2133_ECC_NON_REG DISK_CONTROLLER_RAID HARD_DRIVE_3_00TB_SATA_III SRIOV_ENABLED BANDWIDTH_5000_GB MONITORING_HOST_PING 1_GBPS_REDUNDANT_PUBLIC_PRIVATE_NETWORK_UPLINKS REBOOT_KVM_OVER_IP 1_IP_ADDRESS NOTIFICATION_EMAIL_AND_TICKET AUTOMATED_NOTIFICATION UNLIMITED_SSL_VPN_USERS_1_PPTP_VPN_USER_PER_ACCOUNT NESSUS_VULNERABILITY_ASSESSMENT_REPORTING --complex-type SoftLayer_Container_Product_Order_Hardware_Server_Gateway_Appliance --extras '{"hardware":[{"hostname":"gateway01","domain":"example.com"},{"hostname":"gateway02","domain":"example.com"}]}'

Output:
:...................................................................................:
: name : value :
:...................................................................................:
: id : 35311111 :
: created : 2019-03-19T10:04:09-06:00 :
: status : PENDING_AUTO_APPROVAL :
:....................................................................................

Example2:
By default the quantity is 1:

>slcli order place --billing monthly VIRTUAL_ROUTER_APPLIANCE_1_GPBS DALLAS05 INTEL_INTEL_XEON_E31270_V6_3_80 OS_JUNIPER_VSRX_15_X_UP_TO_1GBPS_STANDARD RAM_32_GB_DDR4_2133_ECC_NON_REG DISK_CONTROLLER_RAID HARD_DRIVE_3_00TB_SATA_III SRIOV_ENABLED BANDWIDTH_5000_GB MONITORING_HOST_PING 1_GBPS_REDUNDANT_PUBLIC_PRIVATE_NETWORK_UPLINKS REBOOT_KVM_OVER_IP 1_IP_ADDRESS NOTIFICATION_EMAIL_AND_TICKET AUTOMATED_NOTIFICATION UNLIMITED_SSL_VPN_USERS_1_PPTP_VPN_USER_PER_ACCOUNT NESSUS_VULNERABILITY_ASSESSMENT_REPORTING --complex-type SoftLayer_Container_Product_Order_Hardware_Server_Gateway_Appliance --extras '{"hardware":[{"hostname":"gateway01","domain":"example.com"}]}'

Output:
:...................................................................................:
: name : value :
:...................................................................................:
: id : 35322222 :
: created : 2019-03-19T11:08:14-06:00 :
: status : PENDING_AUTO_APPROVAL :
:....................................................................................

Example3:
ORDER CLOUD_SERVER:

>slcli order place --quantity 2 --billing hourly CLOUD_SERVER AMSTERDAM GUEST_PRIVATE_CORE_1 RAM_2_GB OS_CENTOS_7_X_MINIMAL_64_BIT GUEST_DISK_25_GB_SAN BANDWIDTH_0_GB_2 1_GBPS_PUBLIC_PRIVATE_NETWORK_UPLINKS MONITORING_HOST_PING AUTOMATED_NOTIFICATION UNLIMITED_SSL_VPN_USERS_1_PPTP_VPN_USER_PER_ACCOUNT NESSUS_VULNERABILITY_ASSESSMENT_REPORTING 1_IP_ADDRESS NOTIFICATION_EMAIL_AND_TICKET REBOOT_REMOTE_CONSOLE --extras "{"privateCloudOrderFlag":false,"useHourlyPricing":true,""virtualGuests": [{"hostname": "test", "domain": "softlayer.com"},{"hostname": "test1", "domain": "softlayer.com"}]}" --complex-type SoftLayer_Container_Product_Order_Virtual_Guest

Output:
:...................................................................................:
: name : value :
:...................................................................................:
: id : 35333333 :
: created : 2019-03-19T11:15:28-06:00 :
: status : PENDING_AUTO_APPROVAL :
:....................................................................................

@coveralls
Copy link

coveralls commented Mar 20, 2019

Coverage Status

Coverage increased (+0.0008%) to 91.706% when pulling 31c1dad on FernandoOjeda:fo_order_place_quantity_option into 428753b on softlayer:master.

Copy link
Member

@allmightyspiff allmightyspiff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, just make sure the default quantity option is 1 so this change doesn't break any code that doesn't explicitly set the quantity.


def generate_order(self, package_keyname, location, item_keynames, complex_type=None,
hourly=True, preset_keyname=None, extras=None, quantity=1):
hourly=True, preset_keyname=None, extras=None, quantity=None):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd say leave this as quantity=1 that way you can just leave order['quantity'] = quantity and can avoid the extra if statement

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

help="Flag denoting whether or not to only verify the order, not place it")
@click.option('--quantity',
type=int,
help="The quantity of the item being ordered")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add a default of 1 here, so users just ordering 1 item don't have to specify that option

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@allmightyspiff allmightyspiff merged commit 8bd5e0a into softlayer:master Mar 21, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants