blob: c13302783de2ebd9533a2ce1f6acb91196ec71aa (
plain)
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
|
import argparse,sys
from clusterman.config import *
from clusterman.commands import node
def main():
parser = argparse.ArgumentParser()
subparsers = parser.add_subparsers(dest="target", help='Target')
##### Node commands #####
target_node = subparsers.add_parser("node")
node_subparsers=target_node.add_subparsers(dest="command", help='Command')
# Scan
node_cmd_scan=node_subparsers.add_parser("scan")
node_cmd_scan.add_argument("-t", "--timeout" ,help="Timeout", type=float)
# Check
node_cmd_scan=node_subparsers.add_parser("check")
node_cmd_scan.add_argument("-t", "--timeout" ,help="Timeout", type=float)
# List
node_cmd_list=node_subparsers.add_parser("list")
##### Frontend commands #####
target_frontend = subparsers.add_parser("frontend")
# Check if command specified:
if len(sys.argv)==1:
parser.print_help(sys.stderr)
sys.exit(1)
# Parse arguments:
args = parser.parse_args()
# Run the proper handler
if args.target == "node":
if args.command == "scan":
if args.timeout:
node.scan(node_cmd_scan.timeout)
else:
node.scan(CONF["timeout"])
elif args.command == "check":
if args.timeout:
node.check(node_cmd_scan.timeout)
else:
node.check(CONF["timeout"])
elif args.command == "list":
node.ls()
else:
target_node.print_help(sys.stderr)
sys.exit(1)
if args.target == "frontend":
print("Do frontend related stuff")
|