Cisco NSO – Create Service

In NSO, service is defined in YANG model. And once YANG model is defined and compiled, it will then be encoded to XML. There are few variations to define encode, such as “template only” and “python and template”. As name suggests, template is the most basic pattern, and it directly map the YANG model to XML. While with python some arbitrary operation can be configured based on YANG model before passing any values for XML encode.


1. Generate skeleton

Service package is composed from many files, you can create one by one, but you can generate a service skeleton by calling “ncs-make-package”

2. Compile with YANG model

First, we need to define how the service look like. It’s basically to define what information you want to correct in order to create a service. Because we are going to define service to modify snmp community, we need to get following information:

  • snmp community name
  • snmp community access right

So here in “leaf”, we defined what kind of information user can pass to this service. Eventually, these leaf will be presented as argument when user configures this service.

One you configured the model, we need to compile it.

3. Create python function

Those variables are passed to python function once user configures the service. In this example, I just added current year after the user passed value to make a community name.

4. Create XML template

This is the final piece of the service definition. This XML file will have an outlined XML, which is used to define the architecture of the service and eventually it is used to create the actual configuration on managed network devices.

5. Load the package into NSO

All the components in the package are ready, now you need to load the package into the NSO. You should see “oper-status up” if you configured correctly.

6. Test

Let’s test how we can use this newly created package to manage a service.

First, create a service. As you can see, leaf elemts are displayed as argument candidate.

Let’s see what command line will be sent to the managed devices.

We can see “snmp-server community testcomm2019 RO” will be sent to the device. Commit the change and see if it really changes the configuration.

It looks good, and config in Cisco (csr1000v) is also changed correclty.

And changing the access right…

…is also propagated to the device correctly.

Once you are done with your service, you can delete the service…

And that configuration is also deleted from the device.

The evaluation version of NSO comes with only a few NEDs, and obviously I have not tried much. It is quite different from other competitors in terms of how service is defined.