From 188f2171c62af50c95cda38e2bb86e7cf47413bd Mon Sep 17 00:00:00 2001 From: Daniil Baturin Date: Thu, 7 Jan 2021 15:48:22 +0200 Subject: T3165: use a separate file for "base" CLI nodes. --- Makefile | 3 +++ interface-definitions/base/base.xml | 23 +++++++++++++++++++++++ scripts/build-command-op-templates | 1 + scripts/build-command-templates | 15 +++++++++++---- 4 files changed, 38 insertions(+), 4 deletions(-) create mode 100644 interface-definitions/base/base.xml diff --git a/Makefile b/Makefile index 588595e42..964c533f2 100644 --- a/Makefile +++ b/Makefile @@ -34,6 +34,9 @@ $(BUILD_DIR): interface_definitions: $(BUILD_DIR) $(obj) mkdir -p $(TMPL_DIR) + # Build "base" templates (service, interfaces, other high-level nodes) + $(CURDIR)/scripts/build-command-templates $(CURDIR)/interface-definitions/base/base.xml $(CURDIR)/schema/interface_definition.rng $(TMPL_DIR) + find $(BUILD_DIR)/interface-definitions -type f -name "*.xml" | xargs -I {} $(CURDIR)/scripts/build-command-templates {} $(CURDIR)/schema/interface_definition.rng $(TMPL_DIR) || exit 1 # XXX: delete top level node.def's that now live in other packages diff --git a/interface-definitions/base/base.xml b/interface-definitions/base/base.xml new file mode 100644 index 000000000..919478d45 --- /dev/null +++ b/interface-definitions/base/base.xml @@ -0,0 +1,23 @@ + + + + + Network interfaces + + + + + High availability mechanisms + + + + + Network address translation + + + + + Network and system services + + + diff --git a/scripts/build-command-op-templates b/scripts/build-command-op-templates index c60b32a1e..54cc07794 100755 --- a/scripts/build-command-op-templates +++ b/scripts/build-command-op-templates @@ -193,6 +193,7 @@ def process_node(n, tmpl_dir): f.write('help: {0}\n'.format(props['help'])) else: # Something has already generated this file + print("Warning: refusing to overwrite already existing file {}".format(nodedef_path)) pass # Create the inner node.tag part diff --git a/scripts/build-command-templates b/scripts/build-command-templates index d6585b0cc..f09941e68 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 +# Copyright (C) 2017,2021 VyOS maintainers # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public @@ -279,19 +279,26 @@ def process_node(n, tmpl_dir): f.write(make_node_def(props)) else: # Something has already generated that file + print("Warning: refusing to overwrite already existing file {}".format(nodedef_path)) pass - if node_type == "node": + if (node_type == "node") and (children is None): + print("Warning: non-leaf, non-tag without children may be incomplete ({})".format(nodedef_path)) + pass + elif node_type == "node": inner_nodes = children.iterfind("*") for inner_n in inner_nodes: process_node(inner_n, my_tmpl_dir) - if node_type == "tagNode": + elif node_type == "tagNode": + if children is None: + raise ValueError("A without children is not allowed") + + inner_nodes = children.iterfind("*") 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) else: -- cgit v1.2.3