Download as pdf or txt
Download as pdf or txt
You are on page 1of 205

Network Automation Journey

with Cisco Network Services


Orchestrator (NSO)

Sunpreetsingh Arora CSE @sunpreetsinghar


Hector Oses CSE

TECNMS-4175
Cisco Webex Teams

Questions?
Use Cisco Webex Teams to chat
with the speaker after the session

How
1 Find this session in the Cisco Events Mobile App
2 Click “Join the Discussion”
3 Install Webex Teams or go directly to the team space
4 Enter messages/questions in the team space

TECNMS-4175 © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public 3
The bridge between Network
Automation and Business

TECNMS-4175 © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public 4
Agenda

• Introduction
• Network Automation challenges
• NSO Architecture
• Device Management + Lab
• YANG
• Service Manager
• Package Manager

• Service Design + Lab

TECNMS-4175 © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public 5
Sunpreetsingh Arora Hector Oses

TECNMS-4175 © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public 6
Network Automation
Challenges
Business Challenges
*

95% 70% 75%


Network Changes Policy Violations OpEx Spent on Network
Performed Manually Due to Human Error Changes and Troubleshooting

$60B Spent on Network Operations Labor and Tools


Source: McKinsey study conducted for Cisco in 2016

TECNMS-4175 © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public 8
The automation drive

Complexity Quality Economics

• Increasing number of • Faster time to market • Reduce Opex


complex technologies
• Differentiation • Reduce human errors
• Increasing scale demand
• Account RoIe of
• Skills shortage • Security focus technology
investment with
business outcomes
TECNMS-4175 © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public 9
The Benefits of Automation

+ +
DIGITAL
EFFICIENCY AGILITY TRANSFORMATION

IT COST REDUCTION ABILITY TO MEET SLAS TIME TO PROVISION STRATEGIC ALLOCATION REVENUE GROWTH
IT SERVICES OF IT BUDGET
77% 72% 87% 200% 11%
Source: Source: IDC InfoBrief, sponsored by Cisco, Cloud Going Mainstream. All Are Trying, Some Are Benefiting; Few Are Maximizing Value. September 2016

10

TECNMS-4175 © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public 10
Tie Islands of Automation Together
End-to-End Automation Delivers Business Value

Multiple Operating Systems and platforms (>10) Scripts (>10,000) Orchestration software, cross-
team collaboration
Different Types of Automation Tools (>50) Manual Activity (>1,000)

TECNMS-4175 © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public 11
Network Management Challenges

• We are configuring different devices. - multi-vendor environment.


• There is no real service management
• There is no abstract models beyond device level
• Understand the capabilities and limitations of each device and device
group
• Ensure consistency and reliability of configurations across all devices
• Backup and restore configurations.

Device 1: Device 2: Device 3: Device 4: Device 1233:


Vendor A Vendor A Vendor A Vendor B Vendor W
Model X Model X Model Y Model Z Model T
Version 1.2 Version 1.4 Version 1.3 Version 9.5 Version F

TECNMS-4175 © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public 12
Simplifying complexity and improving quality
Full Service Automation
Lifecycle Management

Model Driven

Real Time Services

Multi Vendor, Multi


Service Type Support

Rich Set of
Northbound API’s
Speed Flexibility
Network-wide
Unified (CLI)

TECNMS-4175 © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public 13
Orchestration Architecture

Services Layer L2VPN L3VPN NFV Security

Network Services Orchestrator

Network devices

TECNMS-4175 © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public 14
Quick History

• Founded in Sweden in 2005


• Acquired by Cisco in 2014
• Developed Conf-D and NCS
• NCS evolved into NSO!

TECNMS-4175 © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public 15
Addressing Network Management Challenges

Cisco NSO Solution


• Multi-vendor service orchestration platform Management Network
Applications Engineer
• Multi-vendor service-layer SDN controller NETCONF, REST,
CLI, WebUI
Java, Scripts
• Supports traditional L2-L7 networking, virtual devices
and OpenFlow Cisco
NSO
• Provides a single API and single UI to entire managed
environment
• Keeps accurate copy of network configuration state

TECNMS-4175 © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public 16
KP
Solutions ecosystem

NGENA
SERENO SP-NAC MVSO
NFVO
ULTRA
NSO WAE

vMS MORPH NFVi


VTS eNFV
ROBOT

TECNMS-4175 © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public 17
NSO Architecture
NSO Network Abstraction

OSS/BSS Network EMS/NMS


Engineer

NETCONF REST CLI WebUI SNMP JSON Northbound APIs


NSO
Service Service Management Layer End-to-end Service
Models View

Device
Models Network Services
Device Management Layer Global Device View

Orchestrator
Network Element Driver (NED) NED NED NED Southbound APIs

Multivendor
Physical and/or
Virtual Device
Environment

TECNMS-4175 © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public 19
NSO Architectural Components

OSS/BSS Network EMS/NMS


Engineer
NETCONF REST CLI WebUI SNMP JSON Northbound APIs
NSO
Package Any scripting
Service Templates Manager Script API
Service language
Models Manager
Core Alarm Developer Java or Python
Mapping Logic Engine Manager extensions
API
Device Device
CDB Notification
Models Manager FASTMAP
Receiver ...
Network Element Driver (NED) NED NED NED Southbound APIs

NETCONF REST CLI OpenFlow etc.

TECNMS-4175 © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public 20
NSO components
Cisco NSO Core Engine

• Performs core functionality


Transaction Management
Session Management / Authentication • Glue for all NSO components
Role-based Access Control
Redundancy / Replication • Reads initial configuration from ncs.conf
Event Logging / Audit Trailing
• All other configuration and operational
Validation (syntactic and semantic)
data is handled in the CDB main
configuration database (CDB)
Rollback Management
Upgrades and Downgrades

TECNMS-4175 © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public 22
CDB

/ (root)

• Stores configuration data for devices and system


• ACID compliant
devices services alarms snmp nacm
• Fast, lightweight, fault-tolerant d1 s1
Service configuration
• Compact binary XML-analogue format based on service’s
YANG model
• In-memory DB with file system journaling for persistence config

• 1:N data replication support Device configuration


based on device’s
• In-service data model update YANG model

• Automatic schema and data update


• Automatic loading of initialization data

TECNMS-4175 © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public 23
Device Manager

• Handles device configurations


• Device configuration framework defined using YANG data models from NEDs

• Service models map to device configurations:


• Configuration templates (XML)
• Java or Python code

• FASTMAP algorithm controls and optimizes southbound configuration actions:


• Create NETCONF REST CLI SNMP
NSO
• Modify Service Service Templates
Models Manager
• Delete Mapping Logic
Device Device
Models Manager FASTMAP
CDB
NED NED NED

TECNMS-4175 © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public 24
NSO CLI

• In Operational mode, the CLI displays operational data stored in CDB


• In Configuration mode, the CLI displays network configuration data stored in CDB

Cisco Style Juniper Style


admin@nso# operational mode CLI admin@nso> operational mode CLI

admin@nso(config)# configuration mode admin@nso% configuration mode

Operational Mode Configuration Mode


admin@nso# show devices list admin@nso# configure
NAME ADDRESS NED ID ADMIN STATE admin@nso(config)# show full-configuration
------------------------------------------ devices device ce0
P11 127.0.0.1 cisco-ios-xr unlocked P12
127.0.0.1 cisco-ios-xr unlocked P21 devices device PE11
127.0.0.1 cisco-ios-xr unlocked PE11 address 127.0.0.1
127.0.0.1 cisco-ios unlocked PE12 port 10101
127.0.0.1 cisco-ios unlocked PE21 ssh host-key ssh-dss
127.0.0.1 cisco-ios-xr unlocked PE22 key-data ...
127.0.0.1 cisco-ios-xr unlocked !
... ...

TECNMS-4175 © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public 25
Device
Configuration
Management
Synchronizing from Device

• Device Configurations in NSO and actual Device Configuration should


match
• After initial device discovery or import, it makes sense to synchronize
configurations from devices
sync-to
sync-from
admin@nso# devices sync-from check- sync
sync-result { Cisco compare-config
NSO
device lb0
result
true
}

TECNMS-4175 © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public 27
Synchronizing to Device

• When a device has been configured out of band


• Clears up rogue configuration
• “dry-run” option available to check changes
sync-to
sync-from
admin@nso# devices device PE11 sync-to
check- sync
result true Cisco compare-config
NSO

Change device
configuration over CLI.

TECNMS-4175 © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public 28
Check Sync

• Check if a device has been configured out of band


admin@nso# devices check-sync
sync-result {
device PE11
result in-
sync
}
...

• Check if a subset of managed devices has been configured out of band


admin@nso# devices device PE1..9 check-sync
devices device PE1 check-sync
result in-sync
devices device PE2 check-sync
result in-sync
devices device PE3 check-sync

TECNMS-4175 © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public 29
Comparing Configuration

• Compare out-of-sync device configuration


admin@nso(config)# devices device PE11 check-sync
result out-of-sync
info got: 334bb33aae40155831edfa0b6a978f39 expected: a1424cd35da4499f6a71b3d38ae648a8

admin@nso(config)# devices device PE11 compare-config “ - ” represents configuration


diff
devices { items that should be deleted from
device PE11 { the CDB in order to be the same
config {
ios:interface { as on the device
Loopback 10 {
ip {
address {
primary { “+” represents configuration
- address 10.1.1.1;
+ address 2.2.2.2; items that should be added to the
} CDB in order to be the same as
}
} on the device

TECNMS-4175 © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public 30
Displaying Configuration

• Display only new parts of configuration:


admin@nso# config
admin@nso(config)# devices device PE11 config ios:interface Loopback 20
admin@nso(config-if)# ip address 10.2.2.2 255.255.255.255
admin@nso(config)# devices device PE11 config ios:interface Loopback 30
admin@nso(config-if)# ip address 10.3.3.3 255.255.255.255
admin@nso(config-if)# show configuration
devices device PE11
config
ios:interface Loopback30 Displays current configuration items
▪ Display full configuration
ip address 10.3.3.3 255.255.255.255 in the current configuration mode
no shutdown
exit
!
!
admin@nso(config)#

TECNMS-4175 © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public 31
Displaying Configuration (Cont.)

• Display only new parts of configuration:


admin@nso(config-if)# top
admin@nso(config)# show Go to root of the data tree to display
configuration devices device the all configuration items of the
PE11 configuration session
config
ios:interface Loopback20
ip address 10.1.1.1 255.255.255.255
no
shutdown
▪ Display full configuration
exit
ios:interface Loopback30
ip address 10.3.3.3 255.255.255.255
no shutdown
exit
!
!

TECNMS-4175 © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public 32
Configuring Devices

• Configuration change happens after final commit statement


admin@nso# config
admin@nso(config)#
admin@nso(config)# devices device PE11 config ios:interface Loopback 20
admin@nso(config-if)# ip address 10.2.2.2 255.255.255.255
admin@nso(config)# devices device PE11 config ios:interface Loopback 30
admin@nso(config-if)# ip address 10.3.3.3 255.255.255.255
admin@nso(config-if)# commit
admin@nso#

TECNMS-4175 © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public 33
Displaying Configuration

• Display entire CDB:


admin@nso# show running-config
or
admin@nso(config)# show full-configuration

• Display portion of CDB:


admin@nso# show configuration devices device PE11 config ios:interface Loopback
devices device PE11 config
ios:interface Loopback0
ip address 10.1.1.1 255.255.255.255
no shutdown
...

TECNMS-4175 © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public 34
Rollbacks

• Every transaction has a corresponding rollback file:


admin@nso:~/ncs-run/logs$ ls rollback*
admin@nso:~/ncs-run/logs$ more rollback10157
Displays what NSO did
admin@nso# show configuration commit 10157
devices device PE11
config
no ios:interface Loopback10 Displays what NSO would
!
! do if you execute a
admin@nso# show configuration rollback 10157 rollback
!
! Created by: admin
! Date: 2016-01-14 14:40:58
! Client: cli
!
devices device PE11
config
ios:interface Loopback10
ip address 10.1.1.1 255.255.255.255
no shutdown

TECNMS-4175 © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public 35
Rollbacks – Examples

• Rollback 3 latest transactions (last change ID is 10157):


admin@nso(config)# rollback configuration 10155

• Rollback only changes done in 3rd latest transaction:


admin@nso(config)# rollback selective 10155

• Rollback interface changes on PE11 in the 3 latest transactions:


admin@nso(config)# rollback configuration 10155 devices device PE11 config ios:interface

• Rollback interface changes on PE11 in the 3rd latest transaction:


admin@nso(config)# rollback selective 10155 devices device PE11 config ios:interface

TECNMS-4175 © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public 36
Configured Devices

• List devices with basic parameters


Device address and description
NED ID
Administrative state
admin@nso# show devices list

--------------------------------------------------------
NAME ADDRESS DESCRIPTION NED ID ADMIN STATE

P11 127.0.0.1 - cisco-ios-xr unlocked


P12 127.0.0.1 - cisco-ios-xr unlocked
P21 127.0.0.1 - cisco-ios-xr unlocked
PE11 127.0.0.1 - cisco-ios unlocked
PE12 127.0.0.1 - cisco-ios unlocked
PE21 127.0.0.1 - cisco-ios-xr unlocked
PE22 127.0.0.1 - cisco-ios-xr unlocked
PE31 127.0.0.1 - cisco-ios-xr unlocked
PE41 127.0.0.1 - cisco-ios-xr unlocked

TECNMS-4175 © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public 37
Device Connection
Management
Device States

Oper State Description


Enabled Device is reachable from NSO.
Disabled Device is unreachable from NSO.

Admin State Description


Southbound-locked (default) Configuration change is possible
not pushed to the device.
Locked Configuration change is
not possible.
Unlocked Configuration change is
possible and pushed to the
device.

TECNMS-4175 © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public 39
Oper State

• The actual state of a managed device


• It is either 'enabled' or 'disabled'
• If NSO initiates operations and the device is unreachable the oper state is
set to disabled Cisco NSO

SSH not possible


= disabled
SSH is up
= enabled

TECNMS-4175 © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public 40
Admin State

• Southbound-locked (default): possible to manipulate the configuration but


changes are never pushed to the device
• Locked: all changes to device are forbidden
• Unlocked: this is the state we set a device into when the device is
operational. All changes to the device will be sent southbound
Cisco Configure PE11
NSO
Configure PE12
Configure PE21

PE11: unlocked – PE12: unlocked - PE21: locked –


Configuration changed Configuration changed transaction FAILS

TECNMS-4175 © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public 41
Adding a Device

• Manually: useful for small number of devices (e.g. development and


testing)
• Cloning: replicate a device from an existing device
• Templates: replicate a device from a template
• Bulk upload: useful for initial definition of many devices

admin@nso(config)# devices device PE101 address 10.1.1.1


admin@nso(config-device-PE101)# device-type cli ned-id cisco-ios protocol ssh
admin@nso(config-device-PE101)# authgroup default
admin@nso(config-device-PE101)# commit
Commit complete.

TECNMS-4175 © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public 42
Lab Exercise 1
Netsim

Optional add-on to NEDs NETCONF REST CLI SNMP


• NSO
Service Service Templates
Manager
• Simulates device’s native CLI Models
Mapping Logic
Device
Device
• Useful for development and testing Models Manager FASTMAP
CDB
CLI
NETCONF SNMP Generic
Lightweight: enables simulation of many
NED
• NED
XML
NED NED

devices on a desktop Config

YANG ConfD
NSO normally
Uses YANG model and ConfD in reverse
Device
• Model Java for managing a device as
to simulate a device’s CLI SSH if it were real

CLI
CLI over SSH Config

Java for
• ! Netsim is not a replacement for real SSH srv. Netsim
Netsim simulating
devices !
ConfD
device’s
CLI

TECNMS-4175 © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public 44
Starting Simulated Devices

• Below example creates 3 Cisco IOS devices: Create 3


devices
cisco@ncs:~/lab$ ncs-netsim create-network <NED package> <#N devices>
cisco@ncs:~/lab$ ncs-netsim create-network $NCS_DIR/packages/neds/cisco-ios 3 c

Use prefix “c” for


device names

• Simply run netsim inside the lab folder


cisco@ncs:~/lab$ ncs-netsim start
DEVICE c0 OK STARTED
DEVICE c1 OK STARTED
DEVICE c2 OK STARTED
cisco@ncs:~/lab$

TECNMS-4175 © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public 45
Netsim Options

• Netsim supports creating, adding and deleting simulated devices on the fly

cisco@ncs:~$ ncs-netsim --help

Usage ncs-netsim [--dir <NetsimDir>]

create-network <NcsPackageDir> <NumDevices> <Prefix> |


add-to-network <NcsPackageDir> <NumDevices> <Prefix> |
delete-network |
[-a | --async] start [devname] |
[-a | --async ] stop [devname] |
[-a | --async ] reset [devname] |
[-a | --async ] restart [devname] |
list |
is-alive [devname] |
status [devname] |
whichdir |
ncs-xml-init [devname] |
packages |
netconf-console devname [XpathFilter] |
[-w | --window] [cli | cli-c | cli-i] devname

TECNMS-4175 © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public 46
KP
Access Simulated Devices

• You can run the CLI towards the simulated devices


cisco@ncs:~$ ncs-netsim cli-i c1
admin connected from 127.0.0.1 using console *
c1> enable
c1# show running-config
class-map m
match mpls experimental topmost 1
match packet length max 255
match packet length min 2
match qos-group 1
!
c1# exit

TECNMS-4175 © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public 47
Introduction to YANG
YANG

"YANG is a data modeling language used to model configuration and state


data manipulated by the Network Configuration Protocol (NETCONF),
NETCONF remote procedure calls, and NETCONF notifications. YANG is
used to model the operations and content layers of NETCONF“ IETF RFC
6020
Service Models
The YANG models describe
The NETCONF protocol allows a
everything there is to …
manager to set configuration, YANG
▪ Configure
query configuration and state
▪ Monitor
and execute actions on the NETCONF ▪ Admin actions
device
▪ Notifications
(similar to SNMP).
…for each device type and
version (similar to MIBs).
Device 3: Device 4: Device 9:
Vendor A Vendor B Vendor W
Model Y Model Z Model T
Note! NETCONF is not the only Version Version Version F
protocol. NSO also uses NEDs. 1.3 9.5

TECNMS-4175 © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public 49
YANG Characteristics

• Designed for readability


• Simplicity enables fast service model development
• Modularity and hierarchy enable reuse of code

TECNMS-4175 © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public 50
Modeling a Football team in Yang

• Team should have a name.


• Has multiple players.
• Players have names.
• They have specific positions.
• They have an age.

TECNMS-4175 © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public 51
YANG Model Hierarchy and Modularity

acme.yang sirius.yang
module acme { module sirius {
namespace A; namespace B; ▪ Imported fragments are just
import sirius; ... referenced, not included
▪ Used to group reusable definitions
include aurora; } that can be reused by many other
include orion; modules
▪ Similar to libraries in programing
... languages
}
include include
▪ Useful to split large modules into smaller
orion.yang
more manageable files
submodule orion {
aurora.yang ▪ Submodule can never be included in any
submodule aurora { other module
... ▪ Module and submodules share the same
...
namespace
}
}

TECNMS-4175 © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public 52
Yang Data Types
YANG Data Types

• Built-in data types


• Derived data types:
RFC-defined data types (RFC 6991)
NSO-defined data types
Custom data types

TECNMS-4175 © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public 54
YANG Supports a Number of Data Types

Built-in Types Derived Types


typedef my-base-int32-type {
Name Description
type int32 {
int8/16/32/64 Integer range "1..4 | 10..20";
}
uint8/16/32/64 Unsigned integer }
decimal64 Non-integer
typedef derived-int32 {
string Unicode string type my-base-int32-type {
enumeration Set of alternatives range "11..max";
}
boolean True or false }
bits Boolean array typedef string255 {
binary Binary BLOB
type string {
length "1..255";
leafref Reference }
}
identityref Unique identity
empty No value, void typedef derived-str {
type string255 {
union Choice of member types length "11 | 42..max";
pattern "[0-9a-fA-F]*";
instance-identifier References a data tree node }
}

TECNMS-4175 © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public 55
Derived Type Restrictions
typedef acl-num-type {
• Range: type int32 {
range "1..199 | 1300..2699";
• Applies to integer and decimal types }
}
• "x .. y" typedef std-acl-num-type {
• "min .. x” , ”x .. max”. type acl-num-type {
range "min..99 | 1300..1999";
}
• Length: }
typedef ext-acl-num-type {
• For string type type acl-num-type {
range "100..199 | 2000..max";
• Same syntax }
}
• Pattern: typedef acl-name-type {
type string {
• For string type length "1..50";
pattern "[a-zA-Z][a-zA-Z0-9-_]*";
• Uses regular expressions }
}
• Fraction-digits: typedef std-acl-name-type { type acl-name-type; }
typedef ext-acl-name-type { type acl-name-type; }
• Applies to decimal type typedef const-type {
type decimal64 {
fraction-digits 4;
range "2.7182 .. 3.1415";
}
}
TECNMS-4175 © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public 56
Combined Derived Types

typedef intf-ip-addr-type {
• Enumeration: type union {
type inet:ip-address;
• Defines a set of names type enumeration {
enum "none";
enum "unnumbered";
• Union: enum "dhcp";
}
• Used to define a type with a combination of two or more }
other types }

typedef acl-id-type {
type union {
type acl-num-type;
type acl-name-type;
}
}

TECNMS-4175 © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public 57
YANG Types Example

// percentage type // DSCP type


typedef percentage-type typedef dscp-type;
{ type union;
type uint8 { type uint8 { range "0..63";
range } type enumeration {
"1..100"; enum af11;
} enum af12;
} enum af13;
// Weekday type enum af21;
typedef weekday-type enum af22;
{ type enum af23;
enumeration { enum af31;
enum Mon; enum af32;
enum Tue; enum af33;
enum Wed; enum af41;
enum Thu; enum af42;
enum Fri; enum af43;
enum Sat; enum cs1;
enum Sun; enum cs2;
} enum cs3;
} enum cs4;
// Hour & minute & optional second enum cs5;
type typedef hhmm-type { enum cs6;
type string { enum cs7;
pattern '([0-1]?[0-9]|2[0-3]):' + enum default;
'([0-5][0-9])(:[0-5][0-9])?';
} enum dscp;
} enum ef;
// Route Distinguisher AS:NUM or enum precedence;
}
IP:NUM typedef rd-type { }
type string { }
pattern '((\d+)((\.\d+){3})?)\:\d+';
}
}

TECNMS-4175 © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public 58
YANG Data
Definitions
Basic YANG Statements Defining Data Nodes

YANG Programming Description


Equivalent
Container
Leaf Variable Contains a single value of a specific type

Leaf-List Array Contains a list of values of the same type List 11 25 Leaf

11 22
Container Record Contains a single structure containing zero
or more values or other statements 11 Leaf- List 22 Leaf- List
(hierarchy) Key leaf
(list index)

List Array of Contains a list of zero or more sets of 7 5


1 3
Records values and other statements
(hierarchy)

TECNMS-4175 © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public 60
Modeling Cisco IOS commands in Yang
container

interface

list list

interface Loopback 1 Loopback FastEthernet

ip address 10.0.0.1 255.255.255.255 container container

id ip id ip
interface FastEthernet 1/2 key key

ip address 10.1.0.2 255.255.255.0 address address


container container

ipaddress ipaddress
leaf leaf

mask mask
leaf leaf

TECNMS-4175 © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public 61
Modeling Cisco IOS commands in Yang (Cont)

container interface {
list Loopback { container
key id;
leaf id {
type uint16 { interface
range "1..65535";
} list
} list
container ip {
container address { Loopback FastEthernet
leaf ipaddress {
type string;
}
leaf mask { container container
type string;
} id ip id ip
}
} key key
}
list FastEthernet {
key id; address address
leaf id {
type string; container container
}
container ip {
container address {
leaf ipaddress { ipaddress ipaddress
type string;
}
leaf mask { leaf leaf
type string;
}
} mask mask
}
} leaf leaf
}

TECNMS-4175 © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public 62
Leaf

id XPath: mask XPath:


/interface/Loopback [id=“1”] /interface/Loopback[id='1']/ip/address/mask
1 255.255.255.255

YANG (data model) XML (data) YANG (data model) XML (data)
leaf id { <interface> leaf mask{ <interface>
type uint16 { type string;
range "1..65535"; <Loopback> } <Loopback>
} <id>1</id> <id>1</id>
}
</Loopback> <ip>
</interface> <address>
<ipaddress></ipaddress>
<mask>255.255.255.255</mask>
</address>
</ip>
</Loopback>
</interface>

• Single value using a built-in or derived data type


• Zero or one instance

TECNMS-4175 © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public 63
Leaf Attributes

Attribute Description
config Whether this leaf is a configurable value ("true") or operational
value ("false"). Inherited from parent container if not specified
default Specifies default value for this leaf. Implies that leaf is optional
mandatory Whether the leaf is mandatory ("true") or optional ("false")
must XPath constraint that will be enforced for this leaf
type The data type (and range etc) of this leaf
when Conditional leaf, only present if XPath expression is true
description Human readable definition and help text for this leaf
reference Human readable reference to some other element or spec
units Human readable unit specification (e.g. Hz, MB/s, ℉)
status Whether this leaf is "current", "deprecated" or "obsolete"

TECNMS-4175 © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public 64
Container

C interface XPath: YANG (data model)


container interface {
/interface
L Loopback list Loopback {
key id;
K id C ip leaf id {}
container ip {
C address container address {
leaf ipaddress {}
ipaddress mask leaf mask {}
}
}
}
}

• Used to group one or more other statements


XML (data)

• Has no data type by itself <interface>


</interface>

• May have an implicit meaning

TECNMS-4175 © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public 65
List

XPath: YANG (data model)


list Loopback {
/interface/Loopback [id=“1”] key id;
L Loopback /interface/Loopback [id=“1”]/ip / address / ipaddress leaf id {
type uint16 {
/interface/Loopback [id=“1”]/ip / address / mask range "1..65535";
K id C ip /interface/Loopback [id=“2”] }
/interface/Loopback [id=“2”]/ip / address / ipaddress }
C address container ip {
/interface/Loopback [id=“2”]/ip / address / mask container address {
leaf ipaddress {
ipaddress mask type string;
}
leaf mask {
1 10.0.0.1 255.255.255.255 type string;
}

2 10.0.0.2 255.255.255.255 }
}
}

XML (data)

• Contains one or more sub statements <interface>


<Loopback>
<id>1</id>
• Requires one unique identifier (key) …
</Loopback>
<Loopback>
• Zero or more instances <id>2</id>

</Loopback>
</interface>

TECNMS-4175 © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public 66
List: Single Key

L user

K name uid full-name class


yang 1010 Yan Goode admin
hawk 1152 Ron Hawk oper
ling 1202 Lin Grossman viewer
XPath:
/ user [name='yang'] / name = yang list user {
/ user [name='yang'] / uid = 1010 key name;
/ user [name='yang'] / full-name = Yan Goode ...
/ user [name='yang'] / class = admin }

• The key refers to a leaf


• The key values must be unique

TECNMS-4175 © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public 67
List: Combined Key

L route

K prefix K length next-hop metric list route {


key "prefix length";
192.0.2.0 24 10.100.1.2 20 ...
198.51.100.0 24 192.168.31.5 40 }

203.0.113.0 24 172.31.11.1 50
XPath:
/ route [prefix='198.51.100.0'][length='24'] / next-hop = 192.168.31.5
/ route [prefix='198.51.100.0'][length='24'] / metric = 40

• Keys refer to leaf statements


• Key combinations must be unique

TECNMS-4175 © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public 68
Leaf-list

L vlan
XPath:
10 vlan
30
240
330
YANG (data model) XML (data)
leaf-list vlan { <vlan>10</vlan>
type uint16 { <vlan>20</vlan>
range "0..2147483647"; <vlan>240</vlan>
} <vlan>330</vlank>
}

• Example: switchport trunk allowed vlan 10,30,240,330


• Unique values using a single built-in or derived data type
• Zero or more instances

TECNMS-4175 © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public 69
List and Leaf-List Attributes

Attribute Description
max-elements Max number of elements in a list
min-elements Min number of elements in a list
ordered-by List entries are sorted by "system" or "user". System
means elements are sorted in a natural order
(numerically, alphabetically, etc). User means the order
the operator entered them in is preserved.

leaf-list domain-search {
type string; system order user order
ordered-by user; cisco.com example.com
min-elements 1;
example.com
≠ cisco.com
max-elements 2;
}

TECNMS-4175 © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public 70
Grouping
G Grouping
YANG (data model)
grouping app { address port
leaf address {
type inet:ip-address;
}
leaf port {
type inet:port-number;
}
} C http-server
container http-server {
uses app { port (default: 80)
refine port { address
default 80;
}
} C smtp-server
}
container smtp-server { address port (default: 25)
uses app {
refine port {
default 25;
}
}
} 10.1.1.1 80 XPath:
10.1.2.1 25 / http-server
/ http-server / address
/ http-server / port

Used to group YANG code for reuse


/ smtp-server
• / smtp-server / address
/ smtp-server / port

• Can be refined upon use

TECNMS-4175 © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public 71
Leafref
L services C app

K ip K port R address R Port


192.0.2.213 16772 198.51.100.22 19234
198.51.100.22 19234
203.0.113.89 22315
list services { container app {
key "ip port" leaf address {
type leafref {
leaf ip { path "/services/ip";
type inet:ipv4-address; }
}
} leaf port {
type leafref {
leaf port { path "/services[ip=current()/../address]/port";
type uint16; }
} }
} }

• Refer to a leaf or leaf-list elsewhere in the tree

• Inherits data type from referenced node

• The path keyword is used to match:

the position in the tree

the key(s) if referring to a leaf-list or leafs within a list (all key leafs must be referenced)

TECNMS-4175 © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public 72
YANG Module Structure

acme.yang
module acme {
namespace "http://acme.example.com/module";
prefix acme; Header Information
organization "ACME Inc.";
description "Module describing the ACME products";
revision 2007-06-09 { description "Initial revision."; } Revision Information
import ietf-yang-types { prefix yang; }
include acme-system; Imports & Includes
typedef percentage-type {
type uint8 { range "1..100"; } Type Definitions
}
grouping ifdata {
leaf ipv4-address {
type inet:ipv4-address;
}
leaf ipv4-mask { Reusable Node
type inet:ipv4-address; Declarations
}
}

TECNMS-4175 © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public 73
YANG Module Structure(Cont.)

list loopback-interface {
key "Loopback";
leaf Loopback {
type string; Configuration & Operational
} Data Declarations
uses ifdata;
}
notification link-failure {
description "A link failure has been detected";
leaf if-name { type string; }
leaf if-admin-status { type uint8; }
}

rpc clear-interface { Action (RPC) &


input { Notification Declarations
leaf interface-name { type string; }
}
output {
leaf status { type string; }
}
}
} End of Module File

TECNMS-4175 © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public 74
NSO and YANG

• NSO has it‘s own YANG models: tailf-ncs-*.yang


• The NSO YANG model can be augmented
• tailf-ncs-devices.yang references a flat list of devices
• A device is identified by a free form text string

container devices {
tailf:info "The managed devices and device communication
settings"; uses connect-grouping {
augment "connect/input" {
leaf-list device {
tailf:info "Only connect to these
devices."; type leafref { path
'/devices/device/name'; }
}
}
}
}

TECNMS-4175 © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public 75
Devices and Device YANG Models

• To manage a device, we need a corresponding YANG model


• Device models are deployed as part of NED packages
• All imported modules appear under /devices/device/config in the CDB

TECNMS-4175 © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public 76
The bridge between Network
Automation and Business

TECNMS-4175 © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public 77
KP

Service Manager
Service Manager

• Service modeling using YANG


• Service to Device mapping through Template + Python/Java code
• Service activation, modification, decommissioning, restoration
• Service synchronization with device configurations
• Aggregated operational data
NETCONF REST CLI SNMP
NSO
Service Service Templates
Models Manager
Mapping Logic
Device Device
Models Manager FASTMAP CDB

NED NED NED

TECNMS-4175 © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public 79
NSO Service through CLI (Cisco Style)

Edit an existing service instance


or create a new one

admin@ncs(config)# services l3mplsvpn 10002 link 3 interface ...


... Check service
admin@ncs(config)# services l3mplsvpn 10001 check-sync synchronization status to
in-sync true mapped device configuration
admin@ncs(config)# services l3mplsvpn 10001 deep-check-sync Check service
in-sync true synchronization status to
actual device configuration
admin@ncs(config)# services l3mplsvpn 10001 re-deploy
Re-deploy the service
admin@ncs(config)# services l3mplsvpn 10001 un-deploy
instance
admin@ncs(config)# no services l3mplsvpn 10002

Un-deploy the service


instance (i.e. remove from
Delete the service instance devices, but keep in CDB)

TECNMS-4175 © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public 80
Comparing Configurations: Service or Device

CDB
Get Modifications Device 1 S1 S1
configuration
S1 Device 1
Service instance
configuration S2
Device 2
S2 S2
configuration Compare
Device 2

admin@nso# service l3mplsvpn S1 get-modifications


admin@nso# devices device PE11 compare-config

• Get device modifications made by a service instance


• Get discrepancies between CDB version of device configuration and actual
device configuration

TECNMS-4175 © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public 81
Templates

• Simplify changes in network configuration


• Two types:
• Device templates for direct activation (e.g. through NSO CLI, REST)
• Configuration templates for service mapping to device configurations

NETCONF REST CLI SNMP


NSO
Service Service Templates
Models Manager
Mapping Logic
Device Device
Models Manager FASTMAP CDB

NED NED NED

TECNMS-4175 © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public 82
Mapping Logic

Service
Parameters
• Transforms the service models to device models
• When templates are not enough: Java or Python
• External call-outs can be made code (optional)

• Expressions or algorithms in Java or Python code can be used

• Uses FASTMAP Configuration


Template (XML)
• 1 page of code for a complex service

NETCONF REST CLI SNMP Device


NSO Configuration
Service Service Templates
Models Manager
Mapping Logic
Device Device
Models Manager FASTMAP CDB

NED NED NED

TECNMS-4175 © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public 83
Mapping Logic (Cont.)

Service Mapping Mapping


Model logic A Logic B
2 x mapping logic

firewall filter ip

rule term access-list

source- ip- prefix: from source


10.1.1.0/24
prefix: 10.1.1.0/24 address:
source- port: 10.1.1.0
161 wildcard:
protocol: udp
protocol: 0.0.0.255
udp protocol: udp
port: 161
port: 161

to destination

TECNMS-4175 © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public 84
FastMap
FASTMAP

• FASTMAP controls and optimizes southbound configuration actions:


Create: defines the “to-be” state
Modify: FASTMAP algorithm calculates the necessary changes to be
applied
Delete: FASTMAP algorithm stores the “undo” operation needed to
revert to the original state
• Operator is only concerned with NSO NETCONF REST CLI SNMP

defining the “to-be” state (i.e. Service Service Templates


Models Manager

create operation)
Mapping Logic
Device Device
Models Manager FASTMAP CDB

NED NED NED

TECNMS-4175 © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public 86
Example: Create a New Service Instance

admin@nso# config
Entering configuration mode terminal
admin@ncs(config)# services l2vpn ACME
admin@ncs(config-l2vpn-ACME)# pw-id 102

admin@ncs(config-l2vpn-ACME)# link Site1


• YANG service model governs admin@ncs(config-link-PE11)# device PE11
admin@ncs(config-link-PE11)# intf 0/5
service parameter API admin@ncs(config-link-PE11)# remote 10.1.1.15
admin@ncs(config-link-PE11)# exit

admin@ncs(config-l2vpn-ACME)# link Site2


admin@ncs(config-link-PE11)# device PE12
admin@ncs(config-link-PE11)# intf 0/9
admin@ncs(config-link-PE12)# remote 10.1.1.11
admin@ncs(config-link-PE12)# top
admin@ncs(config)#

TECNMS-4175 © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public 87
Example: Create a New Service
admin@ncs(config)# commit dry-run
device PE11
config {
ios:interface {
GigabitEthernet 0/5 {
+
xconnect {
address 10.1.1.15; • NED device model governs device
+ vcid 102;
+
}
encapsulation mpls; configuration parameters
}
} }
device PE12
• XML, Java or Python map service
config {
ios:interface { parameters to device configurations
GigabitEthernet 0/9 {
xconnect {
+ address 10.1.1.11;
+ vcid 102; Service parameters
+ encapsulation mpls;
} mapped to device
}
} configuration
admin@ncs(config)# commit dry-run outformat native
device PE11
interface GigabitEthernet0/5
xconnect 10.1.1.12 102 encapsulation mpls
• CLI NED's YANG model also
exit
exit
contains additional information that
device PE12
interface GigabitEthernet0/9
governs mapping of YANG
xconnect 10.1.1.11 102 encapsulation mpls
exit
statements to CLI commands
exit
Can display native
admin@ncs(config)# commands in case
of CLI NED
TECNMS-4175 © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public 88
FASTMAP: Service Create

CDB / Device

/services /devices

./l2vpn[name='ACME'] ./device[name='PE11'] PE11


./config interface GigabitEthernet0/5
./pw-id=102 xconnect 10.1.1.15 102 encapsulation mpls
./interface !
1 2 ./link[2] ./GigabitE[name='0/5']
./xconnect PE12
./device='PE11'
./interface='0/5' address='10.1.1.15'
interface GigabitEthernet0/9
./remote='10.1.1.15' vcid='102'
xconnect 10.1.1.11 102 encapsulation mpls
encapsulation='mpls'
!

: service mapping & diff & remember reverse Configuration sent to devices
diff

TECNMS-4175 © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public 89
Modify and Existing Service: Example 1
admin@nso# config
Entering configuration mode terminal
admin@ncs(config)# services l2vpn ACME
admin@ncs(config-l2vpn-ACME)# pw-id 122
admin@ncs(config-link-PE12)# top
admin@ncs(config)# commit dry-run
device PE11
config {
ios:interface {
GigabitEthernet 0/5 {
xconnect {

Only one parameter changed


- vcid 102;
+ vcid 122; •
}
}

}
}
• CDB shows only minimal diff changes
device PE12
config {
ios:interface {
admin@nso# config
GigabitEthernet 0/9 {
• Changed parameter affects both
Entering configuration
-
xconnectmode
admin@ncs(config)#vcid
{ terminal
102; l2vpn ACME
services devices
+ vcid 122;
admin@ncs(config-l2vpn-ACME)# pw-id 122
}
admin@ncs(config-link-PE12)# top
admin@ncs(config)# commit dry-run outformat native
device PE11
interface GigabitEthernet0/5
xconnect 10.1.1.12 122 encapsulation mpls
exit
exit
device PE12
interface GigabitEthernet0/9
xconnect 10.1.1.11 122 encapsulation mpls
exit
exit

TECNMS-4175 © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public 90
Modify and Existing Service: Example 2

admin@nso# config
Entering configuration mode terminal
admin@ncs(config)# services l2vpn ACME
admin@ncs(config-l2vpn-ACME)# link Site1
admin@ncs(config-l2vpn-ACME)# remote 10.1.1.12
admin@ncs(config-link-PE12)# top
admin@ncs(config)# commit dry-run
device PE11 • Only one parameter changed
config {

CDB shows only minimal diff changes


ios:interface {
GigabitEthernet 0/11 { •
xconnect {
-
admin@nso# config address 10.1.1.15;
+ address
Entering configuration
}
10.1.1.12;
mode terminal • Changed parameter affects only one
device
admin@ncs(config)# services l2vpn ACME
}
admin@ncs(config-l2vpn-ACME)# link Site1
}
admin@ncs(config-l2vpn-ACME)# remote 10.1.1.12
}
admin@ncs(config-link-PE12)# top
admin@ncs(config)# commit dry-run outformat native
device PE11
interface GigabitEthernet0/5
xconnect 10.1.1.12 122 encapsulation mpls
exit
exit

TECNMS-4175 © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public 91
Delete a Service Instance
admin@nso# config
Entering configuration mode terminal
admin@ncs(config)# no services l2vpn ACME
admin@ncs(config)# commit dry-run
device PE11
config {
ios:interface {
GigabitEthernet 0/6 {
xconnect {
- address 10.1.1.12;
-
-
vcid 122;
encapsulation mpls; • Only one parameter changed
}
}
}
}
• CDB shows only minimal diff changes
device PE12
config {
ios:interface {
GigabitEthernet 0/9 {
admin@nso# config xconnect {
• Reverse diff used to undo the
-
Entering configuration
-
admin@ncs(config)#
address
mode 10.1.1.11;
vcid 122;
services
terminal
l2vpn mpls;
ACME
configuration changes of the service
-
}
}
encapsulation
admin@ncs(config-l2vpn-ACME)#
admin@ncs(config-l2vpn-ACME)#
link Site1
intf 0/6
instance
}
admin@ncs(config-link-PE12)# top
admin@ncs(config)# commit dry-run outformat native
device PE11
interface GigabitEthernet0/6
no xconnect 10.1.1.12 122 encapsulation mpls
exit
device PE12
interface GigabitEthernet0/9
no xconnect 10.1.1.11 122 encapsulation mpls
exit
exit

TECNMS-4175 © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public 92
Handling Services Sharing Resources
• Multiple service instances configuring the same shared prerequisite
configuration
CDB NSO maps service
Service Instances Device Changes parameter to device
configuration
L2 VPN a1 xconnect a1
Refcount=1 NSO counts owners of each
Backpointer=l2vpn[name='A1'] configuration element

Operator loopback 1
creates service Refcount=1 NSO remembers owners of
Backpointer=l2vpn[name='A1'] each configuration element
instance

• Example: L2VPN service using common Loopback interfaces

TECNMS-4175 © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public 93
Handling Services Sharing Resources
• Second L2VPN service uses the same Loopback interface

CDB
Service Instances Device Changes

L2 VPN a1 xconnect a1
Refcount=1
Backpointer=l2vpn[name='A1']
Backpointer=l2vpn[name='a1']
L2 VPN a2
xconnect a2
Refcount=1
Backpointer=l2vpn[name='a2']
NSO increases the count of
owners of shared
Operator loopback 1 configuration elements
creates another
Refcount=2
service instance Backpointer=l2vpn[name='a1'],
NSO updates the list of
l2vpn[name='a2'] owners of shared
configuration elements

TECNMS-4175 © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public 94
Handling Services Sharing Resources
• Deleting first L2VPN does not delete Loopback interface configuration

CDB
Service Instances Device Changes NSO only deletes those
elements whose reference
L2 VPN a1 xconnect a1
count is 1
Refcount=1
Backpointer=l2vpn[name='A1']
Backpointer=l2vpn[name='a1']
L2 VPN a2
xconnect a2
Refcount=1
Backpointer=l2vpn[name='a2']
NSO decrements reference
count on those elements that
Operator were not deleted
deletes one loopback 1
service instance Refcount=1 NSO updates the list of
Backpointer=l2vpn[name='a2']
owners of shared
configuration elements
Cisco Network Services Orchestrator 36

TECNMS-4175 © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public 95
Handling Services Sharing Resources
• Deleting last L2VPN does delete Loopback interface configuration

CDB
Service Instances Device Changes NSO only deletes those
elements whose reference
count is 1

L2 VPN a2
xconnect a2
Refcount=1
Backpointer=l2vpn[name='a2'] NSO deletes shared element
Operator as well
deletes last loopback 1
service instance Refcount=1
Backpointer=l2vpn[name='a2']

TECNMS-4175 © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public 96
Reactive FASTMAP
Example: Virtual Network Function (VNF)
1. Service Request arrives Service Order Request

2. Service instance is created, but it 1


requires VM resources first 5
Service Model

3. Device Manager instruct VM Manager to


spins up VMs 2 4
Device Model
4. Once VM is ready a service trigger
application invokes service again 6 6 6
3

5. Service redeploy is issued VNF Infrastructure VM Manager

6. Now devices can be configured

TECNMS-4175 © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public 97
Northbound API
and Integration
options
Northbound APIs

• Human interaction:
• NSO CLI
Network
• WebUI OSS/BSS
Engineer
EMS/NMS

• Automation integration:
• NETCONF NSO NETCONF REST CLI WebUI SNMP

• REST/RESTCONF Service Service Templates


Models Manager
• JSON/RPC Mapping Logic
Device Device
Manager FASTMAP
Monitoring:
Models
• CDB
NED NED NED
• SNMP
• NETCONF

TECNMS-4175 © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public 99
Human Interaction
Cisco NSO CLI Overview

• Single point of configuration


• Usability characteristics : Auto-completion and syntax help
• Two CLI modes : Operational mode and Configuration mode

admin@ncs# ?
Possible completions:
alarms - Alarm management
autowizard - Automatically query for mandatory elements
cd - Change working directory
clear - Clear parameter
cluster - Cluster configuration
compare - Compare running configuration to another configuration or a file
complete-on-space - Enable/disable completion on space
compliance - Compliance reporting
config - Manipulate software configuration information
describe - Display transparent command information
devices - The managed devices and device communication settings
display-level - Configure show command display level
...

TECNMS-4175 © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public 100
Human Interaction
Cisco NSO CLI for Configuration
Cisco Style Juniper Style
admin@nso# admin@nso> configure
admin@nso# config Entering configuration mode
admin@nso(config)# private [ok][2016-01-27 11:14:12]
admin@nso(config)# devices device PE11
... [edit]
admin@nso(config-device-PE11)# top admin@nso% set devices device PE11
admin@nso(config)# exit | commit | abort ... admin@nso% exit | commit | revert
admin@nso# [ok][2016-01-27 11:15:44]
admin@nso# show running-config admin@nso> show configuration
cluster authgroup default cluster {
default-map same-user authgroup default {
default-map same-pass default-map {
umap admin same-user;
same-user same-pass;
... }
...

switch cli

• Two modes: operational and configuration


• Two CLI styles: Cisco and Juniper (use the switch cli command to switch
between them)

TECNMS-4175 © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public 101
Human Interaction
Graphical User Interface

TECNMS-4175 © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public 102
NSO Automation Integration
Cisco NSO NETCONF API

• Use cases:
• Integration with other OSS/NMS systems Any NETCONF client

• Task automation using scripts


• Bulk data import or export SSH (default)
Plain TCP
NETCONF 1.0
NETCONF Server NETCONF 1.1
• NSO provides a NETCONF client: W3C XPath 1.0

• netconf-console: client application in Python CDB


• Any NETCONF client can be used

TECNMS-4175 © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public 103
NSO Automation Integration
Cisco NSO Web Integration

• Use cases:
Integration with
• Integrate with existing EMS / NMS systems existing WebUI

• Integrate with existing web-based management portals EMS / NMS / Web Portal

Web Server
• APIs: JavaScript
REST API
(JSON/RPC)
• JSON RPC for more complex integration requiring maintenance of Data
session state JSON XML Format
MAAPI
• REST/RESTCONF for simple single transactions
CDB

REST example using curl and a GET request:


curl -u admin:admin http://localhost:8080/api/running/devices/device/PE13/config/router?deep&select=bgp;ospf

TECNMS-4175 © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public 104
NSO Automation Integration
Cisco NSO REST API Example

cisco@nso:~$ curl -u admin:admin


http://localhost:8080/api/running/devices/device/PE11/config/ios:router/bgp?deep
<collection xmlns:y="http://tail-f.com/ns/rest">
<bgp>
<as-no>1</as-no> Use prefixes where Use deep to display
<bgp>
<bestpath> needed all child elements
</bestpath>
<log-neighbor-changes/>
<nexthop> HTTP methods:
</nexthop>
</bgp> ▪ GET to retrieve resources
<distance> ▪ PUT to replace resources
</distance>
<neighbor> ▪ POST to create resources
<id>10.0.0.101</id>
</neighbor>
▪ DELETE to delete resources
...

• XML encoded data received or sent by default NSO is moving


• JSON can be used instead of XML if desired towards
RESTCONF
TECNMS-4175 © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public 105
Package Manager
Package Manager

• Loads and manages packages


• All additions to core NSO functionality are deployed as packages:
• Simplifies deployment
• Enables Hot-deploy/redeploy/upgrade

• Primary package types:


• Services NSO NETCONF REST CLI WebUI SNMP JAVA/JavaScript

• Device NED’s Service Templates Package Script API


Service Manager
Models Manager
Mapping Logic Core Alarm Developer
Engine Manager API
Device Device
CDB Notification
Models Manager FASTMAP Receiver ...
Network Element Driver (NED) NED NED NED

TECNMS-4175 © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public 107
Package Structure

packages Central repository of all packages

• Dedicated directory per package mypkg Package directory

• Package’s configuration schema defined package-meta-data.xml


Defines package
components to load
as YANG model src Package sources
./mypkg/src/yang/mypkg.yang
Makefile Defines components to compile
• Device configuration
yang YANG model
./mypkg/templates/mypkg.xml
java Java code (optional)
• Java or Python code to augment the
default functionality templates XML templates (for mapping)
./mypkg/src/java/src/com/acme/mypkg/mypkg.java
python Python code (optional)

TECNMS-4175 © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public 108
Package Management

• Create package skeleton: ncs-make-package


• Simplifies initial package creation by creating a skeleton directory and file structure

• Develop package:
• Use a text editor or an appropriate IDE to develop the package by modifying and creating the necessary files
(YANG, Java, Python, XML templates)

• Compile packages: make


• Includes syntax and semantic verification of package definitions
• Reads the Makefile to determine the components to compile
• Reload packages: packages reload (in NSO CLI)
• Activates new packages or upgrades existing packages
• Reads the package-meta-data.xml file to determine which components to load

TECNMS-4175 © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public 109
Create a Package Skeleton

• Use ncs-make-package to create a development starting point from a package


template (i.e. skeleton)
• Available package templates:
• Service skeleton: template based (XML), java or python based
• NED package
• Data provider package

• Options:
• Specify a destination directory
• Etc.

TECNMS-4175 © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public 110
Compile Packages

root@nso:/var/opt/ncs/packages$ cd cisco-ios/src
root@nso:/var/opt/ncs/packages/cisco-ios/src$ make
cd java && ant -q all
BUILD SUCCESSFUL
Total time: 0 seconds
cd ../netsim && make all
make[1]: Entering directory
`/var/opt/ncs/packages/cisco-ios/netsim' make[1]:
Nothing to be done for `all'.
make[1]: Leaving directory `/var/opt/ncs/packages/cisco-ios/netsim‘

root@nso:/var/opt/ncs/packages/cisco-ios/src$

• Compile packages to ensure they are compiled by the correct version of the
compiler
• You may also do make clean and then make to perform a complete recompile of the
package

TECNMS-4175 © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public 111
Reload Packages

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.
reload-result {
package cisco-ios
result true
}
reload-result {
package cisco-iosxr
result true
}

admin@ncs#

• Depending on the number of packages it may take some time for the
package upgrade process to complete
• It may take even longer in case a package upgrade is performed in a live
system with multiple service packages with many service instances

TECNMS-4175 © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public 112
Verifying Packages

admin@ncs# show packages package package-version


PACKAGE
NAME VERSION
----------------------
cisco-ios 4.0.4
cisco-iosxr 4.1

admin@ncs#

• Check if all the required packages are loaded using the show packages
command

TECNMS-4175 © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public 113
Network Element Drivers
NETCONF REST CLI SNMP
• Used to communicate southbound NSO
Service Templates
Service
Models Manager
• Model driven: Mapping Logic
Device Device
FASTMAP
• YANG device models Models Manager CDB

Deployed as NSO packages


NETCONF CLI SNMP Generic
• NED NED NED NED

• NED types: REST


NETCONF CLI
• NETCONF NED: YANG model over SSH over SNMP SOAP
SSH WS
• CLI NED: YANG model etc.

+ YANG extensions to map CLI and YANG


+ Java code for SSH communication
• SNMP NED: YANG model
• Generic NED: YANG model
+ framework for an arbitrary NED implementation

TECNMS-4175 © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public 114
Service Package
Creating a Service Package

1. Create a package skeleton


2. Use the Cisco NSO CLI to configure a sample service
3. Create the service template 1.
Create a Service Skeleton

Create the service model in YANG


Service Template Service Model
4. Skeleton File (XML) Skeleton File (YANG)

Configure Sample Service


5. Compile and deploy the package using Cisco NSO CLI

Create Service Template


(XML)

Create Service Model


(YANG)

Service Template Service Model


(XML) (YANG)

Create Service Model


(YANG)

TECNMS-4175 © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public 116
Step 1: Create a Package Skeleton
cisco@nso:~/nso-run$ cd packages/
cisco@nso:~/nso-run/packages$ ncs-make-package –-help
Usage: ncs-make-package [options] package-name

ncs-make-package --netconf-ned DIR package-name


ncs-make-package --snmp-ned DIR package-name
ncs-make-package --data-provider-skeleton package-name
ncs-make-package --generic-ned-skeleton package-name
ncs-make-package --erlang-skeleton package-name
ncs-make-package --service-skeleton TYPE package-name

where TYPE is one of:


java Java based service
java-and-template Java service with template
python Python based service
python-and-template Python service with template
template Template service (no code)

ADDITIONAL OPTIONS
--dest DIR
--build
--verbose
-h | --help

• Service Skeleton Types:


• Customize service skeleton depending on requirements (only template, python code…)

TECNMS-4175 © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public 117
Step 2: Check the YANG File
cisco@nso:~/nso-run/packages$ ncs-make-package --service-skeleton template
loopbackbasic
cisco@nso:~/nso-run/packages$ cd loopbackbasic/
cisco@nso:~/nso-run/packages/loopbackbasic$ ls -al
total 24
drwxrwxr-x 5 cisco cisco 4096 Nov 15 06:48 .
drwxrwxr-x 3 cisco cisco 4096 Nov 15 06:48 ..
-rw-rw-r-- 1 cisco cisco 380 Nov 15 06:48 package-meta-data.xml
drwxr-xr-x 3 cisco cisco 4096 Nov 15 06:48 src
Create a package
drwxr-xr-x 2 cisco cisco 4096 Nov 15 06:48 templates
drwxr-xr-x 3 cisco cisco 4096 Oct 25 08:09 test
cisco@nso:~/nso-run/packages/loopbackbasic$ cd src/
cisco@nso:~/nso-run/packages/loopbackbasic/src$ ls -al
total 16
drwxr-xr-x 3 cisco cisco 4096 Nov 15 06:48 .
drwxrwxr-x 5 cisco cisco 4096 Nov 15 06:48 ..
-rw-rw-r-- 1 cisco cisco 722 Nov 15 06:48 Makefile
drwxr-xr-x 2 cisco cisco 4096 Nov 15 06:48 yang
cisco@nso:~/nso-run/packages/loopbackbasic/src$ cd yang/
cisco@nso:~/nso-run/packages/loopbackbasic/src/yang$ ls -al
total total 12
drwxr-xr-x 2 cisco cisco 4096 Nov 15 06:48 .
drwxr-xr-x 3 cisco cisco 4096 Nov 15 06:48 ..
Edit service model
-rw-rw-r-- 1 cisco cisco 597 Nov 15 06:48 loopbackbasic.yang
cisco@nso:~/nso-run/packages/loopback/src/yang$ vi loopbackbasic.yang

• Preferably use an IDE for YANG which has syntax highlighting and YANG validation
capability (e.g. Eclipse, Visual Studio Code)

TECNMS-4175 © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public 118
Step 3: Check the Template XML File

cisco@nso:~/nso-run/packages/loopbackbasic/src/yang$ cd ..
cisco@nso:~/nso-run/packages/loopbackbasic/src$ cd ..
cisco@nso:~/nso-run/packages/loopbackbasic$ cd templates/
cisco@nso:~/nso-run/packages/loopbackbasic/templates$ ls -al
total 12
drwxr-xr-x 2 cisco cisco 4096 Nov 15 06:48 .
drwxrwxr-x 5 cisco cisco 4096 Nov 15 06:48 ..
-rw-rw-r-- 1 cisco cisco 739 Nov 15 06:48 loopbackbasic-template.xml
cisco@nso:~/nso-run/packages/loopbackbasic/templates$ vi loopbackbasic-template.xml

Edit device template

• The template maps to actual device configurations


• Contains mapping for each device type used to implement the service

TECNMS-4175 © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public 119
Things to Learn?

• How to build the device templates


• How to design a YANG service model
• Use the "top-down" or "bottom-up" approach, depending on the design
environment

Top down: Bottom up:


1. Build the YANG service model based on service 1. Manually configure the new service using the Cisco
description and parameters NSO CLI
2. Manually configure the new service using the Cisco 2. Export the configuration into XML format
NSO CLI 3. Replace exact values with variables →XML service
3. Export the configuration into XML format template
4. Replace exact values with variables → XML service 4. Build the YANG service model around the created
template template(s)

TECNMS-4175 © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public 120
Simple Example – Loopback Service

Cisco IOS Example Cisco IOS XR Example Juniper Junos Example


interface Loopback0 interface Loopback0 lo0 {
ip address 1.1.1.1 255.255.255.255 ipv4 address 2.2.2.2 255.255.255.255 unit 0 {
! ! family inet {
address 3.3.3.3/32;
}
}
}
• Service requirements:
• Configure loopback interfaces:
• IP address
• Subnet mask
• Platforms: Cisco IOS, Cisco IOS XR, Juniper Junos

• Note: This example is used throughout the remainder of this lesson to illustrate how to create a simple template-
based service model.

TECNMS-4175 © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public 121
Informal Service Model Defining Service
Parameters

Loopback
IP Address
Device Subnet Mask
IP Address
Subnet Mask
IP Address
Subnet Mask
/device
/device/loopback-number
/device/loopback-number/ip-address
/device/loopback-number/mask

TECNMS-4175 © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public 122
Creating a Service Package

1. Create a package skeleton


2. Use the Cisco NSO CLI to configure a sample service
3. Create the service template Create a Service Skeleton

Create the service model in YANG


Service Template Service Model
4. Skeleton File (XML) Skeleton File (YANG)

Configure Sample Service


Compile and deploy the package
2.
5. using Cisco NSO CLI

Create Service Template


(XML)

Create Service Model


(YANG)

Service Template Service Model


(XML) (YANG)

Create Service Model


(YANG)

TECNMS-4175 © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public 123
Example: Configure a Loopback Interface

admin@ncs(config)# devices device ios0 config ios:interface Loopback 0 ip address 1.1.1.1 255.255.255.255
admin@ncs(config)# top
admin@ncs(config)# devices device iosxr0 config cisco-ios-xr:interface Loopback 0 ipv4 address 2.2.2.2 255.255.255.255
admin@ncs(config)# top
admin@ncs(config)# devices device junos0 config junos:configuration interfaces interface lo0 unit 0 family inet address 3.3.3.3/32

• Notice that the NEDs for Cisco IOS, Cisco IOS XR, and Juniper Junos expose slightly
different syntax due to different device CLIs
• Central point of management prepends another layer to the configuration hierarchy:
devices
• Repeat the service configuration step for each type of device in your environment

TECNMS-4175 © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public 124
Example: Check Candidate Configuration
admin@ncs% commit dry-run
cli {
local-node {
data devices {
device ios0 {
config {
ios:interface {
Loopback 0 {
ip {
address {
• Display candidate configuration +
+
primary {
address 1.1.1.1;
mask 255.255.255.255;
changes }
}
}

}
}
• “+” indicates configuration items that }
}
device iosxr0 {

will be written to CDB


config {
cisco-ios-xr:interface {
Loopback 0 {
ipv4 {
address {
“-” indicates configuration items that
+ ip 2.2.2.2;
• +
}
mask 255.255.255.255;

will be deleted from CDB


}
}
}
}
}
device junos0 {
config {
junos:configuration {
interfaces {
interface lo0 {
unit 0 {
family {
inet {
+ address 3.3.3.3/32;
}
}
}
}
}
}
}
}
}
}
}

TECNMS-4175 © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public 125
Example: Check Native Configuration

• Up-to three configuration verification stages:


• Cisco NSO validation
• Device validation before configuration activation
• Device validation at configuration activation time

• Any one of the verification stages failing will result in all changes being
reverted on all devices that were part of the same transaction

TECNMS-4175 © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public 126
Example: Check Native Configuration Cont.
admin@ncs% commit dry-run outformat native
native { device {
device { name junos0
name ios0 data <rpc xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"
data interface Loopback0 message-id="1">
ip address 1.1.1.1 255.255.255.255 <edit-config xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0">
exit <target>
} <candidate/>
device { </target>
name iosxr0 <test-option>test-then-set</test-option>
data interface Loopback 0 <error-option>rollback-on-error</error-option>
ipv4 address 2.2.2.2 <config>
255.255.255.255 <configuration xmlns="http://xml.juniper.net/xnm/1.1/xnm">
exit <interfaces>
} <interface>
<name>lo0</name>
<unit>
<name>0</name>
<family>
<inet>
<address>
<name>3.3.3.3/32</name>
</address>
</inet>
</family>
</unit>
</interface>
</interfaces>
</configuration>
</config>
</edit-config>
</rpc>
}
}

TECNMS-4175 © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public 127
Example: Check XML Configuration
• Display changes in XML format as a starting point for the service template
admin@ncs% commit dry-run outformat xml <device>
result-xml { <name>junos0</name>
local-node { <config>
data <devices xmlns="http://tail-f.com/ns/ncs"> <configuration xmlns="http://xml.juniper.net/xnm/1.1/xnm">
<device> <interfaces>
<name>ios0</name> <interface>
<config> <name>lo0</name>
<interface xmlns="urn:ios"> <unit>
<Loopback> <name>0</name>
<family>
<name>0</name>
<ip> Device Types → <inet>
<address>
<address>
<primary> Different NEDs → Different <name>3.3.3.3/32</name>
</address>
<address>1.1.1.1</address>
<mask>255.255.255.255</mask> XML namespaces </inet>
</family>
</primary> </unit>
</address> </interface>
</ip> </interfaces>
</Loopback> </configuration>
</interface> </config>
</config> </device>
</device> </devices>
<device> }
<name>iosxr0</name> }
<config>
<interface xmlns="http://tail-f.com/ned/cisco-ios-xr">
<Loopback>
<id>0</id>
<ipv4>
<address>
<ip>2.2.2.2</ip>
<mask>255.255.255.255</mask>
</address>
</ipv4>
</Loopback>
</interface>
</config>
</device>

• If looking at existing configuration after it has already been committed:


show devices device iosxr0 config cisco-ios-xr:interface Loopback | display xml

TECNMS-4175 © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public 128
Creating a Service Package

1. Create a package skeleton


2. Use the Cisco NSO CLI to configure a sample service
3. Create the service template Create a Service Skeleton

Create the service model in YANG


Service Template Service Model
4. Skeleton File (XML) Skeleton File (YANG)

Configure Sample Service


5. Compile and deploy the package using Cisco NSO CLI

Create Service Template


3. (XML)

Create Service Model


(YANG)

Service Template Service Model


(XML) (YANG)

Create Service Model


(YANG)

TECNMS-4175 © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public 129
Creating the Service Template

cisco@nso:~/ncs-run$ cd packages/
cisco@nso:~/ncs-run/packages$ cd loopbackbasic
cisco@nso:~/ncs-run/packages/loopbackbasic$ cd templates 1. Edit the skeleton XML service
cisco@nso:~/ncs-run/packages/loopbackbasic/templates$ ls -l
total 4 template file
-rw-rw-r-- 1 cisco cisco 739 Nov 15 06:48 loopbackbasic-
template.xml
cisco@nso:~/ncs-run/packages/loopbackbasic/templates$ more loopbackbasic-
template.xml
2. Define variables in curly
<config-template xmlns="http://tail-f.com/ns/config/1.0"
servicepoint="loopbackbasic"> brackets: {variable}
<devices xmlns="http://tail-f.com/ns/ncs">
<device>
<!--
Select the devices from some data structure in the service
model. In this skeleton the devices are specified in a leaf-list.
3. Variables are mapped to the
-->
Select all devices in that leaf-list:
service model:
<name>{/device}</name>
<config>
<!--
Add device-specific parameters here. 4. Use the path based on the
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>
informal service model
-->
</config>
</device>
hierarchy
</devices>
</config-template>
cisco@nso:~/ncs-run/packages/loopback/templates$ vi loopbackbasic-template.xml

TECNMS-4175 © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public 130
Example: Convert XML Configuration to Template

• IOS:
admin@ncs% commit dry-run outformat xml <config-template xmlns="http://tail-f.com/ns/config/1.0"
result-xml { servicepoint="loopbackbasic">
local-node { <devices xmlns="http://tail-f.com/ns/ncs">
data <devices xmlns="http://tail-f.com/ns/ncs"> <device>
<device> <name>{/device}</name>
<name>ios0</name> <config>
<config>
<interface xmlns="urn:ios"> Variable <interface xmlns="urn:ios">
<Loopback> <Loopback>
<name>0</name> <name>{/loopback-number}</name>
<ip> <ip>
<address> Variable <address>
<primary> <primary>
<address>1.1.1.1</address> <address>{/ip-address}</address>
<mask>255.255.255.255</mask> <mask>255.255.255.255</mask>
</primary> Fixed </primary>
</address> </address>
</ip> </ip>
</Loopback> </Loopback>
</interface> </interface>
</config>
</device>

TECNMS-4175 © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public 131
Example: Convert XML Configuration to Template

• IOS XR:

<device>
<name>iosxr0</name>
<config>
<interface xmlns="http://tail-f.com/ned/cisco-ios-xr"> <interface xmlns="http://tail-f.com/ned/cisco-ios-xr">
<Loopback> Variable <Loopback>
<id>0</id> <id>{/loopback-number}</id>
<ipv4> <ipv4>
<address> Variable <address>
<ip>2.2.2.2</ip> <ip>{/ip-address}</ip>
<mask>255.255.255.255</mask> <mask>255.255.255.255</mask>
</address> Fixed </address>
</ipv4> </ipv4>
</Loopback> </Loopback>
</interface> </interface>
</config>
</device>

TECNMS-4175 © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public 132
Example: Convert XML Configuration to Template

• JUNOS:
<device>
<name>junos0</name>
<config>
<configuration xmlns="http://xml.juniper.net/xnm/1.1/xnm"> <configuration xmlns="http://xml.juniper.net/xnm/1.1/xnm">
<interfaces> <interfaces>
<interface> <interface>
<name>lo0</name> <name>lo{/loopback-number}</name>
<unit> Variable <unit tags="replace">
<name>0</name> <name>0</name>
<family> <family>
<inet> <inet>
<address> Variable <address>
<name>3.3.3.3/32</name> <name>{/ip-address}/32</name>
</address> </address>
</inet> Fixed </inet>
</family> </family>
</unit> </unit>
</interface> </interface>
</interfaces> </interfaces>
</configuration> </configuration>
</config>
</device> </config>
</devices> </device>
</devices>
</config-template>

TECNMS-4175 © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public 133
Template Options (Cont.)

• The template usage can be modified if desired:


• default XPath context: by default XPath root is set to the root of service instance data – it can be changed to
another context to simplify work
• conditional statements: Sometimes it is necessary to control which parts of a template that should be
evaluated. The when attribute makes it possible to set a conditional statement that controls if the sub-tree
should be evaluated or not
• loop statements: Sometimes statements in a sub-tree needs to be applied several times. The attribute for
each can be used to accomplish this iteration

TECNMS-4175 © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public 134
Creating a Service Package

1. Create a package skeleton


2. Use the Cisco NSO CLI to configure a sample service
3. Create the service template Create a Service Skeleton

Create the service model in YANG


Service Template Service Model
4. Skeleton File (XML) Skeleton File (YANG)

Configure Sample Service


5. Compile and deploy the package using Cisco NSO CLI

Create Service Template


(XML)

Create Service Model


(YANG) 4.
Service Template Service Model
(XML) (YANG)

Create Service Model


(YANG)

TECNMS-4175 © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public 135
Step 1: Creating the Service Model:
Start with Skeleton Model

namespace "http://com/example/loopbackbasic";
prefix loopbackbasic; 1. Change directory to ../src/yang
import ietf-inet-types { prefix inet; }
import tailf-ncs { prefix ncs; }
augment /ncs:services {
list loopbackbasic
2. Edit the skeleton service model
{ key name;
uses ncs:service-data;
ncs:servicepoint
3. The module augments the Cisco NSO
services module
"loopbackbasic";
leaf name {
type string;
}
// may replace this with other ways of refering to the devices.
leaf-list device {
4. Devices are already references
type leafref {
path "/ncs:devices/ncs:device/ncs:name";
}
}
5. Replace the dummy leaf with your
// replace with your own stuff here
leaf dummy {
type inet:ipv4-address;
service model
} Replace this section with
}
}
} your service model.

TECNMS-4175 © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public 136
Step 2: Creating the Service Model:
Informal Service Model

1. Reuse existing resources (e.g.


devices)
Augment the services module
C devices
2.
L device

ios0
iosxr0
junos0

C services

L loopbackbasic

K name U loopback-number U ip-address R device

tpl1 0 1.1.1.1 ios0


tpl2 0 2.2.2.2 iosxr0
tpl3 0 3.3.3.3 junos0

TECNMS-4175 © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public 137
Step 2: Creating the Service Model:
Top Level List

L loopbackbasic • Add your data model to the skeleton


K name U loopback-number U ip-address R device based on the informal design you
tpl1 0 1.1.1.1 ios0
have created earlier:
tpl2 0 2.2.2.2 iosxr0
tpl3 0 3.3.3.3 junos0 • Leaf name is used as key for the list
of services
module loopback {
namespace "http://com/example/loopback";
prefix loopback;
• Leafs device, loopback-number and
import ietf-inet-types { prefix inet; } ip-address are leafs identifying the
loopback interface parameters
import tailf-ncs { prefix ncs; }
import tailf-common { prefix tailf; }
augment /ncs:services {
list loopbackbasic {
leaf name { ... }
leaf device { ... }
leaf loopback-number { ... }
leaf ip-address { ... }
}
}
}

TECNMS-4175 © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public 138
Step 3: Creating the Service Model:
Service Instance ID

L loopbackbasic • Tell NSO that this is a service


The custom name for the service is
K name U loopback-number U ip-address R device

tpl1
tpl2
0
0
1.1.1.1
2.2.2.2
ios0
iosxr0
used as unique identifier in the list
tpl3 0 3.3.3.3 junos0
• Optionally use the NSO-specific
annotations to provide textual
...
list loopbackbasic { description used in NSO CLI and
WebUI
key name;

uses ncs:service-data;
ncs:servicepoint
"loopbackbasic";
• One implicit requirement: name is
mandatory as it is the key
leaf name {
tailf:info "Service Instance Name";
type string;
}
...

TECNMS-4175 © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public 139
Step 3: Creating the Service Model:
Implement Service Model

L loopbackbasic

Keep the default reference to the


K name U loopback-number U ip-address R device

tpl1
tpl2
0
0
1.1.1.1
2.2.2.2
ios0
iosxr0
live list of devices
tpl3 0 3.3.3.3 junos0
• One requirement: device is
mandatory
...
list loopbackbasic {
...
leaf device {
tailf:info "Router name";
mandatory true;
type leafref {
path "/ncs:devices/ncs:device/ncs:name";
}
}
...

TECNMS-4175 © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public 140
Step 3: Creating the Service Model:
Implement Service Model (Cont.)

L loopbackbasic

One requirement: loopback interface


K name U loopback-number U ip-address R device

tpl1
tpl2
0
0
1.1.1.1
2.2.2.2
ios0
iosxr0
number is mandatory
tpl3 0 3.3.3.3 junos0

...
list loopbackbasic {
...
leaf loopback-number {
tailf:info "Loopback Interface Number";
mandatory true;
type uint32;
}
...

TECNMS-4175 © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public 141
Step 3: Creating the Service Model:
Implement Service Model (Cont.)

L loopbackbasic • The inet:ipv4-address data type limits


K name U loopback-number U ip-address R device the value to a properly formatted IPv4
tpl1 0 1.1.1.1 ios0
address
tpl2 0 2.2.2.2 iosxr0
tpl3 0 3.3.3.3 junos0 • One requirement: ip-address is
mandatory
...
list loopbackbasic {
...
leaf ip-address {
tailf:info "Valid IP";
mandatory true;
type inet:ipv4-address;
}
...

TECNMS-4175 © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public 142
Regular Expressions – Quick Overview

Matching a single character


. dot matches any single character
[a-zA-Z0-9] matches a single character from a range of characters
Quantifiers
char* The preceeding character appears zero or more times
char+ The preceeding character appears one or more times
char? The preceeding character appears zero or one time
char{n} The preceeding character appears exactly n times
char{n,} The preceeding character appears at least n times
char{n,m} The preceeding character appears at least n and no more than m times
Grouping
(abc)* The preceeding group of characters appears zero or more times
Logical operators
(abc)|(cde) Matches at least one of the expressions on left or right of the OR operator
[^a-zA-Z0-9] Matches a single character NOT from the specified range of characters
Escape character to match any character that has a special meaning in regular expressions: .?+*(){}[]\|
\. Matches the dot character
\\ Matches the backslash
Multiple character escape sequences: \w \W \s \S \d \D
\d Matches any decimal number; equals [0-9]+
\w Matches a contiguous sequence of alphanumeric characters; equals [a-zA-Z]+

TECNMS-4175 © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public 143
Regular Expressions - Example

• Goal: match valid IP addresses in the range from 10.100.0.0 to 10.199.255.255


valid not in range not valid IP not valid IP
10.100.1.1 10.200.1.1 1001.100.1.1 10.100.1.500 ✓ = match
 = no match
• Which of the above addresses will be matched by the following regular expressions

10.\d+.\d+.\d+ 10.100.1.1 ✓ 10.200.1.1 ✓ 1001.100.1.1 ✓ 10.100.1.500 ✓


10\.\d+\.\d+\.\d+ 10.100.1.1 ✓ 10.200.1.1 ✓ 1001.100.1.1  10.100.1.500

10\.1[0-9][0-9]\.[0-9]+\.[0-9]+ 10.100.1.1 ✓ 10.200.1.1  1001.100.1.1  10.100.1.500 ✓

• Do not reinvent the wheel - reuse ietf-yang-types and ietf-inet-types modules


where a number of useful data types are already defined
(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5]) ipv4-address
data type
and
10\.1[0-9][0-9]\.[0-9]+\.[0-9]+ 10.100.1.1 ✓ 10.200.1.1  1001.100.1.1  10.100.1.500

TECNMS-4175 © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public 144
Step 4: Creating the Service Model:
Final Service Model

module loopbackbasic { leaf device {


namespace tailf:info
"http://com/example/loopbackbasic"; "Router name";
mandatory true;
prefix loopbackbasic; type leafref {
path "/ncs:devices/ncs:device/ncs:name";
import ietf-inet-types { prefix inet; } }
import tailf-ncs { prefix ncs; } }
import tailf-common { prefix tailf; } leaf loopback-number {
tailf:info "Loopback Interface Number";
augment /ncs:services { mandatory true;
type uint32;
list loopbackbasic { }
key name; leaf ip-address {
tailf:info "Valid IP";
uses ncs:service-data; mandatory true;
ncs:servicepoint } type inet:ipv4-address;
"loopbackbasic"; }
}
leaf name {
tailf:info "Service Instance Name";
mandatory true;
type string;
}
...

• Parameter hierarchy, data types, restrictions, NSO-specific annotations (e.g.


descriptions used by the Cisco NSO GUI and CLI)

TECNMS-4175 © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public 145
Creating a Service Package

1. Create a package skeleton


2. Use the Cisco NSO CLI to configure a sample service
3. Create the service template Create a Service Skeleton

Create the service model in YANG


Service Template Service Model
4. Skeleton File (XML) Skeleton File (YANG)

Configure Sample Service


5. Compile and deploy the package using Cisco NSO CLI

Create Service Template


(XML)

Create Service Model


(YANG)

Service Template Service Model


(XML) (YANG)

Create Service Model


(YANG) 5.

TECNMS-4175 © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public 146
Compile and Deploy the Service Model
cisco@nso:~/ncs-run/packages/loopbackbasic/src/yang$ cd ..
cisco@nso:~/ncs-run/packages/loopbackbasic/src$ make
mkdir -p ../load-dir
/Users/rereich/NCS_Builds/./nso-4.5.2/bin/ncsc `ls loopbackbasic-ann.yang > /dev/null 2>&1 && echo "-a loopbackbasic-ann.yang"` \
-c -o ../load-dir/loopbackbasic.fxs yang/loopbackbasic.yang
cisco@nso:~/ncs-run/packages/loopbackbasic/src$

admin@ncs% request 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.

• Compile the changes on the server


• Request the reload of packages in the Cisco NSO CLI

TECNMS-4175 © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public 147
Parameter Restrictions Enforced Already in GUI
and CLI
YANG data types and
constraints are validated

admin@nso(config)# services loopbackbasic test device ios0 loopback-number 1 ip-address 260.


--------------------------------------------------------------------------------------^
syntax error: "260." is not a valid value.

admin@nso(config)# services loopbackbasic test device ios0 loopback-number 1 ip-address 1.1.1.1


admin@ncs(config-loopbackbasic-test)# top
admin@nso(config)# commit
Commit complete.
admin@nso(config)# exit
admin@nso# show running-config services loopbackbasic
test
services loopbackbasic test
device ios0
loopback-number 1
ip-address 1.1.1.1
!

• First configuration validation stage

TECNMS-4175 © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public 148
KP

LAB Exercise 2
Q&A
Summary

• Network Automation Challenges


• NSO Architecture
• Device Manager
• YANG data modeling
• NSO Service Manager
• NSO Package Manager
• Design a service with NSO

TECNMS-4175 © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public 151
TUE WED THU
BRKOPS-2700
Opening Keynote NSO Access Control
09:00
08:30
BRKOPS-3339
NSO Reconciliation
BRKOPS-2695 11:00 BRKOPS-2418 11:00
NSO Use Cases & Migration to BRKOPS-2383 11:15
Features Segment Routing NSO LSA
100K+ devices
BRKNMS-2733 12:15
NSO&Ansible with BRKOPS-1456
Business Process Orch 14:45
Camunda Workflow
Automation Platform

Guest Keynote
17:00

Cisco Live Celebration

Automation &
18:30
OPS
Orchestration with Operations Track
Cisco NSO
TECNMS-4175 © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public 152
Continue Your Education

• Related sessions
• The 3 Stages of Network Automation and Orchestration - PSOSPG-2941
• Automated NSO Delivery with CI/CD - LTRNMS-2984

• DevNet
• Quick Wins of using NSO - DEVLIT-4019
• Get Started Automating Your Network with Cisco NSO - DEVNET-4805

• Lab
• Introduction to Cisco Network Service Orchestrator (NSO) - LABNMS-2011
• Real-time Services Automation with NSO and Model-Driven Telemetry - LABOPS-2320

TECNMS-4175 © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public 153
Call to Action – We want you to…

• Check out DevNet’s Learning Labs on NSO https://learninglabs.cisco.com/


• DevNet NSO page (download for free) https://developer.cisco.com/site/nso/
• Become NSO Developer Hub member :
https://communities.cisco.com/community/developer/nso-developer-hub
• Have NSO always with you: Play with a local-install on your laptop

© 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public
The bridge between Network
Automation and Business

TECNMS-4175 © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public 155
Complete your
online session
survey • Please complete your session survey
after each session. Your feedback
is very important.
• Complete a minimum of 4 session
surveys and the Overall Conference
survey (starting on Thursday) to
receive your Cisco Live t-shirt.
• All surveys can be taken in the Cisco Events
Mobile App or by logging in to the Content
Catalog on ciscolive.com/emea.

Cisco Live sessions will be available for viewing on


demand after the event at ciscolive.com.

TECNMS-4175 © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public 156
Continue your education

Demos in the
Walk-In Labs
Cisco Showcase

Meet the Engineer


Related sessions
1:1 meetings

TECNMS-4175 © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public 157
Thank you
Backup Slides
Network Automation
Challenges (extra)
NSO Architecture
(extra)
Automatic Service Package Upgrade

• Every package reload action triggers a service upgrade process


• Automatic service upgrade succeeds in the following cases:
• Deleted nodes: always succeeds; deletes nodes from data tree
• Added nodes: succeeds if not mandatory without default
• Re-ordered nodes: always succeeds
• Type changes: succeeds if smart type conversion succeeds or there is a default value
• Key changes: succeeds if modified key leaf is still unique
• Default values: always succeeds and changes values only to those leafs that had a default value

TECNMS-4175 © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public 163
Device Configuration Management
(extra)
Cloning a Device

• Devices can be instantiated from other devices


• These devices can be immediately configured
• All configuration succeeds within NSO and nothing is sent to devices
(southbound-locked state!)
• All device configuration is cloned!
admin@nso(config)# devices device PE12 instantiate-from-other-device device-name PE11
admin@nso(config)# devices device PE13 instantiate-from-other-device device-name PE11
admin@nso(config)# devices device PE12 address 10.1.1.12
admin@nso(config)# devices device PE13 address 10.1.1.13
admin@nso(config)# commit
Commit complete.

TECNMS-4175 © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public 165
Create a Device Using Templates

• Devices can be instantiated from templates


• These devices can be immediately configured
• All configuration succeeds due to southbound-locked state
• Only template specific configuration is applied
admin@nso(config)# devices device www5 apply-template template-name std-web-server
admin@nso(config)# devices device www5 address 127.0.0.1 port 23456 authgroup default
admin@nso(config)# commit

TECNMS-4175 © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public 166
Load Using “ncs_load“ Command

• A convenient way of loading and saving configuration


• ncs_load without any options it will print the current configuration
• Load (-l) option uploads XML contents to the CDB
• Merge (-m) option updates the existing device list
• Example of uploading and merging configurations of Netsim devices to
NSO:
admin@nso:~$ ncs-netsim ncs-xml-init > devices.xml
admin@nso:~$ ncs_load -l -m devices.xml

Make sure you use the -m option to merge the XML contents with
the CDB. The default action is replace which would delete the
entire CDB and replace it with the XML contents!

TECNMS-4175 © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public 167
Meta Configuration – Single Device

admin@nso(config)# devices device PE11


Highlighted parameters represent the
minimum required configuration for a device
Possible completions:
address - IP address or host name for the management interface
authgroup - Authentication credentials for the device
config - NCS copy of the device configuration
connect-timeout - Timeout in seconds for new connections
description - Free form textual description
device-type - Management protocol for the device
live-status-protocol - Additional protocols for the live-tree (read-only)
location - Physical location of devices in the group
netconf-notifications - NETCONF notifications from the device
port - Port for the management interface
read-timeout - Timeout in seconds used when reading data
remote-node - Name of remote node which connects to device
snmp-notification-address - Notification address if different from device address
source - How the device was added to NCS
state - Show states for the device
trace - Enable trace for this device
write-timeout - Timeout in seconds used when writing data

TECNMS-4175 © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public 168
Meta Configuration – All Devices

admin@nso(config)# devices global-settings

Possible completions:
commit-queue - Enables and configures the commit-queue
commit-retries - Retry commits on transient errors
connect-timeout - Timeout in seconds for new connections
ned-settings - Control which device capabilities ncs uses
out-of-sync-commit-behaviour - Specifies the behaviour of a commit operation involving a device that
is
out of sync with ncs.
read-timeout - Timeout in seconds used when reading data
report-multiple-errors - By default, when the ncs device manager commits data southbound and
when
there are errors, we only report the first error to the operator,
this flag makes ncs report all errors reported by managed devices
session-pool - Control how sessions to related devices can be
pooled. ssh-keep-alive - Controls SSH keep alive settings
trace - Trace the southbound communication to devices
trace-dir - The directory where trace files are stored
write-timeout - Timeout in seconds used when writing data

TECNMS-4175 © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public 169
Device Action – All Devices

admin@nso# devices ?

Possible completions:
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-queues - 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
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

TECNMS-4175 © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public 170
Introduction to YANG
(extra)
Service Manager
(extra)
Service Configuration Maintenance Tools

CDB
Check Sync Device 1 S1 S1
configuration
S1 Device 1
Service instance
configuration S2 Device 2
S2
configuration S2
Deep Check Sync
Device 2

admin@nso# service l3mplsvpn S1 check-sync


admin@nso# service l3mplsvpn S2 deep-check-sync

• Internal sync check between service configuration and device-specific


configuration as a result of the service-to-device mapping logic
• Extend sync check to the actual device configuration

TECNMS-4175 © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public 173
FastMap
(extra)
FASTMAP: Create a Service Instance

Undo
Service NSO stores the device level undo
Service Instance information (reverse-diff) for
Model
each service instance as a binary
• Create Database APIs object inside the service instance

Create
Model-to-
• Modify model mapping

• Delete Database APIs

Device
Models Device Changes

To
devices

TECNMS-4175 © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public 175
FASTMAP: Modify a Service Instance

Undo
Service Update the undo
Service Instance
Model information for the
Undo
Database APIs modified service instance

Create
Delete
Delete Create the
existing modified instance
instance
Database APIs
• Create

• Modify
Device
Models Device Changes

To • Delete
devices
Only send differences
to devices.

TECNMS-4175 © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public 176
FASTMAP: Service Modify (1)

CDB / Device

/services /devices

./l2vpn[name='ACME'] ./device[name='PE11'] PE11


./config interface GigabitEthernet0/5
./pw-id=122 xconnect 10.1.1.15 122 encapsulation mpls
./interface !
1 2 ./link[2] ./GigabitE[name='0/5']
./xconnect
./device='PE11' PE12
./interface='0/5' address='10.1.1.15'
interface GigabitEthernet0/9
./remote='10.1.1.15' vcid='122'
xconnect 10.1.1.11 122 encapsulation mpls
encapsulation='mpls'
!

Only diff sent to devices


FASTMAP: service mapping & diff
CLI NED may have additional
& update reverse diff
dependencies between configuration
options (e.g. single line)

TECNMS-4175 © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public 177
FASTMAP: Service Modify (2)

CDB / Device

/services /devices

./l2vpn[name='ACME'] ./device[name='PE11'] PE11


./config interface GigabitEthernet0/5
./pw-id=122 xconnect 10.1.1.12 122 encapsulation mpls
./interface !
1 2 ./link[2] ./GigabitE[name='0/5']
./xconnect
./device='PE11' PE12
./interface='0/5' address='10.1.1.12'
./remote='10.1.1.12' vcid='102'
encapsulation='mpls'

Diff sent only to affected device


FASTMAP: service mapping & diff
& update reverse diff

TECNMS-4175 © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public 178
Modify and Existing Service: Example 3

admin@nso# config
Entering configuration mode terminal
admin@ncs(config)# services l2vpn ACME
admin@ncs(config-l2vpn-ACME)# link Site1
admin@ncs(config-l2vpn-ACME)# intf 0/6
admin@ncs(config-link-PE12)# top
admin@ncs(config)# commit dry-run
device PE11

Only one parameter changed


config {
ios:interface { •
GigabitEthernet 0/5 {
xconnect {
-
-
address 10.1.1.12;
vcid 122; • CDB shows only minimal diff changes
- encapsulation mpls;
}
}
GigabitEthernet 0/6 {
xconnect {
+ address 10.1.1.12;
+ vcid 122;
+ encapsulation mpls;
}
}
}
}

TECNMS-4175 © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public 179
Modify and Existing Service: Example 3 (Cont.)

admin@nso# config
Entering configuration mode terminal • Changed parameter affects only one
admin@ncs(config)# services l2vpn ACME
admin@ncs(config-l2vpn-ACME)# link Site1 device
admin@ncs(config-l2vpn-ACME)# intf 0/6
admin@ncs(config-link-PE12)# top
admin@ncs(config)# commit dry-run outformat native • CLI NED may have additional
device PE11
interface GigabitEthernet0/5 dependencies between configuration
no xconnect 10.1.1.12 122 encapsulation mpls
exit
interface GigabitEthernet0/6
options (e.g. multiple parameters in a
xconnect 10.1.1.12 122 encapsulation mpls single line)
exit
exit

TECNMS-4175 © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public 180
FASTMAP: Service Modify (3)

CDB / Device

/services /devices

./l2vpn[name='ACME'] ./device[name='PE11'] PE11


./config interface GigabitEthernet0/5
./pw-id=102 no xconnect 10.1.1.12 102 encapsulation mpls
./interface !
1 2 ./link[2] interface GigabitEthernet0/6
./GigabitE[name='0/6'] xconnect 10.1.1.12 102 encapsulation mpls
./xconnect !
./device='PE11'
./interface='0/6' address='10.1.1.12'
./remote='10.1.1.12' vcid='102' PE12
encapsulation='mpls'

FASTMAP: service mapping & diff & Diff of parent requires


update reverse diff reconfiguration of all child nodes

TECNMS-4175 © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public 181
FASTMAP: Delete a Service Instance

Undo

Service Instance
Model

• Create Undo Database APIs

Delete
Apply the undo
• Modify configuration

Database APIs
• Delete
Device
Models Device Changes

To
devices

TECNMS-4175 © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public 182
FASTMAP: Service Delete

CDB / Device

/services /devices

./device[name='PE11'] PE11
./config interface GigabitEthernet0/6
no xconnect 10.1.1.12 122 encapsulation mpls
./interface !
./GigabitE[name='0/6']

PE12
interface GigabitEthernet0/9
no xconnect 10.1.1.11 122 encapsulation mpls
!

FASTMAP: reverse diff applied Reverse diff sent to devices

TECNMS-4175 © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public 183
Northbound API and Integration options
(extra)
Cisco NSO Server User Interfaces

root@NCS:/opt/ncs/ncs-4.1.1/# ls -l
total 368
Shell drwxr-xr-x 2 root root 4096 Jun 28 12:46 bin
SSH on port 22 -rw-r--r-- 1 root root 140956 Jun 28 12:47 CHANGES
drwxr-xr-x 4 ro ot root 4096 Jun 27 21:36 doc
CLI SSH on port 2024 admin@ncs# show ncs-state version3 ro
drwxr-xr-x ot root 4096 Jun 28 12:46 erlang
version 4.1.1; drwxr-xr-x 3 ro ot root 4096 Jun 28 12:45 etc
admin@ncs# drwxr-xr-x 10 ro ot root 4096 Jun 28 12:50 examples.ncs
WebUI drwxr-xr-x 2 root root 4096 Jun 28 12:46 include
Cisco NSO HTTP on port 8080
drwxr-xr-x 3 root root 4096 Jun 28 12:45 java
Server
drwxr-xr-x 5 root root 4096 Jun 28 12:48 lib
-rw-r--r-- 1 root root 128459 Jun 28 12:47 LICENSE
drwxr-xr-x 5 root root 4096 Jun 27 21:34 man
-rw-r--r-- 1 root root 541 Jul 4 14:10 ncsrc
-rw-r--r-- 1 root root 509 Jul 4 14:10 ncsrc.tcsh
drwxr-xr-x 3 root root 4096 Jul 4 14:10 netsim
drwxr-xr-x 17 root root 4096 Oct 28 10:40 packages
-rwxr--r-- 1 root root 17694 Jun 28 12:47 README
drwxr-xr-x 4 root root 4096 Jun 28 12:46 scripts
drwxr-xr-x 3 root root 4096 Jun 28 12:45 src
drwxr-xr-x 4 root root 4096 Jun 28 12:47 support
drwxr-xr-x 3 root root 4096 Jun 28 12:45 var
-rw-r--r-- 1 root root 220 Jun 28 12:47 VERSION

• The ncs.conf file contains the server configuration with default


management ports

TECNMS-4175 © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public 185
Cisco NSO REST API Example (Cont.)

cisco@nso:~$ curl -u admin:admin -H "Accept: application/vnd.yang.data+json"


http://localhost:8080/api/running/devices/device/PE11/config/ios:router/bgp?deep
{
"tailf-ned-cisco-ios:router": {
"bgp": [
{
"as-no": 1,
"address-family": {
"ipv4": [
Instruct NSO to reply Depth options:
{
"af": "unicast", using JSON for data - Default: 5 levels
"bgp-af": {
"bgp": {
"bestpath": {
encoding - "deep": all levels
},
"nexthop": { - "shallow": 2 levels
}
}
},
"neighbor": [
{
"id": "10.1.1.13",
"remote-as": "1",
"capability":
}, {
"translate-update": {
}
},
...

• JSON can be used instead of XML if desired

TECNMS-4175 © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public 186
Package Manager
(extra)
NETCONF NED

• Native NED for NSO NSO NETCONF REST CLI SNMP

Service Service Templates


• No coding required YANG
Models Manager
Mapping Logic
Device Device
Device
Only YANG device model required
Manager FASTMAP
• Model
Models CDB

NETCONF CLI SNMP Generic

• Can be used with any device NED NED NED NED

supporting NETCONF (e.g. by


incorporating ConfD) NETCONF
over SSH
XML
Config

TECNMS-4175 © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public 188
CLI NED

• YANG device model: NSO NETCONF REST CLI SNMP

Service Service Templates


Device config options Models Manager
Mapping Logic
Device Device

CLI syntax through YANG Models Manager FASTMAP


CDB
CLI
extensions NETCONF
NED
NED
SNMP
NED
Generic
NED
XML

ConfD converts to and from between


Config
• YANG
ConfD
XML and CLI
Device
Model Java for
SSH

CLI CLI
Config
over SSH

TECNMS-4175 © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public 189
Generic NED

• Custom implementation of southbound NSO NETCONF REST CLI SNMP

protocol Service
Models
Service
Manager
Templates

Mapping Logic
• Array of operations in the form of DOM* Device
Models
Device
Manager FASTMAP
(Document Object Model) manipulations
CDB
Generic
(JAVA) are sent to the device
NETCONF CLI SNMP
NED
NED NED NED
XML
Config
YANG
Device
Model Java for
Protocol X

Protocol
X Config

*The Document Object Model (DOM) is a programming interface for HTML and XML documents. It represents the
page so that programs can change the document structure, style, and content. The DOM represents the
document as nodes and objects. That way, programming languages can connect to the page.

TECNMS-4175 © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public 190
Installing NEDs

• Local Installation
• System Installation • Extract the package to the /packages
• Extract the package to /var/opt/ncs/packages unless subdirectory of the running directory
you used a non-default location • Alternatively, link to the lab-grade packages in
the installation directory

cisco@nso:/var/opt/ncs/packages$ sudo tar -xzvf /tmp/ncs-4.1.1-cisco-ios-4.0.4.tar.gz cisco-ios


cisco-ios/
cisco-ios/build-meta-data.xml cisco-
ios/CHANGES
cisco-ios/README
cisco-ios/netsim/
...
cisco@nso:/var/opt/ncs/packages$ sudo tar -xzvf /tmp/ncs-4.1.1-cisco-iosxr-4.1.tar.gz cisco-iosxr
cisco-iosxr/
cisco-iosxr/build-meta-data.xml cisco-
iosxr/CHANGES
cisco-iosxr/netsim/
...

TECNMS-4175 © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public 191
Using Existing Packages

• Existing packages:
• NEDS ($NCS_DIR/packages/neds)
• Services ($NCS_DIR/packages/services)
• Tools ($NCS_DIR/packages/tools)

• Copy or softlink packages from the NSO installation or another location where the
packages are stored:

cisco@nso:/var/opt/ncs/packages$ sudo cp -r $NCS_DIR/packages/neds/cisco-ios packages/


cisco@nso:/var/opt/ncs/packages$ sudo cp -r $NCS_DIR/packages/neds/cisco-iosxr packages/

or
cisco@nso:/var/opt/ncs/packages$ sudo ln -s $NCS_DIR/packages/neds/cisco-iosxr packages/cisco-ios
cisco@nso:/var/opt/ncs/packages$ sudo ln -s $NCS_DIR/packages/neds/cisco-iosxr packages/cisco-iosxr

TECNMS-4175 © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public 192
Activate NED Packages

• Any change in the package will not be automatically activate:


• Recompile packages (optional; used when package was compiled using a different version of NSO)
• Reload packages to activate them
• Verify packages

TECNMS-4175 © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public 193
NED Development Process

NED Delivery
NED Delivery NED Delivery
Development/
Sales Analysis /
Testing
Acceptance /
Preparation Support
Iterations (1+n)

Input: Scoping: YANG-model


• Requirements Update
Use Case(s) Device(s): Java-code
• Configuration(s) documentation
Lux-script(s)
• User guide(s) Planning: Delivery server
• Access • Resources
(remote/VM/physical)* • Estimates
• If support case: Testing
additional logs QA
Acceptance

TECNMS-4175 © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public 194
Service Package
Template Options

• The template uses tags to control the processing of lists:


• merge (default): the changes will be merged with the existing data
• replace: configuration will be replaced by the new configuration
• delete: delete anything from this point
• nocreate: merge data if it already exists, otherwise do nothing

TECNMS-4175 © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public 196
System Requirements
System Requirements: Operating System

• Supported architecture: 64-bit x86 architecture


• Two distributions available:
OSX (e.g. nso-4.5.2.darwin.x86_64.installer.bin)
Linux (e.g. nso-4.5.2.linux.x86_64.installer.bin)
• Java JDK version 7.0 or higher (i.e. development version 1.7 or higher)

TECNMS-4175 © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public 198
System Configuration and Installation Type

• NSO has two installation types that influence system administration:


Local installation: should be used development, testing and similar
environments
System installation: used in a final production environment
• Understand the implications of installation types when managing the
system:
Location of files and directories
Availability of certain features

TECNMS-4175 © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public 199
System Installation Local Installation

• Intended for production environment • Intended for in labs and on desktops


and pre-production verification lab
• NSO can run as user
• NSO can run as root or specific user
(from version 4.0.1) • Simple to switch between NSO
instances (versions)
• System integrated with the Linux OS:
• Everything installed in one or two
• Installation directory:/opt/ncs/ncs- directories
4.1.1 (linked to by /opt/ncs/current)
• Installation directory: all static files (e.g.
• Running directory: /var/opt/ncs binaries, libraries, scripts, tools)
• Log directory: /var/log/ncs • Running directory: all dynamic files
(e.g. CDB, logs, configuration,
• Configuration directory: /etc/ncs packages)

TECNMS-4175 © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public 200
Cisco NSO Local Installation Directory Structure

You may have multiple installation


~ ncs- 4.0.1/
directories for multiple version of NSO
ncs- 4.1/
ncs- 4.1.1/ bin/
lib/ Standalone NSO deployments
Installation
doc/ with sample solutions
Directory
examples.ncs web-server/ ncs- cdb/
ncs.conf

datacenter/ ncs-cdb/
ncs-run/ ncs- cdb/
ncs.conf
Running Directory ncs.conf

TECNMS-4175 © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public 201
Cisco NSO System Installation Directory
Structure

/ opt/ ncs/ ncs- 4.0.1/


ncs- 4.1/
ncs- 4.1.1/ bin/
lib/
Symbolic link Installation Directory
doc/
current/ examples.ncs

var/ opt/ ncs/ ncs- cdb/ Running Directory

log/ ncs/ Logging Directory

etc/ ncs/ ncs.conf Configuration Directory

TECNMS-4175 © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public 202
Other
Alarm Manager

• Manages native alarms and provides: device


device
device
object
• Extensible alarm-types object
object
alarm- Alarm
• Configurable mapping to alarm standards alarm-
type
alarm- model
type
type
• Northbound SNMP Alarm MIB
specific-
specific-
problem
• CDB knows device – service mapping specific-
problem
problem
cleared
cleared
active
time time
time
time time
time
sev user
Services sev
sev user
user
State and model-based text state
text
text state
Devices correlation rather than state
notification-based
Resource Operator

TECNMS-4175 © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public 204

You might also like