1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
#!/usr/bin/env python
__metaclass__ = type
from argparse import ArgumentParser
import subprocess
import sys
from jujupy import (
CannotConnectEnv,
Environment,
until_timeout,
)
def deploy_stack(environment):
""""Deploy a test stack in the specified environment.
:param environment: The name of the desired environment.
"""
env = Environment.from_config(environment)
# Clean up any leftover junk
env.destroy_environment()
env.bootstrap()
try:
# wait for status info....
try:
try:
env.get_status()
except CannotConnectEnv:
print "Status got Unable to connect to env. Retrying..."
env.get_status()
env.wait_for_started()
except subprocess.CalledProcessError as e:
if getattr(e, 'stderr', None) is not None:
sys.stderr.write(e.stderr)
raise
finally:
env.destroy_environment()
def main():
parser = ArgumentParser('Test a cloud')
parser.add_argument('env', help='The juju environment to test')
args = parser.parse_args()
try:
deploy_stack(args.env)
except Exception as e:
print '%s: %s' % (type(e), e)
sys.exit(1)
if __name__ == '__main__':
main()
|