softlayer / softlayer-python

A set of Python libraries that assist in calling the SoftLayer API.
http://softlayer.github.io/softlayer-python/
MIT License
152 stars 193 forks source link

Select default no-term price instead of sending an order with conflicting terms #1425

Closed scottwn closed 3 years ago

scottwn commented 3 years ago

Reminder: No username or APIkeys should be added to these issues, as they are public.

Describe the bug When we run the following command in certain enterprise accounts

slcli order place --verify --billing monthly 2U_DUAL_INTEL_XEON_PROCESSOR_SCALABLE_FAMILY_12_DRIVES ASHBURN04 INTEL_INTEL_XEON_6140_2_30 OS_UBUNTU_16_04_LTS_XENIAL_XERUS_64_BIT RAM_96_GB_DDR4_2133_ECC_REG DISK_CONTROLLER_NONRAID HARD_DRIVE_1_00_TB_SATA_2 10_GBPS_REDUNDANT_PUBLIC_PRIVATE_NETWORK_UPLINKS BANDWIDTH_500_GB 1_IP_ADDRESS REBOOT_KVM_OVER_IP UNLIMITED_SSL_VPN_USERS_1_PPTP_VPN_USER_PER_ACCOUNT MONITORING_HOST_PING_AND_TCP_SERVICE NOTIFICATION_EMAIL_AND_TICKET NESSUS_VULNERABILITY_ASSESSMENT_REPORTING AUTOMATED_REBOOT_FROM_MONITORING --complex-type SoftLayer_Container_Product_Order_Hardware_Server --extras '{"techIncubatorItemPrice": [{"priceType": "STANDARD"}] }'

We get the following error

SoftLayerAPIError(SoftLayer_Exception_Order): There are term-based prices being used with different term lengths 36 and 12.

@allmightyspiff suggested that the error is caused by logic that just selects the first price available and doesn't attempt to match termLength. The logic is in https://github.com/softlayer/softlayer-python/blob/master/SoftLayer/managers/ordering.py#L409

Expected behavior I expect slcli to default to no-term pricing instead of attempting term based prices that may not match, which would successfully return a price list when verifying an order.

Version 5.4.2

allmightyspiff commented 3 years ago

@scottwn I've got a fix for this on https://github.com/softlayer/softlayer-python/tree/issues1425 which I think will work. It will at least select 0 term prices currently. My catalog doesn't have any term limited prices though, so before I merge, can you check if this code fixes the issue?

This issue doesn't add the ability to select Term Length prices yet though, as I'm assuming you want to only select month to month prices, but if thats not the case just let me know.