Ncorg Netconf Yang Tutorial PDF
Ncorg Netconf Yang Tutorial PDF
v0.6 2014-07-10
Network Managed
Manager Device
Network
The schema for shared management information is defined independently of
the protocol, using a modular data modeling language
API Contract
Management Modules
A B C
Network Managed
Manager Device
SNMP
SMIv2 (MIB) Modules
A B C
SNMP SNMP
Manager Agent
NETCONF
YANG Modules
A B C
NETCONF NETCONF
Client Server
Request
Network Managed
Manager Response Device
Content
Operations
Network Managed
Manager Device
Messages
Transport
configuration
operational
state
statistics
Content
Operations
Network Managed
Manager Device
Messages
Transport
configuration
operational
state
statistics
RFC-defined in SNMP
YANG-defined in NETCONF
Content
Operations
Network Managed
Manager Device
Messages
Transport
configuration
operational
state
statistics
Content
Operations
Network Managed
Manager Device
Messages
Transport
configuration
operational
state
statistics
Content
Operations
Network Managed
Manager Device
Messages
Transport
configuration
operational
state
statistics
container
scalar table leaf leaf-list list
YANG YANG
Module No schema used
Choice is 1 of N cases simple or complex subtree
Case is 1 or more data-def
choice anyxml
Two forms of anyxml
case leaf container
MODULE-IDENTITY namespace-stmt
(OID) (URI)
fooMod ::= { mib-2 x } namespace urn:ietf:params:xml:ns:yang:foo
SMIv2 YANG
AUGMENT fooEntry
fooMod.N foo NS bar NS
barMod.N
fooTable fooEntry augment /foo:fooEntry
fooEntry X
i X X
barMod.2.7.1.2.1.<INDEX>
X /foo:list1[foo:i=”42”]/bar:X
/foo:list1[foo:i=”42”]/foo:X
fooMod.1.2.1.1.1.<INDEX>
A B C D D
id2 C
container
module A module B
con2
grouping g1 container con2 {
uses A:g1;
} leaf a leaf b
leaf a leaf b
uses-stmt replaced by
contents of grouping 'g1'
:writable-running
edit-config <running>
Automatic NV-save
copy-config
:writable-running + :startup
copy-config
edit-config
<running> <startup>
copy-config
:candidate
commit
edit-config
<candidate> <running>
Automatic NV-save
copy-config
- Edits are collected then applied all-or-none, and automatically saved to NV-storage
:candidate + :startup
commit copy-config
edit-config
<candidate> <running> <startup>
copy-config
- Edits are collected then applied all-or-none, and manually saved to NV-storage
<rpc>
NETCONF NETCONF
Client <rpc-reply> Server
module example-mod {
namespace
“http://example.com/ns/example-mod”;
prefix “ex”;
rpc test {
input { <rpc-reply message-id="101"
leaf count { type uint32; } xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
leaf msg { type string; } <ok />
} </rpc-reply>
// no output section!!
}
}
<rpc-reply message-id="101"
xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
<rpc-error>
... contents explained later!!!
</rpc-error>
</rpc-reply>
Parameter Description
target Configuration datastore to edit
default- Default edit mode; Default (merge)
operation Values (merge, replace, none)
test-option Values (test-then-set, set, test-only); D: (set)
error-option Values (stop-on-error, continue-on-error,
rollback-on-error); Default (stop-on-error)
config Portion of the configuration to edit
NETCONF/YANG Tutorial 46
Using the candidate datastore
● Edit phase
– <edit-config> used to collect edits in the (shared scratchpad) candidate datastore
– Global <lock> and <unlock> should be used to prevent multi-client collisions
●
Commit phase
– <commit> used to apply scratchpad all-or-none to the running datastore
● Commit with rollback
– <commit> w/ <confirmed> parameter for automatic rollback unless confirming <commit>
sent by client
– <cancel-commit> used to force manual rollback
● Cancel an edit
– <discard-changes> used to remove any edits from the candidate and re-sync with the
running datastore
NETCONF/YANG Tutorial 48
Part 3
● Overview
– Comparison of SNMP/SMIv2 and NETCONF/YANG properties
● NETCONF Basics
– Overview of core NETCONF protocol concepts
● YANG Basics
– Overview of core YANG data modeling concepts
● Advanced Topics
– Overview of advanced NETCONF and YANG concepts
● YANG:
– 2 forward slashes (//) used to indicate rest of line is a comment
// Implementation of the Ethernet History group is optional.
// Consult the MODULE-COMPLIANCE macro for the authoritative
// conformance information for this MIB.
– C style multi-line comments also allowed
/* Implementation of the Ethernet History group is optional.
Consult the MODULE-COMPLIANCE macro for the authoritative
conformance information for this MIB.
*/
Local definitions such as type names and groupings are not imported.
The current module prefix is allowed, but not required.
NETCONF/YANG Tutorial 56
YANG Filenames
● SMIv2: no standard naming conventions for MIB modules
● YANG: File naming conventions mandatory for standard
modules
– Directory path information is not part of the specification
– Organization SHOULD prefix module name
– 2 forms of a YANG file name
● any revision:
– <module-name>.yang
example-foo.yang
● specific revision:
– <module-name>@<revision-date>.yang
[email protected]
NETCONF/YANG Tutorial 59
YANG Identities
● Used to declare enumerated values with distributed naming authority
● SMIv2: “OBJECT IDENTITY” macro
– Declares an OBJECT IDENTIFIER value
transportDomainUdpIpv4 OBJECT-IDENTITY
STATUS current
DESCRIPTION
"The UDP over IPv4 transport domain. ...”
::= { transportDomains 1 }
● YANG: “identity” statement
– Declares an identityref leaf or leaf-list value
– Identity names are scoped by the module containing the identity statement
identity transportDomainUdpIpv4 {
status current
description
"The UDP over IPv4 transport domain. ...”;
}
NETCONF/YANG Tutorial (c) 2014 YumaWorks, Inc. 60
YANG Features
● All definitions in a YANG module are mandatory to
implement, unless they are part of a YANG feature
– feature-stmt: used to declare a YANG feature
feature radius {
description
"Indicates that the device can be configured as a RADIUS client.";
reference
"RFC 2865: Remote Authentication Dial In User Service (RADIUS)";
}
● SNMP conformance specified separately in MIB module
– GROUP macro (to specify objects in a named group)
– MANDATORY-GROUP sub-clause of MODULE-COMPLIANCE macro
● container
● leaf
● leaf-list
● list
● choice
● case
● anyxml
● uses
typedef knob2-range {
type knob-range { range “10 .. max”; }
}
leaf knob2 {
type knob2-range;
“max” for “knob2-range”
}
is “100”, not “2147483647”
1 2 3 4 5 6 ...
Replay 1 (stops when session is closed)
Replay 2 (finite)