-
Notifications
You must be signed in to change notification settings - Fork 13
02. What is YANG?
OpenConfig adopted YANG data modeling language (RFC 6020) to define vendor-neutral configuration model and operational state model.
So what is YANG?
YANG is an IETF standard described in RFC 6020.
YANG is a data modeling language used to model both configuration data and state data manipulated by the Network Configuration Protocol (NETCONF).
This allows a complete description of all data sent between a NETCONF client and server.
YANG can model configuration data (writable data), as well as state data (read-only status), based on the "config" statement:
- When a node is tagged with
config true
, it is flagged as configuration data. it can be returned using NETCONF's <get-config> operation. - When a node is tagged with
config false
, it is flagged as state data. it can be returned using NETCONF's <get> operation, not the <get-config> operation. it cannot be manipulated using <edit-config> netconf operation.
YANG modules can be translated into an equivalent XML syntax called YANG Independent Notation (YIN)
A leaf:
- Has exactly one value of a particular type.
- Has no children
YANG Example:
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";
}
NETCONF XML Example:
<host-name>my.example.com</host-name>
host-name is a leaf. It has no children. It has one value of type string. It is a configuration data: it can be manipulated using <edit-config> netconf operation, it is returned in NETCONF <get‐config> operation.
cpu-temp is a leaf. It has no children. It has one value of type int32 (32-bit signed integer). It is a state data. it is returned in NETCONF <get> operation. it is not returned in NETCONF <get‐config> operation. it can not be manipulated using <edit-config> netconf operation.
Like the leaf node but defines a set of nodes rather than a single node. Each node has a value but no child nodes.
So a leaf-list:
- has no children
- holds multiple values of (the same) particular type.
YANG Example:
leaf-list domain-search {
type string;
ordered-by user;
description "List of domain names to search";
}
NETCONF XML Example:
<domain-search>high.example.com</domain-search>
<domain-search>low.example.com</domain-search>
A container:
- has no value
- has only a set of child nodes.
YANG Example:
container system {
container login {
leaf message {
type string;
description
"Message given at start of login session";
}
}
}
NETCONF XML Example:
<system>
<login>
<message>Good morning</message>
</login>
</system>
YANG Example:
container system {
leaf host-name {
type string;
description "Hostname for this system";
}
leaf-list domain-search {
type string;
description "List of domain names to search";
}
container login {
leaf message {
type string;
description
"Message given at start of login session";
}
}
}