SlideShare a Scribd company logo
1 of 32
YANG Tutorial ā€“ part 1
Presented by Tail-f
MAY 27, 2013 2Ā©2013 TAIL-F all rights reserved
TUTORIAL: NETCONF AND YANG
YANG Modules
MAY 27, 2013 3Ā©2013 TAIL-F all rights reserved
TUTORIAL: NETCONF AND YANG
YANG Header
module acme-module {
namespace "http://acme.example.com/module";
prefix acme;
import ā€ietf-yang-types" {
prefix yang;
}
include "acme-system";
organization "ACME Inc.";
contact joe@acme.example.com;
description ā€Module describing the ACME productsā€;
revision 2007-06-09 {
description "Initial revision.";
}
MAY 27, 2013 4Ā©2013 TAIL-F all rights reserved
TUTORIAL: NETCONF AND YANG
YANG Module Contents
Header information
Imports & Includes
Type definitions
Configuration & Operational
data declarations
Action (RPC) & Notification declarations
MAY 27, 2013 5Ā©2013 TAIL-F all rights reserved
TUTORIAL: NETCONF AND YANG
Module Y NamespaceModule X Namespace
Imports & Includes
Fragment
A.yang
Fragment
B.yang
Fragment
C.yang
Fragment
D.yang
Fragment
E.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
MAY 27, 2013 6Ā©2013 TAIL-F all rights reserved
TUTORIAL: NETCONF AND YANG
Submodules
module acme-module {
namespace ā€œā€¦ā€;
prefix acme;
import ā€ietf-yang-types" {
prefix yang;
}
include "acme-system";
organization "ACME Inc.";
contact joe@acme.example.com;
description ā€Module describing the
ACME productsā€;
revision 2007-06-09 {
description "Initial revision.";
}
submodule acme-system {
belongs-to acme-module {
prefix acme;
}
import ā€ietf-yang-types" {
prefix yang;
}
container system {
ā€¦
}
}
Attention: The submodule cannot
reference definitions in main module
Each submodule belongs to one
specific main module
MAY 27, 2013 7Ā©2013 TAIL-F all rights reserved
TUTORIAL: NETCONF AND YANG
YANG Types
MAY 27, 2013 8Ā©2013 TAIL-F all rights reserved
TUTORIAL: NETCONF AND YANG
YANG Base Types
ā€¢ Most YANG elements have a
data type
ā€¢ Type may be a base type or
derived type
ā€¢ Derived types may be simple
typedefs or groupings
(structures)
ā€¢ There are 20+ base types to
start with
Type Name Meaning
int8/16/32/64 Integer
uint8/16/32/64 Unsigned integer
decimal64 Non-integer
string Unicode string
enumeration Set of alternatives
boolean True or false
bits Boolean array
binary Binary BLOB
leafref Reference
identityref Unique identity
empty No value, void
ā€¦and more
MAY 27, 2013 9Ā©2013 TAIL-F all rights reserved
TUTORIAL: NETCONF AND YANG
Typedef Statement
Defines a new simple type
typedef percent {
type uint16 {
range "0 .. 100";
}
description "Percentage";
}
leaf completed {
type percent;
}
percent
completed
MAY 27, 2013 10Ā©2013 TAIL-F all rights reserved
TUTORIAL: NETCONF AND YANG
Type Restrictions
Integers
typedef my-base-int32-type {
type int32 {
range "1..4 | 10..20";
}
}
typedef derived-int32 {
type my-base-int32-type {
range "11..max"; // 11..20
}
}
Strings
typedef my-base-str-type {
type string {
length "1..255";
}
}
typedef derived-str {
type my-base-str-type {
length "11 | 42..max";
pattern "[0-9a-fA-F]*";
}
}
MAY 27, 2013 11Ā©2013 TAIL-F all rights reserved
TUTORIAL: NETCONF AND YANG
Union Statement
Union allows creation of special types
typedef threshold {
description ā€Threshold value in percent";
type union {
type uint16 {
range "0 .. 100";
}
type enumeration {
enum disabled {
description "No threshold";
}
}
}
}
MAY 27, 2013 12Ā©2013 TAIL-F all rights reserved
TUTORIAL: NETCONF AND YANG
CommonYANG Types
ā€¢ Commonly used
YANG types defined
in RFC 6021
ā€¢ Use
import ā€œietf-yang-typesā€ {
prefix yang;
}
to reference these
types as e.g.
type yang:counter64;
ļ© www.rfc-editor.org/rfc/rfc6021.txt
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
MAY 27, 2013 13Ā©2013 TAIL-F all rights reserved
TUTORIAL: NETCONF AND YANG
Grouping Statement
Defines a new structured type
grouping target {
leaf address {
type inet:ip-address;
description "Target IP";
}
leaf port {
type inet:port-number;
description
"Target port number";
}
}
container peer {
container destination {
uses target;
}
}
target
peer
address
port
destination
address
port
MAY 27, 2013 14Ā©2013 TAIL-F all rights reserved
TUTORIAL: NETCONF AND YANG
Grouping Statement with Refine
grouping target {
leaf address {
type inet:ip-address;
description "Target IP";
}
leaf port {
type inet:port-number;
description
"Target port number";
}
}
container servers {
container http {
uses target {
refine port {
default 80;
}
}
}
}
Groupings may be refined when used
MAY 27, 2013 15Ā©2013 TAIL-F all rights reserved
TUTORIAL: NETCONF AND YANG
YANG Data Definitions
MAY 27, 2013 16Ā©2013 TAIL-F all rights reserved
TUTORIAL: NETCONF AND YANG
Leaf Statement
Holds a single value of a particular
type
Has no children
leaf host-name {
type string;
mandatory true;
config true;
description "Hostname for this system";
}
leaf cpu-temp {
type int32;
units degrees-celsius;
config false;
description ā€Current temperature in CPU";
}
host-name
cpu-temp
MAY 27, 2013 17Ā©2013 TAIL-F all rights reserved
TUTORIAL: NETCONF AND YANG
Attributes for leaf
config Whether this leaf is a configurable value (ā€œtrueā€) or operational value (ā€œfalseā€).
Inherited from parent container if not specified
default Specifies default value for this leaf. Implies that leaf is optional
mandatory Whether the leaf is mandatory (ā€œtrueā€) or optional (ā€œfalseā€)
must XPath constraint that will be enforced for this leaf
type The data type (and range etc) of this leaf
when Conditional leaf, only present if XPath expression is true
description Human readable definition and help text for this leaf
reference Human readable reference to some other element or spec
units Human readable unit specification (e.g. Hz, MB/s, ā„‰)
status Whether this leaf is ā€œcurrentā€, ā€œdeprecatedā€ or ā€œobsoleteā€
MAY 27, 2013 18Ā©2013 TAIL-F all rights reserved
TUTORIAL: NETCONF AND YANG
Container Statement
Groups related leafs and containers
container system {
container services {
container ssh {
presence "Enables SSH";
description "SSH service specific configuration";
// more leafs, containers and other things here...
}
}
}
system
services
ā€¦
ssh
ā€¦
Presence
MAY 27, 2013 19Ā©2013 TAIL-F all rights reserved
TUTORIAL: NETCONF AND YANG
Leaf-list Statement
Holds multiple values of a
particular type
Has no children
leaf-list domain-search {
type string;
ordered-by user;
description "List of domain names to search";
}
domain-search
MAY 27, 2013 20Ā©2013 TAIL-F all rights reserved
TUTORIAL: NETCONF AND YANG
List Statement
user
name classfull-nameuid
Default
list user {
key name;
leaf name {
type string;
}
leaf uid {
type uint32;
}
leaf full-name {
type string;
}
leaf class {
type string;
default viewer;
}
}
MAY 27, 2013 21Ā©2013 TAIL-F all rights reserved
TUTORIAL: NETCONF AND YANG
Attributes for list and leaf-list
max-elements Max number of elements in list. If max-elements is not specified, there is no
upper limit, i.e. ā€œunboundedā€
min-elements Min number of elements in list. If min-elements is not specified, there is no
lower limit, i.e. 0
ordered-by List entries are sorted by ā€œsystemā€ or ā€œuserā€. System means elements are
sorted in a natural order (numerically, alphabetically, etc). User means the
order the operator entered them in is preserved.
ā€œordered-by userā€ is meaningful when the order among the elements have
significance, e.g. DNS server search order or firewall rules.
MAY 27, 2013 22Ā©2013 TAIL-F all rights reserved
TUTORIAL: NETCONF AND YANG
Keys
user
name classfull-nameuid
Default
/user{yang}/name = yang
/user{yang}/uid = 1010
/user{yang}/class = admin
/user{ling}/class = viewer
yang 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 talking about.
No two rows can have same key
value
MAY 27, 2013 23Ā©2013 TAIL-F all rights reserved
TUTORIAL: NETCONF AND YANG
Keys
user
name classfull-nameuid
Default
1010 yang Yan Goode admin
1152 hawk Ron Hawk oper
1202 ling Lin Grossman viewer
If we want, we could select the
uid to be key instead.
/user{1010}/name = yang
/user{1010}/uid = 1010
/user{1010}/class = admin
/user{1202}/class = viewer
MAY 27, 2013 24Ā©2013 TAIL-F all rights reserved
TUTORIAL: NETCONF AND YANG
Unique Statement
Non- key fields can also be
declared unique.
Multiple fields can be declared
unique separately or in
combination
user
name classfull-nameuid
Default
list user {
key uid;
unique name;
ā€¦
No two rows above can have
same uid, nor name
1010 yang Yan Goode admin
1152 hawk Ron Hawk oper
1202 ling Lin Grossman viewer
MAY 27, 2013 25Ā©2013 TAIL-F all rights reserved
TUTORIAL: NETCONF AND YANG
Multiple keys
Multiple key fields are
needed when a single key
field isnā€™t unique.
Key fields must be a unique
combination
route
prefix metricnext-hopip
Default
list route {
key ā€œip prefixā€;
ā€¦
/route{16.40.0.0 16}/next-hop
= 220.40.0.1
Key order significant
16.40.0.0 16 220.40.0.1 20
16.42.0.0 16 82.193.16.1 40
16.42.0.0 24 82.193.16.6 50
MAY 27, 2013 26Ā©2013 TAIL-F all rights reserved
TUTORIAL: NETCONF AND YANG
Leafref
Here, the RIP routing
subsystem has a list of
leafrefs pointing out existing
interfaces
interface
addressname
0 .. 64
container rip {
list network-ifname {
key ifname;
leaf ifname {
type leafref {
path ā€œ/interface/nameā€;
}
}
eth0.16
eth0.19 192.168.0.1
eth2.5 24.97.238.15
rip
network-ifname
ifname
eth0.19
MAY 27, 2013 27Ā©2013 TAIL-F all rights reserved
TUTORIAL: NETCONF AND YANG
Multiple Key Leafref
client
portip
container video {
leaf v-ip {
type leafref {
path "/client/ip";
}
}
leaf v-port {
type leafref {
path "/client[ip=current()/../v-ip]/port";
}
}
12.36.2.19 33115
12.36.2.19 33667
67.3.51.196 33667
video
v-portv-ip
12.36.2.19 33667
MAY 27, 2013 28Ā©2013 TAIL-F all rights reserved
TUTORIAL: NETCONF AND YANG
Deref() XPATH Operator
container video {
leaf v-ip {
type leafref {
path "/client/ip";
}
}
leaf v-port {
type leafref {
path "/client
[ip=current()/../v-ip]/port";
}
}
leaf v-stream {
type leafref {
path "/client
[ip=current()/../v-ip]
[port=current()/../v-port]
/stream";
}
}
container video-deref {
leaf v-ip {
type leafref {
path "/client/ip";
}
}
leaf v-port {
type leafref {
path "deref(../v-ip)
/../portā€;
}
}
leaf v-stream {
type leafref {
path "deref(../v-port)
/../stream";
}
}
MAY 27, 2013 29Ā©2013 TAIL-F all rights reserved
TUTORIAL: NETCONF AND YANG
YANG Actions (RPCs) & Notifications
MAY 27, 2013 30Ā©2013 TAIL-F all rights reserved
TUTORIAL: NETCONF AND YANG
RPC Statement
Administrative actions with input
and output parameters
rpc activate-software-image {
input {
leaf image {
type binary;
}
}
output {
leaf status {
type string;
}
}
}
image
status
activate-software-image
MAY 27, 2013 31Ā©2013 TAIL-F all rights reserved
TUTORIAL: NETCONF AND YANG
Notification Statement
Notification with output parameters
notification config-change {
description
ā€The configuration changed";
leaf operator-name {
type string;
}
leaf-list change {
type instance-identifier;
}
}
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
Module 5: YANG Tutorial - part 1

More Related Content

What's hot

[Webinar Slides] Programming the Network Dataplane in P4
[Webinar Slides] Programming the Network Dataplane in P4[Webinar Slides] Programming the Network Dataplane in P4
[Webinar Slides] Programming the Network Dataplane in P4
Open Networking Summits
Ā 
FTTx GPON System Troubleshooting.pptx
FTTx GPON System Troubleshooting.pptxFTTx GPON System Troubleshooting.pptx
FTTx GPON System Troubleshooting.pptx
TedevTu
Ā 

What's hot (20)

Tail f - Why ConfD
Tail f - Why ConfDTail f - Why ConfD
Tail f - Why ConfD
Ā 
Tail-f - Why NETCONF
Tail-f - Why NETCONFTail-f - Why NETCONF
Tail-f - Why NETCONF
Ā 
Module 9: CDB Technical Intro
 Module 9: CDB Technical Intro Module 9: CDB Technical Intro
Module 9: CDB Technical Intro
Ā 
[Webinar Slides] Programming the Network Dataplane in P4
[Webinar Slides] Programming the Network Dataplane in P4[Webinar Slides] Programming the Network Dataplane in P4
[Webinar Slides] Programming the Network Dataplane in P4
Ā 
MPLS on Router OS V7 - Part 2
MPLS on Router OS V7 - Part 2MPLS on Router OS V7 - Part 2
MPLS on Router OS V7 - Part 2
Ā 
Yang in OpenDaylight
Yang in OpenDaylightYang in OpenDaylight
Yang in OpenDaylight
Ā 
Howto createOpenFlow Switchusing FPGA (at FPGAX#6)
Howto createOpenFlow Switchusing FPGA (at FPGAX#6)Howto createOpenFlow Switchusing FPGA (at FPGAX#6)
Howto createOpenFlow Switchusing FPGA (at FPGAX#6)
Ā 
NETCONFćØYANG恮話
NETCONFćØYANG恮話NETCONFćØYANG恮話
NETCONFćØYANG恮話
Ā 
OpenDaylight app development tutorial
OpenDaylight app development tutorialOpenDaylight app development tutorial
OpenDaylight app development tutorial
Ā 
Segment Routing for Dummies
Segment Routing for DummiesSegment Routing for Dummies
Segment Routing for Dummies
Ā 
Multi Chassis LAG for Cloud builders
Multi Chassis LAG for Cloud buildersMulti Chassis LAG for Cloud builders
Multi Chassis LAG for Cloud builders
Ā 
Sockets and Socket-Buffer
Sockets and Socket-BufferSockets and Socket-Buffer
Sockets and Socket-Buffer
Ā 
Model driven telemetry
Model driven telemetryModel driven telemetry
Model driven telemetry
Ā 
FTTx GPON System Troubleshooting.pptx
FTTx GPON System Troubleshooting.pptxFTTx GPON System Troubleshooting.pptx
FTTx GPON System Troubleshooting.pptx
Ā 
Automating for Monitoring and Troubleshooting your Cisco IOS Network
Automating for Monitoring and Troubleshooting your Cisco IOS NetworkAutomating for Monitoring and Troubleshooting your Cisco IOS Network
Automating for Monitoring and Troubleshooting your Cisco IOS Network
Ā 
VPLS Fundamental
VPLS FundamentalVPLS Fundamental
VPLS Fundamental
Ā 
eBPF Workshop
eBPF WorkshopeBPF Workshop
eBPF Workshop
Ā 
Building efficient 5G NR base stations with IntelĀ® XeonĀ® Scalable Processors
Building efficient 5G NR base stations with IntelĀ® XeonĀ® Scalable Processors Building efficient 5G NR base stations with IntelĀ® XeonĀ® Scalable Processors
Building efficient 5G NR base stations with IntelĀ® XeonĀ® Scalable Processors
Ā 
VXLAN and FRRouting
VXLAN and FRRoutingVXLAN and FRRouting
VXLAN and FRRouting
Ā 
Software Defined Network (SDN) using ASR9000 :: BRKSPG-2722 | San Diego 2015
Software Defined Network (SDN) using ASR9000 :: BRKSPG-2722 | San Diego 2015Software Defined Network (SDN) using ASR9000 :: BRKSPG-2722 | San Diego 2015
Software Defined Network (SDN) using ASR9000 :: BRKSPG-2722 | San Diego 2015
Ā 

Viewers also liked

Viewers also liked (8)

Open Network OS Overview as of 2015/10/16
Open Network OS Overview as of 2015/10/16Open Network OS Overview as of 2015/10/16
Open Network OS Overview as of 2015/10/16
Ā 
Dynamic Service Chaining
Dynamic Service Chaining Dynamic Service Chaining
Dynamic Service Chaining
Ā 
Tail-f Webinar OpenFlow Switch Management Using NETCONF and YANG
Tail-f Webinar OpenFlow Switch Management Using NETCONF and YANGTail-f Webinar OpenFlow Switch Management Using NETCONF and YANG
Tail-f Webinar OpenFlow Switch Management Using NETCONF and YANG
Ā 
Module 11: Operational Data Providers
Module 11: Operational Data ProvidersModule 11: Operational Data Providers
Module 11: Operational Data Providers
Ā 
Module 8: C Data Types
Module 8: C Data TypesModule 8: C Data Types
Module 8: C Data Types
Ā 
Webinar: Applying REST to Network Management ā€“ An Implementorā€™s View
Webinar: Applying REST to Network Management ā€“ An Implementorā€™s View Webinar: Applying REST to Network Management ā€“ An Implementorā€™s View
Webinar: Applying REST to Network Management ā€“ An Implementorā€™s View
Ā 
Module 12: NETCONF Northbound Interface
Module 12: NETCONF Northbound InterfaceModule 12: NETCONF Northbound Interface
Module 12: NETCONF Northbound Interface
Ā 
Module 7: Installation and Getting Started
Module 7: Installation and Getting StartedModule 7: Installation and Getting Started
Module 7: Installation and Getting Started
Ā 

Similar to Module 5: YANG Tutorial - part 1

lec14.pdf
lec14.pdflec14.pdf
lec14.pdf
HEMAHEMS5
Ā 
C1320prespost
C1320prespostC1320prespost
C1320prespost
FALLEE31188
Ā 
Presentation on structure,functions and classes
Presentation on structure,functions and classesPresentation on structure,functions and classes
Presentation on structure,functions and classes
Alisha Korpal
Ā 
C++lecture9
C++lecture9C++lecture9
C++lecture9
FALLEE31188
Ā 
in c languageTo determine the maximum string length, we need to .pdf
in c languageTo determine the maximum string length, we need to .pdfin c languageTo determine the maximum string length, we need to .pdf
in c languageTo determine the maximum string length, we need to .pdf
stopgolook
Ā 
Abstract Data Types (a) Explain briefly what is meant by the ter.pdf
Abstract Data Types (a) Explain briefly what is meant by the ter.pdfAbstract Data Types (a) Explain briefly what is meant by the ter.pdf
Abstract Data Types (a) Explain briefly what is meant by the ter.pdf
karymadelaneyrenne19
Ā 
Savitch Ch 17
Savitch Ch 17Savitch Ch 17
Savitch Ch 17
Terry Yoast
Ā 

Similar to Module 5: YANG Tutorial - part 1 (20)

Java New Programming Features
Java New Programming FeaturesJava New Programming Features
Java New Programming Features
Ā 
DataBase Management System Lab File
DataBase Management System Lab FileDataBase Management System Lab File
DataBase Management System Lab File
Ā 
Operator overloading
Operator overloading Operator overloading
Operator overloading
Ā 
lec14.pdf
lec14.pdflec14.pdf
lec14.pdf
Ā 
BCA IPU VB.NET UNIT-II
BCA IPU VB.NET UNIT-IIBCA IPU VB.NET UNIT-II
BCA IPU VB.NET UNIT-II
Ā 
Lecture 7
Lecture 7Lecture 7
Lecture 7
Ā 
C1320prespost
C1320prespostC1320prespost
C1320prespost
Ā 
C++ tutorials
C++ tutorialsC++ tutorials
C++ tutorials
Ā 
.Net Classes and Objects | UiPath Community
.Net Classes and Objects | UiPath Community.Net Classes and Objects | UiPath Community
.Net Classes and Objects | UiPath Community
Ā 
Presentation on structure,functions and classes
Presentation on structure,functions and classesPresentation on structure,functions and classes
Presentation on structure,functions and classes
Ā 
C++lecture9
C++lecture9C++lecture9
C++lecture9
Ā 
Unit 5 (1)
Unit 5 (1)Unit 5 (1)
Unit 5 (1)
Ā 
Certification preparation - Net classses and functions.pptx
Certification preparation - Net classses and functions.pptxCertification preparation - Net classses and functions.pptx
Certification preparation - Net classses and functions.pptx
Ā 
in c languageTo determine the maximum string length, we need to .pdf
in c languageTo determine the maximum string length, we need to .pdfin c languageTo determine the maximum string length, we need to .pdf
in c languageTo determine the maximum string length, we need to .pdf
Ā 
Easy Understanding of Structure Union Typedef Enum in C Language.pdf
Easy Understanding of Structure Union Typedef Enum in C Language.pdfEasy Understanding of Structure Union Typedef Enum in C Language.pdf
Easy Understanding of Structure Union Typedef Enum in C Language.pdf
Ā 
Struts 2 + Spring
Struts 2 + SpringStruts 2 + Spring
Struts 2 + Spring
Ā 
Clean code _v2003
 Clean code _v2003 Clean code _v2003
Clean code _v2003
Ā 
Abstract Data Types (a) Explain briefly what is meant by the ter.pdf
Abstract Data Types (a) Explain briefly what is meant by the ter.pdfAbstract Data Types (a) Explain briefly what is meant by the ter.pdf
Abstract Data Types (a) Explain briefly what is meant by the ter.pdf
Ā 
Savitch Ch 17
Savitch Ch 17Savitch Ch 17
Savitch Ch 17
Ā 
Diagrams
DiagramsDiagrams
Diagrams
Ā 

Recently uploaded

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(ā˜Žļø+971_581248768%)**%*]'#abortion pills for sale in dubai@
Ā 

Recently uploaded (20)

Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
Ā 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
Ā 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Ā 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
Ā 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
Ā 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Ā 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
Ā 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Ā 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
Ā 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
Ā 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
Ā 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Ā 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
Ā 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
Ā 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
Ā 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
Ā 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
Ā 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
Ā 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Ā 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
Ā 

Module 5: YANG Tutorial - part 1

  • 1. YANG Tutorial ā€“ part 1 Presented by Tail-f
  • 2. MAY 27, 2013 2Ā©2013 TAIL-F all rights reserved TUTORIAL: NETCONF AND YANG YANG Modules
  • 3. MAY 27, 2013 3Ā©2013 TAIL-F all rights reserved TUTORIAL: NETCONF AND YANG YANG Header module acme-module { namespace "http://acme.example.com/module"; prefix acme; import ā€ietf-yang-types" { prefix yang; } include "acme-system"; organization "ACME Inc."; contact joe@acme.example.com; description ā€Module describing the ACME productsā€; revision 2007-06-09 { description "Initial revision."; }
  • 4. MAY 27, 2013 4Ā©2013 TAIL-F all rights reserved TUTORIAL: NETCONF AND YANG YANG Module Contents Header information Imports & Includes Type definitions Configuration & Operational data declarations Action (RPC) & Notification declarations
  • 5. MAY 27, 2013 5Ā©2013 TAIL-F all rights reserved TUTORIAL: NETCONF AND YANG Module Y NamespaceModule X Namespace Imports & Includes Fragment A.yang Fragment B.yang Fragment C.yang Fragment D.yang Fragment E.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
  • 6. MAY 27, 2013 6Ā©2013 TAIL-F all rights reserved TUTORIAL: NETCONF AND YANG Submodules module acme-module { namespace ā€œā€¦ā€; prefix acme; import ā€ietf-yang-types" { prefix yang; } include "acme-system"; organization "ACME Inc."; contact joe@acme.example.com; description ā€Module describing the ACME productsā€; revision 2007-06-09 { description "Initial revision."; } submodule acme-system { belongs-to acme-module { prefix acme; } import ā€ietf-yang-types" { prefix yang; } container system { ā€¦ } } Attention: The submodule cannot reference definitions in main module Each submodule belongs to one specific main module
  • 7. MAY 27, 2013 7Ā©2013 TAIL-F all rights reserved TUTORIAL: NETCONF AND YANG YANG Types
  • 8. MAY 27, 2013 8Ā©2013 TAIL-F all rights reserved TUTORIAL: NETCONF AND YANG YANG Base Types ā€¢ Most YANG elements have a data type ā€¢ Type may be a base type or derived type ā€¢ Derived types may be simple typedefs or groupings (structures) ā€¢ There are 20+ base types to start with Type Name Meaning int8/16/32/64 Integer uint8/16/32/64 Unsigned integer decimal64 Non-integer string Unicode string enumeration Set of alternatives boolean True or false bits Boolean array binary Binary BLOB leafref Reference identityref Unique identity empty No value, void ā€¦and more
  • 9. MAY 27, 2013 9Ā©2013 TAIL-F all rights reserved TUTORIAL: NETCONF AND YANG Typedef Statement Defines a new simple type typedef percent { type uint16 { range "0 .. 100"; } description "Percentage"; } leaf completed { type percent; } percent completed
  • 10. MAY 27, 2013 10Ā©2013 TAIL-F all rights reserved TUTORIAL: NETCONF AND YANG Type Restrictions Integers typedef my-base-int32-type { type int32 { range "1..4 | 10..20"; } } typedef derived-int32 { type my-base-int32-type { range "11..max"; // 11..20 } } Strings typedef my-base-str-type { type string { length "1..255"; } } typedef derived-str { type my-base-str-type { length "11 | 42..max"; pattern "[0-9a-fA-F]*"; } }
  • 11. MAY 27, 2013 11Ā©2013 TAIL-F all rights reserved TUTORIAL: NETCONF AND YANG Union Statement Union allows creation of special types typedef threshold { description ā€Threshold value in percent"; type union { type uint16 { range "0 .. 100"; } type enumeration { enum disabled { description "No threshold"; } } } }
  • 12. MAY 27, 2013 12Ā©2013 TAIL-F all rights reserved TUTORIAL: NETCONF AND YANG CommonYANG Types ā€¢ Commonly used YANG types defined in RFC 6021 ā€¢ Use import ā€œietf-yang-typesā€ { prefix yang; } to reference these types as e.g. type yang:counter64; ļ© www.rfc-editor.org/rfc/rfc6021.txt 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
  • 13. MAY 27, 2013 13Ā©2013 TAIL-F all rights reserved TUTORIAL: NETCONF AND YANG Grouping Statement Defines a new structured type grouping target { leaf address { type inet:ip-address; description "Target IP"; } leaf port { type inet:port-number; description "Target port number"; } } container peer { container destination { uses target; } } target peer address port destination address port
  • 14. MAY 27, 2013 14Ā©2013 TAIL-F all rights reserved TUTORIAL: NETCONF AND YANG Grouping Statement with Refine grouping target { leaf address { type inet:ip-address; description "Target IP"; } leaf port { type inet:port-number; description "Target port number"; } } container servers { container http { uses target { refine port { default 80; } } } } Groupings may be refined when used
  • 15. MAY 27, 2013 15Ā©2013 TAIL-F all rights reserved TUTORIAL: NETCONF AND YANG YANG Data Definitions
  • 16. MAY 27, 2013 16Ā©2013 TAIL-F all rights reserved TUTORIAL: NETCONF AND YANG Leaf Statement Holds a single value of a particular type Has no children leaf host-name { type string; mandatory true; config true; description "Hostname for this system"; } leaf cpu-temp { type int32; units degrees-celsius; config false; description ā€Current temperature in CPU"; } host-name cpu-temp
  • 17. MAY 27, 2013 17Ā©2013 TAIL-F all rights reserved TUTORIAL: NETCONF AND YANG Attributes for leaf config Whether this leaf is a configurable value (ā€œtrueā€) or operational value (ā€œfalseā€). Inherited from parent container if not specified default Specifies default value for this leaf. Implies that leaf is optional mandatory Whether the leaf is mandatory (ā€œtrueā€) or optional (ā€œfalseā€) must XPath constraint that will be enforced for this leaf type The data type (and range etc) of this leaf when Conditional leaf, only present if XPath expression is true description Human readable definition and help text for this leaf reference Human readable reference to some other element or spec units Human readable unit specification (e.g. Hz, MB/s, ā„‰) status Whether this leaf is ā€œcurrentā€, ā€œdeprecatedā€ or ā€œobsoleteā€
  • 18. MAY 27, 2013 18Ā©2013 TAIL-F all rights reserved TUTORIAL: NETCONF AND YANG Container Statement Groups related leafs and containers container system { container services { container ssh { presence "Enables SSH"; description "SSH service specific configuration"; // more leafs, containers and other things here... } } } system services ā€¦ ssh ā€¦ Presence
  • 19. MAY 27, 2013 19Ā©2013 TAIL-F all rights reserved TUTORIAL: NETCONF AND YANG Leaf-list Statement Holds multiple values of a particular type Has no children leaf-list domain-search { type string; ordered-by user; description "List of domain names to search"; } domain-search
  • 20. MAY 27, 2013 20Ā©2013 TAIL-F all rights reserved TUTORIAL: NETCONF AND YANG List Statement user name classfull-nameuid Default list user { key name; leaf name { type string; } leaf uid { type uint32; } leaf full-name { type string; } leaf class { type string; default viewer; } }
  • 21. MAY 27, 2013 21Ā©2013 TAIL-F all rights reserved TUTORIAL: NETCONF AND YANG Attributes for list and leaf-list max-elements Max number of elements in list. If max-elements is not specified, there is no upper limit, i.e. ā€œunboundedā€ min-elements Min number of elements in list. If min-elements is not specified, there is no lower limit, i.e. 0 ordered-by List entries are sorted by ā€œsystemā€ or ā€œuserā€. System means elements are sorted in a natural order (numerically, alphabetically, etc). User means the order the operator entered them in is preserved. ā€œordered-by userā€ is meaningful when the order among the elements have significance, e.g. DNS server search order or firewall rules.
  • 22. MAY 27, 2013 22Ā©2013 TAIL-F all rights reserved TUTORIAL: NETCONF AND YANG Keys user name classfull-nameuid Default /user{yang}/name = yang /user{yang}/uid = 1010 /user{yang}/class = admin /user{ling}/class = viewer yang 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 talking about. No two rows can have same key value
  • 23. MAY 27, 2013 23Ā©2013 TAIL-F all rights reserved TUTORIAL: NETCONF AND YANG Keys user name classfull-nameuid Default 1010 yang Yan Goode admin 1152 hawk Ron Hawk oper 1202 ling Lin Grossman viewer If we want, we could select the uid to be key instead. /user{1010}/name = yang /user{1010}/uid = 1010 /user{1010}/class = admin /user{1202}/class = viewer
  • 24. MAY 27, 2013 24Ā©2013 TAIL-F all rights reserved TUTORIAL: NETCONF AND YANG Unique Statement Non- key fields can also be declared unique. Multiple fields can be declared unique separately or in combination user name classfull-nameuid Default list user { key uid; unique name; ā€¦ No two rows above can have same uid, nor name 1010 yang Yan Goode admin 1152 hawk Ron Hawk oper 1202 ling Lin Grossman viewer
  • 25. MAY 27, 2013 25Ā©2013 TAIL-F all rights reserved TUTORIAL: NETCONF AND YANG Multiple keys Multiple key fields are needed when a single key field isnā€™t unique. Key fields must be a unique combination route prefix metricnext-hopip Default list route { key ā€œip prefixā€; ā€¦ /route{16.40.0.0 16}/next-hop = 220.40.0.1 Key order significant 16.40.0.0 16 220.40.0.1 20 16.42.0.0 16 82.193.16.1 40 16.42.0.0 24 82.193.16.6 50
  • 26. MAY 27, 2013 26Ā©2013 TAIL-F all rights reserved TUTORIAL: NETCONF AND YANG Leafref Here, the RIP routing subsystem has a list of leafrefs pointing out existing interfaces interface addressname 0 .. 64 container rip { list network-ifname { key ifname; leaf ifname { type leafref { path ā€œ/interface/nameā€; } } eth0.16 eth0.19 192.168.0.1 eth2.5 24.97.238.15 rip network-ifname ifname eth0.19
  • 27. MAY 27, 2013 27Ā©2013 TAIL-F all rights reserved TUTORIAL: NETCONF AND YANG Multiple Key Leafref client portip container video { leaf v-ip { type leafref { path "/client/ip"; } } leaf v-port { type leafref { path "/client[ip=current()/../v-ip]/port"; } } 12.36.2.19 33115 12.36.2.19 33667 67.3.51.196 33667 video v-portv-ip 12.36.2.19 33667
  • 28. MAY 27, 2013 28Ā©2013 TAIL-F all rights reserved TUTORIAL: NETCONF AND YANG Deref() XPATH Operator container video { leaf v-ip { type leafref { path "/client/ip"; } } leaf v-port { type leafref { path "/client [ip=current()/../v-ip]/port"; } } leaf v-stream { type leafref { path "/client [ip=current()/../v-ip] [port=current()/../v-port] /stream"; } } container video-deref { leaf v-ip { type leafref { path "/client/ip"; } } leaf v-port { type leafref { path "deref(../v-ip) /../portā€; } } leaf v-stream { type leafref { path "deref(../v-port) /../stream"; } }
  • 29. MAY 27, 2013 29Ā©2013 TAIL-F all rights reserved TUTORIAL: NETCONF AND YANG YANG Actions (RPCs) & Notifications
  • 30. MAY 27, 2013 30Ā©2013 TAIL-F all rights reserved TUTORIAL: NETCONF AND YANG RPC Statement Administrative actions with input and output parameters rpc activate-software-image { input { leaf image { type binary; } } output { leaf status { type string; } } } image status activate-software-image
  • 31. MAY 27, 2013 31Ā©2013 TAIL-F all rights reserved TUTORIAL: NETCONF AND YANG Notification Statement Notification with output parameters notification config-change { description ā€The configuration changed"; leaf operator-name { type string; } leaf-list change { type instance-identifier; } } 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

Editor's Notes

  1. Mandatory ā€œtrueā€ has some implications for the config. Must always be there, not upgradeable.
  2. Must expressions can touch the entire config, even config=false data. Evaluating them can be very expensive, care has to be taken when writing them. Dependency expressions are essential. They may easily become a performance hog. Adorn with tailf:dependency expressions. Easy to get a slow system since ConfD cannot know which expressions to evaluate.
  3. Unique needs to be used with care. The code becomes quadratic when large number of instances are added. Use with care.