-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
40 lines (29 loc) · 1.15 KB
/
main.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
import sys
import argparse
import json
from nodedata.clab import *
# DEFINE GLOBAL VARs HERE
debug_on = False
def errlog(*args, **kwargs):
print(*args, file=sys.stderr, **kwargs)
def debug(*args, **kwargs):
if debug_on:
errlog(*args, **kwargs)
def main():
# CLI arguments parser
parser = argparse.ArgumentParser(prog='node_data.py', description='Node Data API for Containerlab (experimental)')
parser.add_argument('-r', '--root', required=True, help='root directory to search for topology subfolders')
parser.add_argument('-t', '--topology', required=False, help='topology name to look for inventory file')
parser.add_argument('-s', '--secrets', required=False, help='path to a file with kinds_credentials')
parser.add_argument('-d', '--debug', required=False, help='enable debug output', action=argparse.BooleanOptionalAction)
# Common parameters
args = parser.parse_args()
global debug_on
debug_on = (args.debug == True)
debug(f"DEBUG: arguments {args}")
root = args.root
topology = args.topology
secrets = args.secrets
print(json.dumps(get_clab_node_data(root, topology, secrets)))
if __name__ == "__main__":
main()