Skip to content

Instantly share code, notes, and snippets.

@sebgoa
Created March 19, 2013 13:28
Show Gist options
  • Save sebgoa/5196100 to your computer and use it in GitHub Desktop.
Save sebgoa/5196100 to your computer and use it in GitHub Desktop.
Basic boto script to talk to CloudStack
#!/usr/bin/env python
import sys
import os
import boto
import boto.ec2
region = boto.ec2.regioninfo.RegionInfo(name="ROOT",endpoint="localhost")
apikey='KEbkKWtYIz_q_fnpOdwnHoZUJt5tiBNiHvf-oApytBd0adU-s-DRP3an1pqL6TutyUCzjRB9UNrBybVr3kcZ6Q'
secretkey='lXaWYrdJfwP6brE2tOxGnOSN8z_Evt7yyCg95jI__ywhmAFcZdhovAQX7-nGeG54thLtFI3HSFVa2dOPKsWcPQ'
def main():
'''Establish connection to EC2 cloud'''
conn =boto.connect_ec2(aws_access_key_id=apikey,
aws_secret_access_key=secretkey,
is_secure=False,
region=region,
port=7080,
path="/awsapi",
api_version="2010-11-15")
'''Get list of images that I own'''
images = conn.get_all_images()
print images
myimage = images[0]
'''Pick an instance type'''
vm_type='m1.small'
reservation = myimage.run(instance_type=vm_type,security_groups=['default'])
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment