1
1
#!/usr/bin/env python
2
2
from __future__ import print_function
3
from argparse import ArgumentParser
6
6
from textwrap import dedent
7
from argparse import ArgumentParser
9
from jujuconfig import (
13
parse_new_state_server_from_error,
8
16
from utility import (
9
18
add_basic_testing_arguments,
12
20
from deploy_stack import (
15
24
from assess_container_networking import (
16
cleaned_bootstrap_context,
20
30
__metaclass__ = type
82
92
:return: None. Raises exception on failure.
84
94
for space in sorted(network_config.keys()):
85
client.add_space(space)
95
client.juju('space create', space)
86
96
for subnet in network_config[space]:
87
client.add_subnet(subnet, space)
97
client.juju('subnet add', (subnet, space))
89
99
for name in sorted(charms_to_space.keys()):
90
100
if 'charm' not in charms_to_space[name]:
100
110
client.juju('add-unit', 'mediawiki')
101
111
status = client.wait_for_started()
103
spaces = client.list_space()
113
spaces = yaml.load(client.get_juju_output('space list'))
105
115
unit_priv_address = {}
153
163
return (ipv4 & mask) == subnet
157
args = parse_args(argv)
158
configure_logging(args.verbose)
159
bs_manager = BootstrapManager.from_args(args)
160
bs_manager.client.enable_feature('address-allocation')
161
with cleaned_bootstrap_context(bs_manager, args) as ctx:
162
assess_spaces_subnets(bs_manager.client)
163
return ctx.return_code
168
client = get_client(args)
169
juju_home = get_juju_home()
170
bootstrap_host = None
172
if args.clean_environment:
174
if not clean_environment(client):
175
with temp_bootstrap_env(juju_home, client):
176
client.bootstrap(args.upload_tools)
177
except Exception as e:
179
client.destroy_environment()
180
client = get_client(args)
181
with temp_bootstrap_env(juju_home, client):
182
client.bootstrap(args.upload_tools)
184
client.destroy_environment()
185
client = get_client(args)
186
with temp_bootstrap_env(juju_home, client):
187
client.bootstrap(args.upload_tools)
189
logging.info('Waiting for the bootstrap machine agent to start.')
190
client.wait_for_started()
191
bootstrap_host = get_machine_dns_name(client, 0)
193
assess_spaces_subnets(client)
195
except Exception as e:
198
if bootstrap_host is None:
199
bootstrap_host = parse_new_state_server_from_error(e)
200
except Exception as e:
201
print_now('exception while dumping logs:\n')
205
if bootstrap_host is not None:
206
dump_env_logs(client, bootstrap_host, args.logs)
207
if not args.keep_env:
208
if args.clean_environment:
209
clean_environment(client)
211
client.destroy_environment()
166
214
if __name__ == '__main__':