Closed allmightyspiff closed 6 years ago
The price ID is written in the error message, how does this need to be written in the slcli order command ????
@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)
Hi Christopher,
I have edited the script to add the VLAN I want the new server to be in, I presume that packageId": 1035 is for SUSPEND_CLOUD_SERVER ?,but until last week had never used the Softlayer API, how do I place the order with a script ?
@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.
Hi Christophe,
Should I be able to run this from Windows 10, from the CMD line ?, need some clear instructions on how to run this script, does the attached look OK, I have added VLAN details, but not sure if the syntax is correct ?
Regards
Marcus
From: Christopher Gallo [mailto:notifications@github.com] Sent: 25 September 2018 19:27 To: softlayer/softlayer-python softlayer-python@noreply.github.com Cc: Walton Marcus, SPS Ltd. UK marcus.walton@swisspost.com; Mention mention@noreply.github.com Subject: Re: [softlayer/softlayer-python] slcli order doesn't support licenses that require capacity (#1039)
@marcuswaltonhttps://github.com/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.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/softlayer/softlayer-python/issues/1039#issuecomment-424451232, or mute the threadhttps://github.com/notifications/unsubscribe-auth/ApXSKKj7FkzBAYTvRXozIJ9TsOumhP-Lks5uenV3gaJpZM4W3jHI.
Swiss Post Solutions Ltd, Parkshot House, 5 Kew Road, Richmond, TW9 2PR, UK | Registered in England: 04482213
@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.
Hi Christopher,
I ordered “SUSPEND-CLOUD_SERVER”s with the below python script you helped me with last week, but I now need to order Data disks for the servers, I need to order a 100GB disk for one and a 1TB disk for the other, I have two questions:
· What command do I use to find the priceid for the disks.
· What command can I use to order the disks for the VM’s, I have the servers virtualGuestID’s
Many thanks Regards
Marcus
""" 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": "TEST.net", "hostname": "TEST01", "privateNetworkOnlyFlag": True, "primaryBackendNetworkComponent": {"networkVlanId": 2437917} } ],
"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
]
}
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'].placeOrder(orderData) pp(result)
Swiss Post Solutions Ltd, Parkshot House, 5 Kew Road, Richmond, TW9 2PR, UK | Registered in England: 04482213
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'
Hi Fernando,
Great many thanks this has now worked.
Regards
Marcus
From: FernandoOjeda [mailto:notifications@github.com] Sent: 03 October 2018 16:59 To: softlayer/softlayer-python softlayer-python@noreply.github.com Cc: Walton Marcus, SPS Ltd. UK marcus.walton@swisspost.com; Mention mention@noreply.github.com Subject: Re: [softlayer/softlayer-python] slcli order doesn't support licenses that require capacity (#1039)
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
API_USERNAME = 'set me'
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.
"""
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
API_USERNAME = 'set me'
API_KEY = 'set me'
vsId = 11111
client = SoftLayer.create_client_from_env(
username=API_USERNAME,
api_key=API_KEY
)
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'
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/softlayer/softlayer-python/issues/1039#issuecomment-426692342, or mute the threadhttps://github.com/notifications/unsubscribe-auth/ApXSKH__-DO_yIdeTz-i3e1YH5Q0nHUOks5uhN6_gaJpZM4W3jHI.
Swiss Post Solutions Ltd, Parkshot House, 5 Kew Road, Richmond, TW9 2PR, UK | Registered in England: 04482213
This change has been added to the master branch, and will be released early next week. Look for this fix in v5.6.0
Need to check if a price has a capacity restriction, and if so, select the appropriate price id based on that.