diff options
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/build-command-op-templates | 33 | ||||
-rwxr-xr-x | scripts/build-command-templates | 2 | ||||
-rwxr-xr-x | scripts/generate-configd-include-json.py | 2 | ||||
-rwxr-xr-x | scripts/override-default | 2 | ||||
-rwxr-xr-x | scripts/transclude-template | 2 |
5 files changed, 35 insertions, 6 deletions
diff --git a/scripts/build-command-op-templates b/scripts/build-command-op-templates index 9eef25a2f..94bbd1d07 100755 --- a/scripts/build-command-op-templates +++ b/scripts/build-command-op-templates @@ -3,7 +3,7 @@ # build-command-template: converts new style command definitions in XML # to the old style (bunch of dirs and node.def's) command templates # -# Copyright (C) 2017-2024 VyOS maintainers <maintainers@vyos.net> +# Copyright VyOS maintainers and contributors <maintainers@vyos.io> # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public @@ -30,6 +30,8 @@ import functools from lxml import etree as ET from textwrap import fill +debug = True + # Defaults validator_dir = "/opt/vyatta/libexec/validators" default_constraint_err_msg = "Invalid value" @@ -177,7 +179,13 @@ def process_node(n, tmpl_dir): node_type = n.tag - my_tmpl_dir.append(name) + if name: + my_tmpl_dir.append(name) + else: + # Virtual tag nodes have no names, + # that's a normal situation. + # In that case we create subdirs at the current level. + pass if debug: print(f"Name of the node: {name};\n Created directory: ", end="") @@ -234,6 +242,27 @@ def process_node(n, tmpl_dir): inner_nodes = children.iterfind("*") for inner_n in inner_nodes: process_node(inner_n, my_tmpl_dir) + elif node_type == "virtualTagNode": + # The outer structure is already created + + # Create the inner node.tag part + my_tmpl_dir.append("node.tag") + os.makedirs(make_path(my_tmpl_dir), exist_ok=True) + if debug: + print("Created path for the virtualTagNode: {}".format(make_path(my_tmpl_dir)), end="") + + # Not sure if we want partially defined tag nodes, write the file unconditionally + nodedef_path = os.path.join(make_path(my_tmpl_dir), "node.def") + # Only create the "node.def" file if it exists but is empty, or if it + # 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(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) elif node_type == "leafNode": # This is a leaf node if debug: diff --git a/scripts/build-command-templates b/scripts/build-command-templates index 36929abb2..5d4d27e8c 100755 --- a/scripts/build-command-templates +++ b/scripts/build-command-templates @@ -3,7 +3,7 @@ # build-command-template: converts new style command definitions in XML # to the old style (bunch of dirs and node.def's) command templates # -# Copyright (C) 2017 VyOS maintainers <maintainers@vyos.net> +# Copyright VyOS maintainers and contributors <maintainers@vyos.io> # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public diff --git a/scripts/generate-configd-include-json.py b/scripts/generate-configd-include-json.py index b4b627fce..8d0accaf1 100755 --- a/scripts/generate-configd-include-json.py +++ b/scripts/generate-configd-include-json.py @@ -1,5 +1,5 @@ #!/usr/bin/env python3 -# Copyright (C) 2024 VyOS maintainers and contributors +# Copyright VyOS maintainers and contributors <maintainers@vyos.io> # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License version 2 or later as diff --git a/scripts/override-default b/scripts/override-default index 5058e79b3..fe5b07bde 100755 --- a/scripts/override-default +++ b/scripts/override-default @@ -5,7 +5,7 @@ # directive. Must be called before build-command-templates, as the schema # disallows redundancy. # -# Copyright (C) 2021 VyOS maintainers and contributors +# Copyright VyOS maintainers and contributors <maintainers@vyos.io> # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License version 2 or later as diff --git a/scripts/transclude-template b/scripts/transclude-template index 767583acd..932f91351 100755 --- a/scripts/transclude-template +++ b/scripts/transclude-template @@ -4,7 +4,7 @@ # interpret #include statements to include nested XML fragments and # snippets in documents. # -# Copyright (C) 2021 VyOS maintainers and contributors +# Copyright VyOS maintainers and contributors <maintainers@vyos.io> # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License version 2 or later as |