Interface definitions

From VyOS Wiki
Jump to: navigation, search

Interface definitions allow developers to specify which configuration nodes can exist and what their properties are. In simpler terms, they allow you to create configuration mode commands.

Mapping from the old node.def style to the new XML definitions

Old concept/syntax New syntax Notes
mynode/node.def
 <node name="mynode"> </node> 
Leaf nodes (nodes with values) use <leafNode> tag instead
mynode/node.tag , tag:
 <tagNode name="mynode> </node> 
help: My node
 <properties> <help>My node</help> 
val_help: <format>; some string
 <properties> <valueHelp> <format> format </format> <description> some string </description> 
Do not add angle brackets around the format, they will be inserted automatically
syntax:expression: pattern ...
 <properties> <constraint> <regex> ... 
<constraintErrorMessage> will be displayed on failure
syntax:expression: $VAR(@) in "foo", "bar", "baz" None Use regex
syntax:expression: exec ...
 <properties> <constraint> <validator> <name ="foo" argument="bar"> 
"${vyos_libexecdir}/validators/foo bar $VAR(@)" will be executed, <constraintErrorMessage> will be displayed on failure
syntax:expression: (arithmetic expression) None External arithmetic validator may be added if there's demand, complex validation is better left to commit-time scripts
priority: 999
 <properties> <priority>999</priority 
Please leave a comment explaining why the priority was chosen (e.g. "after interfaces are configured")
multi:
 <properties> <multi/> 
Only applicable to leaf nodes
allowed: echo foo bar
 <properties> <completionHelp> <list> foo bar </list> 
allowed: cli-shell-api listNodes vpn ipsec esp-group
 <properties> <completionHelp> <path> vpn ipsec esp-group </path> ... 
allowed: /path/to/script
 <properties> <completionHelp> <script> /path/to/script </script> ... 
default: None Move default values to scripts
commit:expression: None All commit time checks should be in the verify() function of the script
begin:/create:/delete: None All logic should be in the scripts