Skip to content

Instantly share code, notes, and snippets.

bmpotter

Block or report user

Report or block bmpotter

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@bmpotter
bmpotter / order-preset-bare-metal.py-2.py
Last active Oct 20, 2016
An alternative/better way to order hourly pre-set bare metal svr configurations
View order-preset-bare-metal.py-2.py
import os
import sys
from pprint import pprint as pp
import SoftLayer
# !!!!! To run this you must also get getOrderItemsDict() and supporting functions
# from: https://gist.github.com/bmpotter/db0c5feda536f2d502cd
def getPresetsDict(client, pkgId=200):
@bmpotter
bmpotter / getOrderItemsDict.py
Last active Oct 14, 2015
Get all of the item price objects for the given pkg, keyed by the keyName
View getOrderItemsDict.py
import os
import sys
from pprint import pprint as pp
import SoftLayer
def getOrderItemsDict(client, pkgId, location=None, displayFiltered=False):
'''Get all of the item price objects for the given pkg, keyed by the keyName, with the id as the value,
and organize these keyName/id pairs by category. The issue here is that keyName is the same between accounts,
the id is not. But it is the id that we need to pass into the order.
If location==None, return only the location independent price objects.
@bmpotter
bmpotter / pkg.253.tor01.txt
Created Aug 13, 2015
Example output of getOrderItemsDict() for pkg 253 in Toronto from order-custom-monthly-bare-metal.py
View pkg.253.tor01.txt
{'av_spyware_protection': {'catName': 'Anti-Virus & Spyware Protection',
'isRequired': False,
'items': {'MCAFEE_VIRUSSCAN_ANTIVIRUS_WINDOWS': {'description': 'McAfee VirusScan Enterprise',
'fee': '0',
'hourlyFee': '0',
'id': 397,
'locationGroupId': '',
'priceId': 594}}},
'bandwidth': {'catName': 'Public Bandwidth',
'isRequired': True,
@bmpotter
bmpotter / order-custom-monthly-bare-metal.py
Last active May 24, 2017
Example of ordering a monthly custom bare metal server
View order-custom-monthly-bare-metal.py
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.
@bmpotter
bmpotter / bare-metal-pkgs.txt
Created Aug 12, 2015
Sample output of query the custom bare metal product pkgs using https://gist.github.com/bmpotter/664ee9af622ce08da9a4
View bare-metal-pkgs.txt
[{'id': 56,
'name': 'Quad Processor Multi Core Nehalem EX',
'server': ['Quad Intel Xeon E7-4850 (10 Cores, 2.00 GHz)'],
'type': {'keyName': 'BARE_METAL_CPU'}},
{'id': 126,
'name': 'Single Xeon 1200 Series (Sandy Bridge / Haswell)',
'server': ['Single Intel Xeon E3-1270 v3 (4 Cores, 3.50 GHz)',
'Single Intel Xeon E3-1270 (4 Cores, 3.40 GHz)'],
'type': {'keyName': 'BARE_METAL_CPU'}},
{'id': 142,
@bmpotter
bmpotter / get-bare-metal-pkgs.py
Last active Aug 29, 2015
Get the SoftLayer product packages that can be used to order custom monthly bare metal servers
View get-bare-metal-pkgs.py
import os
import pprint
import SoftLayer
client = SoftLayer.Client(username=os.environ['SLUSERNAME'], api_key=os.environ['SLAPIKEY'], endpoint_url=SoftLayer.API_PUBLIC_ENDPOINT)
mask = 'id, name, description, type.keyName, items.id, items.description, items.categories.categoryCode'
# We only want pkgs that include a server category because there are some older packages without a server category
# that can not be used any more.
filterStr = {
"items": {"categories": {"categoryCode": {"operation":"server"} } },
@bmpotter
bmpotter / get-bare-metal-provision-status.py
Last active Aug 29, 2015
Get the status of a bare metal server that is in the process of being provisioned
View get-bare-metal-provision-status.py
import os
import pprint
import SoftLayer
client = SoftLayer.Client(username=os.environ['SLUSERNAME'], api_key=os.environ['SLAPIKEY'], endpoint_url=SoftLayer.API_PUBLIC_ENDPOINT)
# Call this repeatedly while the bare metal server is being provisioned, until provisionDate is filled in.
mask = 'mask[id,fullyQualifiedDomainName,provisionDate,hardwareStatus,lastTransaction[elapsedSeconds,transactionStatus[friendlyName]],operatingSystem[id,passwords[password,username]]]'
hostname = 'simplebmi'
domain = 'test.com'
filterStr = {"hardware":{"hostname":{"operation":hostname},"domain":{"operation":domain}}}
@bmpotter
bmpotter / order-preset-bare-metal.py
Created Aug 12, 2015
Example of ordering an hourly pre-set configuration bare metal server
View order-preset-bare-metal.py
import os
import pprint
import SoftLayer
client = SoftLayer.Client(username=os.environ['SLUSERNAME'], api_key=os.environ['SLAPIKEY'], endpoint_url=SoftLayer.API_PUBLIC_ENDPOINT)
hw = {
'datacenter': {'name': 'tor01'},
'hostname': 'simplebmi',
'domain': 'test.com',
'hourlyBillingFlag': True,
@bmpotter
bmpotter / calc-preset-hourly-price.py
Last active Aug 29, 2015
Code for calculating the precise price of hourly bare metal pre-set configurations
View calc-preset-hourly-price.py
import os
import pprint
import SoftLayer
client = SoftLayer.Client(username=os.environ['SLUSERNAME'], api_key=os.environ['SLAPIKEY'], endpoint_url=SoftLayer.API_PUBLIC_ENDPOINT)
pkgId = 200
mask = 'id, description, keyName, totalMinimumRecurringFee, configuration, configuration.price.hourlyRecurringFee, configuration.price.item.keyName'
# http://sldn.softlayer.com/reference/services/SoftLayer_Product_Package/getActivePresets
presets = client['Product_Package'].getActivePresets(id=pkgId, mask=mask)
@bmpotter
bmpotter / hw-create-options.txt
Last active Aug 29, 2015
Example output of Hardware::getCreateObjectOptions() method
View hw-create-options.txt
{'datacenters': [{'template': {'datacenter': {'name': 'ams01'}}},
{'template': {'datacenter': {'name': 'ams03'}}},
{'template': {'datacenter': {'name': 'dal01'}}},
{'template': {'datacenter': {'name': 'dal05'}}},
{'template': {'datacenter': {'name': 'dal06'}}},
{'template': {'datacenter': {'name': 'dal09'}}},
{'template': {'datacenter': {'name': 'fra02'}}},
{'template': {'datacenter': {'name': 'hkg02'}}},
{'template': {'datacenter': {'name': 'hou02'}}},
{'template': {'datacenter': {'name': 'lon02'}}},
You can’t perform that action at this time.