NSO CLI Automation Scripts

To reduce the amount of typing required for executing the steps as described in sections Managing Network Equipment with NETCONF & YANG using NSO and Building and Installing a NETCONF NED of this document, there is a set of automation scripts that can be found at https://github.com/ConfD-Developer/ConfD-Demos/tree/master/ned-test for automating the CLI commands in ncs_cli. The ned-test.py script file is already included as part of the NYAT container. The --help flag can be given at any time to get help about available sub-commands and command flags.

$ docker exec nyat ned-test.py --help
usage: ned-test [-h]
                {init,build-ned,import-tests,install-ned,test-ned,cleanup,debug}
                ...

positional arguments:
  {init,build-ned,import-tests,install-ned,test-ned,cleanup,debug}
                        sub-command help
    init                Configure device and authentication information.
    build-ned           Build a NETCONF NED based on YANG models found on
                        device_name or local YANG-models.
    import-tests        Import test vectors and optionally translate test
                        configurations.
    install-ned         Install a previously built NED.
    test-ned            Test the NETCONF/YANG interface of "device_name" by
                        applying all installed test configurations.
    cleanup             Remove test device and artifacts produced during
                        testing.
    debug               Test commands

optional arguments:
  -h, --help            show this help message and exit

To accomplish the steps as described in Managing Network Equipment with NETCONF & YANG using NSO, just do:

$ docker exec ned-test.py init --ip-address 10.80.26.213 \
                               --username admin \
                   --password admin test1a

This creates both an NSO device and a corresponding authgroup. The device and the authgroup have the same names and this makes it easy to support devices with different access credentials. Port 830 is the default for NETCONF devices and can be omitted.

Building NEDs are much easier if we use the script to accomplish the steps as described in Building and Installing a NETCONF NED, you can use the following command:

$ docker exec ned-test.py build-ned --install \
                        --ned-name tailf-dhcpd \
                        --vendor Tail-f \
                        --version 1.0 \
                        --yang-source device test1a

An important option not shown in the command above is -e (or –exclude) which allows users to indicate YANG modules to be excluded from the build. See docker exec nyat ned-test.py build-ned –help for more information and other options.

The --install option above automatically installs the new NED for the test1a device. If we didn’t give this option, we can install it later using the install-ned command:

$ docker exec nyat ned-test.py install-ned -N tailf-dhcpd-nc-1.0 test1a

The install-ned sub-command can also be used when we want to install an already existing NED for our device.