Page MenuHomeVyOS Platform

XML schema: add valueHelp support in op-mode definitions.
Open, Requires assessmentPublicFEATURE REQUEST

Description

When looking at e.g. traceroute XML defintion in op-mode a valueHelp equivalent from interface definition would be very good. The hostname/ip address definitions do not need to be "faked" but can trather be reused at multiple locations like we do in op-mode

Details

Difficulty level
Unknown (require assessment)
Version
-
Why the issue appeared?
Will be filled on close
Is it a breaking change?
Unspecified (possibly destroys the router)

Event Timeline

c-po assigned this task to dmbaturin.Mar 16 2020, 9:36 PM
c-po created this task.

Could you describe your "dream syntax" for it?
The op mode node.def's simply don't have a concept of value help in vyatta-cfg, only comp_help (<completionHelp> in XML terms).

pasik added a subscriber: pasik.Mar 18 2020, 9:51 PM
c-po added a comment.May 1 2020, 7:20 AM

Presumably a val_help line in the op-mode node.def, too

c-po added a comment.May 1 2020, 7:34 AM

The following adds support into the XML generation but I have no clue about vyatta-cfg how those files get executed.

diff --git c/schema/op-mode-definition.rnc i/schema/op-mode-definition.rnc
index cbe51e6..4bedb54 100644
--- c/schema/op-mode-definition.rnc
+++ i/schema/op-mode-definition.rnc
@@ -69,6 +69,7 @@ children = element children
 properties = element properties
 {
     help? &
+    valueHelp* &
     completionHelp*
 }

@@ -88,6 +89,13 @@ help = element help
     text
 }

+# valueHelp tags contain information about acceptable value format
+valueHelp = element valueHelp
+{
+    element format { text } &
+    element description { text }
+}
+
 command = element command
 {
     text
diff --git c/schema/op-mode-definition.rng i/schema/op-mode-definition.rng
index 900f41e..2846281 100644
--- c/schema/op-mode-definition.rng
+++ i/schema/op-mode-definition.rng
@@ -115,6 +115,9 @@
         <optional>
           <ref name="help"/>
         </optional>
+        <zeroOrMore>
+          <ref name="valueHelp"/>
+        </zeroOrMore>
         <zeroOrMore>
           <ref name="completionHelp"/>
         </zeroOrMore>
@@ -131,6 +134,20 @@
       <text/>
     </element>
   </define>
+  <!-- valueHelp tags contain information about acceptable value format -->
+  <define name="valueHelp">
+    <element name="valueHelp">
+      <interleave>
+        <element name="format">
+          <text/>
+        </element>
+        <element name="description">
+          <text/>
+        </element>
+      </interleave>
+    </element>
+  </define>
+  <!-- command to be executed -->
   <define name="command">
     <element name="command">
       <text/>
diff --git c/scripts/build-command-op-templates i/scripts/build-command-op-templates
index 689d19e..9547fe9 100755
--- c/scripts/build-command-op-templates
+++ i/scripts/build-command-op-templates
@@ -95,6 +95,15 @@ def get_properties(p):
     except:
         props["help"] = "No help available"

+    # Get value help strings
+    try:
+        vhe = p.findall("valueHelp")
+        vh = []
+        for v in vhe:
+            vh.append( (v.find("format").text, v.find("description").text) )
+        props["val_help"] = vh
+    except:
+        props["val_help"] = []

     # Get the completion help strings
     try:
@@ -131,6 +140,9 @@ def make_node_def(props, command):
     if "help" in props:
         node_def += "help: {0}\n".format(props["help"])

+    if "val_help" in props:
+        for v in props["val_help"]:
+            node_def += "val_help: {0}; {1}\n".format(v[0], v[1])

     if "comp_help" in props:
         node_def += "allowed: {0}\n".format(props["comp_help"])

When populating valHelp nodes in an op-mode this will result in:

cpo@LR1.wue3:~$ traceroute
Possible completions:
  <text>        Track network path to node
val_help: ipv4; IPv4
val_help: ipv6; IPv6
val_help: fqdn; FWDN
  ipv4          Track network path to <hostname|IPv4 address>
  ipv6          Track network path to <hostname|IPv6 address>
  vrf           Track network path to specified node via given VRF instance