module yangcli { 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 ."; description " Command Line Interface for the NETCONF protocol: Client side Usage: yangcli [parameters] yangcli --help yangcli --version 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. Any interactive input breaks in the script or command will be skipped. "; revision 2011-03-05 { description "Added 'xml-nons' display mode to display-mode parameter. Added 'cli' and 'system' to show command; subset of show vars."; } 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 { description "Number of log entries. -1 means all entries"; type int32 { range "-1 | 1 .. max"; } } typedef LogIndex { description "Index into a log buffer."; type uint32; } /************************************************************* * * Groupings for parameters used in multiple commands * *************************************************************/ grouping FillParms { leaf target { 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."; // type schema-instance-identifier; TBD type string { length "1..max"; } mandatory true; ncx:schema-instance; } leaf optional { description "If present, then prompt for leafs that are optional. If not, skip these objects."; type empty; } 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 CommonPduParms { description "Common parms for some local commands that generate NETCONF PDUs"; choice from { mandatory true; leaf varref { description "Use the contents of the specified variable as the content"; type string; } case from-cli { uses FillParms; } } } grouping EditParms { description "Common parms for create, merge, replace commands"; uses CommonPduParms; leaf timeout { description "Timeout to use"; type nt:Timeout; } } grouping SGetParms { description "Common parms for sget and sget-config operations."; leaf nofill { 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."; type empty; } uses ncxapp:CliWithDefaultsParm; } grouping XGetParms { description "Common parms for xget and xget-config operations."; choice from { mandatory true; leaf varref { description "Use the contents of the specified variable as the content"; type string; } leaf select { 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."; type string { length "1..max"; } ncx:xpath; } } leaf timeout { description "Timeout to use"; type nt:Timeout; } uses ncxapp:CliWithDefaultsParm; } 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 { description "User name to use for NETCONF sessions."; type nt:NcxUserName; } leaf server { description "IP address or DNS name of the NETCONF server target."; type string; } leaf password { description "User password to use for NETCONF sessions. If none, then user will be prompted before connecting."; type string; ncx:password; } leaf ncport { description "NETCONF port number to use. If not present, then port 830, followed by port 22, will be tried."; type uint16 { range "1..max"; } default 830; } leaf timeout { description "Number of seconds to wait for a response from the server before declaring a timeout. Zero means do not timeout at all."; type nt:Timeout; } } grouping XPathParms { description "Common parameters used for XPath script constructs"; leaf expr { description "XPath expression string to evaluate. Use quotes if there are any whitespace or special characters in the expression."; type yang:xpath1.0 { length "1..max"; } mandatory true; } 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."; } } /************************************************************* * * CLI parameter set for yangcli program * *************************************************************/ container yangcli { ncx:cli; description "CLI Parameter Set for the NETCONF Client Application."; uses ncxapp:NcxAppCommon; uses ncxapp:SubdirsParm; uses ConnectParms; leaf autocomp { 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."; type boolean; default true; } leaf autoload { 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."; type boolean; default true; } leaf autohistory { 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."; type boolean; default true; } leaf bad-data { description "Specifies how invalid user input from the CLI will be handled when filling PDUs for remote operations."; type enumeration { enum ignore { description "Silently accept invalid PDU and data model parameters. Intended for advanced server testing mode only."; } enum warn { description "Warn, but accept invalid PDU and data model parameters."; } enum check { description "Prompt the user to keep the invalid value or re-enter the value."; } enum error { description "Prompt the user to re-enter the invalid value."; } } default "check"; } leaf batch-mode { 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."; type empty; } leaf default-module { description "Default module name string to use before 'netconf' and 'yangcli' are tried. The module prefix may need to be used for other modules."; type nt:NcxName; } leaf display-mode { description "Controls how values are displayed during output to STDOUT or a log file."; type enumeration { enum plain { description "Plain identifier without any prefix format."; } enum prefix { description "Plain text with XML prefix added format."; } enum module { description "Plain text with module name as prefix added format."; } enum xml { description "XML format."; } enum xml-nons { description "XML format, but no namespace (xmlns) attributes will be generated."; } } default plain; } leaf fixorder { 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"; type boolean; default true; } uses ncxapp:ModuleParm; uses ncxapp:DeviationParm; uses ncxapp:DatapathParm; uses ncxapp:RunpathParm; choice run-startup-mode { leaf run-script { 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."; type string { length "1 .. 4095"; } } leaf run-command { 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."; type string { length "1 .. 4095"; } } } } /************************************************************* * * RPC methods for local commands within yangcli * *************************************************************/ rpc cd { description "Change the current working directory."; input { ncx:default-parm dir; leaf dir { description "Directory path to use."; type string; mandatory true; } } } rpc connect { description "Connect to a NETCONF server."; input { ncx:default-parm server; uses ConnectParms { refine user { mandatory true; } refine server { mandatory true; } refine password { mandatory true; } } } } rpc create { description "Create some NETCONF config data with the edit-config operation"; input { ncx:default-parm target; uses EditParms; } } rpc delete { description "Delete some NETCONF config data with the edit-config operation"; input { ncx:default-parm target; leaf target { description "Xpath expression indicating the node which is going to be deleted."; type string; mandatory true; } } } 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 { ncx:default-parm expr; uses XPathParms; } } 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 end { description "End an 'if' command block or a 'while' command block. If no block is in progress then an error will occur. "; } 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: - is a simple type - contains 1 node that is a simple type Remove the container: - contains a single complex element Retain the container: - 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 { ncx:default-parm expr; uses XPathParms; } output { anyxml data { 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."; mandatory true; } } } rpc eventlog { description "Access the notification event log"; input { ncx:default-parm show; choice eventlog-action { default show-case; case show-case { leaf show { 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."; type LogCount; default -1; } leaf start { description "Start at the specified event index number instead of the beginning of the event log."; type LogIndex; } uses ncxapp:HelpMode; } leaf clear { description "Clear the specified number of notification event log entries. The value zero means clear all the entries."; type LogCount; default 25; } } } } 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 { ncx:default-parm target; uses FillParms; } 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 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 { 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."; type nt:Timeout; default 120; } leaf retry-interval { 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."; units seconds; type uint32 { range "1 .. 300"; } default 2; } leaf cleanup { description "Indicates whether the locks obtained should be automatically released if an RPC operation fails (after the get-locks succeeds)."; type boolean; default true; } } } rpc help { description "Print the yangcli help text"; input { ncx:default-parm command; choice helptype { leaf command { description "Show help for the specified command, also called an RPC method"; type nt:NcxIdentifier; } leaf commands { description "Show info for all local commands"; type empty; } leaf notification { description "Show help for the specified notification"; type nt:NcxIdentifier; } leaf object { description "Show help for the specified object"; type nt:NcxIdentifier; } leaf type { description "Show help for the specified type"; type nt:NcxIdentifier; } } uses ncxapp:HelpMode; } } rpc history { description "Access the command line history buffer"; input { ncx:default-parm show; choice history-action { default show-case; case show-case { leaf show { description "Show the specified number of history buffer entries. -1 means show all entries."; type LogCount; default -1; } uses ncxapp:HelpMode; } leaf clear { description "Clear all the history buffer entries."; type empty; } leaf load { description "Load the command history buffer from the specified file spec."; type string; default "~/.yuma/.yangcli_history"; } leaf save { description "Save the command history buffer in the specified filespec."; type string; default "~/.yuma/.yangcli_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 { ncx:default-parm expr; uses XPathParms; } } rpc insert { description "Insert some NETCONF config data with the edit-config operation"; input { ncx:default-parm target; uses EditParms; leaf order { 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."; type enumeration { enum first; enum last; enum before; enum after; } default last; } leaf operation { description "The edit-config operation that should be used."; type enumeration { enum create; enum merge; enum replace; } default merge; } leaf edit-target { 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]."; type string; } } } rpc list { description "List some NETCONF info."; input { choice listtype { mandatory true; leaf commands { description "List all local and remote commands"; type empty; } leaf files { description "List all available data files."; type empty; } leaf objects { description "List all available top-level object names."; type empty; } leaf oids { description "List all available object identifiers."; type empty; } leaf modules { description "List all available local YANG files."; type empty; } leaf scripts { description "List all available script files."; type empty; } } leaf module { description "List only from this module, if specified."; type nt:NcxIdentifier; } uses ncxapp:HelpMode; } } rpc log-error { description "Write a message to the output log if the log-level is greater or equal to 'error'."; input { ncx:default-parm msg; leaf msg { description "The formatted text string to write to the log."; type string; mandatory true; } } } rpc log-warn { description "Write a message to the output log if the log-level is greater or equal to 'warn'."; input { ncx:default-parm msg; leaf msg { description "The formatted text string to write to the log."; type string; mandatory true; } } } rpc log-info { description "Write a message to the output log if the log-level is greater or equal to 'info'."; input { ncx:default-parm msg; leaf msg { description "The formatted text string to write to the log."; type string; mandatory true; } } } rpc log-debug { description "Write a message to the output log if the log-level is greater or equal to 'debug'."; input { ncx:default-parm msg; leaf msg { description "The formatted text string to write to the log."; type string; mandatory true; } } } rpc merge { description "Merge some NETCONF config data with the edit-config operation"; input { ncx:default-parm target; uses EditParms; } } rpc mgrload { description "Load a module or other file into the client. Use the 'load' command to load a module into the server."; input { ncx:default-parm module; leaf module { description "Module name to load"; type nt:NcxName; mandatory true; } leaf revision { description "Module revision to load."; type nt:Date; } uses ncxapp:DeviationParm; } } rpc pwd { description "Print the current working directory."; } rpc replace { description "Create some NETCONF config data with the edit-config operation"; input { ncx:default-parm target; uses EditParms; } } rpc quit { description "Quit the yangcli application"; } rpc recall { description "Recall the specified command line history buffer entry into the current command line."; input { ncx:default-parm index; leaf index { description "Index [0..N] of the command line history entry to recall."; type LogIndex; mandatory true; } } } rpc release-locks { description "Unlock all the server databases that were previously locked with the get-locks command."; } rpc run { description "Internal command to run a script."; input { ncx:default-parm script; leaf script { description "script filespec to run"; type string; mandatory true; } // hardwired parameter names required at this time // just allow 9 parameter/value pairs // P0 is reserved for the name of the called script leaf P1 { description "script parameter $1"; type string; } leaf P2 { description "script parameter $2"; type string; } leaf P3 { description "script parameter $3"; type string; } leaf P4 { description "script parameter $4"; type string; } leaf P5 { description "script parameter $5"; type string; } leaf P6 { description "script parameter $6"; type string; } leaf P7 { description "script parameter $7"; type string; } leaf P8 { description "script parameter $8"; type string; } leaf P9 { description "script parameter $9"; type string; } } } rpc save { description "Meta command to save configuration edits."; } rpc sget { description "Get some NETCONF running config or state data with the get operation, using an optional subtree filter."; input { ncx:default-parm target; uses CommonPduParms; uses SGetParms; } output { anyxml data { description "The data resulting from the retrieval operation."; } } } rpc sget-config { description "Get some NETCONF config data with the get-config operation, using an optional subtree filter."; input { ncx:default-parm target; uses CommonPduParms; uses SGetParms; container source { description "Particular configuration to retrieve."; choice config-source { mandatory true; leaf candidate { if-feature nc:candidate; description "Only available if 'candidate' capability supported."; type empty; } leaf running { type empty; } leaf startup { if-feature nc:startup; description "Only available if 'startup' capability supported."; type empty; } leaf url { if-feature nc:url; description "URL pointing to config data. Only available if 'url' capability supported."; type nc:ConfigURIType; } } } } output { anyxml data { description "The data resulting from the retrieval operation."; } } } rpc show { description "Local show command for yangcli info."; input { choice showtype { mandatory true; leaf cli { description "Show the yangcli CLI parameters"; type empty; } leaf module { description "Show full info for one module"; type nt:NcxIdentifier; } leaf modules { description "Show info for all modules"; type empty; } leaf local { description "Show info for one local user variable"; type nt:NcxName; } leaf locals { description "Show info for all local user variables"; type empty; } leaf global { description "Show full info for one global user variable"; type nt:NcxName; } leaf globals { description "Show info for all global user variables"; type empty; } leaf objects { description "Show config database objects available at this time"; type empty; } leaf system { description "Show the read-only system environment variables and the read-write yangcli program variables."; type empty; } leaf var { description "Show info for one local or global variable"; type nt:NcxName; } leaf vars { description "Show truncated info for all program variables"; type empty; } leaf version { description "Show yangcli version info"; type empty; } } uses ncxapp:HelpMode; } } 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 { ncx:default-parm expr; uses XPathParms; leaf maxloops { 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."; type uint32; default 65535; } } } rpc xget { description "Get some NETCONF running config or state data with the get operation, using an optional XPath filter."; input { ncx:default-parm select; uses XGetParms; } output { anyxml data { description "The data resulting from the retrieval operation."; } } } rpc xget-config { description "Get some NETCONF config data with the get-config operation, using an optional XPath filter."; input { ncx:default-parm select; uses XGetParms; container source { description "Particular configuration to retrieve."; choice config-source { mandatory true; leaf candidate { if-feature nc:candidate; description "Only available if 'candidate' capability supported."; type empty; } leaf running { type empty; } leaf startup { if-feature nc:startup; description "Only available if 'startup' capability supported."; type empty; } leaf url { if-feature nc:url; description "URL pointing to config data. Only available if 'url' capability supported."; type nc:ConfigURIType; } } } } output { anyxml data { description "The data resulting from the retrieval operation."; } } } }