NC-CLI

The CLI provides a text-based user interface used to manage the configuration of the network services provided by the 6WINDGate management. It is a NETCONF client that can be used locally or remotely over an SSH connection.

The contexts associated to the services are generated from the YANG models, which can be decorated by CLI-specific YANG extensions to adjust the CLI behavior. The CLI provides a comprehensive help system which is derived from the YANG nodes description.

CLI configuration syntax derives from YANG model

One of the key concept of the 6WINDGate management is that the command line interface is directly generated from the YANG models. This means that adding a new service does not require to change the code of nc-cli.

In edition mode, the user can browse and modify the configuration tree:

  • enter into a container by typing its name (ex: interface)

  • enter into a list by typing its name and the key (ex: vrf main)

  • set a leaf by typing its name and its value (ex: mtu 1500)

Let’s take this simple YANG extract:

container interface {
  description "Interface configuration.";

  list ethernet {
    description "Ethernet interface configuration.";
    key "name";

    leaf name {
      type string;
      description "The name of the interface";
    }

    leaf mtu {
      type uint16;
      description "Set the max transmission unit size in octets.";
    }
  }
}

The CLI will behave as below:

vsr running config# interface
vsr running interface#
vsr running interface# <?>
  (...)
  ethernet             Ethernet interface configuration.
vsr running interface# ethernet eth0
vsr running ethernet eth0#
vsr running ethernet eth0# <?>
  (...)
  mtu                  Set the max transmission unit size in octets.
vsr running ethernet eth0# mtu 1500
vsr running ethernet eth0# show config
ethernet eth0
    mtu 1500

The YANG nodes that have the config false statement (this is the case for all nodes under /vrouter:state) cannot be browsed or modified from edition mode. Their value can be shown with the show state [<path>] command.

Some YANG extensions can alter the standard behavior of the CLI. For instance:

  • nc-cli-one-liner is used to create more complex commands: the whole YANG subtree is specified on one line.

  • nc-cli-completion-xpath adds completions, based on a xpath request.

The list of available extensions can in found in $YAMS/yang/vrouter-extensions.yang. Many examples of use can be found in all the vrouter YANG modules.

Note

the choice YANG statement is not supported.

CLI RPC syntax derives from YANG model

By default, RPCs defined in a YANG module are not visible in the CLI. To make them visible, one of the following extension has to be added: nc-cli-cmd, nc-cli-show, or nc-cli-flush.

Let’s take an example:

rpc reboot {
  description
    "Schedule a system reboot after a grace period.";
  input {

    leaf delay {
      type uint32;
      units "seconds";
      default "60";
      description
        "The number of seconds to wait before rebooting.
         During that time, it is possible to cancel the reboot.";
    }

    leaf cancel {
      type empty;
      description
        "If defined, cancel a pending reboot.";
    }

   vr-ext:nc-cli-exclusive;
  }
  output {

    leaf reboot-time {
      type string;
      description
        "The time at which the system will reboot.";
    }
  }
  vr-ext:nc-cli-cmd "reboot";
}

The CLI will behave as below:

vsr running config# cmd <?>
  (...)
  reboot               Schedule a system reboot after a grace period.
vsr running config# cmd reboot <tab>
delay     cancel
vsr running config# cmd reboot <?>
  <return>             Validate command.

  cancel               If defined, cancel a pending reboot.
  delay                Default: 60, unit: seconds.
                       The number of seconds to wait before rebooting. During
                       that time, it is possible to cancel the reboot.
vsr running config# cmd reboot delay <?>
  <uint32>             Default: 60, unit: seconds.
                       The number of seconds to wait before rebooting. During
                       that time, it is possible to cancel the reboot.
vsr running config# cmd reboot delay 10 <?>
  <return>             Validate command.
vsr running config# cmd reboot delay 10
reboot
    reboot-time "Tue 2019-09-10 15:01:52"
    ..

Note

in the CLI, a RPC is always passed on one unique line (nc-cli-one-liner is implicit in the RPC input subtree).