-
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 3 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 |
---|---|---|
|
@@ -15,6 +15,9 @@ | |
'MAP_PFC_PRIORITY_TO_QUEUE_LIST', | ||
'PFC_PRIORITY_TO_PRIORITY_GROUP_MAP_LIST'] | ||
|
||
cbf_maps_model = ['DSCP_TO_FC_MAP_LIST', | ||
'EXP_TO_FC_MAP_LIST'] | ||
|
||
""" | ||
This is the Exception thrown out of all public function of this class. | ||
""" | ||
|
@@ -413,7 +416,7 @@ def _yangConvert(val): | |
return vValue | ||
|
||
""" | ||
Xlate a Qos Maps list | ||
Xlate a Maps list | ||
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. Xlate a Type 1 Lists, Similar to Qos Maps. Example Below: |
||
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 | ||
|
||
|
@@ -465,7 +468,7 @@ def _yangConvert(val): | |
} | ||
} | ||
""" | ||
def _xlateQosMapList(self, model, yang, config, table, exceptionList): | ||
def _xlateMapList(self, model, yang, config, table, exceptionList): | ||
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. _xlateType1MapList |
||
|
||
#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 +527,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) | ||
if model['@name'] in qos_maps_model or model['@name'] in cbf_maps_model: | ||
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. same list maps. |
||
self.sysLog(msg="_xlateMapList: {}".format(model['@name'])) | ||
self._xlateMapList(model, yang, config, table, exceptionList) | ||
return | ||
|
||
#create a dict to map each key under primary key with a dict yang model. | ||
|
@@ -788,14 +791,14 @@ def _revYangConvert(val): | |
} | ||
""" | ||
|
||
def _revQosMapXlateList(self, model, yang, config, table): | ||
def _revMapXlateList(self, model, yang, config, table): | ||
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. _revXlateType1MapList |
||
# 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 +827,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) | ||
if model['@name'] in qos_maps_model or model['@name'] in cbf_maps_model: | ||
self._revMapXlateList(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" | ||
} | ||
] | ||
} | ||
] | ||
} | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 { | ||
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. I am not reviewing YANG models, since I am not SME for this. Thx 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. I will reviews, thanks for reviewing the rest. 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. @smaheshm since Praveen has approved the other changes is this PR ready to be merged in? |
||
|
||
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; | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
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.
This for translation for a specific type, so let`s mark it as Type_1_list_maps_model. Add all lists in it.