Skip to content

Conversation

allmightyspiff
Copy link
Member

modifies managers.ordering.generate_order so that it uses a location ID instead of a long name. Can be either short name (dal13) or keyname (DALLAS13).

Also, default location price id seems to be None now instead of ''

Testing to make sure everything still works.

$ ./slcli --really order place --verify --preset D2620V4_64GB_2X1TB_SATA_RAID_1 BARE_METAL_SERVER  TORONTO      OS_UBUNTU_16_04_LTS_XENIAL_XERUS_64_BIT     BANDWIDTH_0_GB_2      1_GBPS_PUBLIC_PRIVATE_NETWORK_UPLINKS      REBOOT_KVM_OVER_IP 1_IP_ADDRESS      UNLIMITED_SSL_VPN_USERS_1_PPTP_VPN_USER_PER_ACCOUNT     --extras '{"hardware": [{"hostname" : "testOrder1", "domain": "cgallo.com"}], "sshKeys" : [87634], "tags": "cgallo, test"}'      --complex-type SoftLayer_Container_Product_Order_Hardware_Server
OS_UBUNTU_16_04_LTS_XENIAL_XERUS_64_BIT              Ubuntu Linux 16.04 LTS Xenial Xerus (64 bit)           0
BANDWIDTH_0_GB_2                                     0 GB Bandwidth                                         0
1_GBPS_PUBLIC_PRIVATE_NETWORK_UPLINKS                1 Gbps Public & Private Network Uplinks                0
REBOOT_KVM_OVER_IP                                   Reboot / KVM over IP                                   0
1_IP_ADDRESS                                         1 IP Address                                           0
UNLIMITED_SSL_VPN_USERS_1_PPTP_VPN_USER_PER_ACCOUNT  Unlimited SSL VPN Users & 1 PPTP VPN User per account  0
RAM_64_GB_DDR3_1333_REG_2                            64 GB RAM                                              0
HARD_DRIVE_1_00_TB_SATA_2                            1.00 TB SATA                                           0
HARD_DRIVE_1_00_TB_SATA_2                            1.00 TB SATA                                           0
REDUNDANT_POWER_SUPPLY                               Redundant Power Supply                                 0
INTEL_INTEL_XEON_E52620_V4_2_10                      Dual Intel Xeon E5-2620 v4 (16 Cores, 2.10 GHz)        0
DISK_CONTROLLER_RAID                                 RAID                                                   0
(py36)
allmi@SPF-WIN10 MINGW64 ~/Source/softlayer-python (issues922)
$ ./slcli --really order place --preset D2620V4_64GB_2X1TB_SATA_RAID_1 BARE_METAL_SERVER  TORONTO      OS_UBUNTU_16_04_LTS_XENIAL_XERUS_64_BIT     BANDWIDTH_0_GB_2      1_GBPS_PUBLIC_PRIVATE_NETWORK_UPLINKS      REBOOT_KVM_OVER_IP 1_IP_ADDRESS      UNLIMITED_SSL_VPN_USERS_1_PPTP_VPN_USER_PER_ACCOUNT     --extras '{"hardware": [{"hostname" : "testOrder1", "domain": "cgallo.com"}], "sshKeys" : [87634], "tags": "cgallo, test"}'      --complex-type SoftLayer_Container_Product_Order_Hardware_Server
id       24224891
created  2018-03-23T14:41:50-06:00
status   PENDING_AUTO_APPROVAL
(py36)


execution_time    6.180779s
                      Layer_Product_Package::getAllObjects (0.649538s)
                            Location::getDatacenters (0.252585s)
                      Layer_Product_Package::getAllObjects (0.248032s)
                  SoftLayer_Product_Package::getAccountRestrictedActivePresets (0.249819s)
                   oftLayer_Product_Package::getActivePresets (0.226520s)
                      Layer_Product_Package::getAllObjects (0.299368s)
                           _Product_Package::getItems (1.124070s)
                  SoftLayer_Product_Order::placeOrder (3.062829s)


curl -u $SL_USER:$SL_APIKEY -X POST -H "Accept: */*" -H "Accept-Encoding: gzip, deflate, compress" -d '{"parameters": [{"hardware": [{"hostname": "testOrder1", "domain": "cgallo.com"}], "sshKeys": [87634], "tags": "cgallo, test", "packageId": 200, "location": 448994, "quantity": 1, "useHourlyPricing": true, "presetId": 149, "complexType": "SoftLayer_Container_Product_Order_Hardware_Server", "prices": [{"id": 175791}, {"id": 1800}, {"id": 274}, {"id": 906}, {"id": 21}, {"id": 420}]}]}' 'https://api.softlayer.com/rest/v3.1/SoftLayer_Product_Order/placeOrder.json'

Debugging for placing order

$ ./slcli -vvv --really order place --preset D2620V4_64GB_2X1TB_SATA_RAID_1 BARE_METAL_SERVER  TORONTO      OS_UBUNTU_16_04_LTS_XENIAL_XERUS_64_BIT     BANDWIDTH_0_GB_2      1_GBPS_PUBLIC_PRIVATE_NETWORK_UPLINKS      REBOOT_KVM_OVER_IP 1_IP_ADDRESS      UNLIMITED_SSL_VPN_USERS_1_PPTP_VPN_USER_PER_ACCOUNT     --extras '{"hardware": [{"hostname" : "testOrder1", "domain": "cgallo.com"}], "sshKeys" : [87634], "tags": "cgallo, test"}'      --complex-type SoftLayer_Container_Product_Order_Hardware_Server

Calling: SoftLayer_Product_Package::getAllObjects(id=None)
https://api.softlayer.com:443 "GET /rest/v3.1/SoftLayer_Product_Package/getAllObjects.json?objectMask=mask%5Bid%5D&objectFilter=%7B%22keyName%22%3A+%7B%22operation%22%3A+%22BARE_METAL_SERVER%22%7D%7D HTTP/1.1" 200 12

Calling: SoftLayer_Location::getDatacenters(id=None)
https://api.softlayer.com:443 "GET /rest/v3.1/SoftLayer_Location/getDatacenters.json?objectMask=mask%5Bid%2Cname%2Cregions%5Bkeyname%5D%5D&objectFilter=%7B%22regions%22%3A+%7B%22keyname%22%3A+%7B%22operation%22%3A+%22TORONTO%22%7D%7D%7D HTTP/1.1" 200 64

Calling: SoftLayer_Product_Package::getAllObjects(id=None)
https://api.softlayer.com:443 "GET /rest/v3.1/SoftLayer_Product_Package/getAllObjects.json?objectMask=mask%5Bid%5D&objectFilter=%7B%22keyName%22%3A+%7B%22operation%22%3A+%22BARE_METAL_SERVER%22%7D%7D HTTP/1.1" 200 12

Calling: SoftLayer_Product_Package::getAccountRestrictedActivePresets(id=200)
https://api.softlayer.com:443 "GET /rest/v3.1/SoftLayer_Product_Package/200/getAccountRestrictedActivePresets.json?objectFilter=%7B%22activePresets%22%3A+%7B%22keyName%22%3A+%7B%22operation%22%3A+%22_%3D+D2620V4_64GB_2X1TB_SATA_RAID_1%22%7D%7D%7D HTTP/1.1" 200 2

Calling: SoftLayer_Product_Package::getActivePresets(id=200)
https://api.softlayer.com:443 "GET /rest/v3.1/SoftLayer_Product_Package/200/getActivePresets.json?objectFilter=%7B%22activePresets%22%3A+%7B%22keyName%22%3A+%7B%22operation%22%3A+%22_%3D+D2620V4_64GB_2X1TB_SATA_RAID_1%22%7D%7D%7D HTTP/1.1" 200 194

Calling: SoftLayer_Product_Package::getAllObjects(id=None)
https://api.softlayer.com:443 "GET /rest/v3.1/SoftLayer_Product_Package/getAllObjects.json?objectMask=mask%5Bid%5D&objectFilter=%7B%22keyName%22%3A+%7B%22operation%22%3A+%22BARE_METAL_SERVER%22%7D%7D HTTP/1.1" 200 12

Calling: SoftLayer_Product_Package::getItems(id=200)
https://api.softlayer.com:443 "GET /rest/v3.1/SoftLayer_Product_Package/200/getItems.json?objectMask=mask%5Bid%2C+keyName%2C+prices%5D HTTP/1.1" 200 134115

Calling: SoftLayer_Product_Order::placeOrder(id=None)
https://api.softlayer.com:443 "POST /rest/v3.1/SoftLayer_Product_Order/placeOrder.json HTTP/1.1" 200 34659

id       24224055
created  2018-03-23T14:44:34-06:00
status   PENDING_AUTO_APPROVAL
execution_time    6.180779s
                      Layer_Product_Package::getAllObjects (0.649538s)
                            Location::getDatacenters (0.252585s)
                      Layer_Product_Package::getAllObjects (0.248032s)
                  SoftLayer_Product_Package::getAccountRestrictedActivePresets (0.249819s)
                   oftLayer_Product_Package::getActivePresets (0.226520s)
                      Layer_Product_Package::getAllObjects (0.299368s)
                           _Product_Package::getItems (1.124070s)
                  SoftLayer_Product_Order::placeOrder (3.062829s)
version           softlayer-python/v5.4.2
python_version    3.6.2 (v3.6.2:5fd33b5, Jul  8 2017, 04:57:36) [MSC v.1900 64 bit (AMD64)]
library_location  C:\Users\allmi\Source\softlayer-python\SoftLayer

Actual API calls

curl -u $SL_USER:$SL_APIKEY -X GET -H "Accept: */*" -H "Accept-Encoding: gzip, deflate, compress"  'https://api.softlayer.com/rest/v3.1/SoftLayer_Product_Package/getAllObjects.json?objectMask=mask%5Bid%5D&objectFilter=%7B%22keyName%22%3A+%7B%22operation%22%3A+%22BARE_METAL_SERVER%22%7D%7D'
curl -u $SL_USER:$SL_APIKEY -X GET -H "Accept: */*" -H "Accept-Encoding: gzip, deflate, compress"  'https://api.softlayer.com/rest/v3.1/SoftLayer_Location/getDatacenters.json?objectMask=mask%5Bid%2Cname%2Cregions%5Bkeyname%5D%5D&objectFilter=%7B%22regions%22%3A+%7B%22keyname%22%3A+%7B%22operation%22%3A+%22TORONTO%22%7D%7D%7D'
curl -u $SL_USER:$SL_APIKEY -X GET -H "Accept: */*" -H "Accept-Encoding: gzip, deflate, compress"  'https://api.softlayer.com/rest/v3.1/SoftLayer_Product_Package/getAllObjects.json?objectMask=mask%5Bid%5D&objectFilter=%7B%22keyName%22%3A+%7B%22operation%22%3A+%22BARE_METAL_SERVER%22%7D%7D'
curl -u $SL_USER:$SL_APIKEY -X GET -H "Accept: */*" -H "Accept-Encoding: gzip, deflate, compress"  'https://api.softlayer.com/rest/v3.1/SoftLayer_Product_Package/200/getAccountRestrictedActivePresets.json?objectFilter=%7B%22activePresets%22%3A+%7B%22keyName%22%3A+%7B%22operation%22%3A+%22_%3D+D2620V4_64GB_2X1TB_SATA_RAID_1%22%7D%7D%7D'
curl -u $SL_USER:$SL_APIKEY -X GET -H "Accept: */*" -H "Accept-Encoding: gzip, deflate, compress"  'https://api.softlayer.com/rest/v3.1/SoftLayer_Product_Package/200/getActivePresets.json?objectFilter=%7B%22activePresets%22%3A+%7B%22keyName%22%3A+%7B%22operation%22%3A+%22_%3D+D2620V4_64GB_2X1TB_SATA_RAID_1%22%7D%7D%7D'
curl -u $SL_USER:$SL_APIKEY -X GET -H "Accept: */*" -H "Accept-Encoding: gzip, deflate, compress"  'https://api.softlayer.com/rest/v3.1/SoftLayer_Product_Package/getAllObjects.json?objectMask=mask%5Bid%5D&objectFilter=%7B%22keyName%22%3A+%7B%22operation%22%3A+%22BARE_METAL_SERVER%22%7D%7D'
curl -u $SL_USER:$SL_APIKEY -X GET -H "Accept: */*" -H "Accept-Encoding: gzip, deflate, compress"  'https://api.softlayer.com/rest/v3.1/SoftLayer_Product_Package/200/getItems.json?objectMask=mask%5Bid%2C+keyName%2C+prices%5D'
curl -u $SL_USER:$SL_APIKEY -X POST -H "Accept: */*" -H "Accept-Encoding: gzip, deflate, compress" -d '{"parameters": [{"hardware": [{"hostname": "testOrder1", "domain": "cgallo.com"}], "sshKeys": [87634], "tags": "cgallo, test", "packageId": 200, "location": 448994, "quantity": 1, "useHourlyPricing": true, "presetId": 149, "complexType": "SoftLayer_Container_Product_Order_Hardware_Server", "prices": [{"id": 175791}, {"id": 1800}, {"id": 274}, {"id": 906}, {"id": 21}, {"id": 420}]}]}' 'https://api.softlayer.com/rest/v3.1/SoftLayer_Product_Order/placeOrder.json'

@coveralls
Copy link

coveralls commented Mar 23, 2018

Coverage Status

Coverage increased (+0.007%) to 86.983% when pulling d6a9453 on allmightyspiff:issues922 into 4ec8756 on softlayer:master.

"longName": "San Jose 1",
"name": "sjc01"
}]
getDatacenters = [{'id': 1854895, 'name': 'dal13', 'regions': [{'keyname': 'DALLAS13'}]}]
Copy link
Member

Choose a reason for hiding this comment

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

Might be good to combine the fixtures since they are for the same method.

Copy link
Member Author

Choose a reason for hiding this comment

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

The problem is that my method expects only 1 result back, but else where expects multiple results back.... I need to figure out a better way to do these fixtures to deal with different object masks/filters. but that might be for a different project.

# in which the order is made
price_id = [p['id'] for p in matching_item['prices']
if p['locationGroupId'] == ''][0]
if p['locationGroupId'] is None][0]
Copy link
Member

Choose a reason for hiding this comment

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

Tests are still relying on this being an empty string.

"""

mask = "mask[id,name,regions[keyname]]"
if match(r'[a-zA-Z]{3}[0-9]{2}', location) is not 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 might be wrong, but there could still be a case where a user is passing in an id as the location, and previously this was just passed on to the order.

For backwards compatibility, I think this method may want to check for a digit-only string (isdigit) and short circuit the lookup if that is the case.

else:
search = {'regions': {'keyname': {'operation': location}}}
datacenter = self.client.call('SoftLayer_Location', 'getDatacenters', mask=mask, filter=search)
# [{'id': 1854895, 'name': 'dal13', 'regions': [{'keyname': 'DALLAS13'}]}]
Copy link
Member

Choose a reason for hiding this comment

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

I'm not a fan of putting example results like this because they can get out of date quickly. The corresponding fixture is a good way to discover the result structure that is actually used instead IMHO.

@allmightyspiff allmightyspiff changed the title Issues922 Issues922 - DC short names in ordering Mar 27, 2018
@allmightyspiff
Copy link
Member Author

$ ./slcli --really order place --preset D2620V4_64GB_2X1TB_SATA_RAID_1 BARE_METAL_SERVER  tor01      OS_UBUNTU_16_04_LTS_XENIAL_XERUS_64_BIT     BANDWIDTH_0_GB_2      1_GBPS_PUBLIC_PRIVATE_NETWORK_UPLINKS      REBOOT_KVM_OVER_IP 1_IP_ADDRESS      UNLIMITED_SSL_VPN_USERS_1_PPTP_VPN_USER_PER_ACCOUNT     --extras '{"hardware": [{"hostname" : "testOrder1", "domain": "cgallo.com"}], "sshKeys" : [87634], "tags": "cgallo, test"}'      --complex-type SoftLayer_Container_Product_Order_Hardware_Server
:.........:...........................:
:    name : value                     :
:.........:...........................:
:      id : 24422091                  :
: created : 2018-03-29T14:52:55-06:00 :
:  status : PENDING_AUTO_APPROVAL     :
:.........:...........................:

$  ./slcli order place  --billing monthly   DUAL_E52600_V4_4_DRIVES  DALLAS13  BANDWIDTH_500_GB HARD_DRIVE_1_00_TB_SATA_2 DISK_CONTROLLER_NONRAID MONITORING_HOST_PING NOTIFICATION_EMAIL_AND_TICKET OS_CENTOS_7_X_64_BIT 1_GBPS_PUBLIC_PRIVATE_NETWORK_UPLINKS 1_IP_ADDRESS 1_IPV6_ADDRESS  RAM_128_GB_DDR4_2133_ECC_REG REBOOT_KVM_OVER_IP AUTOMATED_NOTIFICATION INTEL_INTEL_XEON_E52690_V4_2_60 UNLIMITED_SSL_VPN_USERS_1_PPTP_VPN_USER_PER_ACCOUNT NESSUS_VULNERABILITY_ASSESSMENT_REPORTING --extras '{"hardware": [{"hostname" : "testOrder1", "domain": "cgallo.com"}], "sshKeys" : [87634], "tags": "cgallo, test"}'      --complex-type SoftLayer_Container_Product_Order_Hardware_Server
This action will incur charges on your account. Continue? [y/N]: y
:.........:...........................:
:    name : value                     :
:.........:...........................:
:      id : 24423609                  :
: created : 2018-03-29T14:50:12-06:00 :
:  status : PENDING_AUTO_APPROVAL     :
:.........:...........................:

@allmightyspiff allmightyspiff merged commit 6007e39 into softlayer:master Mar 29, 2018
@allmightyspiff allmightyspiff deleted the issues922 branch August 31, 2020 22:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants