Last active
May 24, 2017 20:12
-
-
Save bmpotter/27913e92e9ff7b6b0c54 to your computer and use it in GitHub Desktop.
Example of ordering a monthly custom bare metal server
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import pprint | |
import SoftLayer | |
# !!!!! To run this you must also get getOrderItemsDict() and supporting functions | |
# from: https://gist.github.com/bmpotter/db0c5feda536f2d502cd | |
# Main - Order a bare metal svr using the more involved, but more flexible, product package method. | |
# Have a .softlayer file or set SL_USERNAME and SL_API_KEY. | |
# Omit endpoint_url if you are running this on a softlayer svr. | |
client = SoftLayer.Client(endpoint_url=SoftLayer.API_PUBLIC_ENDPOINT) | |
location = 'tor01' | |
pkgId = 253 | |
# Build a structure of categories and items prices for this pkg and this location | |
items = getOrderItemsDict(client, pkgId, location=location) | |
# Build the prices part of the order structure | |
# http://sldn.softlayer.com/reference/services/SoftLayer_Product_Order | |
# this is for pkg 253, Dual E5-2600 v3 Series (4 Drives) | |
prices = [ | |
{'id': getItemPriceId(items, 'server', 'INTEL_XEON_2690_2_60')}, | |
{'id': getItemPriceId(items, 'os', 'OS_UBUNTU_14_04_LTS_TRUSTY_TAHR_64_BIT')}, | |
{'id': getItemPriceId(items, 'ram', 'RAM_64_GB_DDR3_1333_REG_2')}, | |
{'id': getItemPriceId(items, 'disk_controller', 'DISK_CONTROLLER_NONRAID')}, | |
{'id': getItemPriceId(items, 'disk0', 'HARD_DRIVE_2_00_TB_SATA_2')}, | |
{'id': getItemPriceId(items, 'port_speed', '1_GBPS_PUBLIC_PRIVATE_NETWORK_UPLINKS')}, | |
{'id': getItemPriceId(items, 'power_supply', 'REDUNDANT_POWER_SUPPLY')}, | |
{'id': getItemPriceId(items, 'bandwidth', 'BANDWIDTH_500_GB')}, | |
{'id': getItemPriceId(items, 'pri_ip_addresses', '1_IP_ADDRESS')}, | |
{'id': getItemPriceId(items, 'remote_management', 'REBOOT_KVM_OVER_IP')}, | |
{'id': getItemPriceId(items, 'vpn_management', 'UNLIMITED_SSL_VPN_USERS_1_PPTP_VPN_USER_PER_ACCOUNT')}, | |
{'id': getItemPriceId(items, 'monitoring', 'MONITORING_HOST_PING_AND_TCP_SERVICE')}, | |
{'id': getItemPriceId(items, 'notification', 'NOTIFICATION_EMAIL_AND_TICKET')}, | |
{'id': getItemPriceId(items, 'response', 'AUTOMATED_NOTIFICATION')}, | |
{'id': getItemPriceId(items, 'vulnerability_scanner', 'NESSUS_VULNERABILITY_ASSESSMENT_REPORTING')}, | |
] | |
# create order structure | |
productOrder = { | |
"quantity" : 1, | |
"hardware": [{ "hostname": 'foo', "domain": 'bar.com' }], | |
"location": getLocationId(client, location), | |
"packageId": pkgId, | |
"prices": prices, | |
} | |
try: | |
order = client['Product_Order'].verifyOrder(productOrder) | |
# to really order: | |
# order = client['Product_Order'].placeOrder(productOrder, False) | |
pprint.pprint(order) | |
except SoftLayer.exceptions.SoftLayerAPIError as e: | |
print 'order exception: '+str(e.faultCode) + ': ' + e.faultString |
Sorry, for some reason i wasn't notified about this comments, but for others looking here, the answer to the question is: softlayer just doesn't support custom bare metal svrs being ordered hourly. If you try to set the hourly flag on the above order, the order will be rejected.
@bmpotter what about monthly bare metal servers using a fixed configuration preset. Does SoftLayer allow those?
@bmpotter the prices info are specific to the tor01 location I assume; how to find out what they are for a different location (say dal10)?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Awesome question. :)