SlideShare a Scribd company logo
YANG Tutorial – part 2
Presented by Tail-f
MAY 27, 2013 2©2013 TAIL-F all rights reserved
TUTORIAL: NETCONF AND YANG
Advanced YANG Statements
MAY 27, 2013 3©2013 TAIL-F all rights reserved
TUTORIAL: NETCONF AND YANG
Must Statement
Restricts valid values by Xpath 1.0 expression
container timeout {
leaf access-timeout {
description "Maximum time without server response";
units seconds;
mandatory true;
type uint32;
}
leaf retry-timer {
description "Period to retry operation";
units seconds;
type uint32;
must ”current() < ../access-timeout" {
error-app-tag retry-timer-invalid;
error-message "The retry timer must be "
+ "less than the access timeout";
}
}
}
MAY 27, 2013 4©2013 TAIL-F all rights reserved
TUTORIAL: NETCONF AND YANG
Must Statement
leaf interface-group-name {
type string {
length "1..31";
pattern "[a-zA-Z][a-zA-Z0-9_-]*";
}
must "not(/sys:sys/interface[name = current()])" {
error-message ”Must be different from all interface names";
tailf:dependency "/sys:sys/interface/name";
}
}
MAY 27, 2013 5©2013 TAIL-F all rights reserved
TUTORIAL: NETCONF AND YANG
Must Statement
leaf max-weight {
type uint32 {
range "0..1000";
}
default 100;
must "sum(/sys:sys/interface[enabled = 'true']/weight)
< current()" {
error-message "The total weight exceeds the configured
max weight";
}
}
MAY 27, 2013 6©2013 TAIL-F all rights reserved
TUTORIAL: NETCONF AND YANG
Augment Statement
augment /sys:system/sys:user {
leaf expire {
type yang:date-and-time;
}
}
user
name classfull-nameuid expire
+
Default
MAY 27, 2013 7©2013 TAIL-F all rights reserved
TUTORIAL: NETCONF AND YANG
When Statement
augment /sys:system/sys:user {
when ”sys:class = ‘wheel’";
leaf shell {
type string;
}
}
user
name classfull-nameuid expire
+
Default
shell
When
MAY 27, 2013 8©2013 TAIL-F all rights reserved
TUTORIAL: NETCONF AND YANG
Choice Statement
Choice allows one of several
alternatives
choice transfer-method {
leaf transfer-interval {
description "Frequency at which file transfer happens";
type uint16 {
range "15 .. 2880";
}
units minutes;
}
leaf transfer-on-commit {
description "Transfer after each commit";
type empty;
}
}
transfer-interval
transfer-on-commit
transfer-method
MAY 27, 2013 9©2013 TAIL-F all rights reserved
TUTORIAL: NETCONF AND YANG
Choice Statement
Each alternative may consist of multiple definitions
• Either as a named or anonymous group
choice counters {
case four-counters {
leaf threshold {…}
leaf ignore-count {…}
leaf ignore-time {…}
leaf reset-time {…}
}
container warning-only {
…
}
default four-counters;
}
MAY 27, 2013 10©2013 TAIL-F all rights reserved
TUTORIAL: NETCONF AND YANG
Identity Statement
Identities for modeling families of related enumeration constants
module phys-if {
…
identity ethernet {
description
"Ethernet family of PHY
interfaces";
}
identity eth-1G {
base ethernet;
description "1 GigEth";
}
identity eth-10G {
base ethernet;
description "10 GigEth";
}
module newer {
…
identity eth-40G {
base phys-if:ethernet;
description "40 GigEth";
}
identity eth-100G {
base phys-if:ethernet;
description "100 GigEth";
}
…
leaf eth-type {
type identityref {
base ”phys-if:ethernet";
}
}
MAY 27, 2013 11©2013 TAIL-F all rights reserved
TUTORIAL: NETCONF AND YANG
Feature Statement
Mark data as conditional
feature has-local-disk {
description
“System has a local file
system that can be used
for storing log files”;
}
container system {
container logging {
if-feature has-local-disk;
presence “Logging enabled”;
leaf buffer-size {
type filesize;
}
}
}
system
logging
buffer-size
Feature, Presence
The features supported by a system are
meant to stay relatively constant. Adding
a feature is comparable to a hardware
upgrade.
MAY 27, 2013 12©2013 TAIL-F all rights reserved
TUTORIAL: NETCONF AND YANG
Deviations
Systems should conform to standard YANG models
• Still, if a device can’t, that can be properly declared
deviation /base:system/base:user/base:type {
deviate add {
default "admin"; // new users are 'admin' by default
}
}
deviation /base:system/base:name-server {
deviate replace {
max-elements 3;
}
}
MAY 27, 2013 13©2013 TAIL-F all rights reserved
TUTORIAL: NETCONF AND YANG
YANG Modeling Strategy
MAY 27, 2013 14©2013 TAIL-F all rights reserved
TUTORIAL: NETCONF AND YANG
Constraints
• On-board XPATH parser not required
• XPATH is more formal than English, that’s all
• Debate: “Configuration validity must not depend on state”
• Are operators right?
• What are the implications?
• min-elements
• max-elements
• range
• key/unique
• leafref
• must
• when
MAY 27, 2013 15©2013 TAIL-F all rights reserved
TUTORIAL: NETCONF AND YANG
Structure
• Model to mimic an existing interface?
• Model for which interfaces?
• YANG for NETCONF only?
• All interfaces uses the YANG model?
• Multiple models with transformations?
• Multiple models that allow writing?
• What goes in each namespace?
• One, a few or many namespaces?
• No configuration inside operational data
• SNMP transient configuration
MAY 27, 2013 16©2013 TAIL-F all rights reserved
TUTORIAL: NETCONF AND YANG
So what is configuration?
• What is in the factory default?
• Any probing at system boot?
• Do you want pre-provisioning?
• Do you want to support rollbacks?
• Inserting a board, is that an act of configuration?
• Do you need spontaneous reconfiguration?
• Where does the configuration data originate from?
MAY 27, 2013 17©2013 TAIL-F all rights reserved
TUTORIAL: NETCONF AND YANG
VersioningYANG Modules
You must / must not:
• Add a revision statement on
top
• Update organization, contact,
etc
• Do not rename module or
namespace
• Do not remove obsolete
definitions
• Do not reorder data
definitions
You may:
• Add enum, bits, typedef,
grouping, rpc, notification,
extension, feature, identity,
case
• Add non-mandatory data
definitions
• Add mandatory data
definitions within new if-
feature statements
 RFC 6020 sec 10
MAY 27, 2013 18©2013 TAIL-F all rights reserved
TUTORIAL: NETCONF AND YANG
VersioningYANG Modules (cont’d)
You may:
• Add or update a status
statement: current 
deprecated  obsolete
• Expand allowed range, length,
pattern
• Add a default
(but not change it!)
• Add units, add or update a
reference
You may:
• Change mandatory to false (or
remove it)
• Remove or relax min- & max-
elements
• Add or clarify a description
without changing the
semantics
• Change state data to optional
configuration
• Remove an if-feature
MAY 27, 2013 19©2013 TAIL-F all rights reserved
TUTORIAL: NETCONF AND YANG
IETF Modeling Recommendations
• Describe
• Module, security considerations, references, definitions, …
• Top level
• Only one data definition (typ. container) on top level
• Top level data definitions optional
• Enumerations that grow
• Use identityref instead of enumeration
MAY 27, 2013 20©2013 TAIL-F all rights reserved
TUTORIAL: NETCONF AND YANG
IETF Modeling Recommendations
• Specific types
• Use ranges, length restrictions, patterns
• Do not use signed types unless negative values needed
• Standard types
• When possible, use standard types,
e.g. ‘yang-types’ defined in RFC 6021
• Make your own reusable ‘type modules’
MAY 27, 2013 21©2013 TAIL-F all rights reserved
TUTORIAL: NETCONF AND YANG
Yin, YANG and YANG Extensions
MAY 27, 2013 22©2013 TAIL-F all rights reserved
TUTORIAL: NETCONF AND YANG
Yin – the XML representation of YANG
YANG 日
container dhcp {
leaf defaultLeaseTime {
type xs:duration;
default PT600S;
}
leaf maxLeaseTime {
type xs:duration;
default PT7200S;
}
leaf logFacility {
type loglevel;
default local7;
}
Yin 月
<container name="dhcp">
<leaf name="defaultLeaseTime">
<type name="xs:duration"/>
<default value="PT600S"/>
</leaf>
<leaf name="maxLeaseTime">
<type name="xs:duration"/>
<default value="PT7200S”/>
</leaf>
<leaf name="logFacility">
<type name="loglevel"/>
<default value="local7"/>
</leaf>
Lossless
Lossless
MAY 27, 2013 23©2013 TAIL-F all rights reserved
TUTORIAL: NETCONF AND YANG
YANG Extensions - Prototype
module prototype {
namespace "http://tail-f.com…
prefix prototype;
extension create {
argument keylist;
}
extension value {
argument value;
}
extension keylist-value {
argument keylist-value;
}
}
module xyz {
list y {
config false;
tailf:cdb-oper;
prototype:create "b=1,c=0";
prototype:create "b=6,c=0";
prototype:create "b=6,c=1";
key "b c";
leaf b { type int32; }
leaf c { type int32; }
leaf d {
type string;
prototype:keylist-value
"b=1,c=0,cool";
prototype:keylist-value
"b=6,c=1,green";
}
MAY 27, 2013 24©2013 TAIL-F all rights reserved
TUTORIAL: NETCONF AND YANG
YANG Extensions - Prototype
c "/xyz:x/xyz:y{1 0}"
c "/xyz:x/xyz:y{6 0}"
c "/xyz:x/xyz:y{6 1}"
s "/xyz:x/xyz:y{1 0}/xyz:d" "cool"
s "/xyz:x/xyz:y{6 1}/xyz:d" "green"
ubuntu# show x
B C D
-------------
1 0 cool
6 0 -
6 1 green
Prototype
.yang
XYZ
.yang
XYZ
init
data
XYZ
pyang
confdc
prototype.py
MAY 27, 2013 25©2013 TAIL-F all rights reserved
TUTORIAL: NETCONF AND YANG
Example:
Router Device Model (part of)
MAY 27, 2013 26©2013 TAIL-F all rights reserved
TUTORIAL: NETCONF AND YANG
Example: Quagga Types
submodule quagga_common {
belongs-to quagga {
prefix quagga;
}
…
include quagga_top;
typedef PrefixLengthIPv4 {
type uint8 { range 0 .. 32; }
}
…
grouping inetNetworkAddressIPv4 {
leaf address {
type inet:ipv4-address;
mandatory true;
}
leaf prefix-length {
type PrefixLengthIPv4;
mandatory true;
}
}
typedef MacAddressType {
type string {
length 17;
pattern "([0-9a-fA-F][0-9a-fA-F]:){5}
([0-9a-fA-F][0-9a-fA-F])";
}
}
typedef ACLLowRangeType {
type uint32 { range 1 .. 99; }
}
typedef ACLHighRangeType {
type uint32 { range 1300 .. 1999; }
}
typedef ACLExtType {
type union {
type ACLExtLowRangeType;
type ACLExtHighRangeType;
}
}
typedef InfiniteType {
type enumeration {
enum infinite;
}
}
typedef DateTimeInfiniteType {
type union {
type yang:date-and-time;
type InfiniteType;
}
}
MAY 27, 2013 27©2013 TAIL-F all rights reserved
TUTORIAL: NETCONF AND YANG
Example: Quagga Interface Configuration
submodule zebra_confd_if {
belongs-to quagga {
prefix quagga;
}
include confd_top;
include confd_common;
typedef BandwidthRangeType {
type uint64 { range "1 .. 10000000000"; }
}
augment "/system/interface" {
leaf bandwidth {
type BandwidthRangeType;
}
leaf link-detect {
type boolean;
default false;
}
leaf multicast {
type MulticastType;
default if-default;
}
leaf up {
type boolean;
default true;
}
}
}
submodule zebra_confd_if_ip {
belongs-to quagga {
prefix quagga;
}
import ietf-inet-types {
prefix inet;
}
include confd_top;
include confd_common;
augment "/system/interface/ip" {
list address {
key "address prefix-length";
leaf address {
type inet:ipv4-address;
}
leaf prefix-length {
type PrefixLengthIPv4;
}
leaf label {
type string;
}
}
}
}
MAY 27, 2013 28©2013 TAIL-F all rights reserved
TUTORIAL: NETCONF AND YANG
Example: Quagga Status & Notification
submodule zebra_confd_stats_memory {
belongs-to quagga {
prefix quagga;
}
import tailf-common {
prefix tailf;
}
include confd_top;
include confd_common;
augment "/system/stats/memory" {
container zebra {
config false;
tailf:callpoint "zebraGetMemory";
uses memoryStatusType;
}
}
}
notification saExpired {
leaf tunnelName {
type leafref {
path "/system/vpn/ipsec/tunnel/name";
}
mandatory true;
}
leaf spi {
type int64;
mandatory true;
}
}
MAY 27, 2013 29©2013 TAIL-F all rights reserved
TUTORIAL: NETCONF AND YANG
Example:
Q-in-Q Service Model
MAY 27, 2013 30©2013 TAIL-F all rights reserved
TUTORIAL: NETCONF AND YANG
Example: Q-in-Q Service Model (complete)
module qinq-service {
namespace "http://com/example/qinq-service";
prefix qinq;
import tailf-common { prefix tailf; }
import tailf-ncs { prefix ncs; }
list qinq {
key name;
leaf name { type string; }
leaf s-vlan {
mandatory true;
type uint32 { range 1..4094; }
}
must "not (/qt:qinq[name != current()/name]
[s-vlan = current()/s-vlan])” {
error-message "The s-vlan must be unique within
the network”
}
list edge-switch {
key switch;
leaf switch {
type leafref {path /ncs:devices/ncs:device/ncs:name;}
}
list edge-interface {
key interface;
leaf interface { type string; }
leaf-list c-vlan {
type uint32 { range 1..4094; }
}
}
leaf-list trunk-interface {
min-elements 1;
type string;
}
}
list core-switch {
key switch;
leaf switch {
type leafref {path /ncs:devices/ncs:device/ncs:name;}
}
leaf-list trunk-interface {
min-elements 1;
type string;
}
}
}
}
Module 6: YANG Tutorial - part 2

More Related Content

What's hot (20)

PPTX
Java Spring framework, Dependency Injection, DI, IoC, Inversion of Control
Arjun Thakur
 
PDF
Apache Nifi Crash Course
DataWorks Summit
 
PPTX
ConfD で Linux にNetconfを喋らせてみた
Akira Iwamoto
 
PDF
Apache Airflow Architecture
Gerard Toonstra
 
PPTX
Tail f - Why ConfD
Tail-f Systems
 
PDF
Introducing Confluent labs Parallel Consumer client | Anthony Stubbes, Confluent
HostedbyConfluent
 
PPTX
Airflow - a data flow engine
Walter Liu
 
PDF
Git flow
Valerio Como
 
PDF
Apache Airflow
Sumit Maheshwari
 
PDF
Introduction to Apache Airflow
mutt_data
 
PDF
Git flow Introduction
David Paluy
 
PDF
Stream Processing with Flink and Stream Sharing
confluent
 
PDF
Monitoring Kafka without instrumentation using eBPF with Antón Rodríguez | Ka...
HostedbyConfluent
 
PDF
Introduction to Spring's Dependency Injection
Richard Paul
 
PPTX
Apache Airflow overview
NikolayGrishchenkov
 
PPTX
How to Introduce Telemetry Streaming (gNMI) in Your Network with SNMP with Te...
InfluxData
 
PDF
InnoDB Locking Explained with Stick Figures
Karwin Software Solutions LLC
 
PPTX
Tutorial: Using GoBGP as an IXP connecting router
Shu Sugimoto
 
PDF
Spring boot introduction
Rasheed Waraich
 
PDF
Helm 3
Matthew Farina
 
Java Spring framework, Dependency Injection, DI, IoC, Inversion of Control
Arjun Thakur
 
Apache Nifi Crash Course
DataWorks Summit
 
ConfD で Linux にNetconfを喋らせてみた
Akira Iwamoto
 
Apache Airflow Architecture
Gerard Toonstra
 
Tail f - Why ConfD
Tail-f Systems
 
Introducing Confluent labs Parallel Consumer client | Anthony Stubbes, Confluent
HostedbyConfluent
 
Airflow - a data flow engine
Walter Liu
 
Git flow
Valerio Como
 
Apache Airflow
Sumit Maheshwari
 
Introduction to Apache Airflow
mutt_data
 
Git flow Introduction
David Paluy
 
Stream Processing with Flink and Stream Sharing
confluent
 
Monitoring Kafka without instrumentation using eBPF with Antón Rodríguez | Ka...
HostedbyConfluent
 
Introduction to Spring's Dependency Injection
Richard Paul
 
Apache Airflow overview
NikolayGrishchenkov
 
How to Introduce Telemetry Streaming (gNMI) in Your Network with SNMP with Te...
InfluxData
 
InnoDB Locking Explained with Stick Figures
Karwin Software Solutions LLC
 
Tutorial: Using GoBGP as an IXP connecting router
Shu Sugimoto
 
Spring boot introduction
Rasheed Waraich
 

Viewers also liked (12)

PPTX
Module 9: CDB Technical Intro
Tail-f Systems
 
PPTX
Module 3: NETCONF and YANG Concepts
Tail-f Systems
 
PPTX
Tail-f - Why NETCONF
Tail-f Systems
 
PPTX
Module 11: Operational Data Providers
Tail-f Systems
 
PPTX
Module 12: NETCONF Northbound Interface
Tail-f Systems
 
PPTX
Module 8: C Data Types
Tail-f Systems
 
PDF
Open Network OS Overview as of 2015/10/16
Kentaro Ebisawa
 
PDF
Tail-f Webinar OpenFlow Switch Management Using NETCONF and YANG
Tail-f Systems
 
PDF
Webinar: Applying REST to Network Management – An Implementor’s View
Tail-f Systems
 
PDF
Dynamic Service Chaining
Tail-f Systems
 
PPTX
Module 1: ConfD Technical Introduction
Tail-f Systems
 
PPTX
Module 7: Installation and Getting Started
Tail-f Systems
 
Module 9: CDB Technical Intro
Tail-f Systems
 
Module 3: NETCONF and YANG Concepts
Tail-f Systems
 
Tail-f - Why NETCONF
Tail-f Systems
 
Module 11: Operational Data Providers
Tail-f Systems
 
Module 12: NETCONF Northbound Interface
Tail-f Systems
 
Module 8: C Data Types
Tail-f Systems
 
Open Network OS Overview as of 2015/10/16
Kentaro Ebisawa
 
Tail-f Webinar OpenFlow Switch Management Using NETCONF and YANG
Tail-f Systems
 
Webinar: Applying REST to Network Management – An Implementor’s View
Tail-f Systems
 
Dynamic Service Chaining
Tail-f Systems
 
Module 1: ConfD Technical Introduction
Tail-f Systems
 
Module 7: Installation and Getting Started
Tail-f Systems
 
Ad

Similar to Module 6: YANG Tutorial - part 2 (20)

PPTX
Learning netconf yang from scratch
Telematika Open Session
 
PDF
Using Netconf/Yang with OpenDalight
Глеб Хохлов
 
PDF
Netconf yang
Telematika Open Session
 
PDF
Yang in OpenDaylight
Gunjan Patel
 
PDF
Yang in ODL by Jan Medved
OpenDaylight
 
PPTX
Getting started with YANG
CoreStack
 
PPTX
TIAD 2016 : Network automation with Ansible and OpenConfig/YANG
The Incredible Automation Day
 
PPTX
DEVNET-1152 OpenDaylight YANG Model Overview and Tools
Cisco DevNet
 
PPTX
IoT Heaps 3
SushrutaMishra1
 
PPTX
IoT System Management.pptx
DrFaridaAshrafAli
 
PPTX
Dynamic Service Configuration and Automated Network Configuration with NETCON...
Tail-f Systems
 
PPTX
Io t system management with
xyxz
 
PDF
ietf117-netconf-yang-push-data-mesh-integration.pdf
ThomasGraf42
 
PPTX
IOT-Network Management.pptx
V.V.Vanniaperumal College for Women
 
PDF
netconf and yang
pavan penugonda
 
PPTX
IOT System Management with NETCONF-YANG.pptx
ArchanaPandiyan
 
PPTX
Untitled presentation (2).pptx
ArchanaPandiyan
 
PPTX
ietf115-network-telemetry-data-mesh-challenges.pptx
ThomasGraf40
 
PPTX
YANG (哪)
Amey Borkar
 
PDF
Chapter-4.pdf
ssuser01a3d0
 
Learning netconf yang from scratch
Telematika Open Session
 
Using Netconf/Yang with OpenDalight
Глеб Хохлов
 
Yang in OpenDaylight
Gunjan Patel
 
Yang in ODL by Jan Medved
OpenDaylight
 
Getting started with YANG
CoreStack
 
TIAD 2016 : Network automation with Ansible and OpenConfig/YANG
The Incredible Automation Day
 
DEVNET-1152 OpenDaylight YANG Model Overview and Tools
Cisco DevNet
 
IoT Heaps 3
SushrutaMishra1
 
IoT System Management.pptx
DrFaridaAshrafAli
 
Dynamic Service Configuration and Automated Network Configuration with NETCON...
Tail-f Systems
 
Io t system management with
xyxz
 
ietf117-netconf-yang-push-data-mesh-integration.pdf
ThomasGraf42
 
IOT-Network Management.pptx
V.V.Vanniaperumal College for Women
 
netconf and yang
pavan penugonda
 
IOT System Management with NETCONF-YANG.pptx
ArchanaPandiyan
 
Untitled presentation (2).pptx
ArchanaPandiyan
 
ietf115-network-telemetry-data-mesh-challenges.pptx
ThomasGraf40
 
YANG (哪)
Amey Borkar
 
Chapter-4.pdf
ssuser01a3d0
 
Ad

Recently uploaded (20)

PPTX
The Project Compass - GDG on Campus MSIT
dscmsitkol
 
DOCX
Cryptography Quiz: test your knowledge of this important security concept.
Rajni Bhardwaj Grover
 
PDF
IoT-Powered Industrial Transformation – Smart Manufacturing to Connected Heal...
Rejig Digital
 
PDF
Jak MŚP w Europie Środkowo-Wschodniej odnajdują się w świecie AI
dominikamizerska1
 
PDF
Transcript: New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
PPTX
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
PDF
Empower Inclusion Through Accessible Java Applications
Ana-Maria Mihalceanu
 
PDF
CIFDAQ Market Wrap for the week of 4th July 2025
CIFDAQ
 
PDF
Biography of Daniel Podor.pdf
Daniel Podor
 
PDF
DevBcn - Building 10x Organizations Using Modern Productivity Metrics
Justin Reock
 
PDF
Mastering Financial Management in Direct Selling
Epixel MLM Software
 
PDF
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
PPTX
"Autonomy of LLM Agents: Current State and Future Prospects", Oles` Petriv
Fwdays
 
PDF
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
PDF
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
PPTX
AUTOMATION AND ROBOTICS IN PHARMA INDUSTRY.pptx
sameeraaabegumm
 
PPTX
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 
PDF
The Rise of AI and IoT in Mobile App Tech.pdf
IMG Global Infotech
 
PDF
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 
PDF
Staying Human in a Machine- Accelerated World
Catalin Jora
 
The Project Compass - GDG on Campus MSIT
dscmsitkol
 
Cryptography Quiz: test your knowledge of this important security concept.
Rajni Bhardwaj Grover
 
IoT-Powered Industrial Transformation – Smart Manufacturing to Connected Heal...
Rejig Digital
 
Jak MŚP w Europie Środkowo-Wschodniej odnajdują się w świecie AI
dominikamizerska1
 
Transcript: New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
Empower Inclusion Through Accessible Java Applications
Ana-Maria Mihalceanu
 
CIFDAQ Market Wrap for the week of 4th July 2025
CIFDAQ
 
Biography of Daniel Podor.pdf
Daniel Podor
 
DevBcn - Building 10x Organizations Using Modern Productivity Metrics
Justin Reock
 
Mastering Financial Management in Direct Selling
Epixel MLM Software
 
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
"Autonomy of LLM Agents: Current State and Future Prospects", Oles` Petriv
Fwdays
 
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
AUTOMATION AND ROBOTICS IN PHARMA INDUSTRY.pptx
sameeraaabegumm
 
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 
The Rise of AI and IoT in Mobile App Tech.pdf
IMG Global Infotech
 
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 
Staying Human in a Machine- Accelerated World
Catalin Jora
 

Module 6: YANG Tutorial - part 2

  • 1. YANG Tutorial – part 2 Presented by Tail-f
  • 2. MAY 27, 2013 2©2013 TAIL-F all rights reserved TUTORIAL: NETCONF AND YANG Advanced YANG Statements
  • 3. MAY 27, 2013 3©2013 TAIL-F all rights reserved TUTORIAL: NETCONF AND YANG Must Statement Restricts valid values by Xpath 1.0 expression container timeout { leaf access-timeout { description "Maximum time without server response"; units seconds; mandatory true; type uint32; } leaf retry-timer { description "Period to retry operation"; units seconds; type uint32; must ”current() < ../access-timeout" { error-app-tag retry-timer-invalid; error-message "The retry timer must be " + "less than the access timeout"; } } }
  • 4. MAY 27, 2013 4©2013 TAIL-F all rights reserved TUTORIAL: NETCONF AND YANG Must Statement leaf interface-group-name { type string { length "1..31"; pattern "[a-zA-Z][a-zA-Z0-9_-]*"; } must "not(/sys:sys/interface[name = current()])" { error-message ”Must be different from all interface names"; tailf:dependency "/sys:sys/interface/name"; } }
  • 5. MAY 27, 2013 5©2013 TAIL-F all rights reserved TUTORIAL: NETCONF AND YANG Must Statement leaf max-weight { type uint32 { range "0..1000"; } default 100; must "sum(/sys:sys/interface[enabled = 'true']/weight) < current()" { error-message "The total weight exceeds the configured max weight"; } }
  • 6. MAY 27, 2013 6©2013 TAIL-F all rights reserved TUTORIAL: NETCONF AND YANG Augment Statement augment /sys:system/sys:user { leaf expire { type yang:date-and-time; } } user name classfull-nameuid expire + Default
  • 7. MAY 27, 2013 7©2013 TAIL-F all rights reserved TUTORIAL: NETCONF AND YANG When Statement augment /sys:system/sys:user { when ”sys:class = ‘wheel’"; leaf shell { type string; } } user name classfull-nameuid expire + Default shell When
  • 8. MAY 27, 2013 8©2013 TAIL-F all rights reserved TUTORIAL: NETCONF AND YANG Choice Statement Choice allows one of several alternatives choice transfer-method { leaf transfer-interval { description "Frequency at which file transfer happens"; type uint16 { range "15 .. 2880"; } units minutes; } leaf transfer-on-commit { description "Transfer after each commit"; type empty; } } transfer-interval transfer-on-commit transfer-method
  • 9. MAY 27, 2013 9©2013 TAIL-F all rights reserved TUTORIAL: NETCONF AND YANG Choice Statement Each alternative may consist of multiple definitions • Either as a named or anonymous group choice counters { case four-counters { leaf threshold {…} leaf ignore-count {…} leaf ignore-time {…} leaf reset-time {…} } container warning-only { … } default four-counters; }
  • 10. MAY 27, 2013 10©2013 TAIL-F all rights reserved TUTORIAL: NETCONF AND YANG Identity Statement Identities for modeling families of related enumeration constants module phys-if { … identity ethernet { description "Ethernet family of PHY interfaces"; } identity eth-1G { base ethernet; description "1 GigEth"; } identity eth-10G { base ethernet; description "10 GigEth"; } module newer { … identity eth-40G { base phys-if:ethernet; description "40 GigEth"; } identity eth-100G { base phys-if:ethernet; description "100 GigEth"; } … leaf eth-type { type identityref { base ”phys-if:ethernet"; } }
  • 11. MAY 27, 2013 11©2013 TAIL-F all rights reserved TUTORIAL: NETCONF AND YANG Feature Statement Mark data as conditional feature has-local-disk { description “System has a local file system that can be used for storing log files”; } container system { container logging { if-feature has-local-disk; presence “Logging enabled”; leaf buffer-size { type filesize; } } } system logging buffer-size Feature, Presence The features supported by a system are meant to stay relatively constant. Adding a feature is comparable to a hardware upgrade.
  • 12. MAY 27, 2013 12©2013 TAIL-F all rights reserved TUTORIAL: NETCONF AND YANG Deviations Systems should conform to standard YANG models • Still, if a device can’t, that can be properly declared deviation /base:system/base:user/base:type { deviate add { default "admin"; // new users are 'admin' by default } } deviation /base:system/base:name-server { deviate replace { max-elements 3; } }
  • 13. MAY 27, 2013 13©2013 TAIL-F all rights reserved TUTORIAL: NETCONF AND YANG YANG Modeling Strategy
  • 14. MAY 27, 2013 14©2013 TAIL-F all rights reserved TUTORIAL: NETCONF AND YANG Constraints • On-board XPATH parser not required • XPATH is more formal than English, that’s all • Debate: “Configuration validity must not depend on state” • Are operators right? • What are the implications? • min-elements • max-elements • range • key/unique • leafref • must • when
  • 15. MAY 27, 2013 15©2013 TAIL-F all rights reserved TUTORIAL: NETCONF AND YANG Structure • Model to mimic an existing interface? • Model for which interfaces? • YANG for NETCONF only? • All interfaces uses the YANG model? • Multiple models with transformations? • Multiple models that allow writing? • What goes in each namespace? • One, a few or many namespaces? • No configuration inside operational data • SNMP transient configuration
  • 16. MAY 27, 2013 16©2013 TAIL-F all rights reserved TUTORIAL: NETCONF AND YANG So what is configuration? • What is in the factory default? • Any probing at system boot? • Do you want pre-provisioning? • Do you want to support rollbacks? • Inserting a board, is that an act of configuration? • Do you need spontaneous reconfiguration? • Where does the configuration data originate from?
  • 17. MAY 27, 2013 17©2013 TAIL-F all rights reserved TUTORIAL: NETCONF AND YANG VersioningYANG Modules You must / must not: • Add a revision statement on top • Update organization, contact, etc • Do not rename module or namespace • Do not remove obsolete definitions • Do not reorder data definitions You may: • Add enum, bits, typedef, grouping, rpc, notification, extension, feature, identity, case • Add non-mandatory data definitions • Add mandatory data definitions within new if- feature statements  RFC 6020 sec 10
  • 18. MAY 27, 2013 18©2013 TAIL-F all rights reserved TUTORIAL: NETCONF AND YANG VersioningYANG Modules (cont’d) You may: • Add or update a status statement: current  deprecated  obsolete • Expand allowed range, length, pattern • Add a default (but not change it!) • Add units, add or update a reference You may: • Change mandatory to false (or remove it) • Remove or relax min- & max- elements • Add or clarify a description without changing the semantics • Change state data to optional configuration • Remove an if-feature
  • 19. MAY 27, 2013 19©2013 TAIL-F all rights reserved TUTORIAL: NETCONF AND YANG IETF Modeling Recommendations • Describe • Module, security considerations, references, definitions, … • Top level • Only one data definition (typ. container) on top level • Top level data definitions optional • Enumerations that grow • Use identityref instead of enumeration
  • 20. MAY 27, 2013 20©2013 TAIL-F all rights reserved TUTORIAL: NETCONF AND YANG IETF Modeling Recommendations • Specific types • Use ranges, length restrictions, patterns • Do not use signed types unless negative values needed • Standard types • When possible, use standard types, e.g. ‘yang-types’ defined in RFC 6021 • Make your own reusable ‘type modules’
  • 21. MAY 27, 2013 21©2013 TAIL-F all rights reserved TUTORIAL: NETCONF AND YANG Yin, YANG and YANG Extensions
  • 22. MAY 27, 2013 22©2013 TAIL-F all rights reserved TUTORIAL: NETCONF AND YANG Yin – the XML representation of YANG YANG 日 container dhcp { leaf defaultLeaseTime { type xs:duration; default PT600S; } leaf maxLeaseTime { type xs:duration; default PT7200S; } leaf logFacility { type loglevel; default local7; } Yin 月 <container name="dhcp"> <leaf name="defaultLeaseTime"> <type name="xs:duration"/> <default value="PT600S"/> </leaf> <leaf name="maxLeaseTime"> <type name="xs:duration"/> <default value="PT7200S”/> </leaf> <leaf name="logFacility"> <type name="loglevel"/> <default value="local7"/> </leaf> Lossless Lossless
  • 23. MAY 27, 2013 23©2013 TAIL-F all rights reserved TUTORIAL: NETCONF AND YANG YANG Extensions - Prototype module prototype { namespace "http://tail-f.com… prefix prototype; extension create { argument keylist; } extension value { argument value; } extension keylist-value { argument keylist-value; } } module xyz { list y { config false; tailf:cdb-oper; prototype:create "b=1,c=0"; prototype:create "b=6,c=0"; prototype:create "b=6,c=1"; key "b c"; leaf b { type int32; } leaf c { type int32; } leaf d { type string; prototype:keylist-value "b=1,c=0,cool"; prototype:keylist-value "b=6,c=1,green"; }
  • 24. MAY 27, 2013 24©2013 TAIL-F all rights reserved TUTORIAL: NETCONF AND YANG YANG Extensions - Prototype c "/xyz:x/xyz:y{1 0}" c "/xyz:x/xyz:y{6 0}" c "/xyz:x/xyz:y{6 1}" s "/xyz:x/xyz:y{1 0}/xyz:d" "cool" s "/xyz:x/xyz:y{6 1}/xyz:d" "green" ubuntu# show x B C D ------------- 1 0 cool 6 0 - 6 1 green Prototype .yang XYZ .yang XYZ init data XYZ pyang confdc prototype.py
  • 25. MAY 27, 2013 25©2013 TAIL-F all rights reserved TUTORIAL: NETCONF AND YANG Example: Router Device Model (part of)
  • 26. MAY 27, 2013 26©2013 TAIL-F all rights reserved TUTORIAL: NETCONF AND YANG Example: Quagga Types submodule quagga_common { belongs-to quagga { prefix quagga; } … include quagga_top; typedef PrefixLengthIPv4 { type uint8 { range 0 .. 32; } } … grouping inetNetworkAddressIPv4 { leaf address { type inet:ipv4-address; mandatory true; } leaf prefix-length { type PrefixLengthIPv4; mandatory true; } } typedef MacAddressType { type string { length 17; pattern "([0-9a-fA-F][0-9a-fA-F]:){5} ([0-9a-fA-F][0-9a-fA-F])"; } } typedef ACLLowRangeType { type uint32 { range 1 .. 99; } } typedef ACLHighRangeType { type uint32 { range 1300 .. 1999; } } typedef ACLExtType { type union { type ACLExtLowRangeType; type ACLExtHighRangeType; } } typedef InfiniteType { type enumeration { enum infinite; } } typedef DateTimeInfiniteType { type union { type yang:date-and-time; type InfiniteType; } }
  • 27. MAY 27, 2013 27©2013 TAIL-F all rights reserved TUTORIAL: NETCONF AND YANG Example: Quagga Interface Configuration submodule zebra_confd_if { belongs-to quagga { prefix quagga; } include confd_top; include confd_common; typedef BandwidthRangeType { type uint64 { range "1 .. 10000000000"; } } augment "/system/interface" { leaf bandwidth { type BandwidthRangeType; } leaf link-detect { type boolean; default false; } leaf multicast { type MulticastType; default if-default; } leaf up { type boolean; default true; } } } submodule zebra_confd_if_ip { belongs-to quagga { prefix quagga; } import ietf-inet-types { prefix inet; } include confd_top; include confd_common; augment "/system/interface/ip" { list address { key "address prefix-length"; leaf address { type inet:ipv4-address; } leaf prefix-length { type PrefixLengthIPv4; } leaf label { type string; } } } }
  • 28. MAY 27, 2013 28©2013 TAIL-F all rights reserved TUTORIAL: NETCONF AND YANG Example: Quagga Status & Notification submodule zebra_confd_stats_memory { belongs-to quagga { prefix quagga; } import tailf-common { prefix tailf; } include confd_top; include confd_common; augment "/system/stats/memory" { container zebra { config false; tailf:callpoint "zebraGetMemory"; uses memoryStatusType; } } } notification saExpired { leaf tunnelName { type leafref { path "/system/vpn/ipsec/tunnel/name"; } mandatory true; } leaf spi { type int64; mandatory true; } }
  • 29. MAY 27, 2013 29©2013 TAIL-F all rights reserved TUTORIAL: NETCONF AND YANG Example: Q-in-Q Service Model
  • 30. MAY 27, 2013 30©2013 TAIL-F all rights reserved TUTORIAL: NETCONF AND YANG Example: Q-in-Q Service Model (complete) module qinq-service { namespace "http://com/example/qinq-service"; prefix qinq; import tailf-common { prefix tailf; } import tailf-ncs { prefix ncs; } list qinq { key name; leaf name { type string; } leaf s-vlan { mandatory true; type uint32 { range 1..4094; } } must "not (/qt:qinq[name != current()/name] [s-vlan = current()/s-vlan])” { error-message "The s-vlan must be unique within the network” } list edge-switch { key switch; leaf switch { type leafref {path /ncs:devices/ncs:device/ncs:name;} } list edge-interface { key interface; leaf interface { type string; } leaf-list c-vlan { type uint32 { range 1..4094; } } } leaf-list trunk-interface { min-elements 1; type string; } } list core-switch { key switch; leaf switch { type leafref {path /ncs:devices/ncs:device/ncs:name;} } leaf-list trunk-interface { min-elements 1; type string; } } } }