CPS-735 Spike: Support for Yang Language Extension
Overview
The following study describes extending YANG language statements to allow customization of models.
References:
Related JIRA stories:
YANG Language
The YANG language provides us the ability to define and model configurations and state data by defining YANG modules
Modules contain a sequence of statements
Statement syntax is either of the following :
statement = keyword [argument] ;
statement = keyword [argument] { <substatement(s)..> } ;
* argument can be zero or one depending on the statement
* argument is a string
An XML-based equivalent version of YANG is called YIN
YANG uses a tree to define the hierarchy of data wherein each ‘node’ has a value or/and a set of child nodes
4 types of nodes
container nodes
list nodes
leaf nodes
leaf-list nodes
Basic YANG statements
Sample YANG (stores.yang) | Statements and Description |
|---|---|
stores modelmodule stores {
yang-version 1.1;
namespace "org:onap:ccsdk:sample";
prefix book-store;
revision "2020-09-15" {
description
"Sample Model";
}
typedef year {
type uint16 {
range "1000..9999";
}
}
container bookstore {
leaf bookstore-name {
type string;
}
list categories {
key "code";
leaf code {
type string;
}
leaf name {
type string;
}
list books {
key title;
leaf title {
type string;
}
leaf-list authors {
type string;
}
}
}
}
}
| module Statement see example from Line 1
see examples from Lines 2-16
typedef Statement see example from Line 12
container Statement see example from Line 18
leaf Statement see example from Line 27
list Statement see example from Line 35
leaf-list Statement see example from Line 41
|