-
-
Save sudorandom/6257352 to your computer and use it in GitHub Desktop.
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 SoftLayer | |
from pprint import pprint as pp | |
api_username = '' | |
api_key = '' | |
guestId = 1234 | |
hostname = 'host1' | |
domain_name = 'example.com' | |
operating_system = 'CENTOS_5_64' | |
client = SoftLayer.Client( | |
username=api_username, | |
api_key=api_key, | |
) | |
def getImageTemplateGUID(templateName): | |
mask = "mask[name,globalIdentifier]" | |
templates = client['Account'].getBlockDeviceTemplateGroups(mask=mask) | |
for template in templates: | |
if template['name'] == templateName: | |
return template['globalIdentifier'] | |
mask = ''' | |
mask[ | |
startCpus, | |
maxMemory, | |
networkComponents.maxSpeed, | |
blockDevices[device, diskImage.capacity], | |
localDiskFlag | |
]''' | |
guest = client['Virtual_Guest'].getObject(id=guestId, mask=mask) | |
guest['hostname'] = hostname | |
guest['domain'] = domain_name | |
guest['hourlyBillingFlag'] = True | |
guest['blockDevices'] = [guest['blockDevices'][0]] | |
guest['networkComponents'] = [guest['networkComponents'][0]] | |
guest['operatingSystemReferenceCode'] = operating_system | |
order_template = client['Virtual_Guest'].createObject(guest) | |
pp(order_template) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment