Exemple #1
0
#PC * Connect to VPC specified in YAML ("vpc" -> "cidr-block").
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'])
try:
    g['vpc_obj'] = init_lib.init_vpc(g['vpc_conn'], n['cidr-block'])
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
Exemple #2
0
    if count == 0:
        # master subnet
        s['name'] = yaml_lib.yaml_attr( s, 'delegate', '0' )
        s['cidr-block'] = yaml_lib.yaml_attr( s, 'cidr-block', '10.0.0.0/24' )
        print "Looking for master subnet {} ({})".format(s['cidr-block'], s['name'])
    #PC * All others are "Minion Subnets" (i.e. for delegates): CIDR block
    #PC   defaults to 10.0.<delegate>.0/24
    else:
        # minion subnet
        s['delegate'] = yaml_lib.yaml_attr( s, 'delegate', 'MISSING' )
        s['cidr-block'] = yaml_lib.yaml_attr( s, 'cidr-block', '10.0.{}.0/24'.format(count) )
        print "Looking for minion subnet {} (delegate {})".format(s['cidr-block'], s['delegate'])

    #PC * For each subnet (Master or Minion) in YAML: 
    #PC     * Get subnet object and store it.
    g['subnet_obj'].append( init_lib.init_subnet( g['vpc_conn'], g['vpc_obj'].id, s['cidr-block'] ) )
    #PC     * Clobber existing subnet tag with the one specified in YAML.
    init_lib.update_tag( g['subnet_obj'][count], 'Name', y['nametag'] )
    init_lib.update_tag( g['subnet_obj'][count], 'Delegate', s['delegate'] )

    #PC     * Update subnet "MapPublicIpOnLaunch" attribute, so all instances
    #PC       created in this subnet will automatically get a public IP address.
    if not ( 
            hasattr( g['subnet_obj'][count], 'mapPublicIpOnLaunch' ) and 
            g['subnet_obj'][count].mapPublicIpOnLaunch != 'false' 
        ):
        init_lib.set_subnet_map_public_ip( g['ec2_conn'], g['subnet_obj'][count].id )
    print "Found subnet {} (delegate {})".format(s['cidr-block'], s['delegate'])
    count += 1

#PC * If --master option was given on the command line: 
Exemple #3
0
# FIXME: validate that the region exists
y['region'] = yaml_lib.yaml_attr( y, 'region', 'eu-west-1' )
( g['vpc_conn'], g['ec2_conn'] ) = init_lib.init_region( y['region'] )
print "Connected to region {}".format( y['region'] )

#PC * Connect to VPC specified in YAML ("vpc" -> "cidr-block").
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 )