~openstack-charmers/+junk/network-splits

« back to all changes in this revision

Viewing changes to lib/configure_instances.py

  • Committer: James Page
  • Date: 2014-08-06 12:01:37 UTC
  • mfrom: (7.1.1 network-splits)
  • Revision ID: james.page@ubuntu.com-20140806120137-jk08pk1ihstvyew0
MergeĀ andĀ rebase

Show diffs side-by-side

added added

removed removed

Lines of Context:
33
33
 
34
34
    jstat = yaml.load(subprocess.check_output(['juju', 'status']))
35
35
    machines = []
 
36
    machine_ips = []
36
37
    for machine in jstat['machines']:
37
38
        machines.append(jstat['machines'][machine]['instance-id'])
38
39
 
45
46
 
46
47
    pathname = os.path.dirname(sys.argv[0])
47
48
    logger.info('Configuring new network interfaces')
48
 
    for machine in jstat['machines']:
49
 
        subprocess.check_call(['juju', 'scp', '{}/configure-nics.py'.format(pathname),
50
 
                               "{}:".format(machine)])
51
 
    subprocess.check_call(['juju', 'run', '--all', 'sudo apt-get install --yes python-netifaces && sudo python ~ubuntu/configure-nics.py'])
 
49
 
 
50
    machine_admin_ips = []
 
51
    for server in nova.servers.list():
 
52
        if server.id in machines:
 
53
            for net_name in server.addresses:
 
54
                if net_name.endswith('_admin_net'):
 
55
                    machine_admin_ips.append(server.addresses[net_name][0]['addr'])
 
56
                                                                                                                                                                                                               
 
57
    pathname = os.path.dirname(sys.argv[0])
 
58
    for ip in machine_admin_ips:
 
59
        subprocess.check_call(['scp', '{}/configure-nics.py'.format(pathname),
 
60
                               "{}:/home/ubuntu/".format(ip)])
 
61
        subprocess.Popen(['ssh', ip, 'sudo apt-get install --yes python-netifaces && sudo python ~ubuntu/configure-nics.py'])