Skip to content

Instantly share code, notes, and snippets.

@Juice10
Last active October 23, 2015 13:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Juice10/62e1017bf8cd7dfddae1 to your computer and use it in GitHub Desktop.
Save Juice10/62e1017bf8cd7dfddae1 to your computer and use it in GitHub Desktop.
'''
An example of how to create a VSI from the SL python library
'''
from __future__ import print_function
import SoftLayer
from SoftLayer.managers.vs import VSManager
# For nice debug output:
from pprint import pprint as pp
SL_USERNAME = "name"
SL_API_KEY = "api-key"
def create_virtual_server_with_windows_and_vcenter():
#Create a client to the SoftLayer_Account API service.
#Note: currently set without the user ID and API key since
#it will by default use the values set in the CLI
#to use other values use SoftLayer.Client(sl_username, sl_api_key)
domain = 'example.com'
hostname = 'test'
client = SoftLayer.Client(
username = SL_USERNAME,
api_key = SL_API_KEY
)
# to select package ids please use the following script: https://gist.github.com/Juice10/5b93fac6669b2cf3d5c1
order = {
'complexType': 'SoftLayer_Container_Product_Order_Virtual_Guest',
'quantity': 1,
'virtualGuests': [
{'hostname': hostname, 'domain': domain}
],
'location': 168642, # San Jose 1
'packageId': 46, # CCI Package
'prices': [
{'id': 1640}, # 1 x 2.0 GHz Core
{'id': 1644}, # 1 GB RAM
{'id': 905}, # Reboot / Remote Console
{'id': 272}, # 10 Mbps Public & Private Networks
{'id': 50367}, # 250 GB Public Bandwidth
{'id': 21}, # 1 IP Address
{'id': 13887}, # 100 GB (LOCAL)
{'id': 20948}, # Windows Server 2012 Standard Edition (64 bit)
{'id': 164741}, # VMware vCenter 6.0
{'id': 55}, # Host Ping Monitoring
{'id': 57}, # Email and Ticket Notifications
{'id': 58}, # Automated Notification Response
{'id': 420}, # Unlimited SSL VPN Users & 1 PPTP VPN User per account
{'id': 418}, # Nessus Vulnerability Assessment & Reporting
]
}
verification = client['SoftLayer_Product_Order'].verifyOrder(order)
if verification:
print("verified, please uncomment `placeOrder` to place the order")
# uncomment to place order
# result = client['SoftLayer_Product_Order'].placeOrder(order)
# pp(result)
if __name__ == '__main__':
create_virtual_server_with_windows_and_vcenter()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment