-
Notifications
You must be signed in to change notification settings - Fork 1.5k
SONiC CBF MAPs Yang #9116
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SONiC CBF MAPs Yang #9116
Changes from 4 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,12 +8,14 @@ | |
from xmltodict import parse | ||
from glob import glob | ||
|
||
qos_maps_model = ['DSCP_TO_TC_MAP_LIST', | ||
'DOT1P_TO_TC_MAP_LIST', | ||
'TC_TO_PRIORITY_GROUP_MAP_LIST', | ||
'TC_TO_QUEUE_MAP_LIST', | ||
'MAP_PFC_PRIORITY_TO_QUEUE_LIST', | ||
'PFC_PRIORITY_TO_PRIORITY_GROUP_MAP_LIST'] | ||
Type_1_list_maps_model = ['DSCP_TO_TC_MAP_LIST', | ||
'DOT1P_TO_TC_MAP_LIST', | ||
'TC_TO_PRIORITY_GROUP_MAP_LIST', | ||
'TC_TO_QUEUE_MAP_LIST', | ||
'MAP_PFC_PRIORITY_TO_QUEUE_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. | ||
|
@@ -413,15 +415,15 @@ def _yangConvert(val): | |
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 | ||
using yang model. Output will be go in self.xlateJson | ||
|
||
Note: Exceptions from this function are collected in exceptionList and | ||
are displayed only when an entry is not xlated properly from ConfigDB | ||
to sonic_yang.json. | ||
|
||
QOS MAPS Yang has inner list, which is diffrent from config DB. | ||
Type 1 map Yang has inner list, which is diffrent from config DB. | ||
Each field value in config db should be converted to inner list with | ||
key and value. | ||
Example: | ||
|
@@ -465,7 +467,7 @@ def _yangConvert(val): | |
} | ||
} | ||
""" | ||
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. | ||
#This is done to improve performance of mapping from values of TABLEs in | ||
|
@@ -524,12 +526,12 @@ def _xlateQosMapList(self, model, yang, config, table, exceptionList): | |
to sonic_yang.json. | ||
""" | ||
def _xlateList(self, model, yang, config, table, exceptionList): | ||
#Qos Map lists needs special handling because of inner yang list and | ||
#config db format. | ||
if model['@name'] in qos_maps_model: | ||
self.sysLog(msg="_xlateQosMapList: {}".format(model['@name'])) | ||
self._xlateQosMapList(model, yang,config, table, exceptionList) | ||
|
||
# Type 1 lists need special handling because of inner yang list and | ||
# config db format. | ||
if model['@name'] in Type_1_list_maps_model: | ||
self.sysLog(msg="_xlateType1MapList: {}".format(model['@name'])) | ||
self._xlateType1MapList(model, yang, config, table, exceptionList) | ||
return | ||
|
||
#create a dict to map each key under primary key with a dict yang model. | ||
|
@@ -744,7 +746,7 @@ def _revYangConvert(val): | |
|
||
""" | ||
Rev xlate from <TABLE>_LIST to table in config DB | ||
QOS MAP Yang has inner list, each inner list key:val should | ||
Type 1 MAPs Yang has inner list, each inner list key:val should | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Type 1 Maps Lists or Type 1 Lists There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will update, thanks |
||
be mapped to field:value in Config DB. | ||
Example: | ||
|
||
|
@@ -788,14 +790,14 @@ def _revYangConvert(val): | |
} | ||
""" | ||
|
||
def _revQosMapXlateList(self, model, yang, config, table): | ||
def _revXlateType1MapList(self, model, yang, config, table): | ||
# get keys from YANG model list itself | ||
listKeys = model['key']['@value'] | ||
# 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 | ||
# 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') | ||
if inner_clist: | ||
inner_listKey = inner_clist['key']['@value'] | ||
|
@@ -824,10 +826,10 @@ def _revQosMapXlateList(self, model, yang, config, table): | |
Rev xlate from <TABLE>_LIST to table in config DB | ||
""" | ||
def _revXlateList(self, model, yang, config, table): | ||
# special processing for QOS Map table. | ||
if model['@name'] in qos_maps_model: | ||
self._revQosMapXlateList(model, yang, config, table) | ||
|
||
# special processing for Type 1 Map tables. | ||
if model['@name'] in Type_1_list_maps_model: | ||
self._revXlateType1MapList(model, yang, config, table) | ||
return | ||
|
||
# get keys from YANG model list itself | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. eStr should match to the error from Libyang. This may not pass. Do you see successful build of PKG. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Unless I misunderstood what you meant I think the error strings do match in this case. |
||
}, | ||
"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" | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" | ||
} | ||
] | ||
} | ||
] | ||
} | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Type 1 Lists has inner list, which is different from generic lists in config DB.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will update, thanks