NETCONF YANG
NETCONF Transport
NETCONF messages are encoded in XML
NETCONF messages are encrypted by SSH
• SSH provides authentication, integrity and confidentiality
NETCONF is connected oriented using TCP
YANG ?
• Data modeling language• Configuration data
• State data
• Tree structure
• Data and Types
Imports & Includes
YANG Base Types
• Most YANG elements have a
data type
• Type may be a base type or
derived type
• Derived types may be simple
typedefs or groupings
(structures)
• There are 20+ base types to
start with
Typedef Statement
Defines a new simple type
typedef percent {
type uint16 {
range "0 .. 100";
}
description "Percentage";
}
leaf completed {
type percent;
}
Common YANG Types
• Commonly used YANG types defined in RFC 6021
• Use
import “ietf-yang-types” {
prefix yang;
}
to reference these
types as e.g.
type yang:counter64;
Grouping Statement
Defines a new structured type
grouping target {
leaf address {
type inet:ip-address;
description "Target IP";
}
leaf port {
type inet:port-number;
description "Target port number";
}
}
container peer {
container destination {
uses target;
}
}
container servers {
container http {
uses target {
refine port {
default 80;
}
}
}
}
YANG Data Definitions
Leaf Statement
Holds a single value of a particular type
Has no children
leaf host-name {
type string;
mandatory true;
config true;
description "Hostname for this system";
}
leaf cpu-temp {
type int32;
units degrees-celsius;
config false;
description ”Current temperature in CPU";
}
Attributes for leaf
Container Statement
Groups related leafs and containers
container system {
container services {
container ssh {
presence "Enables SSH";
description "SSH service specific configuration";
// more leafs, containers and other things here...
}
}
}
Leaf-list Statement
Holds multiple values of a particular type
Has no children
leaf-list domain-search {
type string;
ordered-by user;
description "List of domain names to search";
}
List Statement
list user {
key name;
leaf name {
type string;
}
leaf uid {
type uint32;
}
leaf full-name {
type string;
}
leaf class {
type string;
default viewer;
}
}
Attributes for leaf and leaf-list
Keys
The key field is used to specify
which row we're talking about.
No two rows can have same key value
If we want, we could select the uid to be key instead.
/user[name=‘yang’]/name = yang
/user[name=‘yang’]/uid = 1010
/user[name=‘yang’]/class = admin
/user[name=‘ling’]/class = viewer
Leafref
To make an element reference one of
the rows in a list, set the element type
to leafref
For lists with multiple keys, the #leafrefs
must match #keys in list
• A valid leafref can never be
null/empty
– But the parent leaf can be
optional
• A valid leafref can never
point to a row that has
been deleted or renamed
• System checks validity of
leafrefs automatically
Here, the RIP routing
subsystem has a list of
leafrefs pointing out existing
interfaces
container rip {
list network-ifname {
key ifname;
leaf ifname {
type leafref {
path “/interface/name”;
}
}
}
}
YANG RPCs & Notifications
RPC Statement
Administrative actions with input
and output parameters
rpc activate-software-image {
input {
leaf image {
type binary;
}
}
output {
leaf status {
type string;
}
}
}
Notification Statement
Notification with output parameters
notification config-change {
description
”The configuration changed";
leaf operator-name {
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>
opendaylight-inventory.yang
module opendaylight-inventory {
namespace "urn:opendaylight:inventory";
prefix inv;
typedef node-id {
type inet:uri;
}
typedef node-connector-id {
type inet:uri;
}
typedef node-ref {
type instance-identifier;
}
typedef node-connector-ref {
type instance-identifier;
}
grouping node {
leaf id {
type node-id;
}
list "node-connector" {
key "id";
uses node-connector;
}
}
grouping node-connector {
leaf id {
type node-connector-id;
}
}
container nodes {
list node {
key "id";
uses node;
. . .
}
}
Augmentation made by
OpenFlow plugin for storing:
1. All switch description
OpenFlow plugin for storing:
1. All switch description
2. All OpenFlow features
3. All tables and its flows
4. All meters, groups
notification node-updated {
status deprecated;
leaf node-ref {
type node-ref;
}
uses node;
}
notification node-connector-updated {
status deprecated;
leaf node-connector-ref {
type node-connector-ref;
}
uses node-connector;
}
notification node-removed {
status deprecated;
leaf node-ref {
type node-ref;
}
}
notification node-connector-removed {
status deprecated;
leaf node-connector-ref {
type node-connector-ref;
}
}
}
ODL’s Inventory Config Data Store
http://localhost:8181/restconf/config/opendaylight-inventory:nodes
ODL’s network-topology.yang (Lithium)
http://localhost:8181/restconf/operational/network-topology:network-topology
module
network-topology {
namespace
"urn:TBD:params:xml:ns:yang:network-topology";
typedef
topology-ref
{
type
leafref
{
path
"/network-topology/topology/inet:uri";
}
}
typedef
node-ref
{
type
leafref
{
path
"/network-topology/topology/node/inet:uri";
}
}
typedef
link-ref
{
type
leafref
{
path
"/network-topology/topology/link/inet:uri";
}
}
grouping
tp-attributes
{
leaf
tp-id
{
type
inet:uri;
}
leaf-list
tp-ref
{
type
tp-ref;
}
}
grouping
node-attributes
{
leaf
node-id
{
type
inet:uri;
}
list
supporting-node
{
key
"node-ref";
leaf
node-ref
{
type
node-ref;
}
}
}
grouping
link-attributes
{
leaf
link-id
{
type
inet:uri;
}
container
source
{
leaf
source-node
{
mandatory
true;
type
node-ref;
}
leaf
source-tp
{
type
tp-ref;
}
}
container
destination
{
leaf
dest-node
{
mandatory
true;
type
node-ref;
}
leaf
dest-tp
{
type
tp-ref;
}
}
list
supporting-link
{
key
"link-ref";
leaf
link-ref
{
type
link-ref;
}
}
}
container
network-topology
{
list
topology
{
key
"topology-id";
leaf
topology-id
{
type
inet:uri;
}
container
topology-types
{
}
list
underlay-topology
{
key
"topology-ref";
leaf
topology-ref
{
type
topology-ref;
}
}
list
node
{
key
"node-id";
uses
node-attributes;
list
termination-point
{
key
"tp-id";
uses
tp-attributes;
}
}
list
link
{
key
"link-id";
uses
link-attributes;
}
}
}
}
评论
发表评论