Nsobasic 4.2 LG PDF
Nsobasic 4.2 LG PDF
Nsobasic 4.2 LG PDF
Lab Guide
Version 4.2
DISCLAIMER WARRANTY: THIS CONTENT IS BEING PROVIDED “AS IS.” CISCO MAKES AND YOU RECEIVE NO WARRANTIES IN
CONNECTION WITH THE CONTENT PROVIDED HEREUNDER, EXPRESS, IMPLIED, STATUTORY OR IN ANY OTHER PROVISION OF
THIS CONTENT OR COMMUNICATION BETWEEN CISCO AND YOU. CISCO SPECIFICALLY DISCLAIMS ALL IMPLIED
WARRANTIES, INCLUDING WARRANTIES OF MERCHANTABILITY, NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR
PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. This learning product may contain early release
content, and while Cisco believes it to be accurate, it falls subject to the disclaimer above.
Table of Contents
Lab Guide........................................................................................................................... 1
Overview .................................................................................................................................. 1
Outline ....................................................................................................................................................1
Lab 1-1: Install NSO ................................................................................................................ 2
Activity Objective....................................................................................................................................2
Visual Objective .....................................................................................................................................2
Required Resources ..............................................................................................................................2
Job Aids .................................................................................................................................................2
Task 1: Connect to the Lab ....................................................................................................................3
Task 2: Install NSO Software.................................................................................................................5
Task 3: Install Cisco IOS and Cisco IOS XR NEDs...............................................................................9
Lab 2-1: Manage Devices...................................................................................................... 13
Activity Objective................................................................................................................................. 13
Visual Objective .................................................................................................................................. 13
Required Resources ........................................................................................................................... 13
Job Aids .............................................................................................................................................. 13
Task 1: Add Devices ........................................................................................................................... 14
Task 2: Create Device Groups ........................................................................................................... 17
Task 3: Create Customers .................................................................................................................. 19
Task 4: Create a Device Template ..................................................................................................... 19
Lab 3-1: Create a Service...................................................................................................... 26
Activity Objective................................................................................................................................. 26
Visual Objective .................................................................................................................................. 26
Required Resources ........................................................................................................................... 26
Job Aids .............................................................................................................................................. 26
Task 1: Service Requirements and Service Model............................................................................. 27
Task 2: Create Device Templates ...................................................................................................... 34
Task 3: Deploy a Service Instance ..................................................................................................... 43
Lab 3-2: Manage Services .................................................................................................... 46
Activity Objective................................................................................................................................. 46
Required Resources ........................................................................................................................... 46
Job Aids .............................................................................................................................................. 46
Task 1: Manage Service Instances..................................................................................................... 46
Task 2: Assign Service Instances to Customers ................................................................................ 49
Lab 4-1: Use NSO APIs ......................................................................................................... 51
Activity Objective................................................................................................................................. 51
Visual Objective .................................................................................................................................. 51
Required Resources ........................................................................................................................... 51
Job Aids .............................................................................................................................................. 51
Task 1: Create a Plug-and-Play Script ............................................................................................... 52
Task 2: Create a Shell Script .............................................................................................................. 55
Lab 4-2: Troubleshoot and Debug NSO ............................................................................... 57
Activity Objective................................................................................................................................. 57
Visual Objective .................................................................................................................................. 57
Required Resources ........................................................................................................................... 57
Job Aids .............................................................................................................................................. 57
Task 1: Deploy a New Service............................................................................................................ 58
Task 2: Device Troubleshooting ......................................................................................................... 65
Task 3: System Troubleshooting ........................................................................................................ 65
Appendix 1............................................................................................................................. 66
Task 1: Optimize Service Model (Advanced) ..................................................................................... 66
Lab Guide
Overview
This guide presents the instructions and other information concerning the lab activities for this course. The
activities follow the topics presented in lessons where you were provided with the necessary information in
order to be able to complete these lab exercises.
Outline
This guide includes these activities and the corresponding lessons:
Lab 1-1: Install NSO
Module 2 Lesson 1: System Setup
Lab 2-1: Manage Devices
Module 2 Lesson 2: Device Manager
Lab 3-1: Create a Service
Module 3 Lesson 3: Service Design
Lab 3-2: Manage a Service
Module 3 Lesson 4: Service Management
Lab 4-1: Use NSO APIs
Module 4 Lesson 1: Cisco NSO Integration Options
Lab 4-2: Troubleshoot and Debug NSO
Module 4 Lesson 2: Cisco NSO System Administration
Appendix 1: Optimize Service Model
Lab 1-1: Install NSO
Complete this lab activity to practice what you have learned in the related training module.
Activity Objective
In this activity, you will install the NSO system. After completing this activity, you will be able to meet these
objectives:
Install NSO software
Perform initial system configuration
Visual Objective
The figure illustrates what you will accomplish in this activity.
Install Cisco
NSO software
Workstation
Required Resources
These are the resources and equipment that are required to complete this activity:
Cisco CCO account to access dCloud
A personal computer with Cisco AnyConnect software and a browser supporting HTML5, JavaScript,
and Java or ActiveX
An SSH client application (optional)
Job Aids
These job aids are available to help you complete the lab activity:
Student guide: System Setup (Module 2 Lesson 1)
The Workstation in the lab contains three documents on the desktop:
— NSO Getting Started Guide
2 Cisco Network Services Orchestrator (NSO) v4.2 © 2016 Cisco Systems, Inc.
— NSO Installation Guide
— NSO User Guide
Activity Procedure
Complete these steps:
Step 1 In the first step, you need to connect to the lab using one of the available mechanisms.
Step 2 Use a web browser to connect to https://dcloud.cisco.com and log in using you CCO account.
When asked, choose the Americas region.
Step 3 Click the My Dashboard link at the top-right corner of the page to access the lab that has been
shared with you.
Step 4 Click the Schedule demo link and select the time range for the lab. Make sure the lab is scheduled
until at least 18:00 (6 P.M.).
Step 5 Once the lab starts, you can click the View Demo link to connect to the lab.
Step 6 Now you need to establish an AnyConnect session. Click the Connect Laptop via AnyConnect link
and follow the steps to complete the establishment of a secure session to the lab. Navigate to
Session Details to get the AnyConnect link and credentials.
Note You need to have the Cisco AnyConnect client installed on your PC.
Your Lab
Internet
Your PC
Step 7 Once the session is established, you can start connecting to lab devices:
Workstation: click the Workstation icon in the Topology view and the click the Remote
Desktop link to open a new browser window with an RDP session to the Windows desktop.
Log in using the username Administrator and password C1sco12345. Alternatively, you can
Your Lab
198.18.133.253
RDP Workstation
SSH
Internet
Your PC
198.18.134.4
Workstation
Step 9 Log in to the shell of the NSO system using the username cisco and password cisco. Accept the
public key if this is the first time you are connecting using your own SSH client software.
cisco@ncs:~$
Step 10 You have successfully connected to NSO if you get the prompt similar to what is shown above.
You can now proceed to the next task, where you will install the NSO software.
4 Cisco Network Services Orchestrator (NSO) v4.2 © 2016 Cisco Systems, Inc.
Task 2: Install NSO Software
In this task, you will install the NSO software.
Activity Procedure
Complete these steps:
Step 1 Use the SSH connection to the NSO server from the previous task.
Step 2 Start the installation using the information provided in the following table. It lists all the required
information needed to install the NSO software.
Installation directory $HOME/ncs-VERSION Replace the VERSION with the NSO version
as seen from the installation file.
This directory will be available in the
$NCS_DIR environment variable once you
use the source ncsrc command in the next
step.
Note For practical purposes it is recommended to use the local installation (--local-install argument)
for all cases such as testing, development, training, proof of concept, demonstration, and similar.
Use the system installation (--system-install argument) only for a final pilot or full production
deployment. The flexibility of NSO allows you to easily migrate packages from, for example, a
development environment to a production environment.
Note In case of local installation, you do not need the elevated super user privileges. In case of a
system install, you would need to execute the installation by elevating the installation process to
super user privileges (e.g. using the sudo command).
cisco@NCS:~$ cd $HOME
cisco@NCS:~$ ls *.bin
nso-4.2.linux.x86_64.installer.bin
cisco@NCS:~$ sh nso-4.2.linux.x86_64.installer.bin $HOME/ncs-4.2
INFO Using temporary directory /tmp/ncs_installer.1962 to stage NCS
installation bundle
INFO Unpacked ncs-4.2 in /home/cisco/ncs-4.2
INFO Found and unpacked corresponding DOCUMENTATION_PACKAGE
INFO Found and unpacked corresponding EXAMPLE_PACKAGE
INFO Generating default SSH hostkey (this may take some time)
INFO SSH hostkey generated
INFO Environment set-up generated in /home/cisco/ncs-4.2/ncsrc
INFO NCS installation script finished
INFO Found and unpacked corresponding NETSIM_PACKAGE
INFO NCS installation complete
cisco@NCS:~$ ls -l
total 160424
drwxr-xr-x 2 cisco cisco 4096 Dec 19 2014 Desktop
Step 3 The local installation relies on some environment variables that are placed into the ncsrc file
located in the directory where you installed the software. Make those variables available to your
shell session by changing to that directory and then using the source ncsrc command. This allows
NSO to access all the required resources within the sandboxed local installation (i.e. executables,
libraries, python, etc.).
cisco@NCS:~$ source $HOME/ncs-4.2/ncsrc
Step 4 Now you need to create a runtime environment in addition to the installation. Use the ncs-setup
command and place the runtime environment as a subdirectory of the installation location as
required by the table above.
cisco@NCS:~$ ncs-setup --dest $HOME/ncs-run
cisco@NCS:~$ ls -l
total 160424
drwxr-xr-x 2 cisco cisco 4096 Dec 19 2014 Desktop
drwxr-xr-x 2 cisco cisco 4096 Dec 5 2014 Documents
drwxr-xr-x 2 cisco cisco 4096 Dec 5 2014 Downloads
-rw-r--r-- 1 cisco cisco 8980 Dec 5 2014 examples.desktop
drwxr-xr-x 2 cisco cisco 4096 Dec 5 2014 Music
drwxrwxr-x 17 cisco cisco 4096 Jan 21 21:41 ncs-4.2
drwxrwxr-x 7 cisco cisco 4096 Jan 21 21:48 ncs-run
-rwxrwxrwx 1 cisco cisco 209885025 Jan 21 20:38 nso-
4.2.linux.x86_64.installer.bin
drwxr-xr-x 2 cisco cisco 4096 Dec 5 2014 Pictures
drwxr-xr-x 2 cisco cisco 4096 Dec 5 2014 Public
drwxr-xr-x 2 cisco cisco 4096 Dec 5 2014 Templates
drwxr-xr-x 2 cisco cisco 4096 Dec 5 2014 Videos
drwxrwxr-x 3 cisco cisco 4096 Jan 16 2015 workspace
cisco@NCS:~$
Step 5 Inspect the installation and try to determine the locations of the components listed in the table
below. For your own learning purposes and future reference, please record them in the space
provided in the table.
Parameter Value
Installation directory
Running directory
Logging directory
6 Cisco Network Services Orchestrator (NSO) v4.2 © 2016 Cisco Systems, Inc.
Note The system installation would default to different directories. Refer to the installation guide and
the user guide for more information regarding the directory structure used in a system
installation.
Step 7 Once the NSO process is started, you should be able to connect to the server using the web user
interface (Web UI) or command line interface (CLI).
Step 8 Use a web browser to connect to the NSO Web UI. You can do that from Workstation by opening
Internet Explorer or Google Chrome and connecting to http://ncs:8080. Alternatively, you can do
it from your own PC by connecting to http://198.18.134.4:8080. Use username admin and
password admin to authenticate.
Step 9 Now use the preferred SSH client to connect to the NSO CLI. Use the same credentials as with
Web UI (admin/admin).
cisco@NCS:~/ncs-run$ ssh [email protected] -p 2024
The authenticity of host '[198.18.134.4]:2024 ([198.18.134.4]:2024)'
can't be established.
DSA key fingerprint is 53:15:04:86:79:ab:c8:c3:30:b4:bb:25:7f:46:de.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '[198.18.134.4]:2024' (DSA) to the list of
known hosts.
[email protected]'s password:
Note Use the switch cli command to switch between the Cisco and Juniper CLI styles.
Activity Verification
You have completed this task when you attain these results:
Successfully connected to the NSO Web UI:
8 Cisco Network Services Orchestrator (NSO) v4.2 © 2016 Cisco Systems, Inc.
Task 3: Install Cisco IOS and Cisco IOS XR NEDs
In this task, you will install the Cisco IOS and Cisco IOS XR NEDs required to support the lab devices.
Activity Procedure
Complete these steps:
Step 1 In the shell of the NSO server, change the directory to $NCS_DIR/packages/neds.
cisco@NCS:~$ cd $NCS_DIR/packages/neds
cisco@NCS:~/ncs-4.2/packages/neds$ ls -l
drwxr-xr-x 8 cisco cisco 4096 Nov 26 15:06 a10-acos
drwxr-xr-x 8 cisco cisco 4096 Nov 26 15:06 cisco-ios
drwxr-xr-x 8 cisco cisco 4096 Nov 26 15:06 cisco-iosxr
drwxr-xr-x 8 cisco cisco 4096 Nov 26 15:06 cisco-nx
drwxr-xr-x 8 cisco cisco 4096 Nov 26 15:06 dell-ftos
drwxr-xr-x 6 cisco cisco 4096 Nov 26 15:07 juniper-junos
cisco@NCS:~/ncs-4.2/packages/neds$
Step 2 Which NEDs are available after the installation? For your own learning purposes, write down the
results in the table below.
Note Those NEDs are lab grade NEDs. We will use IOS provided by the installation and the new
version of IOS-XR NED provided in the repository. The repository is located at /opt/repo.
cisco@NCS:~/ncs-4.2/packages/neds$ ls -l /opt/repo
drwxr-xr-x 8 cisco cisco 4096 Jan 24 23:48 cisco-iosxr-4.1
cisco@NCS:/opt/repo$
Step 3 Change the directory to cisco-ios/src. This directory contains the Makefile to compile the Java
parts of the Cisco IOS NED. Compile NED by issuing the make command.
cisco@NCS:~/ncs-4.2/packages/neds$ cd cisco-ios/src
cisco@NCS:~/ncs-4.2/packages/neds/cisco-ios/src$ make
/home/cisco/ncs-4.2/bin/ncsc --java-disable-prefix --exclude-enums --
fail-on-warnings --java-package com.tailf.packages.ned.ios.namespaces --
emit-java java/src/com/tailf/packages/ned/ios/namespaces/CiscoIos.java
ncsc-out/modules/fxs/tailf-ned-cisco-ios.fxs
/home/cisco/ncs-4.2/bin/ncsc --java-disable-prefix --exclude-enums --
fail-on-warnings --java-package com.tailf.packages.ned.ios.namespaces --
emit-java
java/src/com/tailf/packages/ned/ios/namespaces/CiscoIosStats.java ncsc-
out/modules/fxs/tailf-ned-cisco-ios-stats.fxs
BUILD SUCCESSFUL
Total time: 4 seconds
cd ../netsim && make all
make[1]: Entering directory `/home/cisco/ncs-4.2/packages/neds/cisco-
ios/netsim'
make[1]: Nothing to be done for `all'.
make[1]: Leaving directory `/home/cisco/ncs-4.2/packages/neds/cisco-
ios/netsim'
cisco@NCS:~/ncs-4.2/packages/neds/cisco-ios/src$
Step 4 Now change the directory to /opt/repo/cisco-iosxr-4.1/src. Compile the Cisco IOS XR NED
package as well by issuing the make command again.
cisco@NCS:~/ncs-4.2/packages/neds/cisco-ios$ cd /opt/repo/cisco-iosxr-
4.1/src
cisco@NCS:/opt/repo/cisco-iosxr-4.1/src$ make
cd java && ant -q all
[javac] warning: [options] bootstrap class path not set in
conjunction with -source 1.6
[javac] /opt/repo/cisco-iosxr-
4.1/src/java/src/com/tailf/packages/ned/iosxr/IosxrNedCli.java:168:
warning: [deprecation] CONNECT_CONNECTION_REFUSED in NedWorker has been
deprecated
[javac]
worker.connectError(NedWorker.CONNECT_CONNECTION_REFUSED,
[javac] ^
[javac] /opt/repo/cisco-iosxr-
4.1/src/java/src/com/tailf/packages/ned/iosxr/IosxrNedCli.java:168:
warning: [deprecation] connectError(int,String) in NedWorker has been
deprecated
[javac]
worker.connectError(NedWorker.CONNECT_CONNECTION_REFUSED,
[javac] ^
[javac] 3 warnings
BUILD SUCCESSFUL
Total time: 3 seconds
cd ../netsim && make all
make[1]: Entering directory `/opt/repo/cisco-iosxr-4.1/netsim'
/home/cisco/ncs-4.2/netsim/confd/bin/confdc -c --export none -o aaa.fxs
/home/cisco/ncs-4.2/netsim/confd/src/confd/aaa/tailf-aaa.yang
/home/cisco/ncs-4.2/netsim/confd/bin/confdc -c --export none -a
/home/cisco/ncs-4.2/netsim/confd/src/confd/yang/ietf-netconf-acm-
ann.yang\
-o ietf-netconf-acm.fxs /home/cisco/ncs-
4.2/netsim/confd/src/confd/yang/ietf-netconf-acm.yang
make[1]: Leaving directory `/opt/repo/cisco-iosxr-4.1/netsim'
cisco@NCS:/opt/repo/cisco-iosxr-4.1/src$
Step 5 The two NEDs are now compiled and available for use but they are not available to the running
instance of NSO. One of the ways to make them available to the running instance is by linking a
directory in the ncs-run/packages directory to point to the location of the NEDs in the repository.
cisco@NCS:/opt/repo/cisco-iosxr-4.1/src$cd $HOME/ncs-run/packages
10 Cisco Network Services Orchestrator (NSO) v4.2 © 2016 Cisco Systems, Inc.
cisco@NCS:~/ncs-run/packages$ ln -s /home/cisco/ncs-
4.2/packages/neds/cisco-ios cisco-ios
cisco@NCS:~/ncs-run/packages$ ln -s /opt/repo/cisco-iosxr-4.1 cisco-
iosxr
Step 6 Now connect to the NSO CLI (SSH to 198.18.134.4 on port 2024).
cisco@NCS:~$ ssh [email protected] -p 2024
[email protected]'s password:
Step 7 Force a reload of the packages in order for Cisco IOS and Cisco IOS XR packages to be available
to the running instance of NSO. Use the packages reload command (if you are using the Cisco
style CLI) or the request packages reload command (if you are using the Juniper style CLI). Use
the switch cli command to use your preferred CLI flavor.
admin@ncs> switch cli
admin@ncs# packages reload
Note The remainder of this document will provide guidelines and printouts using the Cisco style CLI.
The output of show commands will also produce a Cisco style output which may not be the
same if you are using the Juniper style CLI.
Activity Verification
You have completed this task when you attain this result:
Use the NSO CLI show packages or show packages package package-version commands to view the
installed packages.
admin@ncs# show packages
packages package cisco-ios
package-version 3.0
description "NED package for Cisco IOS"
ncs-min-version [ 3.0.2 ]
directory ./state/packages-in-use/1/cisco-ios
component upgrade-ned-id
upgrade java-class-name com.tailf.packages.ned.ios.UpgradeNedId
component cisco-ios
ned cli ned-id cisco-ios
ned cli java-class-name com.tailf.packages.ned.ios.IOSNedCli
12 Cisco Network Services Orchestrator (NSO) v4.2 © 2016 Cisco Systems, Inc.
Lab 2-1: Manage Devices
Complete this lab activity to practice what you learned in the related training lesson.
Activity Objective
In this activity, you will manage device in NSO using Web UI and CLI. After completing this activity, you
will be able to meet these objectives:
Add devices to NSO
Create device groups
Create device templates
Visual Objective
The figure illustrates what you will accomplish in this activity. The lab consists of a number of emulated
devices that are available in your environment. As the first post-installation steps, you will have to add these
devices to the NSO and then perform some initial tasks (e.g. synchronize configurations, create device
groups, create device templates, and make sure all devices of the same type share the same common
configuration).
192.168.11.0/24
CE11 CE12
PE11 PE12
Cisco NSO
192.168.21.0/24 192.168.31.0/24
IOS XR
CE21 PE21 PE31 CE31
Required Resources
The same requirements as explained in the first lab.
Job Aids
These job aids are available to help you complete the lab activity.
Student guide: Device Manager (Module 2 Lesson 2)
The Workstation in the lab contains two documents on the desktop:
— NSO Getting Started Guide
— NSO User Guide
Activity Procedure
Complete these steps:
Step 1 The lab is already provided with the set of emulated devices, and the files are located in the
/opt/lab directory. You should start the lab.
Note Do not forget to set environment variables if you have just logged in to server.
Step 2 Now that the devices are available, you can start adding them to the NSO configuration.
Step 3 Using the ncs-netsim command, you can see ports that are used by virtual devices. Also, you can
determine if a virtual device is running or not.
cisco@NCS:/opt/lab$ ncs-netsim list
ncs-netsim list for /opt/lab/netsim
14 Cisco Network Services Orchestrator (NSO) v4.2 © 2016 Cisco Systems, Inc.
Name Type IP Address SSH Port
Step 5 Initially, devices are southbound locked, meaning that no configuration action can be pushed
down to the devices. You should set admin-state to unlocked. Also, in order to enable
communication between NSO and device, SSH keys have to be retrieved.
cisco@NCS:~$ ssh [email protected] -p 2024
[email protected]'s password:
Note The emulated devices use local authentication, so we do not need to perform any additional
configuration steps for authentication. In a real environment, you would have to modify the
authentication group default (i.e. authgroup default) or create a new authentication group where
you would specify the credentials for NSO to use when connecting to devices.
Step 6 There are better and faster ways of importing devices to NSO. In the lab, we are using netsim
simulated devices and we can export all of those using the ncs-netsim program.
cisco@NCS:/opt/lab$ ncs-netsim ncs-xml-init > devices.xml
Note The –l argument is used to trigger a load operation. The –m argument is used to merge with
possible existing data. Use man ncs_load or ncs_load --help to get more information about this
tool.
Step 8 You should now have all eight devices in the NSO configuration and ready to be used.
admin@ncs# show devices brief
NAME ADDRESS DESCRIPTION NED ID
------------------------------------------
CE11 127.0.0.1 - cisco-ios
CE12 127.0.0.1 - cisco-ios
CE21 127.0.0.1 - cisco-ios
CE31 127.0.0.1 - cisco-ios
PE11 127.0.0.1 - cisco-ios
PE12 127.0.0.1 - cisco-ios
PE21 127.0.0.1 - cisco-ios-xr
PE31 127.0.0.1 - cisco-ios
admin@ncs#
Step 9 Use the NSO CLI to retrieve the initial configurations from devices and store them in NSO's
configuration database (CDB).
admin@ncs# devices sync-from
sync-result {
device CE11
result true
}
sync-result {
device CE12
result true
}
sync-result {
device CE21
result true
}
sync-result {
device CE31
result true
}
sync-result {
device PE11
result true
}
sync-result {
device PE12
result true
}
sync-result {
device PE21
result true
}
sync-result {
device PE31
16 Cisco Network Services Orchestrator (NSO) v4.2 © 2016 Cisco Systems, Inc.
result true
}
admin@ncs#
Note There are also other ways of adding devices to NSO. Some of the tools that could also be used
for that will be discussed in a later lab.
Activity Verification
You have completed this task when you attain this result:
You see all the devices added to NSO.
All devices were successfully synced.
Activity Procedure
Complete these steps:
Step 1 First add the group “PE routers”. You can always use the Tab key or question mark as a command
auto-completion and help.
admin@ncs# config
Entering configuration mode terminal
admin@ncs(config)# devices ?
Possible completions:
authgroups - Authentication for managed devices
check-sync - Check if the NCS config is in sync with the
device
check-yang-modules - Check if NCS and the devices have compatible
YANG modules
clear-trace - Clear all trace files
commit-queue - List of queued commits
connect - Set up sessions to all unlocked devices
device - The list of managed devices
device-group - Groups of devices
disconnect - Close all sessions to all devices
fetch-ssh-host-keys - Retrieve SSH host keys from all devices
global-settings - Global settings for all managed devices.
mib-group - A list of named groups of MIBs
profiles - Device profile parameters
session-pool - List of pooled NED sessions
sync - DEPRECATED - use sync-to or sync-from instead
sync-from - Synchronize the config by pulling from the
devices
sync-to - Synchronize the config by pushing to the devices
template - Named configuration templates for devices
admin@ncs(config)# devices device-group "PE Routers"
Step 2 Add devices in group. Tab or question mark also reveal possible command completion options or
possible variable values.
© 2016 Cisco Systems, Inc. Lab Guide 17
admin@ncs(config-device-group-PE Routers)# device-name ?
Possible completions:
CE11 CE12 CE21 CE31 PE11 PE12 PE21 PE31 [
admin@ncs(config-device-group-PE Routers)# device-name [ PE11 PE12 PE21
PE31 ]
Step 3 Now repeat the previous step to create the group “CE Routers”.
admin@ncs(config-device-group-PE Routers)# top
admin@ncs(config)# devices device-group "CE Routers"
admin@ncs(config-device-group-CE Routers)# device-name [ CE11 CE12 CE21
CE31 ]
Step 4 Create a third group, which will consist of the two previously created groups:
admin@ncs(config-device-group-CE Routers)# top
admin@ncs(config)# devices device-group "All Routers"
admin@ncs(config-device-group-All Routers)# device-group [ "PE Routers"
"CE Routers" ]
Step 5 The last step in configuring those device groups is to commit the configuration. Current
configuration that is not yet committed can be seen using the show configuration command. You
always have an option to cancel the current configuration using the abort command and to
commit the configuration using the commit command.
admin@ncs(config-device-group-All Routers)# top
admin@ncs(config)# show configuration
devices device-group "All Routers"
!
devices device-group "PE Routers"
device-name [ PE11 PE12 PE21 PE31 ]
!
devices device-group "CE Routers"
device-name [ CE11 CE12 CE21 CE31 ]
!
devices device-group "All Routers"
device-group [ "CE Routers" "PE Routers" ]
!
admin@ncs(config)# commit
Commit complete.
admin@ncs(config)# exit
Activity Verification
You have completed this task when you attain this result:
All groups were successfully created.
admin@ncs# show devices device-group member
NAME MEMBER
----------------------------------------------------------
All Routers [ CE11 CE12 CE21 CE31 PE11 PE12 PE21 PE31 ]
CE Routers [ CE11 CE12 CE21 CE31 ]
PE Routers [ PE11 PE12 PE21 PE31 ]
admin@ncs#
18 Cisco Network Services Orchestrator (NSO) v4.2 © 2016 Cisco Systems, Inc.
Task 3: Create Customers
Create one or more customers in NSO.
Activity Procedure
Complete these steps:
Step 1 Using Tab or question mark, determine the proper command syntax.
admin@ncs# conf
Entering configuration mode terminal
admin@ncs(config)# customers customer ACME
admin@ncs(config-customer-ACME)#
Step 2 Give the customer a short name and set the status of active.
admin@ncs(config-customer-ACME)# rank 1
admin@ncs(config-customer-ACME)# status active
admin@ncs(config-customer-ACME)# top
admin@ncs(config)# commit
Commit complete.
Step 3 Repeat the above steps to configure as many customers as you wish.
Activity Verification
You have completed this task when you attain this result:
At least one customer was created.
admin@ncs(config)# exit
admin@ncs# show running-config customers
customers customer ACME
rank 1
status active
!
admin@ncs#
Activity Procedure
Complete these steps:
Step 1 Log in to NSO CLI either using SSH or the ncs_cli command.
Note With these templates, we are providing device-specific commands to ensure that all devices of
the same type will have the same common configuration.
Parameter Value
Use the following native configuration examples to help you perform this step:
Cisco IOS
ntp server 10.0.0.1
ip domain name cisco.com
ip name-server 198.18.133.1
Cisco IOS XR
ntp server 10.0.0.1
domain name cisco.com
domain name-server 198.18.133.1
Step 3 Create a new device configuration template called ‘Common’ and enter the template configuration
mode through the devices template config command.
admin@ncs# config
Entering configuration mode terminal
admin@ncs(config)# devices template "Common Device Parameters" config
admin@ncs(config-config)#
Step 4 Add Cisco IOS related configuration by using the ‘ios:’ tag, e.g.
admin@ncs(config-config)# ios:ip domain name cisco.com
admin@ncs(config-config)# ios:ip name-server [ 198.18.133.1 ]
admin@ncs(config-config)# ios:ntp server server-list 10.0.0.1
admin@ncs(config-server-list-10.0.0.1)# exit
admin@ncs(config-config)#
Step 5 Add Cisco IOS XR related configuration by using the ‘cisco-ios-xr:’ tag, e.g.
admin@ncs(config-config)# cisco-ios-xr:domain name cisco.com
admin@ncs(config-config)# cisco-ios-xr:domain name-server 198.18.133.1
admin@ncs(config-name-server-198.18.133.1)# exit
admin@ncs(config-config)# cisco-ios-xr:ntp server server-list 10.0.0.1
admin@ncs(config-server-10.0.0.1)# top
admin@ncs(config)# commit
Commit complete.
admin@ncs(config)#
20 Cisco Network Services Orchestrator (NSO) v4.2 © 2016 Cisco Systems, Inc.
devices template "Common Device Parameters"
config
cisco-ios-xr:domain name cisco.com
cisco-ios-xr:domain name-server 198.18.133.1
!
cisco-ios-xr:ntp server server-list 10.0.0.1
!
ios:ip domain name cisco.com
ios:ip name-server [ 198.18.133.1 ]
ios:ntp server server-list 10.0.0.1
!
!
Step 7 Apply the template to the “All Routers” device group by using the devices device-group apply-
template template-name command.
admin@ncs(config)# devices device-group "All Routers" apply-template
template-name "Common Device Parameters"
apply-template-result {
device CE11
result ok
}
apply-template-result {
device CE12
result ok
}
apply-template-result {
device CE21
result ok
}
apply-template-result {
device CE31
result ok
}
apply-template-result {
device PE11
result ok
}
apply-template-result {
device PE12
result ok
}
apply-template-result {
device PE21
result ok
}
apply-template-result {
device PE31
result ok
Step 8 Issue the commit dry-run command and check the configuration changes.
A
admin@ncs(config)# commit dry-run
device CE11
config {
ios:ip {
domain {
+ name cisco.com;
}
+ name-server 198.18.133.1;
22 Cisco Network Services Orchestrator (NSO) v4.2 © 2016 Cisco Systems, Inc.
ios:ntp {
server {
+ server-list 10.0.0.1 {
+ }
}
}
}
device PE12
config {
ios:ip {
domain {
+ name cisco.com;
}
+ name-server 198.18.133.1;
}
ios:ntp {
server {
+ server-list 10.0.0.1 {
+ }
}
}
}
device PE21
config {
cisco-ios-xr:domain {
+ name cisco.com;
+ # first
+ name-server 198.18.133.1;
}
cisco-ios-xr:ntp {
+ server 10.0.0.1 {
+ }
}
}
device PE31
config {
ios:ip {
domain {
+ name cisco.com;
}
+ name-server 198.18.133.1;
}
ios:ntp {
server {
+ server-list 10.0.0.1 {
+ }
}
}
}
admin@ncs(config)
When checking device configuration, you should see the new configuration commands on the device.
admin@ncs(config)# admin@ncs(config)# show full-configuration devices device
PE11
devices device PE11
address 127.0.0.1
port 10022
ssh host-key ssh-dss
key-data
"AAAAB3NzaC1kc3MAAACBAIMPA3H7rORCErOMUaWnSStEZqgonmRDPN0qbroiVHNS6rX8Nd12\n/7Vkg
j9VuXzngETfPo0goFIq5y6B+hMKjQhLnc29JxH7jYpRdLO5qAvFgEsMixOWNTVbxT5a\nD6in54HBtzh
2tiKYPd57aKHAW1uP0DE2bDShK3yZpc9dJRtXAAAAFQCMQ5jr0rm/7DHrE2P3\nAGHA4UYWWwAAAIBmx
ChndAobkkmFcyisEXacW84ICc7fVgBfDHF8oayxB8c2CSVrBBiaR/je\nb2cF6/1evwr+0NES0HF/O+K
IvxFFuPWGaMLOrZM/2FeFvWtf/qVJWO6vMRZa88wR3gsvqB5/\nTPM13iU3VmOiJxyLEK2NKaMnrFNbT
D17pJ6wCXwKxgAAAIBi7MoRpYWhjWeURPz6+LM6FY6q\nxMmh9LYleL38lod8hZzA0zvdaiZIY6GLgNg
bwG4V7FXnAqfCROy0CF2Tvq2N3F7eTnRFhXdH\nnWWxQdcfbERNL35UN78WozKzMyHmdy3FbkwtMsR2l
L+ylCJWOGEU5ZP4VIK3ng3h5qOB63si\nvQ=="
!
authgroup default
device-type cli ned-id cisco-ios
device-type cli protocol ssh
state admin-state unlocked
config
no ios:service pad
ios:hostname PE11
ios:ip domain name cisco.com
no ios:ip domain-lookup
no ios:ip http secure-server
ios:ip name-server 198.18.133.1
ios:ip source-route
ios:interface GigabitEthernet0/1
exit
…
…
output ommitted
…
…
exit
ios:interface Loopback0
24 Cisco Network Services Orchestrator (NSO) v4.2 © 2016 Cisco Systems, Inc.
exit
ios:ntp server 10.0.0.1
!
!
admin@ncs(config)#
Activity Objective
In this activity, you will create a simple point-to-point Layer-2 MPLS VPN service. After completing this
activity, you will be able to meet these objectives:
Design service requirements
Create device templates
Create a YANG service model
Deploy a service
Visual Objective
The figure illustrates what you will accomplish in this activity. In this lab, we will provide a service to enable
customers to interconnect their sites using Layer-2 connectivity in order to support high availability for the
services where Layer-2 connectivity is required.
DRC
Required Resources
The same requirements as explained in the first lab.
Job Aids
These job aids are available to help you complete the lab activity.
Student guide: Service Design (Module 3 Lesson 3)
The Workstation in the lab contains two documents on the desktop:
— NSO Getting Started Guide
— NSO User Guide
26 Cisco Network Services Orchestrator (NSO) v4.2 © 2016 Cisco Systems, Inc.
Task 1: Service Requirements and Service Model
The first task requires you to design a service model based on the provided high-level service requirements.
The following figure illustrates the topology of the sample Layer-2 MPLS VPN implementation.
192.168.11.0/24
CE11 CE12
Gi0/ 9
NSO
PE11 PE12
L2 MPLS VPN
Gi0/ 0/ 0/ 9
192.168.21.0/24 192.168.31.0/24
IOS XR
CE21 PE21 PE31 CE31
The following table describes the service characteristics and requirements. Use this information as a starting
point for creating a service model.
Parameter Description
VPN Instance Name This is a unique identifier describing an instance of a deployed point-to-point Layer-
2 MPLS VPN.
It is used to provide a descriptive name for the service instance.
Pseudowire Identifier This is a unique number that is used to identify the pseudowire connection across
MPLS between two PE routers.
Remote IP1 Each attachment circuit is connected to a remote end identified by the loopback
address of the other PE router.
All PE routers in the network have Loopback0 addresses in the 10.0.0.X/24
network.
Remote IP2 Each attachment circuit is connected to a remote end identified by the loopback
address of the other PE router.
All PE routers in the network have Loopback0 addresses in the 10.0.0.X/24
network.
Step 3 Create a template-based service skeleton using the ncs-make-package command. Use ncs-make-
package --help or man ncs-make-package to learn how to create template-based packages. Use
“l2vpn” as the name of the new service.
cisco@NCS:~$ cd $HOME/ncs-run/packages
cisco@NCS:~/ncs-run/packages$ ls
cisco-ios cisco-iosxr
cisco@NCS:~/ncs-run/packages$ ncs-make-package --service-skeleton
template l2vpn
cisco@NCS:~/ncs-run/packages$ ls
cisco-ios cisco-iosxr l2vpn
cisco@NCS:~/ncs-run/packages$
Step 4 Edit the service model YANG file using your favorite text editor. You may also use the
Notepad++ text editor on Workstation, which will provide you with syntax highlighting for
YANG (the N: drive is mapped to NSO, so you can easily access the files on NSO).
cisco@NCS:~/ncs-run/packages$ cd l2vpn/src/yang
cisco@NCS:~/ncs-run/packages/l2vpn/src/yang$ vim l2vpn.yang
Step 5 Use the table below to fine-tune the service characteristics based on YANG functionality. Extra
space is provided in case you will use any additional YANG statements.
VPN Identifier
Device1
Interface1
RemoteIP1
Device2
Interface2
RemoteIP2
28 Cisco Network Services Orchestrator (NSO) v4.2 © 2016 Cisco Systems, Inc.
Step 6 Create the formal YANG service model based on your informal service design and the
characteristics defined in the previous step. The figure above illustrates one possible approach and
the sample service instance data:
A list used to support multiple instances of the service. The list is identified by a unique name
(key).
The L2 MPLS VPN uses the pw-id as the pseudowire identifier, which should also be unique.
list l2vpn {
key name;
unique pw-id;
leaf name {
type string;
}
leaf pw-id {
mandatory true;
type uint32;
}
Each link resides on a provider edge (PE) router, so we need to assign a PE router to both
links. A leafref statement is used to link into the NSO's device list.
leaf device1 {
tailf:info “PE Router1”;
mandatory true;
type leafref {
path "/ncs:devices/ncs:device/ncs:name";
}
}
Each link is assigned a customer-facing interface, which is identified by the interface number
(intf-number). At this time, we will only assign physical GigabitEthernet interfaces.
leaf intf-number1 {
tailf:info “GigabitEthernet Interface ID”;
mandatory true;
type string {
pattern "[0-9]{1,2}(/[0-9]{1,2}){1,3}";
Each attachment circuit must also be connected via MPLS (signaling via LDP)
to the other PE router. Therefore, we must specify the IP address (remote-ip) of
the Loopback0 interface on the other PE router (i.e. on the other link instance).
leaf remote-ip1 {
tailf:info "Loopback0 IP Address of Remote PE (10.0.0.X)";
mandatory true;
type inet:ipv4-address {
pattern "10\.0\.0\.[0-9]+";
}
}
Next, repeat the statements for the second device and its elements.
leaf device2 {
tailf:info "PE Router2";
mandatory true;
type leafref {
path "/ncs:devices/ncs:device/ncs:name";
}
}
leaf intf-number2 {
tailf:info "GigabitEthernet Interface ID";
mandatory true;
type string {
pattern "[0-9]{1,2}(/[0-9]{1,2}){1,4}";
}
}
leaf remote-ip2 {
tailf:info "Loopback0 IP Address of Remote PE (10.0.0.X)";
mandatory true;
type inet:ipv4-address {
pattern "10\.0\.0\.[0-9]+";
}
}
Step 7 Save the file when you are done writing your YANG module.
module l2vpn {
namespace "http://com/example/l2vpn";
prefix l2vpn;
import ietf-inet-types {
prefix inet;
}
import tailf-ncs {
prefix ncs;
}
import tailf-common {
prefix tailf;
}
augment /ncs:services {
list l2vpn {
key name;
30 Cisco Network Services Orchestrator (NSO) v4.2 © 2016 Cisco Systems, Inc.
unique pw-id;
uses ncs:service-data;
ncs:servicepoint "l2vpn";
leaf name {
tailf:info "Service Instance Name";
type string;
}
leaf pw-id {
tailf:info "Unique Pseudowire ID";
mandatory true;
type uint32 {
range "1..4294967295";
}
}
leaf device1 {
tailf:info "PE Router1";
mandatory true;
type leafref {
path "/ncs:devices/ncs:device/ncs:name";
}
}
leaf intf-number1 {
tailf:info "GigabitEthernet Interface ID";
mandatory true;
type string {
pattern "[0-9]{1,2}(/[0-9]{1,2}){1,4}";
}
}
leaf remote-ip1 {
tailf:info "Loopback0 IP Address of Remote PE (10.0.0.X)";
mandatory true;
type inet:ipv4-address {
pattern "10\.0\.0\.[0-9]+";
}
}
leaf device2 {
tailf:info "PE Router2";
mandatory true;
type leafref {
path "/ncs:devices/ncs:device/ncs:name";
}
}
leaf intf-number2 {
tailf:info "GigabitEthernet Interface ID";
mandatory true;
type string {
pattern "[0-9]{1,2}(/[0-9]{1,2}){1,4}";
}
}
leaf remote-ip2 {
tailf:info "Loopback0 IP Address of Remote PE (10.0.0.X)";
mandatory true;
type inet:ipv4-address {
Step 8 You may validate your YANG file using pyang. Keep making corrections to your YANG file
until pyang no longer produces any output (i.e. no errors).
cisco@NCS:~/ncs-run/packages/l2vpn/src/yang$ pyang l2vpn.yang
cisco@NCS:~/ncs-run/packages/l2vpn/src/yang$
Step 9 Change the directory to the parent directory where there is a Makefile. Use the make command to
compile the package.
cisco@NCS:~/ncs-run/packages/l2vpn/src/yang$ cd ..
cisco@NCS:~/ncs-run/packages/l2vpn/src$ make
/home/cisco/ncs-4.2/bin/ncsc `ls l2vpn-ann.yang > /dev/null 2>&1 &&
echo "-a l2vpn-ann.yang"` \
--yangpath yang -c -o ../load-dir/l2vpn.fxs yang/l2vpn.yang
cisco@NCS:~/ncs-run/packages/l2vpn/src$
Step 10 If you placed your packages into $HOME/ncs-run/packages, you can proceed and issue the
reload packages command in NSO CLI. If not, you need to copy the entire directory containing
your service to that directory or create a symbolic link to it.
admin@ncs# packages reload
Step 11 Check the availability of CLI commands to manage the service. For example, use the services
l2vpn command followed by a question mark to investigate the new CLI options available for the
provisioning of service instances.
admin@ncs# config
Entering configuration mode terminal
admin@ncs(config)# services l2vpn ?
Possible completions:
Service Instance Name range
admin@ncs(config)# services l2vpn
32 Cisco Network Services Orchestrator (NSO) v4.2 © 2016 Cisco Systems, Inc.
Activity Verification
You have completed this task when you attain these results:
You have a directory structure and file templates for a new service.
cisco@NCS:~/ncs-run/packages$ ls
cisco-ios cisco-iosxr l2vpn
cisco@NCS:~/ncs-run/packages$ ls -l l2vpn
total 20
drwxr-xr-x 2 cisco cisco 4096 Nov 26 15:09 load-dir
-rw-rw-r-- 1 cisco cisco 375 Jan 27 12:39 package-meta-data.xml
drwxr-xr-x 4 cisco cisco 4096 Jan 27 12:39 src
drwxr-xr-x 2 cisco cisco 4096 Jan 27 12:39 templates
drwxr-xr-x 3 cisco cisco 4096 Nov 26 15:09 test
cisco@NCS:~/ncs-run/packages$ ls -l l2vpn/src/yang
total 4
-rw-rw-r-- 1 cisco cisco 633 Jan 27 12:39 l2vpn.yang
cisco@NCS:~/ncs-run/packages$ ls -l l2vpn/templates
total 4
-rw-rw-r-- 1 cisco cisco 733 Jan 27 12:39 l2vpn-template.xml
cisco@NCS:~/ncs-run/packages$
You should have your service available in NSO even though there is no mapping to actual device types
yet. Use the NSO Web UI to inspect the results of the design and installation of your service. Once NSO
Web UI is available, click the Toggle Navigation button in the upper left corner and examine the l2vpn
service page.
Note You still cannot start provisioning services. A service template is missing and it will be created in the next
task.
192.168.11.0/24
CE11 CE12
Gi0/ 9
NSO Lo0:10.0.0.11
PE11 PE12
L2 MPLS VPN
VPN- ID: 1001121
Lo0: 10.0.0.21
Gi0/ 0/ 0/ 9
192.168.21.0/24 192.168.31.0/24
IOS XR
CE21 PE21 PE31 CE31
Activity Procedure
Complete these steps:
Step 2 A network engineer has provided you with the actual configuration for the new service, one for
each device type.
Cisco IOS: PE11
interface GigabitEthernet0/9
xconnect 10.0.0.21 1001121 encapsulation mpls
!
34 Cisco Network Services Orchestrator (NSO) v4.2 © 2016 Cisco Systems, Inc.
Use the devices device PE11 configuration command as a starting point to configure the
Cisco IOS sample.
Use the devices device PE21 configuration command as a starting point to configure the
Cisco IOS XR sample.
admin@ncs# config
Entering configuration mode terminal
admin@ncs(config)# devices device PE11 config ios:interface
GigabitEthernet 0/9
admin@ncs(config-if)# xconnect 10.0.0.21 1001121 encapsulation mpls
admin@ncs(config-if)# top
admin@ncs(config)# devices device PE21 config cisco-ios-xr:l2vpn
admin@ncs(config-l2vpn)# xconnect group GROUP
admin@ncs(config-l2vpn-xc)# p2p CE11-to-CE21
admin@ncs(config-l2vpn-xc-p2p)# interface GigabitEthernet0/0/0/9
admin@ncs(config-l2vpn-xc-p2p)# neighbor 10.0.0.11 pw-id 1001121
admin@ncs(config-l2vpn-xc-p2p-pw)# exit
admin@ncs(config-l2vpn-xc-p2p)# exit
admin@ncs(config-l2vpn-xc)# exit
admin@ncs(config-l2vpn)# exit
admin@ncs(config-config)# cisco-ios-xr:interface GigabitEthernet 0/0/0/9
admin@ncs(config-if)# l2transport
admin@ncs(config-if-l2)# top
admin@ncs(config)#
Step 4 Use the commit dry-run outformat xml command to retrieve the XML version of the
configuration when done configuring the above sample configurations.
Note Please verify that the output contains all the configured parameters. If all or a part of the changes
were committed beforehand, the output will be missing those parts.
Step 6 Edit the XML template file using your preferred editor (e.g. vim, nano).
Note Alternatively, you may use the Notepad++ text editor on Workstation, which will provide you with
syntax highlighting for XML. The N: drive is mapped to NSO, so you can access all files from the
workstation.
Step 7 Copy the XML format or the configuration output into the text editor. Make sure you paste the
configuration into the appropriate section within the device configuration. The initial XML has
two segments where you have to include your XML configuration.
The first section describes the device that the template is configuring and the second section
contains configuration changes.
<config>
<!--
Add device-specific parameters here.
In this skeleton the service has a leaf "dummy"; use that
to set something on the device e.g.:
<ip-address-on-device>{/dummy}</ip-address-on-device>
-->
</config>
</device>
</devices>
</config-template>
cisco@NCS:~/ncs-run/packages/l2vpn/templates$
Since our service model always has two devices, the XML segment has to be duplicated to
accommodate each of them. Open the XML file in any editor and duplicate segments of the XML
code.
36 Cisco Network Services Orchestrator (NSO) v4.2 © 2016 Cisco Systems, Inc.
cisco@NCS:~/ncs-run/packages/l2vpn/templates$ more l2vpn-template.xml
<config-template xmlns="http://tail-f.com/ns/config/1.0"
servicepoint="l2vpn">
<devices xmlns="http://tail-f.com/ns/ncs">
<!-- DEVICE1 -->
<device>
<name>{/device1}</name>
<config>
<!-- DEVICE1/IOS -->
Step 8 Now insert the XML configuration created with commit dry-run outformat xml in the modified
XML skeleton. Replace the device identification with the device name variable in curly brackets
and the configuration segment with XML configuration code. For both devices, add both the IOS
and IOS-XR part of configuration.
cisco@NCS:~/ncs-run/packages/l2vpn/templates$ vim l2vpn-template.xml
cisco@NCS:~/ncs-run/packages/l2vpn/templates$ more l2vpn-template.xml
<config-template xmlns="http://tail-f.com/ns/config/1.0"
servicepoint="l2vpn">
<devices xmlns="http://tail-f.com/ns/ncs">
<!-- DEVICE1 -->
<device>
<name>{/device1}</name>
<config>
<!-- DEVICE1/IOS -->
<interface xmlns="urn:ios">
<GigabitEthernet>
<name>0/9</name>
<xconnect>
<encapsulation>mpls</encapsulation>
<vcid>1001121</vcid>
<address>10.0.0.21</address>
</xconnect>
</GigabitEthernet>
</interface>
<!-- DEVICE1/IOS-XR -->
<interface xmlns="http://tail-f.com/ned/cisco-ios-xr">
<GigabitEthernet>
<id>0/0/0/9</id>
<l2transport/>
</GigabitEthernet>
</interface>
<l2vpn xmlns="http://tail-f.com/ned/cisco-ios-xr">
<xconnect>
<group>
<name>GROUP</name>
38 Cisco Network Services Orchestrator (NSO) v4.2 © 2016 Cisco Systems, Inc.
Step 9 Replace all occurrences of parameters with variables in curly brackets (e.g. replace
“0/9” with “{intf-number}” in the Cisco IOS portion of the configuration). Note that the variable
names must correspond to the YANG statements you used when creating the service model.
Note You may need to revisit your YANG service model and align it with the requirements of the
device mapping logic. While not strictly necessary, the below sample also contains additional
tags, as is best practice. Can you explain why?
40 Cisco Network Services Orchestrator (NSO) v4.2 © 2016 Cisco Systems, Inc.
}
admin@ncs#
Troubleshooting Hints:
The variables must reference data according to the hierarchy of the YANG data model.
As you have two devices being referenced in your informal design (one in each attachment
circuit), you will have to duplicate your XML device templates.
Activity Verification
You have completed this task when you attain these results:
You have successfully configured the sample service using the NSO CLI when you achieve an identical
configuration to the one provided as sample when issuing the commit dry-run outformat native
command.
The important part of this step is to record the XML version of the configuration as shown below. This
output can be retrieved by using the commit dry-run outformat xml command.
Cisco IOS (PE11 portion of the output):
<interface xmlns="urn:ios">
<GigabitEthernet>
<name>0/6</name>
<xconnect>
<encapsulation>mpls</encapsulation>
<vcid>1001121</vcid>
<address>10.0.0.21</address>
</xconnect>
</GigabitEthernet>
</interface>
Note We have simplified the example to only use the GigabitEthernet interface types. You would have to add
another parameter to select among all the available interface types and replicate the interface configurations
within the XML file.
42 Cisco Network Services Orchestrator (NSO) v4.2 © 2016 Cisco Systems, Inc.
Task 3: Deploy a Service Instance
In this task, you will deploy a service instance based on your newly installed service.
Activity Procedure
Complete these steps:
Step 3 Once all service parameters are entered, preview device changes using the commit dry-run or
commit dry-run outformat native command.
admin@ncs(config-l2vpn-CE11-CE21)# commit dry-run
cli devices {
device PE11 {
config {
ios:interface {
GigabitEthernet 0/9 {
xconnect {
+ address 10.0.0.21;
+ vcid 1001121;
+ encapsulation mpls;
}
}
}
}
}
device PE21 {
config {
cisco-ios-xr:interface {
Step 4 Finally, commit the service instance creation using the commit command.
admin@ncs(config-l2vpn-CE11-CE21)# top
admin@ncs(config)# commit
Commit complete.
admin@ncs(config)# exit
Activity Verification
You have completed this task when you attain this result:
The service has been successfully deployed.
admin@ncs# show running-config services l2vpn
services l2vpn CE11-CE21
pw-id 1001121
device1 PE11
intf-number1 0/9
remote-ip1 10.0.0.21
device2 PE21
intf-number2 0/0/0/9
remote-ip2 10.0.0.11
!
admin@ncs# show running-config services l2vpn | display xpath
/services/l2vpn:l2vpn[name='CE11-CE21']/pw-id 1001121
/services/l2vpn:l2vpn[name='CE11-CE21']/device1 PE11
/services/l2vpn:l2vpn[name='CE11-CE21']/intf-number1 0/9
/services/l2vpn:l2vpn[name='CE11-CE21']/remote-ip1 10.0.0.21
/services/l2vpn:l2vpn[name='CE11-CE21']/device2 PE21
/services/l2vpn:l2vpn[name='CE11-CE21']/intf-number2 0/0/0/9
44 Cisco Network Services Orchestrator (NSO) v4.2 © 2016 Cisco Systems, Inc.
/services/l2vpn:l2vpn[name='CE11-CE21']/remote-ip2 10.0.0.11
admin@ncs#
Activity Objective
In this activity, you will manage your newly deployed service and its deployed instances. After completing
this activity, you will be able to meet these objectives:
Create, modify, and delete service instances
Un-deploy and re-deploy service instances
Assign services to customers
Required Resources
The same requirements as explained in the first lab.
Job Aids
These job aids are available to help you complete the lab activity.
Student guide: Service Management (Module 3 Lesson 4)
The Workstation in the lab contains three documents on the desktop:
— NSO Getting Started Guide
— NSO User Guide
Activity Procedure
Complete these steps:
Step 1 Create two additional Layer-2 MPLS VPN service instances using the information below.
46 Cisco Network Services Orchestrator (NSO) v4.2 © 2016 Cisco Systems, Inc.
Link 1: Device PE11
Step 2 Connect to router PE11 (ssh [email protected] -p 10101) and check the running configuration.
You should see the Layer-2 VPN configuration on the three GigabitEthernet interfaces (0/7, 0/8,
and 0/9).
…
interface GigabitEthernet0/7
xconnect 10.0.0.21 1011131 encapsulation mpls
exit
interface GigabitEthernet0/8
xconnect 10.0.0.21 1011121 encapsulation mpls
exit
interface GigabitEthernet0/9
xconnect 10.0.0.21 1001121 encapsulation mpls
exit
…
Step 4 Check to see if the interface configuration has been reverted to a previous state.
…
interface GigabitEthernet0/7
exit
interface GigabitEthernet0/8
xconnect 10.0.0.21 1011121 encapsulation mpls
exit
interface GigabitEthernet0/9
xconnect 10.0.0.21 1001121 encapsulation mpls
exit
…
Step 5 Check to see if the service is still present in the NSO configuration database.
admin@ncs(config)# show full-configuration services l2vpn
services l2vpn CE11-CE21
Note When the service instance is un-deployed, its record in the CDB is maintained, but the device(s)
configuration is reverted.
Step 6 Check the state of the un-deployed service instance using the check-sync command.
admin@ncs(config)# services l2vpn CE11-to-CE31 check-sync
in-sync false
admin@ncs(config)#
Step 7 Now re-deploy the service instance to make it operational again using the re-deploy command.
Then perform another check of synchronization between NSO and the device.
admin@ncs(config)# services l2vpn CE11-to-CE31 re-deploy
admin@ncs(config)# services l2vpn CE11-to-CE31 check-sync
in-sync true
admin@ncs(config)#
48 Cisco Network Services Orchestrator (NSO) v4.2 © 2016 Cisco Systems, Inc.
Task 2: Assign Service Instances to Customers
In this task, you will modify the service model to include the assignment of service instances to customers.
Activity Procedure
Complete these steps:
Step 1 Edit the YANG service model to add another leaf that references the customer data in NSO. The
XPath to reference customer data is: /ncs:customers/ncs:customer/ncs:id.
Modify the YANG service model to include the new leaf.
leaf customer {
tailf:info "Customer name";
type leafref {
path "/ncs:customers/ncs:customer/ncs:id";
}
}
Compile the package.
Reload packages.
Note You should already have at least one customer created from the second lab exercise.
Step 2 Modify one of the existing service instances by assigning it to the customer you have created.
admin@ncs# conf
Entering configuration mode terminal
admin@ncs(config)# services l2vpn CE11-to-CE31 customer ?
Possible completions:
ACME
admin@ncs(config)# services l2vpn CE11-to-CE31 customer ACME
admin@ncs(config-l2vpn-CE11-to-CE31)# top
admin@ncs(config)# commit
Commit complete.
admin@ncs(config)#
Step 4 Now test the rollback functionality by reverting the configuration back to the state when
customers were not assigned to the service instances. Then check the service instance
configuration.
admin@ncs# config
admin@ncs(config)# rollback configuration
Step 5 You may perform another rollback operation to re-assign the customer to the service instance
(basically rolling back last rollback).
admin@ncs# config
Entering configuration mode terminal
admin@ncs(config)# rollback configuration
admin@ncs(config)# commit
Commit complete.
admin@ncs(config)# exit
admin@ncs# show running-config services l2vpn CE11-to-CE31
services l2vpn CE11-to-CE31
customer ACME
pw-id 1011131
device1 PE11
intf-number1 0/7
remote-ip1 10.0.0.21
device2 PE21
intf-number2 0/0/0/7
remote-ip2 10.0.0.11
!
admin@ncs#
Note Every rollback transaction also creates a new rollback file for its own removal.
50 Cisco Network Services Orchestrator (NSO) v4.2 © 2016 Cisco Systems, Inc.
Lab 4-1: Use NSO APIs
Complete this lab activity to practice what you have learned in the related training lesson.
Activity Objective
In this activity, you will test a few of the NSO APIs. After completing this activity, you will be able to meet
these objectives:
Create a plug-and-play script to augment the NSO CLI
Create a shell script to configure NSO
Visual Objective
The figure illustrates what you will accomplish in this activity. In this activity, you will use and create two
types of scripts:
CLI augmentation: script loaded into NSO to provide additional CLI functionality.
Task automation: shell script that performs an action within NSO.
Cisco NSO
Required Resources
The same requirements as explained in the first lab.
Job Aids
These job aids are available to help you complete the lab activity.
Student guide: Cisco NSO Integration Options (Module 4 Lesson 1)
The Workstation in the lab contains three documents on the desktop:
— NSO Getting Started Guide
— NSO Installation Guide
— NSO User Guide
Activity Procedure
Complete these steps:
Requirement Description
Step 2 Create a script file in the scripts/command subdirectory of the running directory of NSO. Check
the activity verification section for a sample of the command line output.
Tip Check the scripts/command subdirectory in the installation directory for sample plug-and-play
scripts that you can copy or use as a starting point to define the required syntax and
parameters definition.
cisco@NCS:~$ cd $HOME/ncs-run/scripts/command
cisco@NCS:~/ncs-run/scripts/command$ vim show-trace
cisco@NCS:~/ncs-run/scripts/command$ more show-trace
#!/bin/sh
set -e
newline=cat
while [ $# -gt 0 ]; do
case "$1" in
--command)
cat << EOF
begin command
modes: oper
styles: c i j
cmdpath: show trace
help: Show the contents of trace log files
more: true
end
begin param
name: file
presence: optional
flag: file
help: Display contents of trace log file
end
begin param
name: list
presence: optional
type: void
52 Cisco Network Services Orchestrator (NSO) v4.2 © 2016 Cisco Systems, Inc.
flag: list
help: List trace log files
end
EOF
exit
;;
list)
cd /home/cisco/ncs-run/logs/
ls -1 *.trace
exit
;;
file)
cd /home/cisco/ncs-run/logs/
more $2
exit
;;
*)
break
;;
esac
shift
done
exit
cisco@NCS:~/ncs-run/scripts/command$
Note Make sure you are not using the Tab key for indentation in your script. Instead use space.
Step 3 In order to start tracing, the session toward devices has to be first disconnected and then connected
again.
admin@ncs#
admin@ncs# devices device PE11 disconnect
admin@ncs# devices device PE11 connect
result true
info (admin) Connected to PE11 - 127.0.0.1:10101
admin@ncs#
Note Once southbound tracing is enabled, a new trace file is created in the logs directory. The file
name is a combination of the NED and device name.
You have completed this task when you attain a result that will produce a similar CLI add-on as
shown below:
admin@ncs# show trace ?
Possible completions:
file - Display contents of trace log file
list - List trace log files
| - Output modifiers
<cr> -
admin@ncs# show trace list
ned-cisco-ios-PE11.trace
xpath.trace
admin@ncs# show trace file ned-cisco-ios-PE11.trace
>> 28-Jan-2016::01:58:14.909 CLI CONNECT to PE11-127.0.0.1:10101 as
admin (Trace=false)
<< 28-Jan-2016::01:58:15.178 CONNECTED 0
>> 28-Jan-2016::01:58:15.179 IS_ALIVE 0
<< 28-Jan-2016::01:58:15.181 IS_ALIVE true
>> 28-Jan-2016::01:58:46.807 CLOSE 0: (Pool: discard)
<< 28-Jan-2016::01:58:46.817 CLOSED
admin@ncs#
54 Cisco Network Services Orchestrator (NSO) v4.2 © 2016 Cisco Systems, Inc.
Task 2: Create a Shell Script
In this task, you will create a shell script that will add customer definitions to NSO.
Activity Procedure
Complete these steps:
Argument Description
Customer name Users of the script must supply the name of the customer
being added.
Step 2 The script automatically sets the following parameters on the customer object:
Parameter Value
Status Active
Rank 128
Note Make sure that NCS environment parameters are loaded (source ncsrc) before you try to
execute the script.
56 Cisco Network Services Orchestrator (NSO) v4.2 © 2016 Cisco Systems, Inc.
Lab 4-2: Troubleshoot and Debug NSO
Complete this lab activity to practice what you have learned in the related training lesson.
Activity Objective
In this activity, you will learn to troubleshoot system- and service design-related issues. After completing this
activity, you will be able to meet these objectives:
Troubleshoot system issues
Troubleshoot service design and deployment issues
Visual Objective
The figure illustrates what you will accomplish in this activity. You will first deploy a new service to
provision Layer-3 MPLS VPNs, and then you will have to provision a service instance for one VPN
interconnecting five customer sites.
You have received an unfinished (untested) service model, which you will have to finalize in order to make it
ready for production purposes. The figure illustrates the five customer sites that need to be interconnected
using Layer 3 MPLS VPNs. BGP will be used to exchange customer routing information with PE routers.
CE11 CE12
PE11 PE12
NSO
BGP CE32
BGP
IOS XR
PE21 PE31 BGP
CE33
Required Resources
The same requirements as explained in the first lab.
Job Aids
These job aids are available to help you complete the lab activity.
Activity Procedure
Complete these steps:
Step 2 In the /opt/resources directory, you will find a new service for provisioning Layer-3 MPLS VPNs.
The service only provides the service model and mapping template. Copy the two files to the new
service skeleton.
cisco@NCS:~/ncs-run/packages$ cp /opt/resources/l3mplsvpn.yang
./l3mplsvpn/src/yang/l3mplsvpn.yang
cisco@NCS:~/ncs-run/packages$ cp /opt/resources/l3mplsvpn.xml
./l3mplsvpn/templates/l3mplsvpn-template.xml
Note There might be problems with this service as the service designer who created the service was
not able to complete the task. You need to troubleshoot the design, which may include errors in
the YANG service model or the device templates.
Step 4 Troubleshoot the YANG service model to fix the syntax errors in order to be able to successfully
compile the service.
Troubleshooting hints:
Enable XPath trace and monitor the Xpath log while executing the commit dry-run
command.
Use pyang to validate the YANG service model
Note Note that a successful compilation does not necessarily mean that the service is functioning
correctly. There may also be semantic errors.
The following XML device template contains the correct XPath expressions to refer to the
YANG data model hierarchy. The fix is highlighted (underlined) and indicates that the
original template wrongly tried to reference the link-id in the parent node.
<config-template xmlns="http://tail-f.com/ns/config/1.0"
58 Cisco Network Services Orchestrator (NSO) v4.2 © 2016 Cisco Systems, Inc.
servicepoint="l3mplsvpn">
<devices xmlns="http://tail-f.com/ns/ncs">
<device tags="nocreate">
<name>{/link/device}</name>
<config>
<rip when="{routing-protocol='rip'}">
<address-family>
<ipv4>
<vrf>
<name>vpn{string(/vpn-id)}</name>
<default-information>
<originate/>
</default-information>
<network>
<ip>0.0.0.0</ip>
</network>
</vrf>
</ipv4>
</address-family>
</rip>
</router>
</config>
</device>
</devices>
</config-template>
The following YANG service model contains the correct syntax and semantics in order to
achieve a working solution. There are three errors in the service model:
— A semicolon is missing.
— Mismatched prefixes were used for the module tailf-ncs.
— The routing-protocol referenced in the when statement is in the parent node.
module l3mplsvpn {
namespace "http://com/example/l3mplsvpn";
prefix l3mplsvpn;
augment /ncs:services {
list l3mplsvpn {
tailf:info "Layer-3 MPLS VPN Service";
key vpn-id;
unique "vpn-name customer";
uses ncs:service-data;
ncs:servicepoint "l3mplsvpn";
leaf vpn-name {
tailf:info "Service Instance Name";
type string;
}
leaf vpn-id {
tailf:info "Service Instance ID (10001 to 19999)";
type uint32 {
range "10001..19999";
}
}
leaf customer {
tailf:info "VPN Customer";
60 Cisco Network Services Orchestrator (NSO) v4.2 © 2016 Cisco Systems, Inc.
type leafref {
path "/ncs:customers/ncs:customer/ncs:id";
}
}
leaf link-name {
tailf:info "Link Name";
type string;
}
leaf link-id {
tailf:info "Link ID";
type uint32 {
range "1..255";
}
}
leaf device {
tailf:info "PE Router";
type leafref {
path "/ncs:devices/ncs:device/ncs:name";
}
}
leaf interface {
tailf:info "Customer Facing Interface";
type string;
}
leaf routing-protocol {
tailf:info "Routing option for the PE-CE link";
type enumeration {
enum bgp;
enum rip;
enum static;
}
}
list static {
tailf:info "Static Route";
key "prefix mask";
when "../routing-protocol='static'"; // It is in the parent node
leaf prefix {
tailf:info "Static Route Prefix";
type inet:ipv4-address;
}
leaf mask {
tailf:info "Static Route Subnet Mask";
type inet:ipv4-address;
}
}
}
}
}
}
Step 5 Reload packages once your service has successfully been compiled.
62 Cisco Network Services Orchestrator (NSO) v4.2 © 2016 Cisco Systems, Inc.
Activity Verification
You have completed this task when you attain this result:
You should be able to create the service instance with the native configuration listed below. Make sure
the result contains the following components:
— Configurations for two devices: PE11 and PE31
— PE11 has two interfaces with IP addressing and is placed inside a VRF
— PE31 has three interfaces with IP addressing and is placed inside a VRF
— PE11 has BGP with two neighbors configured
— PE31 has BGP with three neighbors configured
admin@ncs(config)# commit dry-run outformat native
device PE11
vrf definition vpn10001
rd 1:10001
address-family ipv4
exit-address-family
!
route-target export 1:10001
route-target import 1:10001
!
interface GigabitEthernet0/11
vrf forwarding vpn10001
ip address 172.31.1.1 255.255.255.252
exit
interface GigabitEthernet0/12
vrf forwarding vpn10001
ip address 172.31.2.1 255.255.255.252
exit
router bgp 1
address-family ipv4 unicast vrf vpn10001
neighbor 172.31.1.2 remote-as 65001
neighbor 172.31.1.2 activate
neighbor 172.31.1.2 allowas-in 3
neighbor 172.31.1.2 as-override
neighbor 172.31.1.2 default-originate
neighbor 172.31.2.2 remote-as 65001
neighbor 172.31.2.2 activate
neighbor 172.31.2.2 allowas-in 3
neighbor 172.31.2.2 as-override
neighbor 172.31.2.2 default-originate
redistribute connected
redistribute static
exit-address-family
!
!
device PE31
vrf definition vpn10001
rd 1:10001
address-family ipv4
exit-address-family
!
route-target export 1:10001
route-target import 1:10001
!
interface GigabitEthernet0/11
vrf forwarding vpn10001
ip address 172.31.3.1 255.255.255.252
64 Cisco Network Services Orchestrator (NSO) v4.2 © 2016 Cisco Systems, Inc.
Task 2: Device Troubleshooting
This task will require you to troubleshoot a potential issue in the communication between NSO and the
managed devices.
Activity Procedure
Complete these steps:
Step 1 Enable device trace log files for devices PE11, PE12, PE21, and PE31.
Note You may already have tracing enabled on PE11 from the previous lab.
Step 3 Check to see if the log files for PE routers have been created. The log files are located in the logs
subdirectory of the running directory (e.g. $HOME/ncs-run/logs).
Activity Procedure
Complete these steps:
Step 2 Start a new instance of NSO in the foreground and verbose mode to see what the daemon is doing.
cisco@NCS:~/ncs-run$ ncs --foreground -v
In order to optimize your service model, you will perform the following steps as part of this task:
1. Instead of collecting info for each attachment circuit individually, place circuits in a list called link with
minimum and maximum elements of 2.
2. Link to devices’ interfaces so that they can be selected instead of having to type in the interface number.
3. Automatically retrieve the other PE router's loopback address.
Activity Procedure
This task is split into two separate sub-tasks according to the two optimization requirements described above.
The figure illustrates the use of the deref() function, which moves the current position in the data tree to the
given leafref, supplied as an argument (the sample only shows the structure for Cisco IOS).
66 Cisco Network Services Orchestrator (NSO) v4.2 © 2016 Cisco Systems, Inc.
Note The above figure shows portions of XPath to get from leaf intf-number to the interface ID in the Cisco IOS
NED.
Note The above figure only shows the Cisco IOS example. You will also have to accommodate the same
functionality for Cisco IOS XR devices.
Step 1 Edit the YANG file containing your service model using your preferred editor.
Step 2 Change the leaf statement containing the interface number for the attachment circuits and
reference the interfaces on devices as shown above.
You will also have to duplicate your link list using two containers, one for IOS and another of IOS
XR, as illustrated in the figure below.
L l2vpn
name
pw-id
Check if the device is IOS
L{2} link when "/ncs:devices/ncs:device[ncs:name=current()/../device]/"+
"ncs:device-type/ncs:cli/ncs:ned-id='ios-id:cisco-ios'" {
tailf:dependency "../device";
C ios tailf:dependency "/ncs:devices/ncs:device/ncs:device-type";
}
R device Link to interface table for selected device if it is an IOS device
path "deref(../device)/../ncs:config/ios:interface/"+
R intf-number "ios:GigabitEthernet/ios:name";
Use the following NSO CLI commands to determine the proper XPath to the data that you need:
Cisco IOS XPath
XPath for Cisco IOS (use PE11 as sample):
Use the information from the above show command to construct the following XPath:
path
"deref(../../device)/../ncs:config/ios:interface/ios:GigabitEthernet/ios
:name";
Use the information from the above show command to construct the following XPath:
path "deref(../../device)/../ncs:config/cisco-ios-xr:interface/cisco-
ios-xr:GigabitEthernet/cisco-ios-xr:id";
Note The Cisco IOS XR differs in the interface name “id” instead of “name”. Also make sure you use
the right prefix.
The printout below highlights the main changes to your YANG file:
Import the two NEDs (Cisco IOS and Cisco IOS XR).
68 Cisco Network Services Orchestrator (NSO) v4.2 © 2016 Cisco Systems, Inc.
Create two containers within the link list and put the interface number into the containers.
You need to add the logic that checks for the device type using the when statement (see
figure above).
Change the intf-number from string to leafref and add the XPath pointing to the NED's
interface table (see figure above).
module l2vpn {
namespace "http://com/example/l2vpn";
prefix l2vpn;
augment /ncs:services {
list l2vpn {
key name;
unique pw-id;
uses ncs:service-data;
ncs:servicepoint "l2vpn";
list link {
tailf:info "Attachment Circuits";
min-elements 2;
max-elements 2;
key device;
leaf device {
mandatory true;
type leafref {
path "/ncs:devices/ncs:device/ncs:name";
}
}
container ios {
when … {…}
leaf intf-number {
tailf:info "GigabitEthernet Interface ID";
mandatory true;
type leafref {
path …;
}
}
}
container iosxr {
when … {…}
leaf intf-number {
tailf:info "GigabitEthernet Interface ID";
mandatory true;
type leafref {
path …;
}
}
}
Step 3 You also have to modify the XML template because the data model has changed. Find all
occurrences where intf-num is referenced and modify the paths according to this rule:
Add the container name ios or iosxr between link and intf-num to represent the new hierarchy
in the data model. For example:
— In IOS-specific portions of the XML template:
— “/intfnumber1” becomes “/link[1]/ios/intf-number”
— In IOS XR-specific portion of the XML template:
— “/intfnumber1” becomes “/link[1]/iosxr/intf-number”
Step 4 Add the path to the Cisco IOS and Cisco IOS XR NEDs to the Makefile file in the src
subdirectory of your service package in order to be able to compile your service model including
the NEDs.
YANGPATH= --yangpath ../../cisco-ios/src/ncsc-out/modules/yang \
--yangpath ../../cisco-iosxr/src/ncsc-out/modules/yang
Activity Verification
You have completed this task when you attain this result:
You should now be able to select from the available interface when adding the service.
Step 1 Modify the XML device template to cross-reference the IP addresses. Instead of remote-ip make
use of the deref function to find the actual PE router's loopback address. This is achieved by
looking for the Loopback0 interface. Since device models differ for Cisco IOS and IOS XR,
XPath compound (pipe) operator is required.
…
70 Cisco Network Services Orchestrator (NSO) v4.2 © 2016 Cisco Systems, Inc.
<address>{
deref(/link[2]/device)/../config/interface/Loopback[name='0']
/ip/address/primary/address |
deref(/link[2]/device)/../config/interface/Loopback[id='0']
/ipv4/address/ip
}</address>
…
Note You need to cross-reference the loopback-addresses in the XML device template so that in
link[1] you reference the loopback address from link[2] and vice versa.
Step 2 Remove the unused remote-ip leaf in the service model YANG file.
Activity Verification
You have completed this task when you attain this result:
You should now be able to deploy a service instance without having to know the PE routers' loopback
addresses.
Note Make sure that devices have valid IP addresses configured on the Loopback0 interface. If not, modify the
device configuration. Otherwise, commit will fail.
namespace "http://com/example/l2vpn";
prefix l2vpn;
augment /ncs:services {
list l2vpn {
key name;
unique pw-id;
uses ncs:service-data;
leaf name {
tailf:info "Service Instance Name";
mandatory true;
type string;
}
leaf pw-id {
tailf:info "Unique Pseudowire ID";
mandatory true;
type uint32 {
range "1..4294967295";
}
}
list link {
tailf:info "Attachment Circuits";
min-elements 2;
max-elements 2;
key device;
leaf device {
tailf:info "PE Router";
mandatory true;
type leafref {
path "/ncs:devices/ncs:device/ncs:name";
}
}
container ios {
when "/ncs:devices/ncs:device[ncs:name=current()/../device]/ncs:device-
type/ncs:cli/ncs:ned-id='ios-id:cisco-ios'" {
tailf:dependency "../device";
tailf:dependency "/ncs:devices/ncs:device/ncs:device-type";
}
leaf intf-number {
tailf:info "GigabitEthernet Interface ID";
mandatory true;
type leafref {
path "
deref(../../device)/../ncs:config/ios:interface/ios:GigabitEthernet/ios:name";
}
}
}
container iosxr {
when "/ncs:devices/ncs:device[ncs:name=current()/../device]/ncs:device-
type/ncs:cli/ncs:ned-id='cisco-ios-xr-id:cisco-ios-xr'"{
tailf:dependency "../device";
tailf:dependency "/ncs:devices/ncs:device/ncs:device-type";
}
leaf intf-number {
tailf:info "GigabitEthernet Interface ID";
mandatory true;
type leafref {
path "deref(../../device)/../ncs:config/cisco-ios-xr:interface/cisco-ios-
xr:GigabitEthernet/cisco-ios-xr:id";
}
}
}
leaf remote-ip {
tailf:info "Loopback0 IP Address of Remote PE (10.0.0.X)";
mandatory true;
type inet:ipv4-address {
pattern "10\.0\.0\.[0-9]+";
}
}
}
}
}
72 Cisco Network Services Orchestrator (NSO) v4.2 © 2016 Cisco Systems, Inc.
}
The following printout shows the XML template that is used with the above YANG data model. The major
changes are highlighted.
<?xml version="1.0" encoding="utf-8"?>
<config-template xmlns="http://tail-f.com/ns/config/1.0" servicepoint="l2vpn">
<devices xmlns="http://tail-f.com/ns/ncs">
<device tags="nocreate">
<name>{/link[1]/device}</name>
<config tags="merge">
<device tags="nocreate">
<name>{/link[2]/device}</name>
<config tags="merge">
<interface xmlns="urn:ios" tags="nocreate">
<GigabitEthernet>
<name>{/link[2]/ios/intf-number}</name>
<xconnect tags="merge">
<address>{/link[2]/remote-ip}</address>
<vcid>{/pw-id}</vcid>
The following printout shows the entire Makefile with the highlighted addition of YANGPATH to tell the
ncsc compiler where to find the NED modules that augment the device config containers:
all: fxs
fxs: $(FXS)
../load-dir/%.fxs: yang/%.yang
$(NCSC) `ls $*-ann.yang > /dev/null 2>&1 && echo "-a $*-ann.yang"` \
$(YANGPATH) -c -o $@ $<
clean:
rm -rf ../load-dir/*
74 Cisco Network Services Orchestrator (NSO) v4.2 © 2016 Cisco Systems, Inc.
Sub-Task 2: Automatically Assigning Loopback IP Addresses
The following printout shows the XML template that is used with the above YANG data model. The major
changes are highlighted.
<?xml version="1.0" encoding="utf-8"?>
<config-template xmlns="http://tail-f.com/ns/config/1.0"
servicepoint="l2vpn">
<devices xmlns="http://tail-f.com/ns/ncs">
<device tags="nocreate">
<name>{/link[1]/device}</name>
<config tags="merge">
<device tags="nocreate">
<name>{/link[2]/device}</name>
<config tags="merge">
<interface xmlns="urn:ios" tags="nocreate">
<GigabitEthernet>
76 Cisco Network Services Orchestrator (NSO) v4.2 © 2016 Cisco Systems, Inc.