mirror of
https://github.com/Telecominfraproject/ols-nos.git
synced 2025-12-17 21:37:35 +00:00
[Yang] [CBF Maps] SONiC CBF MAPs Yang (#9116)
* SONiC CBF MAPs Yang
Created SONiC Yang model for the following CBF MAPs:
DSCP_TO_FC_MAP
EXP_TO_FC
This commit is contained in:
@@ -8,12 +8,14 @@ from json import dump, dumps, loads
|
|||||||
from xmltodict import parse
|
from xmltodict import parse
|
||||||
from glob import glob
|
from glob import glob
|
||||||
|
|
||||||
qos_maps_model = ['DSCP_TO_TC_MAP_LIST',
|
Type_1_list_maps_model = ['DSCP_TO_TC_MAP_LIST',
|
||||||
'DOT1P_TO_TC_MAP_LIST',
|
'DOT1P_TO_TC_MAP_LIST',
|
||||||
'TC_TO_PRIORITY_GROUP_MAP_LIST',
|
'TC_TO_PRIORITY_GROUP_MAP_LIST',
|
||||||
'TC_TO_QUEUE_MAP_LIST',
|
'TC_TO_QUEUE_MAP_LIST',
|
||||||
'MAP_PFC_PRIORITY_TO_QUEUE_LIST',
|
'MAP_PFC_PRIORITY_TO_QUEUE_LIST',
|
||||||
'PFC_PRIORITY_TO_PRIORITY_GROUP_MAP_LIST']
|
'PFC_PRIORITY_TO_PRIORITY_GROUP_MAP_LIST',
|
||||||
|
'DSCP_TO_FC_MAP_LIST',
|
||||||
|
'EXP_TO_FC_MAP_LIST']
|
||||||
|
|
||||||
"""
|
"""
|
||||||
This is the Exception thrown out of all public function of this class.
|
This is the Exception thrown out of all public function of this class.
|
||||||
@@ -413,7 +415,7 @@ class SonicYangExtMixin:
|
|||||||
return vValue
|
return vValue
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Xlate a Qos Maps list
|
Xlate a Type 1 map list
|
||||||
This function will xlate from a dict in config DB to a Yang JSON list
|
This function will xlate from a dict in config DB to a Yang JSON list
|
||||||
using yang model. Output will be go in self.xlateJson
|
using yang model. Output will be go in self.xlateJson
|
||||||
|
|
||||||
@@ -421,7 +423,7 @@ class SonicYangExtMixin:
|
|||||||
are displayed only when an entry is not xlated properly from ConfigDB
|
are displayed only when an entry is not xlated properly from ConfigDB
|
||||||
to sonic_yang.json.
|
to sonic_yang.json.
|
||||||
|
|
||||||
QOS MAPS Yang has inner list, which is diffrent from config DB.
|
Type 1 Lists have inner list, which is diffrent from config DB.
|
||||||
Each field value in config db should be converted to inner list with
|
Each field value in config db should be converted to inner list with
|
||||||
key and value.
|
key and value.
|
||||||
Example:
|
Example:
|
||||||
@@ -465,7 +467,7 @@ class SonicYangExtMixin:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
def _xlateQosMapList(self, model, yang, config, table, exceptionList):
|
def _xlateType1MapList(self, model, yang, config, table, exceptionList):
|
||||||
|
|
||||||
#create a dict to map each key under primary key with a dict yang model.
|
#create a dict to map each key under primary key with a dict yang model.
|
||||||
#This is done to improve performance of mapping from values of TABLEs in
|
#This is done to improve performance of mapping from values of TABLEs in
|
||||||
@@ -524,12 +526,12 @@ class SonicYangExtMixin:
|
|||||||
to sonic_yang.json.
|
to sonic_yang.json.
|
||||||
"""
|
"""
|
||||||
def _xlateList(self, model, yang, config, table, exceptionList):
|
def _xlateList(self, model, yang, config, table, exceptionList):
|
||||||
|
|
||||||
#Qos Map lists needs special handling because of inner yang list and
|
# Type 1 lists need special handling because of inner yang list and
|
||||||
#config db format.
|
# config db format.
|
||||||
if model['@name'] in qos_maps_model:
|
if model['@name'] in Type_1_list_maps_model:
|
||||||
self.sysLog(msg="_xlateQosMapList: {}".format(model['@name']))
|
self.sysLog(msg="_xlateType1MapList: {}".format(model['@name']))
|
||||||
self._xlateQosMapList(model, yang,config, table, exceptionList)
|
self._xlateType1MapList(model, yang, config, table, exceptionList)
|
||||||
return
|
return
|
||||||
|
|
||||||
#create a dict to map each key under primary key with a dict yang model.
|
#create a dict to map each key under primary key with a dict yang model.
|
||||||
@@ -744,7 +746,7 @@ class SonicYangExtMixin:
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
Rev xlate from <TABLE>_LIST to table in config DB
|
Rev xlate from <TABLE>_LIST to table in config DB
|
||||||
QOS MAP Yang has inner list, each inner list key:val should
|
Type 1 Lists have inner list, each inner list key:val should
|
||||||
be mapped to field:value in Config DB.
|
be mapped to field:value in Config DB.
|
||||||
Example:
|
Example:
|
||||||
|
|
||||||
@@ -788,14 +790,14 @@ class SonicYangExtMixin:
|
|||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def _revQosMapXlateList(self, model, yang, config, table):
|
def _revXlateType1MapList(self, model, yang, config, table):
|
||||||
# get keys from YANG model list itself
|
# get keys from YANG model list itself
|
||||||
listKeys = model['key']['@value']
|
listKeys = model['key']['@value']
|
||||||
# create a dict to map each key under primary key with a dict yang model.
|
# create a dict to map each key under primary key with a dict yang model.
|
||||||
# This is done to improve performance of mapping from values of TABLEs in
|
# This is done to improve performance of mapping from values of TABLEs in
|
||||||
# config DB to leaf in YANG LIST.
|
# config DB to leaf in YANG LIST.
|
||||||
|
|
||||||
# Gather inner list key and value from model
|
# Gather inner list key and value from model
|
||||||
inner_clist = model.get('list')
|
inner_clist = model.get('list')
|
||||||
if inner_clist:
|
if inner_clist:
|
||||||
inner_listKey = inner_clist['key']['@value']
|
inner_listKey = inner_clist['key']['@value']
|
||||||
@@ -824,10 +826,10 @@ class SonicYangExtMixin:
|
|||||||
Rev xlate from <TABLE>_LIST to table in config DB
|
Rev xlate from <TABLE>_LIST to table in config DB
|
||||||
"""
|
"""
|
||||||
def _revXlateList(self, model, yang, config, table):
|
def _revXlateList(self, model, yang, config, table):
|
||||||
|
|
||||||
# special processing for QOS Map table.
|
# special processing for Type 1 Map tables.
|
||||||
if model['@name'] in qos_maps_model:
|
if model['@name'] in Type_1_list_maps_model:
|
||||||
self._revQosMapXlateList(model, yang, config, table)
|
self._revXlateType1MapList(model, yang, config, table)
|
||||||
return
|
return
|
||||||
|
|
||||||
# get keys from YANG model list itself
|
# get keys from YANG model list itself
|
||||||
|
|||||||
@@ -125,6 +125,8 @@ setup(
|
|||||||
'./yang-models/sonic-scheduler.yang',
|
'./yang-models/sonic-scheduler.yang',
|
||||||
'./yang-models/sonic-wred-profile.yang',
|
'./yang-models/sonic-wred-profile.yang',
|
||||||
'./yang-models/sonic-queue.yang',
|
'./yang-models/sonic-queue.yang',
|
||||||
|
'./yang-models/sonic-dscp-fc-map.yang',
|
||||||
|
'./yang-models/sonic-exp-fc-map.yang',
|
||||||
'./yang-models/sonic-dscp-tc-map.yang',
|
'./yang-models/sonic-dscp-tc-map.yang',
|
||||||
'./yang-models/sonic-dot1p-tc-map.yang',
|
'./yang-models/sonic-dot1p-tc-map.yang',
|
||||||
'./yang-models/sonic-tc-priority-group-map.yang',
|
'./yang-models/sonic-tc-priority-group-map.yang',
|
||||||
|
|||||||
@@ -1310,7 +1310,29 @@
|
|||||||
"scheduler": "TEST@1",
|
"scheduler": "TEST@1",
|
||||||
"wred_profile": "Wred1"
|
"wred_profile": "Wred1"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
"DSCP_TO_FC_MAP": {
|
||||||
|
"Dscp_to_fc_map1": {
|
||||||
|
"1": "1",
|
||||||
|
"2": "2"
|
||||||
|
},
|
||||||
|
"Dscp_to_fc_map2": {
|
||||||
|
"3": "3",
|
||||||
|
"4": "4"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
"EXP_TO_FC_MAP": {
|
||||||
|
"Exp_to_fc_map1": {
|
||||||
|
"1": "1",
|
||||||
|
"2": "2"
|
||||||
|
},
|
||||||
|
"Exp_to_fc_map2": {
|
||||||
|
"3": "3",
|
||||||
|
"4": "4"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
"DSCP_TO_TC_MAP": {
|
"DSCP_TO_TC_MAP": {
|
||||||
"Dscp_to_tc_map1": {
|
"Dscp_to_tc_map1": {
|
||||||
|
|||||||
@@ -0,0 +1,24 @@
|
|||||||
|
{
|
||||||
|
"DSCP_TO_FC_MAP_CREATE": {
|
||||||
|
"desc": "Configure a DSCP to Forwarding class map."
|
||||||
|
},
|
||||||
|
"DSCP_TO_FC_MAP_CREATE_INVALID_DSCP": {
|
||||||
|
"desc": "Configure a DSCP to Forwarding class map with invalid key.",
|
||||||
|
"eStr": "Invalid DSCP"
|
||||||
|
},
|
||||||
|
"DSCP_TO_FC_MAP_CREATE_INVALID_FC": {
|
||||||
|
"desc": "Configure a DSCP to Forwarding class map with invalid value.",
|
||||||
|
"eStr": "Invalid Forwarding Class"
|
||||||
|
},
|
||||||
|
"EXP_TO_FC_MAP_CREATE": {
|
||||||
|
"desc": "Configure a EXP to Forwarding class map."
|
||||||
|
},
|
||||||
|
"EXP_TO_FC_MAP_CREATE_INVALID_EXP": {
|
||||||
|
"desc": "Configure a EXP to Forwarding class map with invalid key.",
|
||||||
|
"eStr": "Invalid EXP"
|
||||||
|
},
|
||||||
|
"EXP_TO_FC_MAP_CREATE_INVALID_FC": {
|
||||||
|
"desc": "Configure a EXP to Forwarding class map with invalid value.",
|
||||||
|
"eStr": "Invalid Forwarding Class"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,159 @@
|
|||||||
|
{
|
||||||
|
"DSCP_TO_FC_MAP_CREATE": {
|
||||||
|
"sonic-dscp-fc-map:sonic-dscp-fc-map": {
|
||||||
|
"sonic-dscp-fc-map:DSCP_TO_FC_MAP": {
|
||||||
|
"DSCP_TO_FC_MAP_LIST": [
|
||||||
|
{
|
||||||
|
"name": "map1",
|
||||||
|
"DSCP_TO_FC_MAP": [
|
||||||
|
{
|
||||||
|
"dscp": "1",
|
||||||
|
"fc": "1"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"dscp":"2",
|
||||||
|
"fc":"2"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "map2",
|
||||||
|
"DSCP_TO_FC_MAP": [
|
||||||
|
{
|
||||||
|
"dscp": "1",
|
||||||
|
"fc": "1"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"dscp":"2",
|
||||||
|
"fc":"2"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
"DSCP_TO_FC_MAP_CREATE_INVALID_DSCP": {
|
||||||
|
"sonic-dscp-fc-map:sonic-dscp-fc-map": {
|
||||||
|
"sonic-dscp-fc-map:DSCP_TO_FC_MAP": {
|
||||||
|
"DSCP_TO_FC_MAP_LIST": [
|
||||||
|
{
|
||||||
|
"name": "map3",
|
||||||
|
"DSCP_TO_FC_MAP": [
|
||||||
|
{
|
||||||
|
"dscp": "64",
|
||||||
|
"fc": "1"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"dscp":"2",
|
||||||
|
"fc":"2"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
"DSCP_TO_FC_MAP_CREATE_INVALID_FC": {
|
||||||
|
"sonic-dscp-fc-map:sonic-dscp-fc-map": {
|
||||||
|
"sonic-dscp-fc-map:DSCP_TO_FC_MAP": {
|
||||||
|
"DSCP_TO_FC_MAP_LIST": [
|
||||||
|
{
|
||||||
|
"name": "map3",
|
||||||
|
"DSCP_TO_FC_MAP": [
|
||||||
|
{
|
||||||
|
"dscp": "1",
|
||||||
|
"fc": "8"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"dscp":"2",
|
||||||
|
"fc":"2"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
"EXP_TO_FC_MAP_CREATE": {
|
||||||
|
"sonic-exp-fc-map:sonic-exp-fc-map": {
|
||||||
|
"sonic-exp-fc-map:EXP_TO_FC_MAP": {
|
||||||
|
"EXP_TO_FC_MAP_LIST": [
|
||||||
|
{
|
||||||
|
"name": "map1",
|
||||||
|
"EXP_TO_FC_MAP": [
|
||||||
|
{
|
||||||
|
"exp": "1",
|
||||||
|
"fc": "1"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"exp":"2",
|
||||||
|
"fc":"2"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "map2",
|
||||||
|
"EXP_TO_FC_MAP": [
|
||||||
|
{
|
||||||
|
"exp": "1",
|
||||||
|
"fc": "1"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"exp":"2",
|
||||||
|
"fc":"2"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
"EXP_TO_FC_MAP_CREATE_INVALID_EXP": {
|
||||||
|
"sonic-exp-fc-map:sonic-exp-fc-map": {
|
||||||
|
"sonic-exp-fc-map:EXP_TO_FC_MAP": {
|
||||||
|
"EXP_TO_FC_MAP_LIST": [
|
||||||
|
{
|
||||||
|
"name": "map3",
|
||||||
|
"EXP_TO_FC_MAP": [
|
||||||
|
{
|
||||||
|
"exp": "8",
|
||||||
|
"fc": "1"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"exp":"2",
|
||||||
|
"fc":"2"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
"EXP_TO_FC_MAP_CREATE_INVALID_FC": {
|
||||||
|
"sonic-exp-fc-map:sonic-exp-fc-map": {
|
||||||
|
"sonic-exp-fc-map:EXP_TO_FC_MAP": {
|
||||||
|
"EXP_TO_FC_MAP_LIST": [
|
||||||
|
{
|
||||||
|
"name": "map3",
|
||||||
|
"EXP_TO_FC_MAP": [
|
||||||
|
{
|
||||||
|
"exp": "1",
|
||||||
|
"fc": "8"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"exp":"2",
|
||||||
|
"fc":"2"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
68
src/sonic-yang-models/yang-models/sonic-dscp-fc-map.yang
Normal file
68
src/sonic-yang-models/yang-models/sonic-dscp-fc-map.yang
Normal file
@@ -0,0 +1,68 @@
|
|||||||
|
module sonic-dscp-fc-map {
|
||||||
|
|
||||||
|
yang-version 1.1;
|
||||||
|
|
||||||
|
namespace "http://github.com/Azure/sonic-dscp-fc-map";
|
||||||
|
|
||||||
|
prefix dtm;
|
||||||
|
|
||||||
|
organization
|
||||||
|
"SONiC";
|
||||||
|
|
||||||
|
contact
|
||||||
|
"SONiC";
|
||||||
|
|
||||||
|
description
|
||||||
|
"DSCP_TO_FC_MAP yang Module for SONiC OS";
|
||||||
|
|
||||||
|
revision 2021-10-29 {
|
||||||
|
description
|
||||||
|
"Initial revision.";
|
||||||
|
}
|
||||||
|
|
||||||
|
container sonic-dscp-fc-map {
|
||||||
|
|
||||||
|
container DSCP_TO_FC_MAP {
|
||||||
|
|
||||||
|
description "DSCP_TO_FC_MAP part of config_db.json";
|
||||||
|
|
||||||
|
list DSCP_TO_FC_MAP_LIST {
|
||||||
|
|
||||||
|
key "name";
|
||||||
|
|
||||||
|
leaf name {
|
||||||
|
type string {
|
||||||
|
pattern '[a-zA-Z0-9]{1}([-a-zA-Z0-9_]{0,31})';
|
||||||
|
length 1..32 {
|
||||||
|
error-message "Invalid length for map name.";
|
||||||
|
error-app-tag map-name-invalid-length;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
list DSCP_TO_FC_MAP { //this is list inside list for storing mapping between two fields
|
||||||
|
|
||||||
|
key "dscp";
|
||||||
|
|
||||||
|
leaf dscp {
|
||||||
|
type string {
|
||||||
|
pattern "6[0-3]|[1-5][0-9]?|[0-9]?" {
|
||||||
|
error-message "Invalid DSCP";
|
||||||
|
error-app-tag dscp-invalid;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
leaf fc {
|
||||||
|
type string {
|
||||||
|
pattern "[0-7]?" {
|
||||||
|
error-message "Invalid Forwarding Class";
|
||||||
|
error-app-tag fc-invalid;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
68
src/sonic-yang-models/yang-models/sonic-exp-fc-map.yang
Normal file
68
src/sonic-yang-models/yang-models/sonic-exp-fc-map.yang
Normal file
@@ -0,0 +1,68 @@
|
|||||||
|
module sonic-exp-fc-map {
|
||||||
|
|
||||||
|
yang-version 1.1;
|
||||||
|
|
||||||
|
namespace "http://github.com/Azure/sonic-exp-fc-map";
|
||||||
|
|
||||||
|
prefix dtm;
|
||||||
|
|
||||||
|
organization
|
||||||
|
"SONiC";
|
||||||
|
|
||||||
|
contact
|
||||||
|
"SONiC";
|
||||||
|
|
||||||
|
description
|
||||||
|
"EXP_TO_FC_MAP yang Module for SONiC OS";
|
||||||
|
|
||||||
|
revision 2021-10-29 {
|
||||||
|
description
|
||||||
|
"Initial revision.";
|
||||||
|
}
|
||||||
|
|
||||||
|
container sonic-exp-fc-map {
|
||||||
|
|
||||||
|
container EXP_TO_FC_MAP {
|
||||||
|
|
||||||
|
description "EXP_TO_FC_MAP part of config_db.json";
|
||||||
|
|
||||||
|
list EXP_TO_FC_MAP_LIST {
|
||||||
|
|
||||||
|
key "name";
|
||||||
|
|
||||||
|
leaf name {
|
||||||
|
type string {
|
||||||
|
pattern '[a-zA-Z0-9]{1}([-a-zA-Z0-9_]{0,31})';
|
||||||
|
length 1..32 {
|
||||||
|
error-message "Invalid length for map name.";
|
||||||
|
error-app-tag map-name-invalid-length;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
list EXP_TO_FC_MAP { //this is list inside list for storing mapping between two fields
|
||||||
|
|
||||||
|
key "exp";
|
||||||
|
|
||||||
|
leaf exp {
|
||||||
|
type string {
|
||||||
|
pattern "[0-7]?" {
|
||||||
|
error-message "Invalid EXP";
|
||||||
|
error-app-tag exp-invalid;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
leaf fc {
|
||||||
|
type string {
|
||||||
|
pattern "[0-7]?" {
|
||||||
|
error-message "Invalid Forwarding Class";
|
||||||
|
error-app-tag fc-invalid;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user