-
Notifications
You must be signed in to change notification settings - Fork 0
/
ops.py
48 lines (44 loc) · 1.46 KB
/
ops.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
from ssh_connection import SshConnection
from ssh_manager import init_elastic
from ssh_tools import simple_logger
if __name__ == "__main__":
import argparse
argp = argparse.ArgumentParser()
argp.add_argument('--id',
help='connection ID',
required=True)
argp.add_argument('-d',
help='disable connection',
dest='disable',
action='store_true',
default=False)
argp.add_argument('-e',
help='enable connection',
dest='enable',
action='store_true',
default=False)
argp.add_argument('-i',
help='invalidate connection',
dest='invalidate',
action='store_true',
default=False)
argp.add_argument('-r',
help='resurrect connection',
dest='resurrection',
action='store_true',
default=False)
args = argp.parse_args()
log = simple_logger()
force = args.resurrection
elastic = init_elastic()
conn = SshConnection(elastic, es_id=args.id, force=force)
if force:
conn.maintain()
elif args.disable:
conn.disable()
elif args.enable:
conn.enable()
elif args.invalidate:
conn.invalidate()
else:
conn.maintain()