November 23, 2017

Create a VSI using the simplified way.

The script creates a simple VSI using the SoftLayer_Virtual_Guest::createObject method

Important manual pages:

Author: SoftLayer Technologies, Inc. <>
import SoftLayer

# For nice debug output:
from pprint import pprint as pp

# Your SoftLayer API username and key.
API_USERNAME = 'set me'

# Generate one at
API_KEY = 'set me'

# To get the configuration options to create the server
# call the SoftLayer_Virtual_Guest::getCreateObjectOptions method.
# e.g.
# createOptions = virtualGuestService.getCreateObjectOptions()
# pp(createOptions)
# Creating our virtual guest server template with the configuration options that we want.
templateObject = {
    "hostname": "host1",  # The name of the server
    "domain": "",  # The domain for the server
    "startCpus": 2,  # The number of logical CPU cores to allocate
    "maxMemory": 2,  # The amount of memory to allocate in gigabytes.
    "localDiskFlag": False,  # Indicates that the vsi has at least one disk local to the host it runs on.
                             # This does not include a SWAP device.
    "hourlyBillingFlag": True,  # Specifies the billing type for the server.
    "operatingSystemReferenceCode": "UBUNTU_LATEST",  # An identifier for the operating system to
                                                      # provision the server with.
    "datacenter": {  # Specifies which datacenter the server is to be provisioned in.
        "name": "dal10"
    "userData": [
            "value": "someValue"

# Declare the API client
client = SoftLayer.create_client_from_env(username=API_USERNAME, api_key=API_KEY)
virtualGuestService = client['SoftLayer_Virtual_Guest']

To test the input parameters call the SoftLayer_Virtual_Guest::generateOrderTemplate method
when you are ready to create the server call the createObject method instead.
    receipt = virtualGuestService.generateOrderTemplate(templateObject)
except SoftLayer.SoftLayerAPIError as e:
    If there was an error returned from the SoftLayer API then bomb out with the
    error message.
    pp("Unable to create the VSI. "
          % (e.faultCode, e.faultString))


We would love to hear it
Open an issue