diff options
author | Christian Poessinger <christian@poessinger.com> | 2018-05-15 20:58:58 +0200 |
---|---|---|
committer | Christian Poessinger <christian@poessinger.com> | 2018-05-15 20:58:58 +0200 |
commit | d34591809104df052d2706edec3ee3f8428cf55e (patch) | |
tree | 4d4f33ef02605bbfea8d7b09feec0c0b9c8d997a /scripts | |
parent | 86771ef232f45058f8cf8c5848ef2e805afadd1b (diff) | |
parent | 30030cc0cc808b9a1c942e89e8698ee2b522b87f (diff) | |
download | vyos-1x-d34591809104df052d2706edec3ee3f8428cf55e.tar.gz vyos-1x-d34591809104df052d2706edec3ee3f8428cf55e.zip |
Merge remote-tracking branch 'upstream/current' into current
* upstream/current:
Do not try to decode data read from /sys files in the show version script, it's already an str.
Dependencies on file and pystache, for install and show version scripts..
Add dependency on hvinfo, too.
T637, T638: add dependencies on tcpdump and bmon.
T638: new op mode CLI for the bandwidth monitor commands.
T637: new op mode for traffic dumps based on tcpdump.
Correct the logic of generating tag nodes for op mode.
Add missing vyos.base module
Fix cron interval regex to allow single digit values.
Fix misplaces ConfigError exception.
Some more valueless fixes.
Mark nodes in SSH and NTP valueless (related to T602).
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/build-command-op-templates | 61 |
1 files changed, 33 insertions, 28 deletions
diff --git a/scripts/build-command-op-templates b/scripts/build-command-op-templates index 72879fe74..865590c2c 100755 --- a/scripts/build-command-op-templates +++ b/scripts/build-command-op-templates @@ -93,7 +93,7 @@ def get_properties(p): try: props["help"] = p.find("help").text except: - pass + props["help"] = "No help available" # Get the completion help strings @@ -113,7 +113,7 @@ def get_properties(p): for i in paths: comp_exprs.append("/bin/cli-shell-api listNodes {0}".format(i.text)) for i in scripts: - comp_exprs.append("sh -c \"{0}\"".format(i.text)) + comp_exprs.append("{0}".format(i.text)) comp_help = " && ".join(comp_exprs) props["comp_help"] = comp_help except: @@ -128,14 +128,6 @@ def make_node_def(props, command): node_def = "" - if "tag" in props: - node_def += "tag:\n" - - - if "type" in props: - node_def += "type: {0}\n".format(props["type"]) - - if "help" in props: node_def += "help: {0}\n".format(props["help"]) @@ -173,32 +165,45 @@ def process_node(n, tmpl_dir): props = get_properties(props_elem) - # Type should not be set for non-tag, non-leaf nodes - if node_type != "node": - props["type"] = "txt" + if node_type == "node": + if debug: + print("Processing node {}".format(name)) + + with open(os.path.join(make_path(my_tmpl_dir), "node.def"), "w") as f: + f.write(make_node_def(props, command)) + + if children is not None: + inner_nodes = children.iterfind("*") + for inner_n in inner_nodes: + process_node(inner_n, my_tmpl_dir) if node_type == "tagNode": - props["tag"] = "True" - + if debug: + print("Processing tag node {}".format(name)) - with open(os.path.join(make_path(my_tmpl_dir), "node.def"), "w") as f: - f.write(make_node_def(props, command)) + os.makedirs(make_path(my_tmpl_dir), exist_ok=True) + with open(os.path.join(make_path(my_tmpl_dir), "node.def"), "w") as f: + f.write('help: {0}\0'.format(props['help'])) - if node_type == "node": - inner_nodes = children.iterfind("*") - for inner_n in inner_nodes: - process_node(inner_n, my_tmpl_dir) - if node_type == "tagNode": my_tmpl_dir.append("node.tag") - if debug: - print("Created path for the tagNode:", end="") os.makedirs(make_path(my_tmpl_dir), exist_ok=True) - inner_nodes = children.iterfind("*") - for inner_n in inner_nodes: - process_node(inner_n, my_tmpl_dir) + if debug: + print("Created path for the tagNode: {}".format(make_path(my_tmpl_dir)), end="") + + with open(os.path.join(make_path(my_tmpl_dir), "node.def"), "w") as f: + f.write(make_node_def(props, command)) + + if children is not None: + inner_nodes = children.iterfind("*") + for inner_n in inner_nodes: + process_node(inner_n, my_tmpl_dir) else: # This is a leaf node - pass + if debug: + print("Processing leaf node {}".format(name)) + + with open(os.path.join(make_path(my_tmpl_dir), "node.def"), "w") as f: + f.write(make_node_def(props, command)) root = xml.getroot() |