module yangcli {
yang-version 1;
namespace "http://netconfcentral.org/ns/yangcli";
prefix "yc";
import ietf-yang-types {
prefix "yang";
}
import yuma-ncx {
prefix "ncx";
}
import yuma-app-common {
prefix "ncxapp";
}
import yuma-types {
prefix "nt";
}
import yuma-netconf {
prefix "nc";
}
organization "Netconf Central";
contact
"Andy Bierman <support@netconfcentral.org>.";
description
"
Command Line Interface for the NETCONF protocol: Client side
Usage:
yangcli [parameters]
Normal Mode:
An interactive CLI shell with command line history.
Autostart-mode:
If the 'server' parameter is present, then yangcli will
attempt to connect to that server upon startup. If the
'user' and 'password' parameters are also present, then
the user will not be prompted before the connection
is attempted. This parameter will be processed first,
if script-mode or batch-mode is used.
Script-mode:
If the 'run-script' or 'run-command' parameter is present,
then the specified script or command will be run
automatically upon startup.
Batch-mode:
If the 'batch-mode' parameter is present, then either the
'run-script' or 'run-command' parameter will be invoked, if
present, and then the program will exit.
Autostart-mode:
If the 'server' parameter is present, then yangcli will
attempt to connect to that server upon startup. If the
'user' and 'password' parameters are also present, then
the user will not be prompted before the connection
is attempted.
Script-mode:
If the 'run-script' parameter is present, then the
specified script will be run automatically upon startup.
";
revision "2010-04-16" {
description
"Added eval command for XPath expression support";
}
revision "2010-01-14" {
description
"Initial published version for 0.9.9 release";
}
typedef LogCount {
type int32 {
range "-1 | 1 .. max";
}
description
"Number of log entries. -1 means all entries";
}
typedef LogIndex {
type uint32;
description "Index into a log buffer.";
}
grouping FillParms {
leaf target {
type string {
length "1..max";
}
mandatory "true";
description
"XPath target object to fill. If prefixes are missing
then the first match in any namespace will be used.
Any prefix used must be the default prefix
assigned to the desired YANG module. Prefix usage is
optional.";
ncx:schema-instance;
}
leaf optional {
type empty;
description
"If present, then prompt for leafs that are optional.
If not, skip these objects.";
}
anyxml value {
description
"Contains a string representing the content
to use for the filled variable.
If a string is entered, then the target value being
filled must be a leaf or leaf-list.
If a variable is referenced, then it will
be used as the content, if the target value being
filled is a leaf or a leaf-list.
If the target value is a complex object,
then the referenced variable must also be
a complex object of the same type. E.g.,
The global variable 'foo' would be specified as:
value=$$foo
The local variable 'bar' would be specified as:
value=$bar
An error will be reported if the global or local
variable does not reference the same object type
as the target parameter.";
}
} // grouping FillParms
grouping CommonPduParms {
description
"Common parms for some local commands that
generate NETCONF PDUs";
choice from {
mandatory "true";
leaf varref {
type string;
description
"Use the contents of the specified variable
as the content";
}
case from-cli {
uses FillParms;
} // case from-cli
} // choice from
} // grouping CommonPduParms
grouping EditParms {
description
"Common parms for create, merge, replace commands";
uses CommonPduParms;
leaf timeout {
type nt:Timeout;
description "Timeout to use";
}
} // grouping EditParms
grouping SGetParms {
description
"Common parms for sget and sget-config operations.";
leaf nofill {
type empty;
description
"If present, and the 'from-cli' option is used
for input, then filling of mandatory nodes
and key leafs will be skipped. Instead, the target
object will be treated as a terminating select node
in the filter element.";
}
uses ncxapp:CliWithDefaultsParm;
} // grouping SGetParms
grouping XGetParms {
description
"Common parms for xget and xget-config operations.";
choice from {
mandatory "true";
leaf varref {
type string;
description
"Use the contents of the specified variable
as the content";
}
leaf select {
type string {
length "1..max";
}
description
"The XPath expression to use in the retrieval
operation. The string may only contain
single quotes, which are required for
string literals. The entire string
will be inserted into a double-quoted
string, within the get-config PDU.
Character entities will be inserted as
needed to maintain well-formed XML.";
ncx:xpath;
}
} // choice from
leaf timeout {
type nt:Timeout;
description "Timeout to use";
}
uses ncxapp:CliWithDefaultsParm;
} // grouping XGetParms
grouping ConnectParms {
description
"Common parms for connecting to a NETCONF server.
Used by the connect operation and if present at
the command line invocation, then the connect
operation will be invoked automatically.";
leaf user {
type nt:NcxUserName;
description "User name to use for NETCONF sessions.";
}
leaf server {
type string;
description
"IP address or DNS name of the NETCONF server target.";
}
leaf password {
type string;
description
"User password to use for NETCONF sessions.
If none, then user will be prompted before connecting.";
ncx:password;
}
leaf ncport {
type uint16 {
range "1..max";
}
default "830";
description
"NETCONF port number to use. If not present, then
port 830, followed by port 22, will be tried.";
}
leaf timeout {
type nt:Timeout;
description
"Number of seconds to wait for a response
from the server before declaring a timeout.
Zero means do not timeout at all.";
}
} // grouping ConnectParms
grouping XPathParms {
description
"Common parameters used for XPath script constructs";
leaf expr {
type yang:xpath1.0 {
length "1..max";
}
mandatory "true";
description
"XPath expression string to evaluate.
Use quotes if there are any whitespace or
special characters in the expression.";
}
anyxml docroot {
description
"Use the contents of the specified variable or
external XML file as the conceptual document to
apply the expression specified in the 'expr' parameter.
If this parameter is missing then a dummy document
will be used. This is only allowed if the
expression only contains variable references
or numeric/string constants.";
}
} // grouping XPathParms
container yangcli {
description
"CLI Parameter Set for the NETCONF Client Application.";
leaf autocomp {
type boolean;
default "true";
description
"Controls whether partial keywords will be
checked for interactive or script commands.
By default, the first match for a partial keyword
will be used if no definition is found for
a command name or parameter name.";
}
leaf autohistory {
type boolean;
default "true";
description
"Controls whether the command line history buffer will
be saved at exit and loaded at startup.
If true, the default history file will be used
(~/.yuma/.yangcli_history) for loading
and saving the history buffer.
If false, the history buffer will only be stored
and loaded manually with the history command.";
}
leaf autoload {
type boolean;
default "true";
description
"Controls whether any modules (except this one)
will be automatically loaded upon startup or
upon session startup with a server. If false,
the 'mgrload' command must be used to
explicitly load all the desired YANG modules.";
}
leaf bad-data {
type enumeration {
enum "ignore" {
value 0;
description
"Silently accept invalid PDU and data model
parameters. Intended for advanced server
testing mode only.";
}
enum "warn" {
value 1;
description
"Warn, but accept invalid PDU and data model
parameters.";
}
enum "check" {
value 2;
description
"Prompt the user to keep the invalid value
or re-enter the value.";
}
enum "error" {
value 3;
description
"Prompt the user to re-enter the invalid value.";
}
}
default "check";
description
"Specifies how invalid user input from the CLI
will be handled when filling PDUs for remote
operations.";
}
leaf batch-mode {
type empty;
description
"If present, the interactive CLI will not be used.
A script should be provided with the 'run-script'
parameter, or a command provided with the 'run-command'
parameter, or else the program will simply exit.
If the auto-connect mode is enabled, then this will mode
simply test if a NETCONF session can be established,
then exit.";
}
leaf default-module {
type nt:NcxName;
description
"Default module name string to use before 'netconf'
and 'yangcli' are tried. The module prefix may need to be
used for other modules.";
}
leaf display-mode {
type enumeration {
enum "plain" {
value 0;
description
"Plain identifier without any prefix format.";
}
enum "prefix" {
value 1;
description
"Plain text with XML prefix added format.";
}
enum "module" {
value 2;
description
"Plain text with module name as prefix added format.";
}
enum "xml" {
value 3;
description "XML format.";
}
}
default "plain";
description
"Controls how values are displayed during output
to STDOUT or a log file.";
}
leaf fixorder {
type boolean;
default "true";
description
"Controls whether PDU parameters will be
automatically sent to the server in the
correct order. If false, the specified order
will be used. If true, then canonical order will
be used";
}
choice run-startup-mode {
leaf run-command {
type string {
length "1 .. 4095";
}
description
"The specified command will be invoked upon startup.
If the auto-connect parameters are provided, then
a session will be established before running the
command.";
}
leaf run-script {
type string {
length "1 .. 4095";
}
description
"The specified script will be invoked upon startup.
If the auto-connect parameters are provided, then
a session will be established before running the
script. If a quoted string is used, then any parameters
after the script name will be passed to the script.";
}
} // choice run-startup-mode
uses ncxapp:NcxAppCommon;
uses ncxapp:SubdirsParm;
uses ConnectParms;
uses ncxapp:ModuleParm;
uses ncxapp:DeviationParm;
uses ncxapp:DatapathParm;
uses ncxapp:RunpathParm;
ncx:cli;
} // container yangcli
rpc cd {
description "Change the current working directory.";
input {
leaf dir {
type string;
mandatory "true";
description "Directory path to use.";
}
ncx:default-parm "dir";
}
} // rpc cd
rpc connect {
description "Connect to a NETCONF server.";
input {
uses ConnectParms {
refine user {
mandatory "true";
}
refine server {
mandatory "true";
}
refine password {
mandatory "true";
}
}
ncx:default-parm "server";
}
} // rpc connect
rpc create {
description
"Create some NETCONF config data with the edit-config operation";
input {
uses EditParms;
ncx:default-parm "target";
}
} // rpc create
rpc delete {
description
"Delete some NETCONF config data with the edit-config operation";
input {
leaf target {
type string;
mandatory "true";
description
"Xpath expression indicating the node which is going
to be deleted.";
}
ncx:default-parm "target";
}
} // rpc delete
rpc elif {
description
"Evaluate an XPath expression locally on the manager.
and execute the block of commands that follow
if the expression is true. The block ends
when a matching 'elif', 'else', or 'end' command is reached.
This may only be used after an 'if' or 'elif' command
or an error (no matching if command) will occur.
";
input {
uses XPathParms;
ncx:default-parm "expr";
}
} // rpc elif
rpc else {
description
"End an 'if' or 'elif' command block, and start a new
command block that must end with an 'end' command.
If no 'if' or 'elif' block is in progress then an error
will occur.
";
} // rpc else
rpc end {
description
"End an 'if' command block or a 'while' command block.
If no block is in progress then an error will occur.
";
} // rpc end
rpc eval {
description
"Evaluate an XPath expression locally on the manager.
All local variables will be available to the session
context, in the following precedence:
1) current script run level
2) global variable
When the result of an eval command is saved
to a user variable, it may be altered as follows:
Convert to string:
- <data> is a simple type
- <data> contains 1 node that is a simple type
Remove the <data> container:
- <data> contains a single complex element
Retain the <data> container:
- <data> contains multiple elements
Usage Examples:
> $x = 5
x = '5'
> $x = eval '$x + 10'
x = '15'
> $y = xget /system
y = data {
system { ... }
}
> $z = eval '//sysname' docroot=$y
z = 'Linux'
> $w = eval '/system/uname' docroot=$y
w = uname {
sysname 'Linux'
...
}
";
input {
uses XPathParms;
ncx:default-parm "expr";
}
output {
anyxml data {
mandatory "true";
description
"The XPath result, returned in a data element.
The content will be a simple string for boolean, string,
and number result types.
The content will be zero or more child elements,
in their proper namespaces, if the result is a node-set.
Only the requested node(s) will be returned,
not their entire path to the document root,
like the get and get-config operations.
An empty 'data' element will be returned if the result
is an empty node-set.";
}
}
} // rpc eval
rpc eventlog {
description "Access the notification event log";
input {
choice eventlog-action {
default "show-case";
case show-case {
leaf show {
type LogCount;
default "-1";
description
"Show the specified number of event log
buffer entries. -1 means show all entries.
If the --full or --brief help-mode parameters
are entered, then the output will be altered.";
}
leaf start {
type LogIndex;
description
"Start at the specified event index number instead of
the beginning of the event log.";
}
uses ncxapp:HelpMode;
} // case show-case
leaf clear {
type LogCount;
default "25";
description
"Clear the specified number of notification
event log entries. The value zero means
clear all the entries.";
}
} // choice eventlog-action
ncx:default-parm "show";
}
} // rpc eventlog
rpc fill {
description
"Fill a value for reuse in a NETCONF PDU or other operation.
Used in an assignment statement to create a variable
for later use:
$foo = fill --target=/t:foo-con/bar-list \
--optional \
--current-value=$bar ";
input {
uses FillParms;
ncx:default-parm "target";
}
output {
anyxml data {
description
"The result of the fill operation.
The name of the value node may not really
be 'data'. If the 'target' or 'current-value'
input parameters are used, then the name
of the result node will be copied instead.
The data type will be inherited from the 'target'
or 'current_value' parameters, and not really be
an 'anyxml' structure. YANG does have a data
type that supports this feature.";
}
}
} // rpc fill
rpc get-locks {
description
"Get a lock for the running configuration
and the candidate and startup configurations,
if needed. If all the locks cannot be obtained,
then release all of them (all-or-nothing).
The entire operation must be completed within
the lock timeout interval, if it is set.";
input {
leaf lock-timeout {
type nt:Timeout;
default "120";
description
"Total time to wait to retrieve all the locks needed
to complete the get-locks command. A value of zero
means to wait forever and not use a timeout value.";
}
leaf retry-interval {
type uint32 {
range "1 .. 300";
}
units "seconds";
default "2";
description
"Retry interval to use if a lock is temporarily
unavailable. The client will wait this number of
seconds before attempting to get the current lock.";
}
leaf cleanup {
type boolean;
default "true";
description
"Indicates whether the locks obtained should be
automatically released if an RPC operation
fails (after the get-locks succeeds).";
}
}
} // rpc get-locks
rpc help {
description "Print the yangcli help text";
input {
choice helptype {
leaf command {
type nt:NcxIdentifier;
description
"Show help for the specified command,
also called an RPC method";
}
leaf commands {
type empty;
description "Show info for all local commands";
}
leaf notification {
type nt:NcxIdentifier;
description
"Show help for the specified notification";
}
leaf object {
type nt:NcxIdentifier;
description "Show help for the specified object";
}
leaf type {
type nt:NcxIdentifier;
description "Show help for the specified type";
}
} // choice helptype
uses ncxapp:HelpMode;
ncx:default-parm "command";
}
} // rpc help
rpc history {
description "Access the command line history buffer";
input {
choice history-action {
default "show-case";
case show-case {
leaf show {
type LogCount;
default "-1";
description
"Show the specified number of history
buffer entries. -1 means show all entries.";
}
uses ncxapp:HelpMode;
} // case show-case
leaf clear {
type empty;
description "Clear all the history buffer entries.";
}
leaf load {
type string;
default "~/.yuma/.yangcli_history";
description
"Load the command history buffer from the
specified file spec.";
}
leaf save {
type string;
default "~/.yuma/.yangcli_history";
description
"Save the command history buffer in the
specified filespec.";
}
} // choice history-action
ncx:default-parm "show";
}
} // rpc history
rpc if {
description
"Evaluate an XPath expression locally on the manager.
and execute the block of commands that follow
if the expression is true. The block ends
when a matching 'elif', 'else', or 'end' command is reached.
";
input {
uses XPathParms;
ncx:default-parm "expr";
}
} // rpc if
rpc insert {
description
"Insert some NETCONF config data with the edit-config operation";
input {
uses EditParms;
leaf order {
type enumeration {
enum "first" {
value 0;
}
enum "last" {
value 1;
}
enum "before" {
value 2;
}
enum "after" {
value 3;
}
}
default "last";
description
"The insert order that should be used.
If the values 'before' or 'after' are selected,
then the edit-target parameter must also be present.";
}
leaf operation {
type enumeration {
enum "create" {
value 0;
}
enum "merge" {
value 1;
}
enum "replace" {
value 2;
}
}
default "merge";
description
"The edit-config operation that should be used.";
}
leaf edit-target {
type string;
description
"The value or key clause that should be used.
This parameter should only be present if the
order selected is 'before' or 'after'.
For a leaf-list, the edit-target contains the
value of the target leaf-list node within the
configuration being edited. The new config
will be inserted before or after this leaf-list
node, depending on the order selected.
E.g., edit-target='some leaf content'.
For a list, the edit-target contains the
key values of the target list node within the
configuration being edited. The new config
will be inserted before or after this list
node, depending on the order selected.
E.g., edit-target=[name='fred'][zipcode=90210].";
}
ncx:default-parm "target";
}
} // rpc insert
rpc list {
description "List some NETCONF info.";
input {
choice listtype {
mandatory "true";
leaf commands {
type empty;
description "List all local and remote commands";
}
leaf files {
type empty;
description "List all available data files.";
}
leaf objects {
type empty;
description
"List all available top-level object names.";
}
leaf oids {
type empty;
description "List all available object identifiers.";
}
leaf modules {
type empty;
description "List all available local YANG files.";
}
leaf scripts {
type empty;
description "List all available script files.";
}
} // choice listtype
leaf module {
type nt:NcxIdentifier;
description
"List only from this module, if specified.";
}
uses ncxapp:HelpMode;
}
} // rpc list
rpc log-error {
description
"Write a message to the output log if the log-level
is greater or equal to 'error'.";
input {
leaf msg {
type string;
mandatory "true";
description
"The formatted text string to write to the log.";
}
ncx:default-parm "msg";
}
} // rpc log-error
rpc log-warn {
description
"Write a message to the output log if the log-level
is greater or equal to 'warn'.";
input {
leaf msg {
type string;
mandatory "true";
description
"The formatted text string to write to the log.";
}
ncx:default-parm "msg";
}
} // rpc log-warn
rpc log-info {
description
"Write a message to the output log if the log-level
is greater or equal to 'info'.";
input {
leaf msg {
type string;
mandatory "true";
description
"The formatted text string to write to the log.";
}
ncx:default-parm "msg";
}
} // rpc log-info
rpc log-debug {
description
"Write a message to the output log if the log-level
is greater or equal to 'debug'.";
input {
leaf msg {
type string;
mandatory "true";
description
"The formatted text string to write to the log.";
}
ncx:default-parm "msg";
}
} // rpc log-debug
rpc merge {
description
"Merge some NETCONF config data with the edit-config operation";
input {
uses EditParms;
ncx:default-parm "target";
}
} // rpc merge
rpc mgrload {
description
"Load a module or other file into the client.
Use the 'load' command to load a module into
the server.";
input {
leaf module {
type nt:NcxName;
mandatory "true";
description "Module name to load";
}
leaf revision {
type nt:Date;
description "Module revision to load.";
}
uses ncxapp:DeviationParm;
ncx:default-parm "module";
}
} // rpc mgrload
rpc pwd {
description "Print the current working directory.";
} // rpc pwd
rpc replace {
description
"Create some NETCONF config data with the edit-config operation";
input {
uses EditParms;
ncx:default-parm "target";
}
} // rpc replace
rpc quit {
description "Quit the yangcli application";
} // rpc quit
rpc recall {
description
"Recall the specified command line history
buffer entry into the current command line.";
input {
leaf index {
type LogIndex;
mandatory "true";
description
"Index [0..N] of the command line
history entry to recall.";
}
ncx:default-parm "index";
}
} // rpc recall
rpc release-locks {
description
"Unlock all the server databases that were
previously locked with the get-locks command.";
} // rpc release-locks
rpc run {
description "Internal command to run a script.";
input {
leaf script {
type string;
mandatory "true";
description "script filespec to run";
}
leaf P1 {
type string;
description "script parameter $1";
}
leaf P2 {
type string;
description "script parameter $2";
}
leaf P3 {
type string;
description "script parameter $3";
}
leaf P4 {
type string;
description "script parameter $4";
}
leaf P5 {
type string;
description "script parameter $5";
}
leaf P6 {
type string;
description "script parameter $6";
}
leaf P7 {
type string;
description "script parameter $7";
}
leaf P8 {
type string;
description "script parameter $8";
}
leaf P9 {
type string;
description "script parameter $9";
}
ncx:default-parm "script";
}
} // rpc run
rpc save {
description
"Meta command to save configuration edits.";
} // rpc save
rpc sget {
description
"Get some NETCONF running config or state data with the get
operation, using an optional subtree filter.";
input {
uses CommonPduParms;
uses SGetParms;
ncx:default-parm "target";
}
output {
anyxml data {
description
"The data resulting from the retrieval operation.";
}
}
} // rpc sget
rpc sget-config {
description
"Get some NETCONF config data with the get-config
operation, using an optional subtree filter.";
input {
uses CommonPduParms;
uses SGetParms;
container source {
description "Particular configuration to retrieve.";
choice config-source {
mandatory "true";
leaf candidate {
if-feature nc:candidate;
type empty;
description
"Only available if 'candidate' capability supported.";
}
leaf running {
type empty;
}
leaf startup {
if-feature nc:startup;
type empty;
description
"Only available if 'startup' capability supported.";
}
leaf url {
if-feature nc:url;
type nc:ConfigURIType;
description
"URL pointing to config data. Only available
if 'url' capability supported.";
}
} // choice config-source
} // container source
ncx:default-parm "target";
}
output {
anyxml data {
description
"The data resulting from the retrieval operation.";
}
}
} // rpc sget-config
rpc show {
description "Local show command for yangcli info.";
input {
choice showtype {
mandatory "true";
leaf module {
type nt:NcxIdentifier;
description "Show full info for one module";
}
leaf modules {
type empty;
description "Show info for all modules";
}
leaf local {
type nt:NcxName;
description "Show info for one local user variable";
}
leaf locals {
type empty;
description "Show info for all local user variables";
}
leaf global {
type nt:NcxName;
description
"Show full info for one global user variable";
}
leaf globals {
type empty;
description
"Show info for all global user variables";
}
leaf objects {
type empty;
description
"Show config database objects available at this time";
}
leaf var {
type nt:NcxName;
description
"Show info for one local or global variable";
}
leaf vars {
type empty;
description
"Show truncated info for all program variables";
}
leaf version {
type empty;
description "Show yangcli version info";
}
} // choice showtype
uses ncxapp:HelpMode;
}
} // rpc show
rpc while {
description
"Evaluate an XPath expression locally on the manager.
and execute the block of commands that follow
while the expression is true. The block ends
when a matching 'end' command is reached.
";
input {
uses XPathParms;
leaf maxloops {
type uint32;
default "65535";
description
"Set a maximum number of loops that can be
iterated for this while command.
The value zero means that no maximum will be
enforced. Use this mode with caution.";
}
ncx:default-parm "expr";
}
} // rpc while
rpc xget {
description
"Get some NETCONF running config or state data with the get
operation, using an optional XPath filter.";
input {
uses XGetParms;
ncx:default-parm "select";
}
output {
anyxml data {
description
"The data resulting from the retrieval operation.";
}
}
} // rpc xget
rpc xget-config {
description
"Get some NETCONF config data with the get-config
operation, using an optional XPath filter.";
input {
uses XGetParms;
container source {
description "Particular configuration to retrieve.";
choice config-source {
mandatory "true";
leaf candidate {
if-feature nc:candidate;
type empty;
description
"Only available if 'candidate' capability supported.";
}
leaf running {
type empty;
}
leaf startup {
if-feature nc:startup;
type empty;
description
"Only available if 'startup' capability supported.";
}
leaf url {
if-feature nc:url;
type nc:ConfigURIType;
description
"URL pointing to config data. Only available
if 'url' capability supported.";
}
} // choice config-source
} // container source
ncx:default-parm "select";
}
output {
anyxml data {
description
"The data resulting from the retrieval operation.";
}
}
} // rpc xget-config
} // module yangcli