+ All Categories
Home > Documents > NETCONF YANG Tutorial ODLSummit2016 (1) -...

NETCONF YANG Tutorial ODLSummit2016 (1) -...

Date post: 18-Mar-2018
Category:
Upload: trannhan
View: 250 times
Download: 9 times
Share this document with a friend
137
NETCONF/YANG Tutorial Ryan Goulding, Senior Engineer, Brocade Giles Heron, Principal Engineer, Cisco Alexis de Talhouët, Software Developer, Inocybe Technologies
Transcript
Page 1: NETCONF YANG Tutorial ODLSummit2016 (1) - Schedschd.ws/hosted_files/opendaylightsummit2016/5f/NETCONF_YANG... · NETCONF/YANG Tutorial Ryan Goulding, Senior Engineer, ... OSS NMS

NETCONF/YANG Tutorial

Ryan Goulding, Senior Engineer, BrocadeGiles Heron, Principal Engineer, Cisco

Alexis de Talhouët, Software Developer, Inocybe Technologies

Page 2: NETCONF YANG Tutorial ODLSummit2016 (1) - Schedschd.ws/hosted_files/opendaylightsummit2016/5f/NETCONF_YANG... · NETCONF/YANG Tutorial Ryan Goulding, Senior Engineer, ... OSS NMS

● NETCONF/YANG Overview

● YANG basics

● YANG advanced

● NETCONF basics

● NETCONF advanced

● OpenDaylight NETCONF/YANG and RESTCONF

● Troubleshooting

● Demo

● Tooling, References etc.

Agenda

Page 3: NETCONF YANG Tutorial ODLSummit2016 (1) - Schedschd.ws/hosted_files/opendaylightsummit2016/5f/NETCONF_YANG... · NETCONF/YANG Tutorial Ryan Goulding, Senior Engineer, ... OSS NMS

NETCONF/YANG Overview

Page 4: NETCONF YANG Tutorial ODLSummit2016 (1) - Schedschd.ws/hosted_files/opendaylightsummit2016/5f/NETCONF_YANG... · NETCONF/YANG Tutorial Ryan Goulding, Senior Engineer, ... OSS NMS

Why NETCONF/YANG – RFC3535

SNMP had failedFor configuration, that isExtensive use in fault handling and monitoring

CLI scripting“Market share” 70%+

AbstractThis document provides an overview of a workshop held by the Internet Architecture Board (IAB) on Network Management. The workshop was hosted by CNRI in Reston, VA, USA from June 4 thru June 6, 2002. The goal of the workshop was to continue the important dialog started between network operators and protocol developers, and to guide the IETFs focus on future work regarding network management.

configuration

Page 5: NETCONF YANG Tutorial ODLSummit2016 (1) - Schedschd.ws/hosted_files/opendaylightsummit2016/5f/NETCONF_YANG... · NETCONF/YANG Tutorial Ryan Goulding, Senior Engineer, ... OSS NMS

Cost and complexity • No well-defined protocols and

data-models• Lack of atomicity• Ordering problem

NETCONFManager

OSSNMSEMS

RFC3535 - legacy situation

Page 6: NETCONF YANG Tutorial ODLSummit2016 (1) - Schedschd.ws/hosted_files/opendaylightsummit2016/5f/NETCONF_YANG... · NETCONF/YANG Tutorial Ryan Goulding, Senior Engineer, ... OSS NMS

RFC3535 - NETCONF/YANG solution

ReducedCost and

complexity

Cost/Value

NETCONFManager

OSSNMSEMS

TransactionsModelsStandardized Protocols

Page 7: NETCONF YANG Tutorial ODLSummit2016 (1) - Schedschd.ws/hosted_files/opendaylightsummit2016/5f/NETCONF_YANG... · NETCONF/YANG Tutorial Ryan Goulding, Senior Engineer, ... OSS NMS

So what is a data model anyway?

Data-Model (e.g. a YANG Model)• A data-model explicitly and precisely determines the

structure, syntax and semantics of the data…• …that is externally visible• Consistent and complete

Protocol (e.g. NETCONF or RESTCONF)• Remote primitives to view and manipulate the data (e.g.

XML RPCs or HTTP methods)• Encoding of the data as defined by the data-model (e.g.

XML or JSON)

Data-Model

Protocol

Page 8: NETCONF YANG Tutorial ODLSummit2016 (1) - Schedschd.ws/hosted_files/opendaylightsummit2016/5f/NETCONF_YANG... · NETCONF/YANG Tutorial Ryan Goulding, Senior Engineer, ... OSS NMS

NETCONFManager

NETCONF

YangModel

s

YANG ModelsYANG Models YANG Models

NETCONF & YANG “in the wild”

NETCONF

YANG Models

Page 9: NETCONF YANG Tutorial ODLSummit2016 (1) - Schedschd.ws/hosted_files/opendaylightsummit2016/5f/NETCONF_YANG... · NETCONF/YANG Tutorial Ryan Goulding, Senior Engineer, ... OSS NMS

Transport

RemoteOperations

MgmtServices

Mgmt info(payload)

Mgmt info(definition)

XML-encoded content

YANG modules

Netconf operations<edit-config>, <get-config>, <get>

Netconf RPC<rpc>, <rpc-reply>

TLS, SSH

Manager (client)

XML content

per YANG

ConceptualData Store

Agent(server)

NETCONF/YANG ”Layer-Cake”

Page 10: NETCONF YANG Tutorial ODLSummit2016 (1) - Schedschd.ws/hosted_files/opendaylightsummit2016/5f/NETCONF_YANG... · NETCONF/YANG Tutorial Ryan Goulding, Senior Engineer, ... OSS NMS

YANG Basics

Page 11: NETCONF YANG Tutorial ODLSummit2016 (1) - Schedschd.ws/hosted_files/opendaylightsummit2016/5f/NETCONF_YANG... · NETCONF/YANG Tutorial Ryan Goulding, Senior Engineer, ... OSS NMS

YANG is a modeling language defined in RFC 6020

Used by NETCONF to define objects and data in requests and replies

Analogous to XML schema and SMI for SNMP (but more powerful)

Models configuration, operational, and RPC data

Provides semantics to better define NETCONF data Constraints (i.e., “MUSTs”)Reusable structuresBuilt-in and derived types

YANG is extensible and modular

YANG modules are for NETCONF what MIBs are for SNMP

What is YANG?

Page 12: NETCONF YANG Tutorial ODLSummit2016 (1) - Schedschd.ws/hosted_files/opendaylightsummit2016/5f/NETCONF_YANG... · NETCONF/YANG Tutorial Ryan Goulding, Senior Engineer, ... OSS NMS

YANG and XML

YANG assumes an XML encoding of instantiated informationDefines XML rendering rulesRelies on XML encoding for certain featuresFacilitates describing XML document hierarchiesNicely aligned with NETCONF ☺

YANG itself is not XMLEmphasis on readability

Familiar structure to C/C++ or Java programmersXML notation exists: YIN (Yang-Independent Notation)

Semantic equivalence Syntactic conversions YANG <-> YIN

Alternative encodings defined (e.g. JSON for RESTconf)

Page 13: NETCONF YANG Tutorial ODLSummit2016 (1) - Schedschd.ws/hosted_files/opendaylightsummit2016/5f/NETCONF_YANG... · NETCONF/YANG Tutorial Ryan Goulding, Senior Engineer, ... OSS NMS

ODL

Transport

RemoteOperations

MgmtServices

Mgmt info(encoding)

Mgmt info(definition)

XML-encoded content

YANG modules

NETCONF operations

XMLRPC

TLS,SSH

JSON JAVA DTO

I2RS

gRPC

HTTP

RESTCONF

TCP

How does YANG go beyond NETCONF?

Page 14: NETCONF YANG Tutorial ODLSummit2016 (1) - Schedschd.ws/hosted_files/opendaylightsummit2016/5f/NETCONF_YANG... · NETCONF/YANG Tutorial Ryan Goulding, Senior Engineer, ... OSS NMS

acme-box module

properties container

interfaces container

name: string, config

name: string, config

interface: list, key = name

oper-state: enum, config

How are YANG modules structured?

Page 15: NETCONF YANG Tutorial ODLSummit2016 (1) - Schedschd.ws/hosted_files/opendaylightsummit2016/5f/NETCONF_YANG... · NETCONF/YANG Tutorial Ryan Goulding, Senior Engineer, ... OSS NMS

How are YANG modules structured?

Header informationImports & Includes

Type definitions

Configuration & Operationaldata declarations

Action (RPC) & Notification declarations

Page 16: NETCONF YANG Tutorial ODLSummit2016 (1) - Schedschd.ws/hosted_files/opendaylightsummit2016/5f/NETCONF_YANG... · NETCONF/YANG Tutorial Ryan Goulding, Senior Engineer, ... OSS NMS

YANG Model - Header

Page 17: NETCONF YANG Tutorial ODLSummit2016 (1) - Schedschd.ws/hosted_files/opendaylightsummit2016/5f/NETCONF_YANG... · NETCONF/YANG Tutorial Ryan Goulding, Senior Engineer, ... OSS NMS

YANG Model – Imports/Includes

Module Y NamespaceModule X Namespace

FragmentA.yang

FragmentB.yang

FragmentC.yang

FragmentD.yang

FragmentE.yang

Each included fragment is a complete YANG file; can never be included in any other module/namespace

include

includeinclude

import

Imported fragments are just referenced, not included

Page 18: NETCONF YANG Tutorial ODLSummit2016 (1) - Schedschd.ws/hosted_files/opendaylightsummit2016/5f/NETCONF_YANG... · NETCONF/YANG Tutorial Ryan Goulding, Senior Engineer, ... OSS NMS

YANG Model – submodules

Attention: The submodule cannot reference definitions in main module

Each submodule belongs to one specific main module

Page 19: NETCONF YANG Tutorial ODLSummit2016 (1) - Schedschd.ws/hosted_files/opendaylightsummit2016/5f/NETCONF_YANG... · NETCONF/YANG Tutorial Ryan Goulding, Senior Engineer, ... OSS NMS

• YANG leaves have a data type

• Type may be a base type or a derived type

• There are 20+ base types…

Type Name Meaningint8/16/32/64 Integeruint8/16/32/64 Unsigned integer

decimal64 Non-integer

string Unicode string

enumeration Set of alternativesboolean True or false

bits Boolean array

binary Binary BLOBleafref Reference “pointer”identityref Unique identityempty No value, void

…and more

YANG Types

Page 20: NETCONF YANG Tutorial ODLSummit2016 (1) - Schedschd.ws/hosted_files/opendaylightsummit2016/5f/NETCONF_YANG... · NETCONF/YANG Tutorial Ryan Goulding, Senior Engineer, ... OSS NMS

percent

completed

Type is referenced by a new leaf XML Instance Data:

<completed>50</completed>

YANG Typedef – defines new simple type

Page 21: NETCONF YANG Tutorial ODLSummit2016 (1) - Schedschd.ws/hosted_files/opendaylightsummit2016/5f/NETCONF_YANG... · NETCONF/YANG Tutorial Ryan Goulding, Senior Engineer, ... OSS NMS

• Commonly used YANG types defined in RFC 6021

• Use:

• And e.g:

counter32/64 ipv4-address

gauge32/64 ipv6-address

object-identifier ip-prefix

date-and-time ipv4-prefix

timeticks ipv6-prefix

timestamp domain-name

phys-address uri

ip-version mac-address

flow-label bridgeid

port-number vlanid

ip-address … and more

Common YANG Types

Page 22: NETCONF YANG Tutorial ODLSummit2016 (1) - Schedschd.ws/hosted_files/opendaylightsummit2016/5f/NETCONF_YANG... · NETCONF/YANG Tutorial Ryan Goulding, Senior Engineer, ... OSS NMS

target

peer

addressport

destinationaddressport

XML Instance Data:<destination>

<address>192.168.0.1</address>

<port>80</port>

</destination>

YANG Grouping – defines structured type

Page 23: NETCONF YANG Tutorial ODLSummit2016 (1) - Schedschd.ws/hosted_files/opendaylightsummit2016/5f/NETCONF_YANG... · NETCONF/YANG Tutorial Ryan Goulding, Senior Engineer, ... OSS NMS

• Holds a single value of a particular type• Has no children• Can’t reference directly from RESTCONF host-name

cpu-temp

XML Instance Data:

<host—name>my-host</host-name>

<cpu-temp>62</cpu-temp>

YANG Data Declarations – Leaf Statement

Page 24: NETCONF YANG Tutorial ODLSummit2016 (1) - Schedschd.ws/hosted_files/opendaylightsummit2016/5f/NETCONF_YANG... · NETCONF/YANG Tutorial Ryan Goulding, Senior Engineer, ... OSS NMS

• Holds multiple values of a particular type• Has no children

domain-search

XML Instance Data:

<domain-search>foo.com</domain-search>

<domain-search>bar.com</domain-search>

YANG Data Declarations – Leaf-List

Page 25: NETCONF YANG Tutorial ODLSummit2016 (1) - Schedschd.ws/hosted_files/opendaylightsummit2016/5f/NETCONF_YANG... · NETCONF/YANG Tutorial Ryan Goulding, Senior Engineer, ... OSS NMS

user

name classfull-nameuidDefault

YANG Data Declarations – List Statement

Page 26: NETCONF YANG Tutorial ODLSummit2016 (1) - Schedschd.ws/hosted_files/opendaylightsummit2016/5f/NETCONF_YANG... · NETCONF/YANG Tutorial Ryan Goulding, Senior Engineer, ... OSS NMS

user

name classfull-nameuidDefaultyang 1010 Yan Goode admin

hawk 1152 Ron Hawk oper

ling 1202 Lin Grossman viewer

The key field is used to specify which row we’re accessingKey can be one leaf, or multipleIn RESTCONF key is URL element (after list name – e.g. “…/user/hawk”)

Where >1 key each key is a new URL element

YANG Lists - Keys

Page 27: NETCONF YANG Tutorial ODLSummit2016 (1) - Schedschd.ws/hosted_files/opendaylightsummit2016/5f/NETCONF_YANG... · NETCONF/YANG Tutorial Ryan Goulding, Senior Engineer, ... OSS NMS

YANG Lists – “Unique” Statement

Non-key fields can also be declared unique.

Multiple leaves can be declared unique separately or in combination

Note ODL doesn’t enforce this (or many other constraints today)

user

name classfull-nameuidDefault

1010 yang Yan Goode admin

1152 hawk Ron Hawk oper

1202 ling Lin Grossman viewer

Page 28: NETCONF YANG Tutorial ODLSummit2016 (1) - Schedschd.ws/hosted_files/opendaylightsummit2016/5f/NETCONF_YANG... · NETCONF/YANG Tutorial Ryan Goulding, Senior Engineer, ... OSS NMS

Groups related leafs and containers system

services

ssh

Presence

YANG Data Declarations – Containers

XML Instance Data:<system>

<services>

</services>

</system>

Page 29: NETCONF YANG Tutorial ODLSummit2016 (1) - Schedschd.ws/hosted_files/opendaylightsummit2016/5f/NETCONF_YANG... · NETCONF/YANG Tutorial Ryan Goulding, Senior Engineer, ... OSS NMS

Create our first YANG model

YANG Basics

Page 30: NETCONF YANG Tutorial ODLSummit2016 (1) - Schedschd.ws/hosted_files/opendaylightsummit2016/5f/NETCONF_YANG... · NETCONF/YANG Tutorial Ryan Goulding, Senior Engineer, ... OSS NMS

Create first YANG model

● Open Eclipse (pre-provisioned workspace)

● Under src/main/yang

○ Right click → new → other

→ search for Yang

○ Give it a name: car

YANG Basics

Page 31: NETCONF YANG Tutorial ODLSummit2016 (1) - Schedschd.ws/hosted_files/opendaylightsummit2016/5f/NETCONF_YANG... · NETCONF/YANG Tutorial Ryan Goulding, Senior Engineer, ... OSS NMS

● The file name and the module name must be the same● The namespace is a global unique URI (Unique Resource Identifier)● The prefix is to define the prefix associated with the module and its

namespace● The revision define the date when this module was first created. You

would change the revision date after updating an existing yang file

YANG Basics

Page 32: NETCONF YANG Tutorial ODLSummit2016 (1) - Schedschd.ws/hosted_files/opendaylightsummit2016/5f/NETCONF_YANG... · NETCONF/YANG Tutorial Ryan Goulding, Senior Engineer, ... OSS NMS

Create our first container:

● The container is used to define an interior data node in the schema tree

YANG Basics

Page 33: NETCONF YANG Tutorial ODLSummit2016 (1) - Schedschd.ws/hosted_files/opendaylightsummit2016/5f/NETCONF_YANG... · NETCONF/YANG Tutorial Ryan Goulding, Senior Engineer, ... OSS NMS

● A container can have as much as sub-statement it needs ● In our example, we have defined two leaves. A leaf requires a type:

○ max-speed■ uint8 (8-bit unsigned integer), this is enough to define the maximum

speed○ gaz-tank-state

■ Enum: this means this leaf can be one values defined in the enum■ Default: it corresponds to the default value assigned to this leaf

YANG Basics

Page 34: NETCONF YANG Tutorial ODLSummit2016 (1) - Schedschd.ws/hosted_files/opendaylightsummit2016/5f/NETCONF_YANG... · NETCONF/YANG Tutorial Ryan Goulding, Senior Engineer, ... OSS NMS

YANG Basics

Page 35: NETCONF YANG Tutorial ODLSummit2016 (1) - Schedschd.ws/hosted_files/opendaylightsummit2016/5f/NETCONF_YANG... · NETCONF/YANG Tutorial Ryan Goulding, Senior Engineer, ... OSS NMS

Import a dependency in YANG:

● Makes definitions from one module available inside another module or submodule

● Import has two substatement to identify the module:○ prefix○ revision-date

YANG Basics

Page 36: NETCONF YANG Tutorial ODLSummit2016 (1) - Schedschd.ws/hosted_files/opendaylightsummit2016/5f/NETCONF_YANG... · NETCONF/YANG Tutorial Ryan Goulding, Senior Engineer, ... OSS NMS

Import a dependency in YANG:

● Let’s import ietf-yang-types

● See more about this import content at http://www.netconfcentral.org/modules/ietf-yang-types

YANG Basics

Page 37: NETCONF YANG Tutorial ODLSummit2016 (1) - Schedschd.ws/hosted_files/opendaylightsummit2016/5f/NETCONF_YANG... · NETCONF/YANG Tutorial Ryan Goulding, Senior Engineer, ... OSS NMS

Import a dependency in the pom file:

● Tell Maven where to fetch the dependency

<dependencies><dependency>

<groupId>org.opendaylight.mdsal.model</groupId><artifactId>ietf-yang-types-20130715</artifactId>

</dependency></dependencies>

YANG Basics

Page 38: NETCONF YANG Tutorial ODLSummit2016 (1) - Schedschd.ws/hosted_files/opendaylightsummit2016/5f/NETCONF_YANG... · NETCONF/YANG Tutorial Ryan Goulding, Senior Engineer, ... OSS NMS

Validate the model with Pyang

● Pyang is a tool to validate and convert YANG module to various format. https://github.com/mbj4668/pyang/wiki

● Use the following command to validate your yang model$ pyang car.yangcar.yang:6: warning: imported module ietf-yang-types not used

YANG Basics

Page 39: NETCONF YANG Tutorial ODLSummit2016 (1) - Schedschd.ws/hosted_files/opendaylightsummit2016/5f/NETCONF_YANG... · NETCONF/YANG Tutorial Ryan Goulding, Senior Engineer, ... OSS NMS

Use our import

● Create a leaf date in our grouping using the ietf-yang-types “date-and-time” definition

● Let’s re-validate our model:

$ pyang car.yang

YANG Basics

Page 40: NETCONF YANG Tutorial ODLSummit2016 (1) - Schedschd.ws/hosted_files/opendaylightsummit2016/5f/NETCONF_YANG... · NETCONF/YANG Tutorial Ryan Goulding, Senior Engineer, ... OSS NMS

View your model

● To see an overview of the data model schemas we can use tree:

$ pyang -f tree car.yangmodule: car

+--rw car-info +--rw max-speed? uint8 +--rw gaz-tank-state? enumeration +--rw date? yang:date-and-time

YANG Basics

Page 41: NETCONF YANG Tutorial ODLSummit2016 (1) - Schedschd.ws/hosted_files/opendaylightsummit2016/5f/NETCONF_YANG... · NETCONF/YANG Tutorial Ryan Goulding, Senior Engineer, ... OSS NMS

YANG Basics

Page 42: NETCONF YANG Tutorial ODLSummit2016 (1) - Schedschd.ws/hosted_files/opendaylightsummit2016/5f/NETCONF_YANG... · NETCONF/YANG Tutorial Ryan Goulding, Senior Engineer, ... OSS NMS

● Yang notions covered:○ Import○ Namespace○ Prefix○ Revision○ Container○ Leaf○ Enum○ Default

YANG Basics

Page 43: NETCONF YANG Tutorial ODLSummit2016 (1) - Schedschd.ws/hosted_files/opendaylightsummit2016/5f/NETCONF_YANG... · NETCONF/YANG Tutorial Ryan Goulding, Senior Engineer, ... OSS NMS

Create Java bindings (OpenDaylight)

● Get at the root of the project

$ cd ~/Training/yang/yang-tutorial; maven clean install$ cd ~/Training/yang/yang-tutorial/target/generated-sources

● All the java bindings should be there

YANG Basics

Page 44: NETCONF YANG Tutorial ODLSummit2016 (1) - Schedschd.ws/hosted_files/opendaylightsummit2016/5f/NETCONF_YANG... · NETCONF/YANG Tutorial Ryan Goulding, Senior Engineer, ... OSS NMS

YANG Advanced

Page 45: NETCONF YANG Tutorial ODLSummit2016 (1) - Schedschd.ws/hosted_files/opendaylightsummit2016/5f/NETCONF_YANG... · NETCONF/YANG Tutorial Ryan Goulding, Senior Engineer, ... OSS NMS

YANG module structure - reminder

Header informationImports & Includes

Type definitions

Configuration & Operationaldata declarations

Action (RPC) & Notification declarations

Page 46: NETCONF YANG Tutorial ODLSummit2016 (1) - Schedschd.ws/hosted_files/opendaylightsummit2016/5f/NETCONF_YANG... · NETCONF/YANG Tutorial Ryan Goulding, Senior Engineer, ... OSS NMS

Enumeration – a type that can take one of several defined values

Best used when set of values is known a-priori

Instance Data:

<connection-status>connected</connection-status>

Advanced YANG Types – Enumerations

Page 47: NETCONF YANG Tutorial ODLSummit2016 (1) - Schedschd.ws/hosted_files/opendaylightsummit2016/5f/NETCONF_YANG... · NETCONF/YANG Tutorial Ryan Goulding, Senior Engineer, ... OSS NMS

Union - a value that represents one of its member types

Instance Data:

<threshold>50</threshold>

Or:

<threshold>disabled</threshold>

Advanced YANG Types - Unions

Page 48: NETCONF YANG Tutorial ODLSummit2016 (1) - Schedschd.ws/hosted_files/opendaylightsummit2016/5f/NETCONF_YANG... · NETCONF/YANG Tutorial Ryan Goulding, Senior Engineer, ... OSS NMS

Choice - allows one of several alternatives

transfer-interval

transfer-on-commit

transfer-method

Instance Data:

<transfer-interval>120</transfer-interval>

Or:<transfer-on-commit/>

Advanced YANG Types - Choice

Page 49: NETCONF YANG Tutorial ODLSummit2016 (1) - Schedschd.ws/hosted_files/opendaylightsummit2016/5f/NETCONF_YANG... · NETCONF/YANG Tutorial Ryan Goulding, Senior Engineer, ... OSS NMS

• Each alternative may consist of multiple definitions• Use case statement to group them• Note that choice and case do not appear in instance data

Instance Data:

<threshold>60</threshold>

<ignore-count>3</ignore-count>

<ignore-time>30</ignore-time>

<reset-time>120</reset-time>

Advanced YANG Types - Choice

Page 50: NETCONF YANG Tutorial ODLSummit2016 (1) - Schedschd.ws/hosted_files/opendaylightsummit2016/5f/NETCONF_YANG... · NETCONF/YANG Tutorial Ryan Goulding, Senior Engineer, ... OSS NMS

base identity defined

refer back to base

additional identities – same base

leaf refers to base identity

Advanced YANG Types - Identity

Page 51: NETCONF YANG Tutorial ODLSummit2016 (1) - Schedschd.ws/hosted_files/opendaylightsummit2016/5f/NETCONF_YANG... · NETCONF/YANG Tutorial Ryan Goulding, Senior Engineer, ... OSS NMS

Original (augmented) YANG module

Namespace http://example.com/schema/interfaces

Namespace http://example.com/schema/ds0

New (augmenting) YANG module

Context node

Information to augment the context

node with

Advanced Data Definition - Augment

Page 52: NETCONF YANG Tutorial ODLSummit2016 (1) - Schedschd.ws/hosted_files/opendaylightsummit2016/5f/NETCONF_YANG... · NETCONF/YANG Tutorial Ryan Goulding, Senior Engineer, ... OSS NMS

Effectively equivalentto the following

Instance Data:

<interfaces>

<ifEntry>

<ifIndex>1</ifIndex>

<ifType>ds0</ifType>

<ifMtu>1500</ifType>

<ds0ChannelNumber>13<ds0ChannelNumber>

</ifEntry>

</interfaces>

YANG Augment - Example

Page 53: NETCONF YANG Tutorial ODLSummit2016 (1) - Schedschd.ws/hosted_files/opendaylightsummit2016/5f/NETCONF_YANG... · NETCONF/YANG Tutorial Ryan Goulding, Senior Engineer, ... OSS NMS

Restricts valid values byXpath 1.0 expression

Xpath expression to validate against data

YANG Constraints – must statement

Page 54: NETCONF YANG Tutorial ODLSummit2016 (1) - Schedschd.ws/hosted_files/opendaylightsummit2016/5f/NETCONF_YANG... · NETCONF/YANG Tutorial Ryan Goulding, Senior Engineer, ... OSS NMS

Administrative actions with input and output parameters

image

status

activate-software-image

YANG RPCs

Page 55: NETCONF YANG Tutorial ODLSummit2016 (1) - Schedschd.ws/hosted_files/opendaylightsummit2016/5f/NETCONF_YANG... · NETCONF/YANG Tutorial Ryan Goulding, Senior Engineer, ... OSS NMS

Notification with output parameters

operator-name

change

config-change

<change>/ex:system/ex:services/ex:ssh/ex:port</change><change>/ex:system/ex:user[ex:name='fred']/ex:type</change><change>/ex:system/ex:server[ex:ip='192.0.2.1'][ex:port='80’]</change>

Instance-identifier values

YANG Notifications

Page 56: NETCONF YANG Tutorial ODLSummit2016 (1) - Schedschd.ws/hosted_files/opendaylightsummit2016/5f/NETCONF_YANG... · NETCONF/YANG Tutorial Ryan Goulding, Senior Engineer, ... OSS NMS

• "extension" node allows definition of new statements to use with YANG module

• Effectively, allow for extension of YANG language

• Add a new keyword with arguments• Escape mechanism to allow for

proprietary extensions• Example usage: augmentation of YANG

modules with information to assist tools with code generation

YANG Extensions

Page 57: NETCONF YANG Tutorial ODLSummit2016 (1) - Schedschd.ws/hosted_files/opendaylightsummit2016/5f/NETCONF_YANG... · NETCONF/YANG Tutorial Ryan Goulding, Senior Engineer, ... OSS NMS

YANG Conformance - Features

“if-feature” makes a statement conditional on the presence of a “feature”

Avoids “lowest common denominator” as can define optional capabilities as features

Page 58: NETCONF YANG Tutorial ODLSummit2016 (1) - Schedschd.ws/hosted_files/opendaylightsummit2016/5f/NETCONF_YANG... · NETCONF/YANG Tutorial Ryan Goulding, Senior Engineer, ... OSS NMS

Used to specify that a NETCONF server doesn’t support part of a model.

Arguments can be:1. not-supported2. delete3. replace4. add5. replace

YANG Conformance - Deviations

Page 59: NETCONF YANG Tutorial ODLSummit2016 (1) - Schedschd.ws/hosted_files/opendaylightsummit2016/5f/NETCONF_YANG... · NETCONF/YANG Tutorial Ryan Goulding, Senior Engineer, ... OSS NMS

YANG Module“Interfaces”

A

if-feature individualStatsif-feature aggregatedStats

YANG Module“myInterfaces”

Feature“individualStats”

Deviation A

YANG Conformance - Illustrated

Page 60: NETCONF YANG Tutorial ODLSummit2016 (1) - Schedschd.ws/hosted_files/opendaylightsummit2016/5f/NETCONF_YANG... · NETCONF/YANG Tutorial Ryan Goulding, Senior Engineer, ... OSS NMS

Improve previously created model

YANG Advanced

Page 61: NETCONF YANG Tutorial ODLSummit2016 (1) - Schedschd.ws/hosted_files/opendaylightsummit2016/5f/NETCONF_YANG... · NETCONF/YANG Tutorial Ryan Goulding, Senior Engineer, ... OSS NMS

Few changes to our model

● Define the enumeration as its own type instead of having it enclosed in the gaz-tank-state. To do so we define a new type using typedef.

● Add car-id leaf to the car-info container so we can identify a car

YANG Advanced

Page 62: NETCONF YANG Tutorial ODLSummit2016 (1) - Schedschd.ws/hosted_files/opendaylightsummit2016/5f/NETCONF_YANG... · NETCONF/YANG Tutorial Ryan Goulding, Senior Engineer, ... OSS NMS

Create an Remote Procedure Call

● Define a Remote Procedure Call using YANG

You will need:

● Operation’s name● Input parameters● Output parameters

YANG Advanced

Page 63: NETCONF YANG Tutorial ODLSummit2016 (1) - Schedschd.ws/hosted_files/opendaylightsummit2016/5f/NETCONF_YANG... · NETCONF/YANG Tutorial Ryan Goulding, Senior Engineer, ... OSS NMS

Create an Remote Procedure Call

● Our RPC will be to get the trank state for a given car● The implementation would look like

YANG Advanced

Page 64: NETCONF YANG Tutorial ODLSummit2016 (1) - Schedschd.ws/hosted_files/opendaylightsummit2016/5f/NETCONF_YANG... · NETCONF/YANG Tutorial Ryan Goulding, Senior Engineer, ... OSS NMS

Create a Notification

● Notification allows you to get notify when a change occurs for a given path in the module

● Let’s define a notification that will be send when we’re out of gaz

YANG Advanced

Page 65: NETCONF YANG Tutorial ODLSummit2016 (1) - Schedschd.ws/hosted_files/opendaylightsummit2016/5f/NETCONF_YANG... · NETCONF/YANG Tutorial Ryan Goulding, Senior Engineer, ... OSS NMS

Create a Grouping

● The grouping statement is used to define a reusable block of nodes. In this grouping, we will define characteristic for our augmentation.

YANG Advanced

Page 66: NETCONF YANG Tutorial ODLSummit2016 (1) - Schedschd.ws/hosted_files/opendaylightsummit2016/5f/NETCONF_YANG... · NETCONF/YANG Tutorial Ryan Goulding, Senior Engineer, ... OSS NMS

Create a Augmentation

● Augment the car-info container with the created grouping● The augmentation will add extra information to the existing container. This

augmentation will thus provide all the information provided by car-info plus the information from sport-car.

YANG Advanced

Page 67: NETCONF YANG Tutorial ODLSummit2016 (1) - Schedschd.ws/hosted_files/opendaylightsummit2016/5f/NETCONF_YANG... · NETCONF/YANG Tutorial Ryan Goulding, Senior Engineer, ... OSS NMS

● Yang notions covered:○ Typedef○ RPC○ Notification○ Grouping○ Augmentation

YANG Advanced

Page 68: NETCONF YANG Tutorial ODLSummit2016 (1) - Schedschd.ws/hosted_files/opendaylightsummit2016/5f/NETCONF_YANG... · NETCONF/YANG Tutorial Ryan Goulding, Senior Engineer, ... OSS NMS

NETCONF Basics

Page 69: NETCONF YANG Tutorial ODLSummit2016 (1) - Schedschd.ws/hosted_files/opendaylightsummit2016/5f/NETCONF_YANG... · NETCONF/YANG Tutorial Ryan Goulding, Senior Engineer, ... OSS NMS

What is NETCONF

Netconf is connection-orientatedSSH, TLS as underlying transport

Netconf client (“manager”) establishes session with server (“agent”)

Data is XML-encoded

Based on RPCs• <rpc xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id=”100">

Defined in RFC4741 (NETCONF 1.0) and RFC6241 (NETCONF 1.1)• ODL supports NETCONF 1.1

Call-home being standardised• Enables managed device to contact server

Page 70: NETCONF YANG Tutorial ODLSummit2016 (1) - Schedschd.ws/hosted_files/opendaylightsummit2016/5f/NETCONF_YANG... · NETCONF/YANG Tutorial Ryan Goulding, Senior Engineer, ... OSS NMS

The NETCONF Hello

Capabilities exchangeData model ID exchange

Framing• NETCONF 1.0 EOM, ]]>]]>• NETCONF 1.1 Chunked Framing

<?xml version="1.0" encoding="UTF-8"?><hello xmlns="urn:ietf:params:xml:ns:netconf:base:1.1"> <capabilities> <capability>urn:ietf:params:netconf:base:1.1</capability> </capabilities></hello>

Page 71: NETCONF YANG Tutorial ODLSummit2016 (1) - Schedschd.ws/hosted_files/opendaylightsummit2016/5f/NETCONF_YANG... · NETCONF/YANG Tutorial Ryan Goulding, Senior Engineer, ... OSS NMS

The NETCONF Hello – Agent Response

<?xml version="1.0" encoding="UTF-8"?><hello xmlns="urn:ietf:params:xml:ns:netconf:base:1.1"><capabilities><capability>urn:ietf:params: netconf:base:1.1</capability><capability>urn:ietf:params:netconf:capability: writable-running:1.0</capability<capability>urn:ietf:params:netconf:capability: candidate:1.0</capability><capability>urn:ietf:params:netconf:capability: confirmed-commit:1.0</capability<capability>urn:ietf:params:netconf:capability:xpath:1.0</capability><capability>urn:ietf:params:netconf:capability: validate:1.0</capability><capability>urn:ietf:params:netconf:capability: rollback-on-error:1.0</capabilit<capability>http://tail-f.com/ns/netconf/with-defaults/1.0</capability><capability>http://tail-f.com/ns/netconf/actions/1.0</capability><capability>http://tail-f.com/ns/netconf/commit/1.0</capability><capability>http://tail-f.com/ns/example/dhcpd?module=dhcpd</capability><capability>urn:ietf:params:xml:ns:yang: ietf-inet-types?revision=2010-09-24&amp;module=ietf-inet-types</capability></capabilities><session-id>5</session-id></hello>

Page 72: NETCONF YANG Tutorial ODLSummit2016 (1) - Schedschd.ws/hosted_files/opendaylightsummit2016/5f/NETCONF_YANG... · NETCONF/YANG Tutorial Ryan Goulding, Senior Engineer, ... OSS NMS

NETCONF get-config operation

<rpc xmlns="urn:ietf:params:xml:ns:netconf:base:1.1” message-id="1"> <get-config> <source> <running/> </source> <filter xmlns="http://tail-f.com/ns/aaa/1.1"> <aaa/> </filter> </get-config></rpc>

Note use of subtree filter:YANG model identified using xmlns for module

Page 73: NETCONF YANG Tutorial ODLSummit2016 (1) - Schedschd.ws/hosted_files/opendaylightsummit2016/5f/NETCONF_YANG... · NETCONF/YANG Tutorial Ryan Goulding, Senior Engineer, ... OSS NMS

NETCONF get-config response

<rpc-reply xmlns="urn:ietf:params:xml:ns:netconf:base:1.1” message-id="1"> <data> <aaa xmlns="http://tail-f.com/ns/aaa/1.1"> <authentication> <users> <user> <name>admin</name> <uid>9000</uid> <gid>0</gid> <password>$1$3ZHhR6Ow$acznsyClFc0keo3B3BVjx/</password> <ssh_keydir>/var/confd/homes/admin/.ssh</ssh_keydir> <homedir>/var/confd/homes/admin</homedir> </user> <user> <name>oper</name> … </users> </authentication> </aaa> </data></rpc-reply>

Page 74: NETCONF YANG Tutorial ODLSummit2016 (1) - Schedschd.ws/hosted_files/opendaylightsummit2016/5f/NETCONF_YANG... · NETCONF/YANG Tutorial Ryan Goulding, Senior Engineer, ... OSS NMS

NETCONF edit-config operation

<rpc xmlns="urn:ietf:params:xml:ns:netconf:base:1.1” message-id="1"> <edit-config> <target><running/></target> <config> <dhcp xmlns="http://tail-f.com/ns/example/dhcpd" xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.1"> <defaultLeaseTime nc:operation="merge”>PT1H </defaultLeaseTime> </dhcp> </config> </edit-config></rpc>

<rpc-reply xmlns="urn:ietf:params:xml:ns:netconf:base:1.1" message-id="1"> <ok/></rpc-reply>

Page 75: NETCONF YANG Tutorial ODLSummit2016 (1) - Schedschd.ws/hosted_files/opendaylightsummit2016/5f/NETCONF_YANG... · NETCONF/YANG Tutorial Ryan Goulding, Senior Engineer, ... OSS NMS

nc:test-option (:validate)test-then-set (default)settest-only

nc:error-optionstop-on-error (default)continue-on-errorrollback-on-error (:rollback-on-error)

nc:operationmergereplacecreatedelete remove (:base:1.1)

Error if item to delete does not exist

Ok if item to delete does not exist

NETCONF edit-config options

Page 76: NETCONF YANG Tutorial ODLSummit2016 (1) - Schedschd.ws/hosted_files/opendaylightsummit2016/5f/NETCONF_YANG... · NETCONF/YANG Tutorial Ryan Goulding, Senior Engineer, ... OSS NMS

<rpc message-id="101” xmlns="urn:ietf:params:xml:ns:netconf:base:1.1"> <copy-config> <target><running/></target> <source> <url>https://[email protected]:passphrase/cfg/new.txt </url> </source> </copy-config></rpc>

<rpc-reply message-id="101” xmlns="urn:ietf:params:xml:ns:netconf:base:1.1"> <ok/></rpc-reply>

NETCONF copy-config operation

Page 77: NETCONF YANG Tutorial ODLSummit2016 (1) - Schedschd.ws/hosted_files/opendaylightsummit2016/5f/NETCONF_YANG... · NETCONF/YANG Tutorial Ryan Goulding, Senior Engineer, ... OSS NMS

<rpc message-id="101” xmlns="urn:ietf:params:xml:ns:netconf:base:1.1"> <delete-config> <target> <startup/> </target> </delete-config></rpc>

<rpc-reply message-id="101” xmlns="urn:ietf:params:xml:ns:netconf:base:1.1"> <ok/></rpc-reply>

NETCONF delete-config operation

Page 78: NETCONF YANG Tutorial ODLSummit2016 (1) - Schedschd.ws/hosted_files/opendaylightsummit2016/5f/NETCONF_YANG... · NETCONF/YANG Tutorial Ryan Goulding, Senior Engineer, ... OSS NMS

<rpc message-id="101” xmlns="urn:ietf:params:xml:ns:netconf:base:1.1"> <lock> <target> <candidate/> </target> </lock></rpc>

<rpc-reply message-id="101” xmlns="urn:ietf:params:xml:ns:netconf:base:1.1"> <ok/></rpc-reply>

NETCONF lock/unlock operation

Page 79: NETCONF YANG Tutorial ODLSummit2016 (1) - Schedschd.ws/hosted_files/opendaylightsummit2016/5f/NETCONF_YANG... · NETCONF/YANG Tutorial Ryan Goulding, Senior Engineer, ... OSS NMS

<rpc message-id="101” xmlns=”urn:ietf:param<get> <filter type="subtree"> <top xmlns="http://example.com/ns/dhc <interfaces> <interface> <ifName>eth0</ifName> </interface> </interfaces> </top> </filter></get>

<rpc-reply message-id="101” xmlns=“urn:ie <data> <top xmlns="http://example.com/ns/dhc <interfaces> <interface> <ifName>eth0</ifName> <ifInOctets>45621</ifInOctets> <ifOutOctets>774344</ifOutOctet </interface> </interfaces> </top> </data></rpc-reply>

NETCONF get operation

Returns both (running) config and operational data

Page 80: NETCONF YANG Tutorial ODLSummit2016 (1) - Schedschd.ws/hosted_files/opendaylightsummit2016/5f/NETCONF_YANG... · NETCONF/YANG Tutorial Ryan Goulding, Senior Engineer, ... OSS NMS

<rpc message-id="101” xmlns="urn:ietf:params:xml:ns:netconf:base:1.1"> <close-session/></rpc>

<rpc-reply message-id="101” xmlns="urn:ietf:params:xml:ns:netconf:base:1.1"> <ok/></rpc-reply>

Polite way to disconnect

NETCONF close-session operation

Page 81: NETCONF YANG Tutorial ODLSummit2016 (1) - Schedschd.ws/hosted_files/opendaylightsummit2016/5f/NETCONF_YANG... · NETCONF/YANG Tutorial Ryan Goulding, Senior Engineer, ... OSS NMS

<rpc message-id="101” xmlns="urn:ietf:params:xml:ns:netconf:base:1.1"> <close-session/></rpc>

<rpc-reply message-id="101” xmlns="urn:ietf:params:xml:ns:netconf:base:1.1"> <ok/></rpc-reply>

(Not so) polite way to disconnect (someone else)Releases any locks, aborts any confirmed commit related to session

NETCONF kill-session operation

Page 82: NETCONF YANG Tutorial ODLSummit2016 (1) - Schedschd.ws/hosted_files/opendaylightsummit2016/5f/NETCONF_YANG... · NETCONF/YANG Tutorial Ryan Goulding, Senior Engineer, ... OSS NMS

<commit>, <discard-changes> (:candidate)

<validate> (:validate)• Copy candidate to running• Discard changes in candidate (copy running to candidate)

<create-subscription> (:notification)

<partial-lock>, <partial-unlock> (:partial-lock)

<commit>, <cancel-commit> (:commit)

<get-schema> (:ietf-netconf-monitoring)

Additional NETCONF Operations(by capabilities)

Page 83: NETCONF YANG Tutorial ODLSummit2016 (1) - Schedschd.ws/hosted_files/opendaylightsummit2016/5f/NETCONF_YANG... · NETCONF/YANG Tutorial Ryan Goulding, Senior Engineer, ... OSS NMS

Use a NETCONF device: ConfD

NETCONF Basics

Page 84: NETCONF YANG Tutorial ODLSummit2016 (1) - Schedschd.ws/hosted_files/opendaylightsummit2016/5f/NETCONF_YANG... · NETCONF/YANG Tutorial Ryan Goulding, Senior Engineer, ... OSS NMS

Setup the VM:

● Update all dependencies

$ sudo apt-get update

● Install an xml parser needed by netconf client

$ sudo apt-get install libxml2-utils

NETCONF Basics

Page 85: NETCONF YANG Tutorial ODLSummit2016 (1) - Schedschd.ws/hosted_files/opendaylightsummit2016/5f/NETCONF_YANG... · NETCONF/YANG Tutorial Ryan Goulding, Senior Engineer, ... OSS NMS

● Get ConfD $ sudo wget -O confd.tar.gz https://db.tt/ClWpS3qR$ tar xvf confd.tar.gz$ sudo mv confd /opt

● Start ConfD:

$ /opt/confd/bin/confd

● See existing models:

$ ls /opt/confd/etc/confd/

For each existing yang model, there is its associated .fxs file

NETCONF Basics

Page 86: NETCONF YANG Tutorial ODLSummit2016 (1) - Schedschd.ws/hosted_files/opendaylightsummit2016/5f/NETCONF_YANG... · NETCONF/YANG Tutorial Ryan Goulding, Senior Engineer, ... OSS NMS

● Generate the .fxs file for the yang files (ConfD’s YANG binary)

$ cd /opt/confd/etc/confd$ /opt/confd/bin/confdc -c /opt/confd/etc/confd/car.yang

$ ls | grep car car.fxs car.yang

● We now have both our yang file and its associated ConfD’s binary

NETCONF Basics

Page 87: NETCONF YANG Tutorial ODLSummit2016 (1) - Schedschd.ws/hosted_files/opendaylightsummit2016/5f/NETCONF_YANG... · NETCONF/YANG Tutorial Ryan Goulding, Senior Engineer, ... OSS NMS

● Stop and restart ConfD so it takes it in account:

$ /opt/confd/bin/confd --stop$ /opt/confd/bin/confd --start-phase0$ /opt/confd/bin/confd --start-phase1$ /opt/confd/bin/confd --start-phase2

NETCONF Basics

Page 88: NETCONF YANG Tutorial ODLSummit2016 (1) - Schedschd.ws/hosted_files/opendaylightsummit2016/5f/NETCONF_YANG... · NETCONF/YANG Tutorial Ryan Goulding, Senior Engineer, ... OSS NMS

● Watch ConfD status:

$ /opt/confd/bin/confd --status--[cut]--SMP support: noUsing epoll: norunning modules: backplane,netconf,cdb,clistatus: startednamespaces: urn:opendaylight:car prefix:car exported to: all urn:ietf:params:xml:ns:yang:iana-crypt-hash prefix:ianach exported to: all urn:ietf:params:xml:ns:yang:ietf-inet-types prefix:inet exported to: all--[cut]--YANG data models: module: car revision: 2016-06-09

namespace: urn:opendaylight:carprefix: carexported to: all

--[cut]--

NETCONF Basics

Page 89: NETCONF YANG Tutorial ODLSummit2016 (1) - Schedschd.ws/hosted_files/opendaylightsummit2016/5f/NETCONF_YANG... · NETCONF/YANG Tutorial Ryan Goulding, Senior Engineer, ... OSS NMS

● Use the netconf-console provided by Confd

● Help$ /opt/confd/bin/netconf-console-tcp --help

● Hello Message$ /opt/confd/bin/netconf-console-tcp --hello

● Get-schema$ /opt/confd/bin/netconf-console-tcp --get-schema=car

NETCONF Basics

Page 90: NETCONF YANG Tutorial ODLSummit2016 (1) - Schedschd.ws/hosted_files/opendaylightsummit2016/5f/NETCONF_YANG... · NETCONF/YANG Tutorial Ryan Goulding, Senior Engineer, ... OSS NMS

● Get-config$ /opt/confd/bin/netconf-console-tcp --get-configSpecify the database:$ /opt/confd/bin/netconf-console-tcp --get-config --db candidate

● Edit-config (use the interactive command line):$ /opt/confd/bin/netconf-console-tcp -i

* Enter a NETCONF operation, end with an empty line

NETCONF Basics

Page 91: NETCONF YANG Tutorial ODLSummit2016 (1) - Schedschd.ws/hosted_files/opendaylightsummit2016/5f/NETCONF_YANG... · NETCONF/YANG Tutorial Ryan Goulding, Senior Engineer, ... OSS NMS

● Lock Payload

<lock><target>

<running/></target>

</lock>

● Unlock Payload

<unlock><target>

<running/></target>

</unlock>

NETCONF Basics

Page 92: NETCONF YANG Tutorial ODLSummit2016 (1) - Schedschd.ws/hosted_files/opendaylightsummit2016/5f/NETCONF_YANG... · NETCONF/YANG Tutorial Ryan Goulding, Senior Engineer, ... OSS NMS

● Edit-config Payload

<edit-config> <target> <candidate/> </target> <config> <car-info xmlns="urn:opendaylight:car" xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" nc:operation="merge"> <max-speed>220</max-speed> <gaz-tank-state>low</gaz-tank-state> <car-id>1</car-id> </car-info> </config></edit-config>

NETCONF Basics

Page 93: NETCONF YANG Tutorial ODLSummit2016 (1) - Schedschd.ws/hosted_files/opendaylightsummit2016/5f/NETCONF_YANG... · NETCONF/YANG Tutorial Ryan Goulding, Senior Engineer, ... OSS NMS

● Response

<?xml version="1.0" encoding="UTF-8"?><rpc-reply xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="2"> <ok/></rpc-reply>

● Exit the interactive command line (ctl+c)

NETCONF Basics

Page 94: NETCONF YANG Tutorial ODLSummit2016 (1) - Schedschd.ws/hosted_files/opendaylightsummit2016/5f/NETCONF_YANG... · NETCONF/YANG Tutorial Ryan Goulding, Senior Engineer, ... OSS NMS

● Get-config$ /opt/confd/bin/netconf-console-tcp --get-config --db candidate

● Response<?xml version="1.0" encoding="UTF-8"?><rpc-reply xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="1"> <data> <car-info xmlns="urn:opendaylight:car">

<max-speed>220</max-speed><gaz-tank-state>low</gaz-tank-state><car-id>1</car-id></car-info>

</data></rpc-reply>

NETCONF Basics

Page 95: NETCONF YANG Tutorial ODLSummit2016 (1) - Schedschd.ws/hosted_files/opendaylightsummit2016/5f/NETCONF_YANG... · NETCONF/YANG Tutorial Ryan Goulding, Senior Engineer, ... OSS NMS

NETCONF Advanced

Page 96: NETCONF YANG Tutorial ODLSummit2016 (1) - Schedschd.ws/hosted_files/opendaylightsummit2016/5f/NETCONF_YANG... · NETCONF/YANG Tutorial Ryan Goulding, Senior Engineer, ... OSS NMS

Definition language:YANG

Information model:YANG modules

Instantiated data:XML

Transport:Netconf

Definition language:SMIv2

Information model:MIB modules

Instantiated data:ASN.1 BER

Transport: SNMP

Import conversion rules exist(MIBs → YANG)“instant content”

Ability to express hierarchy(compare MIBs: flat + tables)Richer conditions, constraints

Facilities for easier reuseRPC/Action support

Human readabilityDynamic extensibility

B2B, Web toolkits

Bulk vs only incremental ops(manipulation of config files,

e.g. edit-config)Transaction support

Configuration vs monitoringor possibly other(no inherent dependency but

will require different bindings)

NETCONF/YANG vs SNMP

Page 97: NETCONF YANG Tutorial ODLSummit2016 (1) - Schedschd.ws/hosted_files/opendaylightsummit2016/5f/NETCONF_YANG... · NETCONF/YANG Tutorial Ryan Goulding, Senior Engineer, ... OSS NMS

NETCONF Advance

Use Case SNMP NETCONFGet collection of status fields Yes Yes. Bulk xfer up to

10x faster.

Set collection of configuration fields Yes, up to 64kB YesSet configuration fields in transaction No YesTransactions across multiple network elements No Yes

Invoke administrative actions Well… YesSend event notifications Yes Yes, connectedBackup and restore configuration Usually not YesSecure protocol v3 is fair YesTest configuration before final commit No Yes

This is where the difference is:In the supported use cases!

What makes NETCONF better than SNMP?

Page 98: NETCONF YANG Tutorial ODLSummit2016 (1) - Schedschd.ws/hosted_files/opendaylightsummit2016/5f/NETCONF_YANG... · NETCONF/YANG Tutorial Ryan Goulding, Senior Engineer, ... OSS NMS

<rpc message-id="101” xmlns="urn:ietf:params:xml:ns:netconf:base:1.1"> <close-session/></rpc>

<rpc-reply message-id="101” xmlns="urn:ietf:params:xml:ns:netconf:base:1.1"> <ok/></rpc-reply>

All other operations are layered on NETCONF RPCBut ”naked” NETCONF RPC can be used to call a YANG RPC

NETCONF rpc operation

Page 99: NETCONF YANG Tutorial ODLSummit2016 (1) - Schedschd.ws/hosted_files/opendaylightsummit2016/5f/NETCONF_YANG... · NETCONF/YANG Tutorial Ryan Goulding, Senior Engineer, ... OSS NMS

<rpc message-id="101” xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"> <create-subscription xmlns=”urn:ietf:params:xml:ns:netconf:notification:1.0”/></rpc>

<rpc-reply message-id="101” xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"> <ok/></rpc-reply>

NETCONF create-subscription operation

Used to request notifications from a specific stream as per RFC5277Note that RFC5277 pre-dates YANG. 5277bis is on its way…

Page 100: NETCONF YANG Tutorial ODLSummit2016 (1) - Schedschd.ws/hosted_files/opendaylightsummit2016/5f/NETCONF_YANG... · NETCONF/YANG Tutorial Ryan Goulding, Senior Engineer, ... OSS NMS

NETCONF Notification

<notification xmlns="urn:ietf:params:netconf:capability:notification:1.0"><netconf-capability-change xmlns="urn:ietf:params:xml:ns:yang:. . . “>

<changed-by><server/></changed-by><added-capability>. . .</added-capability>

</netconf-capability-change><eventTime>2016-09-21T11:22:52-07:00</eventTime>

</notification>

Used to transport YANG-modelled notificationsUnsolicited (once subscription is created!) – no rpc/rpc-reply

Page 101: NETCONF YANG Tutorial ODLSummit2016 (1) - Schedschd.ws/hosted_files/opendaylightsummit2016/5f/NETCONF_YANG... · NETCONF/YANG Tutorial Ryan Goulding, Senior Engineer, ... OSS NMS

Add functionalities to our NETCONF device

NETCONF Advanced

Page 102: NETCONF YANG Tutorial ODLSummit2016 (1) - Schedschd.ws/hosted_files/opendaylightsummit2016/5f/NETCONF_YANG... · NETCONF/YANG Tutorial Ryan Goulding, Senior Engineer, ... OSS NMS

● RPC

Execute the RPC using the netconf-console in interactive mode

$ /opt/confd/bin/netconf-console-tcp -i

* Enter a NETCONF operation, end with an empty line<get-tank-state xmlns="urn:opendaylight:car">

<car-id>1</car-id></get-tank-state>

NETCONF Advanced

Page 103: NETCONF YANG Tutorial ODLSummit2016 (1) - Schedschd.ws/hosted_files/opendaylightsummit2016/5f/NETCONF_YANG... · NETCONF/YANG Tutorial Ryan Goulding, Senior Engineer, ... OSS NMS

● RPC response “Not yet implemented”

● Implement RPC callback with ConfD

Use Tail-f exec callback

● Add this import in the car.yang

import tailf-common { prefix tailf; }

NETCONF Advanced

Page 104: NETCONF YANG Tutorial ODLSummit2016 (1) - Schedschd.ws/hosted_files/opendaylightsummit2016/5f/NETCONF_YANG... · NETCONF/YANG Tutorial Ryan Goulding, Senior Engineer, ... OSS NMS

● Add the following lines to the RPC we created previously

rpc get-tank-state { tailf:exec "/opt/confd/etc/confd/get-tank-state.sh" { tailf:args "-c $(context)"; } input { leaf car-id { type uint8; } } output { leaf current-trank-state { type trank-state; } }}

NETCONF Advanced

Page 105: NETCONF YANG Tutorial ODLSummit2016 (1) - Schedschd.ws/hosted_files/opendaylightsummit2016/5f/NETCONF_YANG... · NETCONF/YANG Tutorial Ryan Goulding, Senior Engineer, ... OSS NMS

● Get into the schema folder

$ cd /opt/confd/etc/confd

● Create the callback script get-tank-state.sh

$ vi get-tank-state.sh

● Add the following into the file, “medium” will be the output

#!/bin/shmesg=mediumecho "current-trank-state $mesg"

NETCONF Advanced

Page 106: NETCONF YANG Tutorial ODLSummit2016 (1) - Schedschd.ws/hosted_files/opendaylightsummit2016/5f/NETCONF_YANG... · NETCONF/YANG Tutorial Ryan Goulding, Senior Engineer, ... OSS NMS

● Regenerate car.fxs

$ rm car.fxs$ /opt/confd/bin/confdc -c car.yang

● Stop and restart ConfD so it takes it in account:

$ /opt/confd/bin/confd --stop$ /opt/confd/bin/confd --start-phase0$ /opt/confd/bin/confd --start-phase1$ /opt/confd/bin/confd --start-phase2

NETCONF Advanced

Page 107: NETCONF YANG Tutorial ODLSummit2016 (1) - Schedschd.ws/hosted_files/opendaylightsummit2016/5f/NETCONF_YANG... · NETCONF/YANG Tutorial Ryan Goulding, Senior Engineer, ... OSS NMS

● Make the script executable

$ chmod +x get-tank-state.sh

● Execute the RPC again

$ /opt/confd/bin/netconf-console-tcp -i

* Enter a NETCONF operation, end with an empty line<get-tank-state xmlns="urn:opendaylight:car">

<car-id>1</car-id></get-tank-state>

NETCONF Advanced

Page 108: NETCONF YANG Tutorial ODLSummit2016 (1) - Schedschd.ws/hosted_files/opendaylightsummit2016/5f/NETCONF_YANG... · NETCONF/YANG Tutorial Ryan Goulding, Senior Engineer, ... OSS NMS

● RPC Response<?xml version="1.0" encoding="UTF-8"?><rpc-reply xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="2"> <current-trank-state xmlns="urn:opendaylight:car">medium</current-trank-state></rpc-reply>

NETCONF Advanced

Page 109: NETCONF YANG Tutorial ODLSummit2016 (1) - Schedschd.ws/hosted_files/opendaylightsummit2016/5f/NETCONF_YANG... · NETCONF/YANG Tutorial Ryan Goulding, Senior Engineer, ... OSS NMS

● Notification (rfc5277)

Requires notifications.yanghttp://www.netconfcentral.org/modulereport/notifications

Payload <create-subscription xmlns="urn:ietf:params:xml:ns:netconf:notification:1.0">

<stream>YOUR-DEFINED-STREAM</stream> </create-subscription>

NETCONF Advanced

Page 110: NETCONF YANG Tutorial ODLSummit2016 (1) - Schedschd.ws/hosted_files/opendaylightsummit2016/5f/NETCONF_YANG... · NETCONF/YANG Tutorial Ryan Goulding, Senior Engineer, ... OSS NMS

● Notification definition (YANG)notification out-of-gas {

description "This notification is sent to signal that the car is out of gas"; leaf temperature-alarm { type leafref { path "/car-info/gaz-tank-state"; } mandatory true; }}

NETCONF Advanced

Page 111: NETCONF YANG Tutorial ODLSummit2016 (1) - Schedschd.ws/hosted_files/opendaylightsummit2016/5f/NETCONF_YANG... · NETCONF/YANG Tutorial Ryan Goulding, Senior Engineer, ... OSS NMS

● Register the stream in ConfD

Modify the confd.conf

● Define the notification callback with ConfD

Create the callback (c)

NETCONF Advanced

Page 112: NETCONF YANG Tutorial ODLSummit2016 (1) - Schedschd.ws/hosted_files/opendaylightsummit2016/5f/NETCONF_YANG... · NETCONF/YANG Tutorial Ryan Goulding, Senior Engineer, ... OSS NMS

OpenDaylight NETCONF/YANG and RESTCONF

Page 113: NETCONF YANG Tutorial ODLSummit2016 (1) - Schedschd.ws/hosted_files/opendaylightsummit2016/5f/NETCONF_YANG... · NETCONF/YANG Tutorial Ryan Goulding, Senior Engineer, ... OSS NMS

MD-SAL

NETCONF

RESTCONF

Node Inventory

• Nodes added by through the config subsystem• ODL connects to each node• ODL learns capabilities (YANG modules) and stores to model cache• Cache at ~/cache/schema (filenames of form [email protected])

Model Cache

XR1 XR2 OpenWRT

Mounting a NETCONF device in ODL

Page 114: NETCONF YANG Tutorial ODLSummit2016 (1) - Schedschd.ws/hosted_files/opendaylightsummit2016/5f/NETCONF_YANG... · NETCONF/YANG Tutorial Ryan Goulding, Senior Engineer, ... OSS NMS

RESTCONF

Page 115: NETCONF YANG Tutorial ODLSummit2016 (1) - Schedschd.ws/hosted_files/opendaylightsummit2016/5f/NETCONF_YANG... · NETCONF/YANG Tutorial Ryan Goulding, Senior Engineer, ... OSS NMS

RESTCONF URIs

Page 116: NETCONF YANG Tutorial ODLSummit2016 (1) - Schedschd.ws/hosted_files/opendaylightsummit2016/5f/NETCONF_YANG... · NETCONF/YANG Tutorial Ryan Goulding, Senior Engineer, ... OSS NMS

RESTCONF to mounted NETCONF device

Page 117: NETCONF YANG Tutorial ODLSummit2016 (1) - Schedschd.ws/hosted_files/opendaylightsummit2016/5f/NETCONF_YANG... · NETCONF/YANG Tutorial Ryan Goulding, Senior Engineer, ... OSS NMS

Mount your running ConfD instance

● Start OpenDaylight (Boron release)

$ sudo ./Training/opendaylight/distribution-karaf-0.5.0/bin/karaf

● Install the NETCONF CLI feature

opendaylight-user@root> feature:install odl-netconf-console

● Mount the ConfD device

opendaylight-user@root>netconf:connect-device --port 2022 --password admin -id confd -U admin -t false -i 10.0.2.15

OpenDaylight NETCONF/YANG and RESTCONF

Page 118: NETCONF YANG Tutorial ODLSummit2016 (1) - Schedschd.ws/hosted_files/opendaylightsummit2016/5f/NETCONF_YANG... · NETCONF/YANG Tutorial Ryan Goulding, Senior Engineer, ... OSS NMS

Mount your running ConfD instance

● List all NETCONF devices

opendaylight-user@root>netconf:list-devices

● Show our NETCONF device attributes

opendaylight-user@root>netconf:show-device -id confd

● For more info on the CLI: https://wiki.opendaylight.org/view/NETCONF:Karaf_CLI

OpenDaylight NETCONF/YANG and RESTCONF

Page 119: NETCONF YANG Tutorial ODLSummit2016 (1) - Schedschd.ws/hosted_files/opendaylightsummit2016/5f/NETCONF_YANG... · NETCONF/YANG Tutorial Ryan Goulding, Senior Engineer, ... OSS NMS

From YANG to APIs

● Use web interface apidoc

opendaylight-user@root>feature:install odl-mdsal-apidocs

→ http://localhost:8181/apidoc/explorer/index.html

● Use web interface yang-ui

opendaylight-user@root>feature:install odl-dlux-yangui

→ http://localhost:8181/index.html#/yangui/index

OpenDaylight NETCONF/YANG and RESTCONF

Page 120: NETCONF YANG Tutorial ODLSummit2016 (1) - Schedschd.ws/hosted_files/opendaylightsummit2016/5f/NETCONF_YANG... · NETCONF/YANG Tutorial Ryan Goulding, Senior Engineer, ... OSS NMS

Mount through VPN a device from dCloud

OpenDaylight NETCONF/YANG and RESTCONF

Page 121: NETCONF YANG Tutorial ODLSummit2016 (1) - Schedschd.ws/hosted_files/opendaylightsummit2016/5f/NETCONF_YANG... · NETCONF/YANG Tutorial Ryan Goulding, Senior Engineer, ... OSS NMS

Troubleshooting

Page 122: NETCONF YANG Tutorial ODLSummit2016 (1) - Schedschd.ws/hosted_files/opendaylightsummit2016/5f/NETCONF_YANG... · NETCONF/YANG Tutorial Ryan Goulding, Senior Engineer, ... OSS NMS

● Basic Process (flow chart)

● Example case and ask the audience how to go about troubleshooting

● Common NETCONF issues and solutions

Troubleshooting

Page 123: NETCONF YANG Tutorial ODLSummit2016 (1) - Schedschd.ws/hosted_files/opendaylightsummit2016/5f/NETCONF_YANG... · NETCONF/YANG Tutorial Ryan Goulding, Senior Engineer, ... OSS NMS

● Basic Process (flow chart)

● Example case and ask the audience how to go about troubleshooting

● Common NETCONF issues and solutions

Troubleshooting

Page 124: NETCONF YANG Tutorial ODLSummit2016 (1) - Schedschd.ws/hosted_files/opendaylightsummit2016/5f/NETCONF_YANG... · NETCONF/YANG Tutorial Ryan Goulding, Senior Engineer, ... OSS NMS

Basic Process (flow chart)

Page 125: NETCONF YANG Tutorial ODLSummit2016 (1) - Schedschd.ws/hosted_files/opendaylightsummit2016/5f/NETCONF_YANG... · NETCONF/YANG Tutorial Ryan Goulding, Senior Engineer, ... OSS NMS

● Basic troubleshooting for NETCONF mount process (flow chart)

● Example Case

● Common NETCONF issues and solutions

Troubleshooting

Page 126: NETCONF YANG Tutorial ODLSummit2016 (1) - Schedschd.ws/hosted_files/opendaylightsummit2016/5f/NETCONF_YANG... · NETCONF/YANG Tutorial Ryan Goulding, Senior Engineer, ... OSS NMS

● Start the controller

● Mount the controller so it is accessible via RESTCONF

● Break a model

● Restart the controller

● Query the operational network-topology

Example Case

Page 127: NETCONF YANG Tutorial ODLSummit2016 (1) - Schedschd.ws/hosted_files/opendaylightsummit2016/5f/NETCONF_YANG... · NETCONF/YANG Tutorial Ryan Goulding, Senior Engineer, ... OSS NMS

● Start the controller

● Mount the controller so it is accessible via RESTCONF

● Break a model

● Restart the controller

● Query the operational network-topology

Example Case

Page 128: NETCONF YANG Tutorial ODLSummit2016 (1) - Schedschd.ws/hosted_files/opendaylightsummit2016/5f/NETCONF_YANG... · NETCONF/YANG Tutorial Ryan Goulding, Senior Engineer, ... OSS NMS

● Open “Terminal Emulator” from the VM Desktop.

Start the controller

Page 129: NETCONF YANG Tutorial ODLSummit2016 (1) - Schedschd.ws/hosted_files/opendaylightsummit2016/5f/NETCONF_YANG... · NETCONF/YANG Tutorial Ryan Goulding, Senior Engineer, ... OSS NMS

● Start the controller

● Mount the controller so it is accessible via RESTCONF

● Break a model

● Restart the controller

● Query the operational network-topology

Example Case

Page 130: NETCONF YANG Tutorial ODLSummit2016 (1) - Schedschd.ws/hosted_files/opendaylightsummit2016/5f/NETCONF_YANG... · NETCONF/YANG Tutorial Ryan Goulding, Senior Engineer, ... OSS NMS

● Start the controller

● Mount the controller so it is accessible via RESTCONF

● Break a model

● Restart the controller

● Query the operational network-topology

Example Case

Page 131: NETCONF YANG Tutorial ODLSummit2016 (1) - Schedschd.ws/hosted_files/opendaylightsummit2016/5f/NETCONF_YANG... · NETCONF/YANG Tutorial Ryan Goulding, Senior Engineer, ... OSS NMS

● Start the controller

● Mount the controller so it is accessible via RESTCONF

● Break a model

● Restart the controller

● Query the operational network-topology

Example Case

Page 132: NETCONF YANG Tutorial ODLSummit2016 (1) - Schedschd.ws/hosted_files/opendaylightsummit2016/5f/NETCONF_YANG... · NETCONF/YANG Tutorial Ryan Goulding, Senior Engineer, ... OSS NMS

● Start the controller

● Mount the controller so it is accessible via RESTCONF

● Break a model

● Restart the controller

● Query the operational network-topology

Example Case

Page 133: NETCONF YANG Tutorial ODLSummit2016 (1) - Schedschd.ws/hosted_files/opendaylightsummit2016/5f/NETCONF_YANG... · NETCONF/YANG Tutorial Ryan Goulding, Senior Engineer, ... OSS NMS

● Basic troubleshooting for NETCONF mount process (flow chart)

● Example Case

● Common NETCONF issues and solutions

Troubleshooting

Page 134: NETCONF YANG Tutorial ODLSummit2016 (1) - Schedschd.ws/hosted_files/opendaylightsummit2016/5f/NETCONF_YANG... · NETCONF/YANG Tutorial Ryan Goulding, Senior Engineer, ... OSS NMS

Tooling, References etc.

Page 135: NETCONF YANG Tutorial ODLSummit2016 (1) - Schedschd.ws/hosted_files/opendaylightsummit2016/5f/NETCONF_YANG... · NETCONF/YANG Tutorial Ryan Goulding, Senior Engineer, ... OSS NMS

“Compile-Time” Tooling

Editor plug-ins:• emacs (yang-mode.el)• vim (yang.vim)• sublime text (sublime-yang-syntax)

pyang• an extensible YANG validator written in Python. • can be used standalone to validate YANG modules, or to translate YANG to YIN, XSD,

DSDL etc.• can be integrated into other applications

libsmi• a library allowing the generation of YANG models from SMI/SMIv2 compliant MIBs• has a variety of supporting tools available for generation, debug etc.

Page 136: NETCONF YANG Tutorial ODLSummit2016 (1) - Schedschd.ws/hosted_files/opendaylightsummit2016/5f/NETCONF_YANG... · NETCONF/YANG Tutorial Ryan Goulding, Senior Engineer, ... OSS NMS

“Run-Time” Tooling

ncclienta Python library that facilitates client-side scripting and application development around the NETCONF protocol

Postman• a Chrome app for REST APIs, allowing for customized sets of REST snippets to be easily

built, maintained and shared• Useful for accessing ODL RESTCONF APIs

OpenDaylight• ODL auto-generates RESTCONF and NETCONF APIs from YANG models• apidocs provides a way to explore both local and mounted YANG models• YANG-UI provides a model-driven WEB UI for exploring YANG models• YANGman is a YANG-aware Postman equivalent

Page 137: NETCONF YANG Tutorial ODLSummit2016 (1) - Schedschd.ws/hosted_files/opendaylightsummit2016/5f/NETCONF_YANG... · NETCONF/YANG Tutorial Ryan Goulding, Senior Engineer, ... OSS NMS

Thanks


Recommended