Note: throughout this post the NSO and NCS abbreviations may be used interchangeably. NSO is the abbreviation for “Cisco Network Services Orchestrator”. However, inside the commands to interact with the platform all begin with NCS. NCS is leftover from the previous product name “Cisco Prime Network Control System (NCS)”
Please be aware that I am learning this as I go. Everything in this post has been tested, however, if you see something that is inaccurate, or needs further description please leave a comment. This will help me and others that may stumble across this post in the future
This is the start of multi part post will focus on using NSO docker image locally. I will create a netsim network with a mix of IOS, IOSXR, and NXOS devices. With this setup I can then use various tools to interact with the devices. Once we have a basic understanding of how NSO works I can take it to the next level. I will bring the docker image into GNS3 and interface with an emulated network topology. But for now, lets just focus on the basics.
For this first part, I will focus on creating the netsim network and interacting with the netsim devices using the netsim CLI. In future parts I will show how to bring the netsim devices into NSO. There I can show how to interact with NSO, and with the devices using various tools such as:
- NCS_CLI
- NSO web interface
- REST and RESTCONF API’s using Postman and Python
- NETCONF API’s using Python
To follow along with this post you need to have a NSO docker container created and running. If you do not already have a NSO lab environment setup, check out my previous post LAB: NSO with Docker Container for instructions for building the NSO docker image. All commands shown below are executed from the bash shell inside the docker container.
Device Packages (NEDS)
NSO ships with a few default Network Element Drivers (NEDS) that can be used for non-production learning activities. In the Docker Container, I have included three of these NEDs in the project folder: cisco-ios-cli-3.8, cisco-ios-xrcli-3.5, and cisco-nx-cli-3.0. The NED packages define how netsim devices will operate, and how NSO will operate with devices (both real and simulated). To see a list of the NEDs that are included with the NSO install, look in the NSO install directory under /packages/neds:
root@e2c1780f3224:~/nso-project# ls ~/nso/packages/neds/
a10-acos-cli-3.0 alu-sr-cli-3.4 cisco-ios-cli-3.0 cisco-ios-cli-3.8 cisco-iosxr-cli-3.0 cisco-iosxr-cli-3.5 cisco-nx-cli-3.0 dell-ftos-cli-3.0 juniper-junos-nc-3.0
root@e2c1780f3224:~/nso-project#
The packages installed in the current project, are in the project packages directory.
root@e2c1780f3224:~/nso-project# ls ~/nso-project/packages/
cisco-ios-cli-3.8 cisco-iosxr-cli-3.5 cisco-nx-cli-3.0
root@e2c1780f3224:~/nso-project#
To add new packages to the project, copy the package folder into the packages directory, and then reload the packages. For example the Juniper NED could be added to the project as follows. First copy the package from the NSO install directory to the project directory cp -R ~/nso/packages/neds/juniper-junos-nc-3.0/ packages/
. Next, connect to the NCS_CL, ncs_cli -C -u admin
, and reload the packages, packages reload.
root@e2c1780f3224:~/nso-project# cp -R ~/nso/packages/neds/juniper-junos-nc-3.0/ packages/
root@e2c1780f3224:~/nso-project# ls packages/
cisco-ios-cli-3.8 cisco-iosxr-cli-3.5 cisco-nx-cli-3.0 juniper-junos-nc-3.0
root@e2c1780f3224:~/nso-project# ncs_cli -C -u admin
admin@ncs# show packages package ?
Description: Show installed packages
Possible completions:
cisco-ios-cli-3.8 NED package for Cisco IOS
cisco-iosxr-cli-3.5 NED package for Cisco IOS XR
cisco-nx-cli-3.0 NED package for the Cisco NX
| Output modifiers
<cr>
# NOTE The Juniper package is not listed yet
admin@ncs# packages reload
>>> System upgrade is starting.
>>> Sessions in configure mode must exit to operational mode.
>>> No configuration changes can be performed until upgrade has completed.
>>> System upgrade has completed successfully.
reload-result {
package cisco-ios-cli-3.8
result true
}
reload-result {
package cisco-iosxr-cli-3.5
result true
}
reload-result {
package cisco-nx-cli-3.0
result true
}
reload-result {
package juniper-junos-nc-3.0
result true
}
admin@ncs# show packages package ?
Description: Show installed packages
Possible completions:
cisco-ios-cli-3.8 NED package for Cisco IOS
cisco-iosxr-cli-3.5 NED package for Cisco IOS XR
cisco-nx-cli-3.0 NED package for the Cisco NX
juniper-junos-nc-3.0 NED package for all JunOS based Juniper routers
| Output modifiers
<cr>
# NOTE: now our juniper package is installed and ready to use
Create The Netsim Network
With the docker container running, and connected to the shell use the NCS command line tools to create a network. This example uses with 6 devices: two IOS, two IOSXR and two NXOS:
- Create the Network with two IOS devices:
ncs-netsim create-network cisco-ios-cli-3.8 2 ios
- Add two IOSXR devices to the existing network:
ncs-netsim add-to-network cisco-iosxr-cli-3.5 2 iosxr
- Finally, add two NXOS devices to the existing network:
ncs-netsim add-to-network cisco-nx-cli-3.0 2 nxos
Once the network and devices are created, start the network with ncs-netsim start
Check the devices are running with ncs-netsim is-alive
Stop the network with ncs-netsim stop
Interacting With The Netsim Devices
With your netsim running, access the console of the simulated devices using ncs-netsim cli-c <device name>
or ncs-netsim cli-i <device name>
From this CLI interface you can now view existing default configuration, add new configuration, etc. This interface is a rough simulation, it will not behave exactly like a real device, or even a fully emulated device like you would have with GNS3 or VIRL. However, it is a close enough approximation that should allow us to understand how NSO will interact with the devices. Eventually I will explore using netsim for testing network automation directly against the devices (not through NSO). However for this we probably will not use the docker image, but rather NSO installed directly into our development environment.
To get started, use the netsim cli tools to add a loopback interface to ios0, iosxr0 and nxos0. For this example I will add loopback 99 to each device. The ios0 device will have an IP address 10.10.99.1/32, iosxr0 – 10.20.99.1/32, and nxos0 – 10.30.99.1/32.
Configuring Loopback 99 on ios0
root@e2c1780f3224:~/nso-project# ncs-netsim cli-i ios0
admin connected from 127.0.0.1 using console on e2c1780f3224
ios0> enable
ios0# configure terminal
Enter configuration commands, one per line. End with CNTL/Z.
ios0(config)# interface Loopback 99
ios0(config-if)# ip address 10.10.99.1 255.255.255.255
ios0(config-if)# no shutdown
ios0(config-if)# end
ios0# show running-config interface Loopback 99
interface Loopback99
no shutdown
ip address 10.10.99.1 255.255.255.255
exit
ios0# copy running-config startup-config
ios0#
ios0# exit
root@e2c1780f3224:~/nso-project#
Adding Loopback 99 on iosxr0
root@e2c1780f3224:~/nso-project# ncs-netsim cli-c iosxr0
admin connected from 127.0.0.1 using console on e2c1780f3224
e2c1780f3224# config t
Entering configuration mode terminal
e2c1780f3224(config)# interface Loopback 99
e2c1780f3224(config-if)# ipv4 address 10.20.99.1 255.255.255.255
e2c1780f3224(config-if)# commit
Commit complete.
e2c1780f3224(config-if)# end
e2c1780f3224# show running-config interface Loopback 99
interface Loopback 99
ipv4 address 10.20.99.1 255.255.255.255
exit
e2c1780f3224# exit
root@e2c1780f3224:~/nso-project#
Configuring Loopback 99 on nxos0
root@e2c1780f3224:~/nso-project# ncs-netsim cli-i nxos0
admin connected from 127.0.0.1 using console on e2c1780f3224
e2c1780f3224> enable
e2c1780f3224# configure terminal
Enter configuration commands, one per line. End with CNTL/Z.
nxos0(config)#interface loopback 99
nxos0(config-if)#ip address 10.30.99.1/32
nxos0(config-if)#no shutdown
nxos0(config-if)#end
e2c1780f3224# show running-config interface loopback 99
interface loopback99
ip address 10.30.99.1/32
ip redirects
no shutdown
!
e2c1780f3224# exit
root@e2c1780f3224:~/nso-project#
Summary
In this post I showed how to create a simple netsim network, and how to use the netsim CLI to interface with the devices. In the next post I will use the NCS CLI to synchronize and manage the devices using NSO.
For more information on how this container can be used look for other posts with the NSO-Docker tag.