~james-page/openstack-charm-testing/mallards

« back to all changes in this revision

Viewing changes to bin/post-deploy-config

Merge baremetal stuff

Show diffs side-by-side

added added

removed removed

Lines of Context:
3
3
import subprocess
4
4
import yaml
5
5
import os
 
6
import sys
6
7
 
7
8
cmd_out = subprocess.check_output(['neutron', 'net-list'])
8
 
admin_net_name = os.environ['OS_USERNAME'] + '_admin_net'
9
 
for line in cmd_out.split('\n'):
10
 
    if admin_net_name in line:
11
 
        admin_net_id = line.split('|')[1].replace(' ','')
 
9
 
 
10
try:
 
11
    net_id = os.environ['NET_ID']
 
12
except KeyError:
 
13
    net_id = None
 
14
 
 
15
if net_id:
 
16
    # Use OSCI / Jenkins environment variable if defined.
 
17
    print 'Using NET_ID environment variable: {}'.format(net_id)
 
18
else:
 
19
    # Preserve existing default behavior (eg. manual testing)
 
20
    net_name = os.environ['OS_USERNAME'] + '_admin_net'
 
21
    print 'Using default network name: {}'.format(net_name)
 
22
    for line in cmd_out.split('\n'):
 
23
        if net_name in line:
 
24
            net_id = line.split('|')[1].replace(' ','')
12
25
 
13
26
gateway_config = yaml.load(subprocess.check_output(['juju', 'status', 'neutron-gateway']))
14
27
 
18
31
 
19
32
if len(uuids) > 0:
20
33
    for uuid in uuids:
21
 
        subprocess.check_call(['nova', 'interface-attach', '--net-id', admin_net_id, uuid])
 
34
        subprocess.check_call(['nova', 'interface-attach', '--net-id', net_id, uuid])
22
35
    subprocess.check_call(['juju', 'set', 'neutron-gateway', 'ext-port=eth1'])