Skip to content
Fetching contributors…
Cannot retrieve contributors at this time
executable file 86 lines (72 sloc) 2.2 KB
This program allows you to upload a public image to the nimber repository
import sys
import string
import random
import os
import sys
import sys
import ConfigParser
from ConfigParser import SafeConfigParser
import time
import tempfile
import traceback
import filecmp
import logging
import shlex
from optparse import SUPPRESS_HELP
import boto
from boto.s3.connection import OrdinaryCallingFormat
from boto.s3.connection import VHostCallingFormat
from boto.s3.connection import SubdomainCallingFormat
from boto.s3.connection import S3Connection
from boto.ec2.connection import EC2Connection
DEBUG = False
def get_nimbus_home():
"""Determines home directory of Nimbus install we are using.
First looks for a NIMBUS_HOME enviroment variable, else assumes that
the home directory is the parent directory of the directory with this
nimbus_home = os.getenv("NIMBUS_HOME")
if not nimbus_home:
script_dir = os.path.dirname(__file__)
nimbus_home = os.path.dirname(script_dir)
return nimbus_home
def main(argv=sys.argv[1:]):
imagename = argv[0]
s = SafeConfigParser()
s3cfg = os.getenv("HOME") + "/.s3cfg"
s.readfp(open(s3cfg, "r"))
s3id = s.get("default", "access_key")
pw = s.get("default", "secret_key")
host_base = s.get("default", "host_base")
use_https = s.getboolean("default", "use_https")
hba = host_base.split(":", 1)
if len(hba) == 2:
port = int(hba[1])
port = 8888
host = hba[0]
except Exception, ex:
print "This program uses the s3cmd configuration file ~/.s3cfg"
print ex
print "getting connection"
ec2conn = EC2Connection(s3id, pw, host='locahost', port=8444, debug=2) = 'localhost'
print "getting image"
image = ec2conn.get_image(imagename)
print "running"
res =, max_count=4)
return 0
if __name__ == "__main__":
rc = main()
Something went wrong with that request. Please try again.