-
Notifications
You must be signed in to change notification settings - Fork 0
/
acs.py
executable file
·66 lines (57 loc) · 2.11 KB
/
acs.py
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
#!/usr/bin/python
from acs.acs_utils import *
from acs.test.MesosTest import *
from acs.test.SwarmTest import *
import optparse
import sys
def main():
"""ACS command line tool"""
usage = "usage: %prog [options] command\n\n"
usage = usage + "Commands:\n\n"
usage = usage + "deploy: deploy a cluster\n\n"
usage = usage + "delete: delete a cluster\n\n"
usage = usage + "test [mesos|swarm]: test a mesos or swarm cluster\n\n"
usage = usage + "addFeature FEATURES: add one or mroe features to a cluster\n"
usage = usage + "\tFEATURES is a comma separated list of features to add.\n\n"
usage = usage + "env: display some useful information about the ACS environment currently configured"
p = optparse.OptionParser(usage=usage, version="%prog 0.1")
p.add_option('--config_file', '-c', default="cluster.ini",
help="define the configuration file to use. Default is 'cluster.ini'")
options, arguments = p.parse_args()
acs = ACSUtils(options.config_file)
log = ACSLog()
cmd = arguments[0]
log.debug("Command: " + str(cmd))
if cmd == "delete":
acs.deleteResourceGroup()
elif cmd == "deploy":
acs.createDeployment()
acs.addFeatures()
print(acs.getEnvironmentSettings)
elif cmd == "scale":
acs.scale(arguments[1])
elif cmd == "test":
mode = acs.getMode()
if mode == "mesos":
log.debug("Test Mesos mode")
test = MesosTest(acs)
test.test_all()
elif mode == "swarm":
log.debug("Test Swarm mode")
test = SwarmTest(acs)
test.testAll()
else:
log.error("Don't know how to test mode " + mode)
elif cmd == "addFeature":
featureList = arguments[1]
log.debug("Features: " + featureList)
acs.addFeatures(featureList)
elif cmd == "env":
print(json.dumps(acs.getEnvironmentSettings(), indent=4))
elif cmd == "docker":
# Deprecated
acs.agentDockerCommand(arguments[1])
else:
log.error("Unkown command: " + cmd)
if __name__ == '__main__':
main()