summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorDaniil Baturin <daniil@baturin.org>2025-06-11 21:33:30 +0100
committerDaniil Baturin <daniil@baturin.org>2025-06-11 21:42:22 +0100
commit9e7832e1fc744ef98272950c324738495c08a5a4 (patch)
treeb31341c61c41fbb3f3d8bbf2de751f6ab53ee6a7 /scripts
parent5a96b6654b48cd994f3a40172c84b876f4284924 (diff)
downloadvyos-1x-9e7832e1fc744ef98272950c324738495c08a5a4.tar.gz
vyos-1x-9e7832e1fc744ef98272950c324738495c08a5a4.zip
op-mode: T7542: add support for "standalone" tag node calls
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/build-command-op-templates27
1 files changed, 26 insertions, 1 deletions
diff --git a/scripts/build-command-op-templates b/scripts/build-command-op-templates
index 0bb62113e..9eef25a2f 100755
--- a/scripts/build-command-op-templates
+++ b/scripts/build-command-op-templates
@@ -124,6 +124,26 @@ def get_properties(p):
return props
+def get_standalone(s):
+ standalone = {}
+
+ if s is None:
+ return {}
+
+ # Get the help string
+ try:
+ standalone["help"] = s.find("help").text
+ except:
+ standalone["help"] = "No help available"
+
+ # Get the command -- it's required by the schema
+ try:
+ standalone["command"] = s.find("command")
+ except:
+ raise AssertionError("Found a <standalone> node without <command>")
+
+ return standalone
+
def make_node_def(props, command):
# XXX: replace with a template processor if it grows
@@ -150,6 +170,7 @@ def process_node(n, tmpl_dir):
my_tmpl_dir = copy.copy(tmpl_dir)
props_elem = n.find("properties")
+ standalone_elem = n.find("standalone")
children = n.find("children")
command = n.find("command")
name = n.get("name")
@@ -163,6 +184,7 @@ def process_node(n, tmpl_dir):
os.makedirs(make_path(my_tmpl_dir), exist_ok=True)
props = get_properties(props_elem)
+ standalone = get_standalone(standalone_elem)
nodedef_path = os.path.join(make_path(my_tmpl_dir), "node.def")
if node_type == "node":
@@ -189,7 +211,10 @@ def process_node(n, tmpl_dir):
# does not exist at all.
if not os.path.exists(nodedef_path) or os.path.getsize(nodedef_path) == 0:
with open(nodedef_path, "w") as f:
- f.write('help: {0}\n'.format(props['help']))
+ if standalone:
+ f.write(make_node_def(standalone, standalone["command"]))
+ else:
+ f.write('help: {0}\n'.format(props['help']))
# Create the inner node.tag part
my_tmpl_dir.append("node.tag")