Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

slcli order doesn't support licenses that require capacity #1039

Closed
allmightyspiff opened this issue Sep 24, 2018 · 10 comments
Closed

slcli order doesn't support licenses that require capacity #1039

allmightyspiff opened this issue Sep 24, 2018 · 10 comments
Assignees
Labels
Ordering Anything related to ordering

Comments

@allmightyspiff
Copy link
Member

allmightyspiff commented Sep 24, 2018

slcli order place --verify --billing hourly SUSPEND_CLOUD_SERVER DALLAS12 --preset B1_8X16X100 BANDWIDTH_0_GB_2 1_GBPS_PRIVATE_NETWORK_UPLINK REBOOT_REMOTE_CONSOLE 1_IP_ADDRESS UNLIMITED_SSL_VPN_USERS_1_PPTP_VPN_USER_PER_ACCOUNT OS_WINDOWS_2012_R2_FULL_STD_64_BIT MONITORING_HOST_PING NOTIFICATION_EMAIL_AND_TICKET AUTOMATED_NOTIFICATION NESSUS_VULNERABILITY_ASSESSMENT_REPORTING --complex-type SoftLayer_Container_Product_Order_Virtual_Guest --extras '{"hardware": [{"hostname": "test", "domain": "us.test.net"}]}'

 

SoftLayerAPIError(SoftLayer_Exception_Public): Windows Server 2012 Standard Edition (64 bit) (17-32 Cores), price ID# 210917, has a Cores capacity restriction that does not match the capacity of 8 x 2.0 GHz or higher Cores, price ID# 210181. Please submit prices that are compatible.

Need to check if a price has a capacity restriction, and if so, select the appropriate price id based on that.

@allmightyspiff allmightyspiff added the Ordering Anything related to ordering label Sep 24, 2018
@marcuswalton
Copy link

The price ID is written in the error message, how does this need to be written in the slcli order command ????

@allmightyspiff
Copy link
Member Author

allmightyspiff commented Sep 25, 2018

@marcuswalton At the moment this won't work in the slcli directly. The following Python code will allow you to place this order however.

"""
Order a new VSI with post script.

The script makes a order for a VSI, it uses the SoftLayer_Product_Order::placeOrder method
for more information please see below:

Important manual pages:
http://sldn.softlayer.com/reference/datatypes/SoftLayer_Container_Product_Order
http://sldn.softlayer.com/reference/datatypes/SoftLayer_Virtual_Guest
http://sldn.softlayer.com/reference/datatypes/SoftLayer_Product_Item_Price
http://sldn.softlayer.com/reference/services/SoftLayer_Product_Order/verifyOrder
http://sldn.softlayer.com/reference/services/SoftLayer_Product_Order/placeOrder

"""
import SoftLayer
from pprint import pprint as pp
"""
Build a skeleton SoftLayer_Container_Product_Order_Virtual_Guest object
containing the order you wish to place.
"""
orderData = {
            "complexType": "SoftLayer_Container_Product_Order_Virtual_Guest",
            "location": "DALLAS12",
            "packageId": 1035,
            "quantity": 1,
            "presetId": 633, #B1_8X16X100
            "useHourlyPricing": True,
            "hardware": [
                {
                    "domain": "us.test.net",
                    "hostname": "test"
                }
            ],

            "prices": [
            {"id": 1800}, #BANDWIDTH_0_GB_2
            {"id": 210289}, #1_GBPS_PRIVATE_NETWORK_UPLINK
            {"id": 905}, #REBOOT_REMOTE_CONSOLE
            {"id": 21}, #1_IP_ADDRESS
            {"id": 420}, #UNLIMITED_SSL_VPN_USERS_1_PPTP_VPN_USER_PER_ACCOUNT
            {"id": 175777}, #OS_WINDOWS_2012_R2_FULL_STD_64_BIT
            {"id": 55}, #MONITORING_HOST_PING
            {"id": 57}, #NOTIFICATION_EMAIL_AND_TICKET
            {"id": 58}, #AUTOMATED_NOTIFICATION
            {"id": 418} #NESSUS_VULNERABILITY_ASSESSMENT_REPORTING
            ]

        }

# Create a SoftLayer API client object
client = SoftLayer.create_client_from_env()

"""
verifyOrder() will check your order for errors. Replace this with a call to
placeOrder() when you're ready to order. Both calls return a receipt object
that you can use for your records.

Once your order is placed it'll go through SoftLayer's provisioning process.
When it's done you'll have a new SoftLayer_Virtual_Guest object and VSI ready
to use.
"""

result = client['Product_Order'].verifyOrder(orderData)
pp(result)

@marcuswalton
Copy link

marcuswalton commented Sep 25, 2018 via email

@allmightyspiff
Copy link
Member Author

allmightyspiff commented Sep 25, 2018

@marcuswalton that is basically just a pyhton script, so place the text in a file called something like order_suspend.py and then run python order_suspend.py and it should work (assuming you have the softlayer python package installed, which is part of the slcli)

I hope that helps, but let us know if you run into any problems.

One thing of note, at the bottom, this script calls https://softlayer.github.io/reference/services/SoftLayer_Product_Order/verifyOrder/ , which only checks to make sure your order is valid.

Change that to placeOrder(orderData) to actually order the server.

@marcuswalton
Copy link

marcuswalton commented Sep 26, 2018 via email

@allmightyspiff
Copy link
Member Author

@marcuswalton I don't see any attachment, try posting directly on this issue instead of responding ot the email.

Also, its just a python script, if you have python installed you should be able to run it.

@FernandoOjeda FernandoOjeda self-assigned this Sep 28, 2018
@marcuswalton
Copy link

marcuswalton commented Oct 3, 2018 via email

@FernandoOjeda
Copy link
Contributor

Hi Marcus,

To add disks to your Servers you have to do an upgrade of them, you can use the following python script example to upgrade your SUSPEND-CLOUD_SERVER:

"""
Upgrade VSI.

The script makes a upgrade for a VSI, it uses the SoftLayer_Product_Order::placeOrder method
for more information please see below:

Important manual pages:
http://sldn.softlayer.com/reference/datatypes/SoftLayer_Container_Product_Order
http://sldn.softlayer.com/reference/datatypes/SoftLayer_Virtual_Guest
http://sldn.softlayer.com/reference/datatypes/SoftLayer_Product_Item_Price
http://sldn.softlayer.com/reference/services/SoftLayer_Product_Order/verifyOrder
http://sldn.softlayer.com/reference/services/SoftLayer_Product_Order/placeOrder

"""
from pprint import pprint as pp

import SoftLayer

# Your SoftLayer API username and key.
API_USERNAME = 'set me'

# Generate one at https://control.softlayer.com/account/users
API_KEY = 'set me'

""" 
Build a skeleton SoftLayer_Container_Product_Order_Virtual_Guest object 
containing the order you wish to place. 
"""
orderData = {

    "complexType": "SoftLayer_Container_Product_Order_Virtual_Guest_Upgrade",
    "properties": [
        {
            "name": "MAINTENANCE_WINDOW",
            "value": "2018-08-20T06:04:10Z"},
        {
            "name": "NOTE_GENERAL",
            "value": "Upgrade instance configuration."

        }
    ],
    "prices": [
        
        {"id": 2277}  # "description": "100 GB (SAN)", 'keyName': 'GUEST_DISK_100_GB_SAN_3',
                       # "categoryCode": "'guest_disk3"
       ],
    "virtualGuests": [
        {
            "id": 11111

        }
    ]
}

client = SoftLayer.create_client_from_env(
    username=API_USERNAME,
    api_key=API_KEY
)

""" 
verifyOrder() will check your order for errors. Replace this with a call to 
placeOrder() when you're ready to order. Both calls return a receipt object 
that you can use for your records. 

Once your order is placed it'll go through SoftLayer's provisioning process. 
When it's done you'll have a new SoftLayer_Virtual_Guest object and VSI ready 
to use. 
"""

# Try first with verifyOrder to check if everything is right, when change with placeOrder.
result = client['Product_Order'].verifyOrder(orderData)
pp(result)

To upgrade your other server to 1.00 TB disk you have to replace the item price id in the script above, like the below example.

{"id": 2279}   # "description": "1.00 TB (SAN)", 'keyName': 'GUEST_DISK_1000_GB_SAN_2',
                       # "categoryCode": "guest_disk4"

To get the item prices available for the disks you can use the following python script:

"""
UpgradeItemPrices VSI.

Retrieve a computing instance’s upgradeable items.

Important manual pages:
https://softlayer.github.io/reference/services/SoftLayer_Virtual_Guest/getUpgradeItemPrices/

"""
from pprint import pprint as pp

import SoftLayer

# Your SoftLayer API username and key.
API_USERNAME = 'set me'

# Generate one at https://control.softlayer.com/account/users
API_KEY = 'set me'

vsId = 11111

client = SoftLayer.create_client_from_env(
    username=API_USERNAME,
    api_key=API_KEY
)

# Try first with verifyOrder to check if everything is right, when change with placeOrder.
result = client['SoftLayer_Virtual_Guest'].getUpgradeItemPrices(id=vsId)
pp(result)

In the response you can search the disks by the keyName, e.g. 'keyName': 'GUEST_DISK_100_GB_SAN_3'

@marcuswalton
Copy link

marcuswalton commented Oct 3, 2018 via email

@allmightyspiff
Copy link
Member Author

This change has been added to the master branch, and will be released early next week. Look for this fix in v5.6.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Ordering Anything related to ordering
Projects
None yet
Development

No branches or pull requests

3 participants