181 Netconf Yang Tutorial 43
181 Netconf Yang Tutorial 43
[email protected]
Today’s Topic: #1 Market Leader in Configuration Management
Operator
SNMP
Experience
Requirements
NETCONF
and
YANG
NETCONF
• Data-Model
• A data-model explicitly and precisely
determines the structure, syntax and
Protocol
semantics of the data…
• …that is externally visible
• Consistent and complete
• Protocol
Data-Model • Remote primitives to view and manipulate the
data
• Encoding of the data as defined by the data-
model
Who ?
NETCONF YANG
• Phil Shafer, Rob Enns • Phil Shafer
• Juniper
• Juniper, XML
• Jürgen Schönwälder
• Jacobs University • Jürgen Schönwälder
• Martin Björklund • Jacobs University, SNMP SMIng
• Tail-f
• Andy Bierman
• Martin Björklund
• Yumaworks • Tail-f
Ken Crozier Eliot Lear
•
• David Partain
• Cisco Systems
• Ericsson, made it happen
• Ted Goddard
• IceSoft
• Steve Waldbusser
• Margaret Wasserman
• Painless Security, LLC
Language Bindings
Momentum
configuration
1. Ease of use is a key requirement for Maybe
not
assume
integrators
and
any network management technology soLware
developers
for
any
addi5on
from the operators point of view. or
change
Manage
VPN Configura5on
configura5on
OSS
NMS
EMS
NETCONF
Manager
Cost
and
complexity
• No well-defined protocols and
data-models
• Lack of atomicity
• Ordering problem
OSS
NMS
EMS
NETCONF
Manager
Reduced
Cost/
Cost
and
Value
complexity
Transac5ons
Models
Standardized
Protocols
Introduction to NETCONF
“RESTConf”
Data Modeling SMI YANG (WSDL, not data) Undefined, (WSDL),
Language WADL, text…
NETCONF Features
Server
Device
Layers
Config
No5fica5on
Content
Data
Data
<EDIT-‐CONFIG>
Opera5ons
<GET-‐CONFIG>
<RPC>
Messages
<NOTIFICATION>
<RPC-‐REPLY>
Secure
SSH
Transport
NETCONF Capabilities
Always!
Commit
Only
one!
R1 R2 R3
:writable-running!
:candidate!
:confirmed-commit!
:rollback-on-error!
:validate!
:startup!
:url (scheme=http, ftp, file, …)
:xpath (filters)
NETCONF Operations
<rpc-reply message-id="101”
xmlns="urn:ietf:params:xml:ns:netconf:base:1.1">!
<ok/>!
</rpc-reply>!
NETCONF capabilities
• :writable-running!
• <edit-config> and <copy-config> can have candidate as a
<target>!
• :candidate!
• Share “scratch-pad”!
• <commit> to running!
• <discard-changes>!
• :confirmed-commit!
• <confirmed> parameter to commit!
• <cancel-commit>!
• :validate!
• <validate>!
• <test-option> parameter to the <edit-config>!
• :startup!
• :url!
• :xpath!
©2013 TAIL-F all rights reserved MAY 27, 2013 52
TUTORIAL: NETCONF AND YANG
NETCONF FILTERS
NETCONF Filters
• Namespace Selection
• Containment Nodes
• Selection Nodes
• Content Match Nodes
• Attribute Match Expression
• XPATH (capability)
<filter
type="subtree">
<top
xmlns="hcp://example.com/schema/1.2/config"/>
</filter>
Selec5on
Node
An
empty
leaf
node
within
a
filter
<top/>
<top></top>
<filter
type="subtree">
<top
xmlns="hcp://example.com/schema/1.2/config">
<users/>
</top>
</filter>
<filter
type="subtree">
<top
xmlns="hcp://example.com/schema/1.2/config">
<users>
<user>
<name>fred</name>
</user>
</users>
</top>
</filter>
Containment
Nodes
<filter
type="subtree">
<t:top
xmlns:t="hcp://example.com/schema/1.2/config">
<t:interfaces>
<t:interface
t:ifName="eth0"/>
</t:interfaces>
</t:top>
</filter>
XML
Acribute….
Selec5on
Node
NOTIFICATIONS
Event Notifications
Example:
VPN provisioning using NETCONF
Network-wide Transactions
VPN Scenario
West
Hello Site
A
North
• Exchange capabilities
Site
B
>>>>> Router-West (Sun Nov 15 14:41:25 CET 2009)!
<hello xmlns="urn:ietf:params:xml:ns:netconf:base:1.1">! East
<capabilities>!
<capability>urn:ietf:params:netconf:base:1.1</capability>!
</capabilities>! West
</hello>!
Validate candidates
Unlock candidates
Using confirmed-commit
Disaster happens
• Network-wide transactions
• Applying and testing a configuration
• Testing and rejecting a configuration
• Rollback when device goes down
• Transactions requiring all devices to be up
• Backlogging transactions
• Synchronizing
YANG ?
acme-‐box
module
• Data modeling language
• Configuration data
• State data proper5es
container
• Tree structure
• Close to device name:
string,
config
• Managing device features
• Data and Types
• Constraints interfaces
container
• Augmentation
• Reusable structures interface:
list,
index
=
name
• Extensions
• SMI translation name:
string,
config
• XML
• NETCONF Transport Encoding oper-‐state:
enum,
config
• YANG – XML Model mapping
YANG ?
Header information
Type definitions
YANG Header
URI
• Leaf
• Leaf-List
• Container
• List
Leaf Statement
leaf host-name {!
type string;!
mandatory true;! NETCONF XML:
config true;! <host-name>my.example.com</host-name>
description "Hostname for this system";!
}!
leaf cpu-temp {!
type int32;!
units degrees-celsius;!
config false;!
description ”Current temperature in CPU";!
}! cpu-‐temp
not
returned
in
! NETCONF
get-‐config
Leaf-list Statement
leaf-list domain-search {!
type string;!
ordered-by user;!
description "List of domain names to search";!
}!
Container Statement
services
ssh
Presence
container system {!
…
container services {!
container ssh {! …
presence "Enables SSH";!
description "SSH service specific configuration";!
// more leafs, containers and other things here...!
}!
}!
}!
NETCONF XML:
<system>
<services>
<ssh>
Presence
containers
explicitly
created/deleted
by
</ssh>
NETCONF
client.
They
also
represent
config
“themselves”.
</services>
“Normal”
containers
have
no
meaning,
just
organiza5on
of
</system>
data.
List Statement
user
Keys
user
/user[name=‘yang’]/name = yang!
The key field is used to specify /user[name=‘yang’]/uid = 1010!
which row we’re talking about. /user[name=‘yang’]/class = admin!
!
No two rows can have same key /user[name=‘ling’]/class = viewer!
value
Keys
user
Unique Statement
user
Multiple keys
route
16.40.0. 16 220.40.0.1 20
0
16.42.0. 16 82.193.16.1 40
0
16.42.0. 24 82.193.16.6 50
0
Leafref
Leafref
interface rip
eth0.16 ifname
eth0.19 192.168.0.1 eth0.19
eth2.5 24.97.238.15
client video
12.36.2.19 33115
12.36.2.19 33667 12.36.2.19 33667
67.3.51.196 33667
container video {!
leaf v-ip { !
type leafref { !
path "/client/ip"; !
}!
}!
leaf v-port { !
type leafref { !
path "/client[ip=current()/../v-ip]/port";!
}!
}!
Grouping Statement
Fragment import
A.yang
include
Fragment
E.yang
Fragment
B.yang
Imported fragments are just
include include referenced, not included
Fragment Fragment
C.yang D.yang
YANG Types
Typedef Statement
Type Restrictions
Integers Strings
typedef my-base-int32-type {! typedef my-base-str-type {!
type int32 {! type string {!
range "1..4 | 10..20";! length "1..255";!
}! }!
}! }!
! !
typedef derived-int32 {! typedef derived-str {!
type my-base-int32-type {! type my-base-str-type {!
range "11..max"; // 11..20! length "11 | 42..max";
}! pattern "[0-9a-fA-F]*";!
} ! }!
}!
Union Statement
typedef threshold {!
description ”Threshold value in percent";!
type union {!
type uint16 {!
range "0 .. 100";!
}!
type enumeration {!
enum disabled {!
description "No threshold";!
}!
}!
}!
}!
RPC Statement
image
rpc activate-software-image {!
input {! status
leaf image {!
type binary;!
}!
}!
output {!
leaf status {!
type string;!
}!
}!
}!
Notification Statement
config-‐change
notification config-change {!
description ! operator-‐name
”The configuration changed";!
leaf operator-name {! change
type string;!
}!
leaf-list change {!
type instance-identifier;!
}!
}!
Instance-identifier values
<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>!
Must Statement
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";!
}!
}!
Augment Statement
user
+
name uid full-name class expire
Default
augment /sys:system/sys:user {!
leaf expire {!
type yang:date-and-time;!
}!
}!
When Statement
user
+
name uid full-name class expire shell
Default When
augment /sys:system/sys:user {!
when ”sys:class = ‘wheel’";!
leaf shell {!
type string;!
}!
}!
Choice Statement
transfer-‐interval
choice transfer-method {!
leaf transfer-interval {! transfer-‐on-‐commit
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;!
}!
}!
Choice Statement
choice counters {!
case four-counters {!
leaf threshold {…}!
leaf ignore-count {…}!
leaf ignore-time {…}!
leaf reset-time {…}!
}! • Only
in
schema
tree
container warning-only {! • Not
in
the
data
tree
or
NETCONF
…! • Device
handles
dele5on
of
“other”
}! case
when
case
is
created.
default four-counters;!
}!
Identity Statement
Feature Statement
Deviations
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;!
}!
}!
IETF Activities
Maybe: Maybe:
• RESTCONF • Topologies
• DHCPv6 option for server discovery • ACLs
• Efficiency extensions • OSPF
! https://datatracker.ietf.org/wg/netconf/charter/
! www.rfc-editor.org/rfc/rfcXXXX.txt
! https://datatracker.ietf.org/wg/netmod/charter/
! https://www.ietf.org/iesg/directorate/yang-doctors.html
! http://www.yang-central.org/