-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlauncher
executable file
·104 lines (79 loc) · 3.36 KB
/
launcher
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#!/usr/bin/python
import os
import json
import re
import pprint
import aeolus.common
import aeolus.launcher
from armonic.xmpp.client import XMPPCallSync, XMPPAgentApi, XMPPError
import logging
format = '%(levelname)-7s %(module)s %(message)s'
aeolus.common.remove_default_handlers()
logger = logging.getLogger("aeolus." + __name__)
logging.basicConfig(level=logging.INFO, format=format)
logging.getLogger("sleekxmpp").setLevel(logging.INFO)
DEPLOYMENT_ID = "aeolus"
if __name__ == '__main__':
import argparse
parser = argparse.ArgumentParser()
parser.add_argument('-w', '--workspace', type=str, required=True)
parser.add_argument('--simulation', '-s', action='store_true', help="Don't perform XMPP calls")
parser.add_argument('--plan', '-p', action='store_true', help="Don't perform XMPP calls")
parser.add_argument('--machine', '-m', action='store_true', help="Show required machines")
parser.add_argument('--nova', '-n', action='store_true', help="Show nova boot commands")
parser.add_argument('--boot', '-b', action='store_true', help="Just boot locations")
parser.add_argument('--verbose', '-v', action='store_true', help="Verbose")
args = parser.parse_args()
if args.verbose:
aeolus.common.get_root_logger().setLevel(logging.DEBUG)
file_replay = args.workspace + "/" + aeolus.common.FILE_ARMONIC_REPLAY_FILLED
file_metis_plan = args.workspace + "/" + aeolus.common.FILE_METIS_PLAN_JSON
file_configuration = args.workspace + "/" + aeolus.common.FILE_CONFIGURATION
with open(file_replay, 'r') as f:
replay = json.load(f)
with open(file_metis_plan, 'r') as f:
metis_plan = json.load(f)
with open(file_configuration, 'r') as f:
configuration = json.load(f)
plan = aeolus.launcher.Plan(replay, metis_plan, configuration)
if args.plan:
import pprint
pprint.pprint([v.view() for v in plan.actions])
exit(0)
if args.simulation:
for p in plan.actions:
print p.armonic_command(jid="[email protected]", password="master")
exit(0)
if args.machine:
machines = []
for location in plan.locations:
for l in configuration['locations']:
if l['name'] == location:
machines.append((location, l['repository']))
if args.machine:
for m, r in machines:
print m, "[%s]" % r
exit(0)
if args.nova:
for l in plan.nova_locations:
print "nova boot --flavor m1.tiny --image %s --meta armonic_xmpp_domain=aeiche.innovation.mandriva.com %s" % (l.image, l.name)
exit(0)
xmpp_account = "[email protected]"
logger.info("Using account XMPP %s" % xmpp_account)
class XMPPClient(XMPPCallSync):
def session_start(self, event):
XMPPCallSync.session_start(self, event)
self.join_muc_room("aeolus")
master = XMPPClient(xmpp_account, "master", autoconnect=True, muc_domain="logs.aeiche.innovation.mandriva.com")
if args.boot:
import pprint
for v in plan.actions:
if v.type in ["nova-boot"]:
v.apply()
elif v.type in ["wait-agent"]:
v.apply(master)
master.disconnect()
exit(0)
for p in plan.run(master):
logger.info(p.armonic_command())
master.disconnect()