Title: YANG in a Nutshell
1YANG in a Nutshell
2YANG has...
- A reasonable self-contained specification
- A focus on readers and reviewers
- Text-based
- Email, patch, and RFC friendly
- Limited Scope, but extensible
- Ability to model config data, state data, RPCs,
and notifications - Experience gained by existing implementations
- Design is based on four proprietary modeling
languages
3Support for YANG
- Running code (multiple implementations)
- People outside the YANG team using it in other
WGs in the IETF - Backing of several NETCONF implementers
- Growing group of fans and admirers
4Semantics and syntax
- Models semantics and data organization
- Syntax falls out of semantics
- Think SMI for NETCONF
Semantic World
YANG
Syntactic World
Anything Else
XML Schema
Relax-NG
Out going XML
Legacy tools
Validation
5Easy to read, easy to learn
- Grok factor
- Direct encoding of data hierarchy
container system leaf host-name
type inethost description "Name of this
host" container services
container ssh presence "Enables
SSH" description "SSH service
specific configuration" // more
leafs, containers and stuff here...
ltsystemgt lthost-namegtfredlt/host-namegt
ltservicesgt ltssh/gt lt/servicesgt lt/systemgt
6Model-Based Infrastructure
Management application
- YANG can form the infrastructure for the
management plane inside the device - Not required, but common wisdom
- Three implementations do this
- Ease the maintenance, stability, and
enhance-ability of the device
YANG Modules
CLI
NETCONF Server
YANG Modules
Management Plane
S1
S2
S3
Subcomponents
7Constraints using "must"
- Constrains nodes by XPath 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 "this lt
../access-timeout" error-app-tag
retry-timer-invalid error-message
"The retry timer must be "
"less than the access timeout"
- Also
- keyref
- unique
- range
- pattern
8Extensibility with "augment"
- Extends data model
- Current or imported modules
- Inserts nodes
- Into an existing hierarchy
- Nodes appear in current module's namespace
- Original (augmented) module is unchanged
- Allows sparse augmentation
- Nodes are only added when condition is true
- "when" is XPath expression
augment interfaces/interface when "type
'ethernet'" container ether-options
leaf auto-negotiation type empty
ltinterfacesgt ltinterfacegt ltnamegtfe-0/0/0lt/nam
egt lttypegtethernetlt/typegt ltether-optionsgt
ltauto-negotiation/gt lt/ether-optionsgt
lt/interfacegt lt/interfacesgt
9The "grouping" Statement
- Defines a reusable collection of nodes
- Use multiple times
- A modules may use groupings imported from other
modules - Refinement
- Use as structure, record, or object
YANG Example grouping target leaf address
type inetip-address
description "Target IP address" leaf
port type inetip-port
description "Target port number"
container peer container destination
uses target
NETCONF XML Encoding ltpeergt ltdestinationgt
ltaddressgt192.0.2.1lt/addressgt ltportgt22lt/portgt
lt/destinationgt lt/peergt
10The "rpc" Statement
rpc activate-software-image input
leaf image-name type string
output leaf status
type string
- Defines RPC
- method names
- input parameters
- output parameters
ltrpc xmlns"urnmumble"gt ltactivate-software-imag
egt ltimage-namegtimage.tgzlt/image-namegt
lt/activate-software-imagegt lt/rpcgt
11Tools (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
12YANGsters Unite!
- Read the draft
- There's a lot more in there
- Join the mailing list
- yang_at_ietf.org
- https//www.ietf.org/mailman/listinfo/yang
- Try out the tools
- www.yang-central.org
- Tutorial at
- http//www.yang-central.org/twiki/bin/view/Main/Ya
ngTutorials