Netconf and Yang Status, Tutorial, Demo: J Urgen SCH Onw Alder
Netconf and Yang Status, Tutorial, Demo: J Urgen SCH Onw Alder
Jürgen Schönwälder
2 / 40
Cool — and what is YANG?
3 / 40
NETCONF and YANG Timeline
Timeline
Jun 2002 IAB network management workshop
May 2003 NETCONF WG established
Dec 2006 NETCONF core RFCs published
2007 YANG design team creates YANG proposal
Apr 2008 NETMOD WG established
2009 YANG core RFCs published
4 / 40
NETCONF Layering Model (RFC4741)
Layers. . .
Layer Example
5 / 40
STOP
6 / 40
$ ssh -s broccoli netconf
<?xml version="1.0" encoding="UTF-8"?>
<hello xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
<capabilities>
<capability>urn:ietf:params:netconf:base:1.0</capability>
<capability>urn:ietf:params:netconf:capability:writable-running:1.0</capability
<capability>urn:ietf:params:netconf:capability:candidate:1.0</capability>
<capability>urn:ietf:params:netconf:capability:confirmed-commit:1.0</capability
<capability>urn:ietf:params:netconf:capability:xpath:1.0</capability>
<capability>urn:ietf:params:netconf:capability:url:1.0?scheme=ftp,file</capabil
<capability>urn:ietf:params:netconf:capability:validate:1.0</capability>
<capability>urn:ietf:params:netconf:capability:rollback-on-error:1.0</capabilit
<capability>http://tail-f.com/ns/aaa/1.1</capability>
<capability>http://tail-f.com/ns/execd/1.1</capability>
<capability>urn:ietf:params:xml:ns:yang:inet-types?revision=2009-05-13</capabil
<capability>urn:ietf:params:xml:ns:yang:yang-types?revision=2009-05-13</capabil
</capabilities>
<session-id>123</session-id></hello>]]>]]>
7 / 40
#! /usr/bin/env python2.6
#
# Connect to the NETCONF server passed on the command line and
# display their capabilities. This script and the following scripts
# all assume that the user calling the script is known by the server
# and that suitable SSH keys are in place. For brevity and clarity
# of the examples, we omit proper exception handling.
#
# $ ./nc01.py broccoli
if __name__ == ’__main__’:
demo(sys.argv[1], os.getenv("USER"))
8 / 40
#! /usr/bin/env python2.6
#
# Retrieve the running config from the NETCONF server passed on the
# command line using get-config and write the XML configs to files.
#
# $ ./nc02.py broccoli
if __name__ == ’__main__’:
demo(sys.argv[1], os.getenv("USER"))
9 / 40
#! /usr/bin/env python2.6
#
# Retrieve a portion selected by an XPATH expression from the running
# config from the NETCONF server passed on the command line using
# get-config and write the XML configs to files.
#
# $ ./nc03.py broccoli "aaa/authentication/users/user[name=’schoenw’]"
if __name__ == ’__main__’:
demo(sys.argv[1], os.getenv("USER"), sys.argv[2])
10 / 40
CONTINUE
11 / 40
NETCONF Operations
get-config(source, filter)
Retrieve a (filtered subset of a) configuration from the
configuration datastore source.
edit-config(target, default-operation,
test-option, error-option, config)
Edit the target configuration datastore by merging,
replacing, creating, or deleting new config elements.
copy-config(target, source)
Copy the content of the configuration datastore source
to the configuration datastore target.
delete-config(target)
Delete the named configuration datastore target.
12 / 40
NETCONF Operations (cont.)
lock(target)
Lock the configuration datastore target.
unlock(target)
Unlock the configuration datastore target.
get(filter)
Retrieve (a filtered subset of a) the running configuration
and device state information.
close-session()
Gracefully close the current session.
kill-session(session)
Force the termination of the session session.
13 / 40
NETCONF Operations (cont.)
discard-changes()
Revert the candidate configuration datastore to the
running configuration (:candidate capability).
validate(source)
Validate the contents of the configuration datastore
source (:validate capability).
commit(confirmed, confirm-timeout)
Commit candidate configuration datastore to the running
configuration (:candidate capability).
create-subscription(stream, filter, start,
stop)
Subscribe to a notification stream with a given filter
and the start and stop times.
14 / 40
Editing Configuration
merge
The configuration data is merged with the configuration at the
corresponding level in the configuration datastore.
replace
The configuration data replaces any related configuration in
the configuration datastore identified by the target parameter.
create
The configuration data is added to the configuration if and
only if the configuration data does not already exist.
delete
The configuration data identified by the element containing
this attribute is deleted in the configuration datastore.
15 / 40
STOP
16 / 40
#! /usr/bin/env python2.6
#
# Create a new user to the running configuration using edit-config
# and the test-option provided by the :validate capability.
#
# $ ./nc04.py broccoli bob 42 42
if __name__ == ’__main__’:
demo(sys.argv[1], os.getenv("USER"), sys.argv[2], sys.argv[3], sys.argv[4])
17 / 40
#! /usr/bin/env python2.6
#
# Delete an existing user from the running configuration using
# edit-config and the test-option provided by the :validate
# capability.
#
# $ ./nc05.py broccoli bob
if __name__ == ’__main__’:
demo(sys.argv[1], os.getenv("USER"), sys.argv[2])
18 / 40
CONTINUE
19 / 40
Configuration Datastores
Definition
A configuration datastore is the complete set of configuration
information that is required to get a device from its initial
default state into a desired operational state.
The <running> configuration datastore represents the
currently active configuration of a device and is always
present.
The <startup> configuration datastore represents the
configuration that will be used during the next startup.
The <candidate> configuration datastore represents a
configuration that may become a <running>
configuration through an explicit commit.
20 / 40
Transaction Models
Direct Model
running
<edit−config>
candidate running
<edit−config> <commit>
running startup
<edit−config> <copy−config>
<commit>
21 / 40
STOP
22 / 40
#! /usr/bin/env python2.6
#
# Delete a list of existing users from the running configuration using
# edit-config; protect the transaction using a lock.
#
# $ ./nc06.py broccoli bob alice
if __name__ == ’__main__’:
demo(sys.argv[1], os.getenv("USER"), sys.argv[2:])
23 / 40
#! /usr/bin/env python2.6
#
# Delete a list of existing users from the running configuration using
# edit-config and the candidate datastore protected by a lock.
#
# $ ./nc07.py broccoli bob alice
if __name__ == ’__main__’:
demo(sys.argv[1], os.getenv("USER"), sys.argv[2:]) 24 / 40
CONTINUE
25 / 40
NETCONF Implementations
27 / 40
YANG, YIN, XSD, RELAX NG
YANG’s purpose
YANG is an extensible NETCONF data modeling language
able to model configuration data, state data, operations, and
notifications. YANG definitions directly map to XML content.
28 / 40
Built-in Data Types
Type system
The data type system is mostly an extension of the SMIng
type system, accommodating XML and XSD requirements.
29 / 40
Leafs, Leaf-lists, Container, Lists
leaf
A leaf has one value, no children, one instance.
leaf-list
A leaf-list has one value, no children, multiple instances.
container
A container has no value, holds related children, has one
instance.
list
A list has no value, holds related children, has multiple
instances, has a key property.
30 / 40
STOP
31 / 40
module jacobs-fake-aaa-module {
namespace "http://tail-f.com/ns/aaa/1.1";
prefix aaa;
organization
"Jacobs University Bremen";
contact
"Juergen Schoenwaelder";
description
"This module contains a fake YANG module for some tail-f data
models and it should only be used for educational purposes.";
revision 2009-07-30 {
description "Initial revision.";
}
feature ssh-keys {
description
"This feature indicate the support of SSH key storage.";
}
// ...
}
32 / 40
container aaa {
container users {
list user {
key "name";
leaf name {
type string {
pattern "[a-zA-Z0-9]+";
}
description
"The name of an account on the system. Note that the name
root is often associated with special priviledges.";
}
leaf uid {
type uint32;
mandatory true;
description
"The id used by the system to identify a user.";
}
leaf gid {
type uint32;
mandatory true;
description
"The id used by the system to identify the user’s group.";
}
33 / 40
leaf password {
type hashed-password;
description
"The hashed password of a user. The special value * means
no access to the system.";
}
leaf ssh_keydir {
type string;
if-feature ssh-keys;
description
"The storage location of SSH keys."
}
leaf homedir {
type string;
default "/";
description
"The home directory of the user.";
}
}
}
}
34 / 40
CONTINUE
35 / 40
Augment, Must, When
augment
The augment statement can be used to place nodes into an
existing hierarchy using the current module’s namespace.
must
The must statement can be used to express constraints (in the
form of XPATH expressions) that must be satisfied by a valid
configuration.
when
The when statement can be used to define sparse
augmentations where nodes are only added when a condition
(expressed in the form of an XPATH expression) is true.
36 / 40
Grouping and Choice
grouping
A grouping is a reusable collection of nodes. The grouping
mechanism can be used to emulate structured data types or
objects. A grouping can be refined when it is used.
choice
A choice allows one alternative of the choice to exist. The
choice mechanism can be used to provide extensibility hooks
that can be exploited using augments.
37 / 40
Notifications and Operations
notification
The notification statement can be used to define the
contents of notifications.
rpc
The rpc statement can be used to define operations together
with their input and output parameters carried over the RPC
protocol.
38 / 40
YANG Implementations
Utilities
yang.el emacs mode for editing yang
39 / 40
Final Words. . .
Acknowledgements
Martin Björklund, Tail-f
Phil Shafer, Juniper Networks
Andy Bierman, Netconf Central
Shikhar Bhushan (ncclient), Jacobs University
Siarhei Kuryla (yang for libsmi), Jacobs University
Ha Manh Tran (netconf testing), Jacobs University
Disclaimer
All errors on the slides are mine.
40 / 40