Created
October 28, 2011 12:38
-
-
Save mekza/1322171 to your computer and use it in GitHub Desktop.
OWS boto test
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
# -*- coding:utf-8 -*- | |
""" | |
""" | |
import sys | |
import time | |
import boto | |
import boto.ec2 | |
#----- Account Declaration ----- | |
account = { | |
'id': 'ID', | |
'key': 'SECRETKEY', | |
'region': boto.ec2.regioninfo.EC2RegionInfo(name = 'eu-west-1-ows', endpoint = 'ows.outscale.com') | |
} | |
def main(): | |
#----- Usage ----- | |
if len(sys.argv) != 4: | |
print '' | |
print 'Usage: %s <TYPE> <ARCH> <NUMBER>' % (sys.argv[0],) | |
print '' | |
print 'Type: Instance Type' | |
print 'Arch: x86_64 or i386' | |
print 'Number: Number of instances you want' | |
print '' | |
sys.exit(1) | |
#----- Connection ----- | |
aws_id = account['id'] | |
aws_key = account['key'] | |
aws_region = account.get('region') | |
inst_type = sys.argv[1] | |
inst_arch = sys.argv[2] | |
inst_num = sys.argv[3] | |
conn = boto.connect_ec2(aws_id, aws_key, region = aws_region, debug = int(False)) | |
#----- Starting Instances ----- | |
images = conn.get_all_images() | |
image = images[6] | |
print 'Running %s %s (%s) instance(s)' % (inst_num,inst_type,inst_arch) | |
image.run(1,inst_num,key_name='martin-pr',security_groups=None,instance_type=inst_type) | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment