0% found this document useful (0 votes)
97 views28 pages

Tutorial Ietf71

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
97 views28 pages

Tutorial Ietf71

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 28

YANG Boot Camp

The YANG Gang


IETF 71
NETCONF Modeling Language
 NETCONF base protocol (rfc 4741)
 RPC mechanism and operations
 Left content and data models for future work
• Operations allow any XML
• <get>, <get-config> and <edit-config>

Mgmt Application

YANG modules
Devices
YANG is ….

 A NETCONF modeling language


 Think SMI for NETCONF
 Models semantics and data organization
 Syntax falls out of semantics
 Able to model config data, state data,
RPCs, and notifications
 Based on SMIng syntax
 Text-based
• Email, patch, and RFC friendly
YANG Concepts

Standard Proprietary
Models Models

config data RPCs notifications

containers

leafs

types
YANG ....

 Directly maps to XML content (on the wire)


 Extensible
 Add new content to existing data models
• Without changing the original model
 Add new statements to the YANG language
• Vendor extensions and future proofing
 Preserves investment in SNMP MIBs
 libsmi translates MIBs to YANG
 See tools at www.yang-central.org
Semantics and syntax

Semantic
World YANG

Syntactic
XML Schema Relax-NG Anything Else
World

Out
Legacy tools
Validation going
XML
YANG values ....

 Readers and reviewers time and learning curve


 Readability is highest priority
 Limited Scope
 Doesn't boil the ocean
 Maximize utility within that scope
 Can be extended in the future
 Experience gained by existing implementations
 Based on four proprietary modeling languages
• Years of experience within multiple vendors
 Quality draft backed by running code
Modules and submodules
 Header statements
 yang-version, namespace, prefix
 Linkage statement
 import and include Mod1 Import
 Meta information Include Mod2
 organization, contact
SubA
 Revision history
 revision Include

SubX SubY SubZ


module acme-module {
namespace "http://acme.example.com/module";
prefix acme;

import "yang-types" {
prefix yang;
}
include "acme-system";

organization "ACME Inc.";


contact [email protected];
description "The module for entities
implementing the ACME products";

revision 2007-06-09 {
description "Initial revision.";
}

}
The "leaf" Statement
 A leaf has
 one value
 no children
YANG Example:
 one instance
leaf host-name {
type string;
mandatory true;
config true;
description "Hostname for this system";
}
NETCONF XML Encoding:

<host-name>my.example.com</host-name>
The "leaf-list" Statement
 A leaf-list has
 one value
YANG Example:  no children
leaf-list domain-search {
 multiple instances
type string;
ordered-by user;
description "List of domain names to search";
}

NETCONF XML Encoding:

<domain-search>high.example.com</domain-search>
<domain-search>low.example.com</domain-search>
<domain-search>everywhere.example.com</domain-search>
The "container" Statement
 A container has
YANG Example:
 no value
container system {
container services {  holds related children
container ssh {  one instance
presence "Enables SSH";
description "SSH service specific configuration";
// more leafs, containers and stuff here...
}
}
} May have specific meaning
NETCONF XML Encoding: (presence)
<system>
Or may simply contain
<services> other nodes
<ssh/>
</services>
</system>
The "must" Statement
 Constrains nodes by
container timeout {
XPath expression
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 "$this < ../access-timeout" {
error-app-tag retry-timer-invalid;
error-message "The retry timer must be "
+ "less than the access timeout";
}
}
}
The "list" Statement  A list is
 uniquely identified
by key(s)
YANG Example:
 holds related
children
list user {  no value
key name; NETCONF XML Encoding:
 multiple instances
leaf name {
type string; <user>
} <name>glocks</name>
leaf uid { <full-name>Goldie</full-name>
type uint32; <class>intruder</class>
} </user>
leaf full-name { <user>
type string; <name>snowey</name>
} <full-name>Snow</full-name>
leaf class { <class>free-loader</class>
type string; </user>
default viewer; <user>
} <name>rzull</name>
} <full-name>Repun</full-name>
</user>
The "augment" Statement
 Extends data model
YANG Example:  Current or imported
modules
augment system/login/user {
leaf expire {  Inserts nodes
type yang:date-and-time;
 Into an existing hierarchy
}
}  Nodes appear in current
module's namespace
 Original (augmented)
module is unchanged
NETCONF XML Encoding:

<user>
<name>alicew</name>
<class>drop-out</class>
<other:expire>2112-04-01T12:00:00</other:expire>
</user>
The "when" Statement
YANG Example:
 Makes sparse
augment system/login/user { augmentation
when "class = wheel";
leaf shell {
 Nodes are only
type string; added when
} condition is true
}  "when" is XPath
expression
NETCONF XML Encoding:

<user>
<name>alicew</name>
<class>wheel</class>
<other:shell>/bin/tcsh</other:shell>
</user>
Built-in types

Category Types
Integral {,u}int{8,16,32,64}
String string, enumeration, boolean
Binary Data binary
Bit fields bits
References instance-identifier, keyref
Other empty
Derived types
YANG Example:
 Constraints
typedef percent {
 range
type uint16 {
range "0 .. 100";  length
}  pattern
description "Percentage";
} • regex
 A modules may use
leaf completed {
type percent; types imported from
}
NETCONF XML Encoding:
other modules

<completed>20</completed>
The "union" type
YANG Example:  Allows a leaf to
leaf limit {
contain a
description "Number to allow"; superset of
type union {
type uint16 { types
range "0 .. 100";
}
type enumeration {
enum none {
NETCONF XML Encoding:
description "No limit";
}
<limit>none</limit>
}
}
} NETCONF XML Encoding:

<limit>20</limit>
The "grouping" Statement
 Defines a reusable
YANG Example collection of nodes
grouping target {  Use multiple times
leaf address {  A modules may use
type inet:ip-address; groupings imported
description "Target IP address";
from other modules
}
leaf port {  Refinement
type inet:ip-port;
description "Target port number";  Use as structure,
} record, or object
}
container peer { NETCONF XML Encoding:
container destination {
uses target; <peer>
} <destination>
} <address>192.0.2.1</address>
<port>22</port>
</destination>
</peer>
The "choice" Statement
 Allow only one member
of the choice to exist in a
YANG Example:
valid config datastore
choice transfer-method {
leaf transfer-interval {
description "Frequency at which file transfer happens";
type uint {
range "15 .. 2880";
}
units minutes;
}

leaf transfer-on-commit {
description "Transfer after each commit";
type empty;
NETCONF XML Encoding:
}
}
<transfer-on-commit/>
The "anyxml" Statement
YANG Example:  Allows arbitrary
anyxml software-version {
XML content to be
description "Number to allow"; carried in YANG-
}
based models
 Opaque
 Limited operations
NETCONF XML Encoding:
• Bulk only
<software-version>
<base>A10.2</base>
<routing>B4.2</routing>
<snmp>C87.12</snmp>
</software-version>
The "rpc" Statement
rpc activate-software-image {
input {  Defines RPC
leaf image-name {  method names
type string;
}  input parameters
}  output parameters
output {
leaf status {
type string;
}
}
<rpc xmlns="urn:mumble">
}
<activate-software-image>
<image-name>image.tgz</image-name>
</activate-software-image>
</rpc>
The "notification" Statement

 Defines notification
YANG Example:  Name
 Content
notification link-failure {
description "A link failure has been detected";
leaf if-index {
type int32 { range "1 .. max"; }
}
leaf if-name {
type keyref {
path "/interfaces/interface/name";
}
}
}
Semantic Differentiators

 Notice that YANG is modeling the semantics and data


organization
 Not just the syntax
Statement Purpose
unique Ensure unique values within list siblings
keyref Ensure referential integrity

config Indicate if a node is config data or not

default Supply default value for leafs

error-app-tag Define the tag used when constraint fails

error-message Define the message used ....

mandatory Node must exist in valid config datastore


Tools (yang-central.org)

 pyang (python)
 Validates YANG
 Translates between YANG and YIN (XML)
 Generates XSD
 yangto (binary)
 Validates YANG
 Generates XSD, dependencies, etc
 libsmi
 Translates SMI/SMIv2 MIBs to YANG
 Other goodies
 Emacs mode
What can you do to help?

 Read the draft


 There's a lot more in there
 Join the mailing list
[email protected]
 https://www.ietf.org/mailman/listinfo/yang

 Try out the tools


 www.yang-central.org
 Tutorial (this) at:
 http://www.yang-central.org/twiki/bin/view/Main/YangTutorials

You might also like