Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Example of ordering a monthly custom bare metal server
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

How do we know this is for a monthly server? If I order hourly what would be the difference?

Awesome question. :)

Owner

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.

renier commented Oct 1, 2016

@bmpotter what about monthly bare metal servers using a fixed configuration preset. Does SoftLayer allow those?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment