Page MenuHomeVyOS Platform

XML schema: add valueHelp support in op-mode definitions.
Open, WishlistPublicFEATURE 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?
Perfectly compatible
Issue type
Internal change (not visible to end users)

Event Timeline

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).

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

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:

[email protected]:~$ 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
erkin set Issue type to Internal change (not visible to end users).Aug 31 2021, 5:18 PM
dmbaturin triaged this task as Wishlist priority.Jan 9 2024, 4:21 PM
dmbaturin edited projects, added VyOS 1.5 Circinus; removed VyOS 1.3 Equuleus (1.3.6).
dmbaturin changed Is it a breaking change? from Unspecified (possibly destroys the router) to Perfectly compatible.
dmbaturin added a project: Restricted Project.Thu, Apr 4, 8:11 PM