Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100755 91 lines (76 sloc) 2.374 kB
0b8aa41 merged virga1 and master
BuzzTroll authored
1 #!/usr/bin/python
2
3 """
4 This program allows you to upload a public image to the nimber repository
5 """
6 import sys
7 import string
8 import random
9 import os
10 import sys
11 import sys
12 import ConfigParser
13 from ConfigParser import SafeConfigParser
14 import time
15 import tempfile
16 import traceback
17 import logging
18 import shlex
19 from optparse import SUPPRESS_HELP
20 import boto
21 from boto.s3.connection import OrdinaryCallingFormat
22 from boto.s3.connection import VHostCallingFormat
23 from boto.s3.connection import SubdomainCallingFormat
24 from boto.s3.connection import S3Connection
25 from boto.ec2.connection import EC2Connection
26
27 DEBUG = False
28
29 def get_nimbus_home():
30 """Determines home directory of Nimbus install we are using.
31
32 First looks for a NIMBUS_HOME enviroment variable, else assumes that
33 the home directory is the parent directory of the directory with this
34 script.
35 """
36 nimbus_home = os.getenv("NIMBUS_HOME")
37 if not nimbus_home:
38 script_dir = os.path.dirname(__file__)
39 nimbus_home = os.path.dirname(script_dir)
40 return nimbus_home
41
42 def main(argv=sys.argv[1:]):
43
44 try:
45 imagename = argv[0]
46
47 try:
48 s = SafeConfigParser()
49 s3cfg = os.getenv("HOME") + "/.s3cfg"
50 s.readfp(open(s3cfg, "r"))
51 s3id = s.get("default", "access_key")
52 pw = s.get("default", "secret_key")
53 host_base = s.get("default", "host_base")
54 use_https = s.getboolean("default", "use_https")
55
56 hba = host_base.split(":", 1)
57 if len(hba) == 2:
58 port = int(hba[1])
59 else:
60 port = 8888
61 host = hba[0]
62 except Exception, ex:
63 print "This program uses the s3cmd configuration file ~/.s3cfg"
64 print ex
65 sys.exit(1)
66
67 print "getting connection"
572868b @buzztroll allowing the port to be overridden by an environment variable
buzztroll authored
68 ec2port = 8444
69 try:
70 ec2port = int(os.environ['NIMBUS_TEST_EC2_PORT'])
71 except:
72 pass
73
74 ec2conn = EC2Connection(s3id, pw, host='locahost', port=ec2port, debug=2)
0b8aa41 merged virga1 and master
BuzzTroll authored
75 ec2conn.host = 'localhost'
76 print "getting image"
77 image = ec2conn.get_image(imagename)
78 print "running"
79 res = image.run(min_count=2, max_count=4)
80 res.stop_all()
81
82 except:
83 raise
84
85 return 0
86
87 if __name__ == "__main__":
88 rc = main()
89 sys.exit(rc)
90
Something went wrong with that request. Please try again.