Exemple #1
0
except SpinupError as e:
    print "{}".format(e)
    sys.exit()

#PC * Get Salt Master subnet (first one in "subnets" list).
#PC * If there are no subnets, print a nice message and exit.
try:
    g['master_subnet'] = init_lib.init_subnet(g['vpc_conn'], g['vpc_obj'].id,
                                              y['subnets'][0]['cidr-block'])
except SpinupError as e:
    print "{}".format(e)
    sys.exit()

#PC * Get Salt Master instance (i.e., the sole instance in the Salt Master subnet).
try:
    g['master_instance'] = init_lib.get_master_instance(
        g['ec2_conn'], g['master_subnet'].id)
except SpinupError as e:
    print "{}".format(e)
    sys.exit()
print "Salt Master is {}".format(g['master_instance'].ip_address)

#PC * Loop over all possible subnets
upper = 41
print "Looping over delegates 1-{}".format(upper - 1)
for delegate in range(1, upper):

    cidr_block = '10.0.{}.0/24'.format(delegate)

    #PC * Get subnet object (raise exception if it doesn't exist).
    g['subnet_obj'] = init_lib.init_subnet(g['vpc_conn'], g['vpc_obj'].id,
                                           cidr_block)
Exemple #2
0
    init_lib.update_tag( g['master_instance'], 'Name', y['nametag'] )

    #PC * Report result to user, and exit.
    print "Master node {} ({}, {}) created.".format(
        g['master_instance'].id, 
        g['master_instance'].ip_address,
        g['master_instance'].private_ip_address
    )
    sys.exit(0)

#PC * --master option was *not* given on the command line. Script continues.
#PC * Check that master exists and get its public IP address. Continue if and
#PC   only if there is a single instance in the Master Subnet.
# FIXME: check that the Master instance state is "running".
g['master_instance'] = init_lib.get_master_instance( 
    g['ec2_conn'], 
    g['subnet_obj'][0].id 
)

#PC * Clobber Master instance tag with hard-coded value "master".
init_lib.update_tag( g['master_instance'], 'Name', y['nametag'] )
print "Found master instance {} ({}, {})".format( 
    g['master_instance'].id, 
    g['master_instance'].ip_address,
    g['master_instance'].private_ip_address
)

#PC * The YAML should contain "install_subnets" which is a list of delegate
#PC   numbers. Look at how many elements are in that list. This is the number
#PC   of subnets that we will be installing.
y['install_subnets'] = yaml_lib.yaml_attr( y, 'install_subnets', None )
n = len(y['install_subnets'])
Exemple #3
0
n = yaml_lib.yaml_attr( y, 'vpc', None )
n['cidr-block'] = yaml_lib.yaml_attr( n, 'cidr-block', None )
n['name'] = yaml_lib.yaml_attr( n, 'name', 'susecon' )
print "Looking for VPC {}".format(n['cidr-block'])
g['vpc_obj'] = init_lib.init_vpc( g['vpc_conn'], n['cidr-block'] )

#PC * Get Salt Master subnet (first one in "subnets" list).
g['master_subnet'] = init_lib.init_subnet( 
    g['vpc_conn'],
    g['vpc_obj'].id,
    y['subnets'][0]['cidr-block']
)

#PC * Get Salt Master instance (i.e., the sole instance in the Salt Master subnet).
g['master_instance'] = init_lib.get_master_instance( 
    g['ec2_conn'], 
    g['master_subnet'].id 
)
print "Salt Master is {}".format( g['master_instance'].ip_address )

#PC * Determine subnet to start.
cidr_block = '10.0.{}.0/24'.format(delegate)

#PC * Get subnet object (raise exception if it doesn't exist).
g['subnet_obj'] = init_lib.init_subnet( g['vpc_conn'], g['vpc_obj'].id, cidr_block )
print "Starting all instances in {} (and attached volumes)".format(cidr_block)

#PC * Get all instances in the subnet.
g['instances'] = g['ec2_conn'].get_only_instances( 
    filters={ "subnet-id": g['subnet_obj'].id } 
)