예제 #1
0
파일: cs_create.py 프로젝트: bfosberry/occ
# prelimsies
seconds_before_retrying = 5
prefix = 'test'
creds_file = os.path.expanduser("~/.rackspace_cloud_credentials")
pyrax.set_credential_file(creds_file)
cs = pyrax.cloudservers

disp_time = helper.disp_time()

# takes a single parameter: quantity of servers to create
if len(sys.argv)<2:
        print '{0}: <number of servers>'.format(sys.argv[0])
        sys.exit(1)
else:
        num_servers = helper.strip_non_numbers(sys.argv[1])
        error = 'ERROR: you entered an invalid number of servers'
        if num_servers == '':
                print error
                sys.exit(1)
        num_servers = int(num_servers)
        if (num_servers < 1) or (num_servers > 50):
                print error, '[ either too few (0) or too many >50 ]'
                sys.exit(1)
        print 'building {0} servers...'.format(num_servers)

create_servers = []
for n in range (1, num_servers+1):
        create_servers.append(prefix+str(n))

# get all OS's in a list, filter list for Cent* matches, sort filtered list, and grab latest version
예제 #2
0
import common as helper

# preliminary
creds_file = os.path.expanduser("~/.rackspace_cloud_credentials")
pyrax.set_credential_file(creds_file)
cdb = pyrax.cloud_databases
seconds_before_retrying = 2
prefix = 'testdb'

# take two parameters: 1: an instance name, 2: number of databases to create
if len(sys.argv) < 3:
    print "syntax: {0} <instance name> <qty db's>".format(sys.argv[0])
    sys.exit(1)

db_instance_name = sys.argv[1]
db_count = helper.strip_non_numbers(sys.argv[2])

# ensure that a valid amount of databases are provided or fail
if db_count == '':
    print 'ERROR: you entered an invalid number of databases, please try again with a proper amount'
    sys.exit(1)

db_count = int(db_count)
if (db_count < 1) or (db_count > 50):
    print 'ERROR: you provided either too few (<1) or too many (>50)'
    sys.exit(1)

# search through flavors and get object for the "1GB" one
inst_512 = [
    flavor for flavor in helper.act_loop(cdb.list_flavors)
    if "1GB" in flavor.name
예제 #3
0
# preliminary
seconds_before_retrying = 5
prefix = 'test'
creds_file = os.path.expanduser("~/.rackspace_cloud_credentials")
pyrax.set_credential_file(creds_file)
cs = pyrax.cloudservers

disp_time = helper.disp_time()

# takes a single parameter: quantity of clones to create
# ensure that a valid amount is provided, cap the amount to 50 for sanity reasons
if len(sys.argv) < 2:
    print '{0}: <number of servers>'.format(sys.argv[0])
    sys.exit(1)
else:
    num_servers = helper.strip_non_numbers(sys.argv[1])
    error = 'ERROR: you entered an invalid number of servers'
    if num_servers == '':
        print error
        sys.exit(1)
    num_servers = int(num_servers)
    if (num_servers < 1) or (num_servers > 50):
        print error, '[ either too few (0) or too many >50 ]'
        sys.exit(1)

create_servers = []
for n in range(1, num_servers + 1):
    create_servers.append(prefix + str(n))

# get most recent cloud server, take an clone image of it
server = helper.act_loop(cs.servers.list)[0]
예제 #4
0
파일: cdb_create_db.py 프로젝트: opmode/occ
import common as helper

# preliminary
creds_file = os.path.expanduser("~/.rackspace_cloud_credentials")
pyrax.set_credential_file(creds_file)
cdb = pyrax.cloud_databases
seconds_before_retrying = 2
prefix = 'testdb'

# take two parameters: 1: an instance name, 2: number of databases to create
if len(sys.argv) < 3:
        print "syntax: {0} <instance name> <qty db's>".format(sys.argv[0])
        sys.exit(1)

db_instance_name = sys.argv[1]
db_count = helper.strip_non_numbers(sys.argv[2])

# ensure that a valid amount of databases are provided or fail
if db_count == '':
	print 'ERROR: you entered an invalid number of databases, please try again with a proper amount'
	sys.exit(1)

db_count = int(db_count)
if (db_count < 1) or (db_count > 50):
	print 'ERROR: you provided either too few (<1) or too many (>50)'
	sys.exit(1)

# search through flavors and get object for the "1GB" one
inst_512 = [flavor for flavor in helper.act_loop(cdb.list_flavors) if "1GB" in flavor.name][0]
# create instance with our flavor 
db_instance = helper.act_loop(cdb.create, db_instance_name, flavor=inst_512.name)