Skip to content

Commit bb0d9c8

Browse files
author
Cosmin Jinga
committed
Changed Xlate functions to handle general Type 1 lists
1 parent c27d392 commit bb0d9c8

File tree

1 file changed

+21
-22
lines changed

1 file changed

+21
-22
lines changed

src/sonic-yang-mgmt/sonic_yang_ext.py

+21-22
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,14 @@
88
from xmltodict import parse
99
from glob import glob
1010

11-
qos_maps_model = ['DSCP_TO_TC_MAP_LIST',
12-
'DOT1P_TO_TC_MAP_LIST',
13-
'TC_TO_PRIORITY_GROUP_MAP_LIST',
14-
'TC_TO_QUEUE_MAP_LIST',
15-
'MAP_PFC_PRIORITY_TO_QUEUE_LIST',
16-
'PFC_PRIORITY_TO_PRIORITY_GROUP_MAP_LIST']
17-
18-
cbf_maps_model = ['DSCP_TO_FC_MAP_LIST',
19-
'EXP_TO_FC_MAP_LIST']
11+
Type_1_list_maps_model = ['DSCP_TO_TC_MAP_LIST',
12+
'DOT1P_TO_TC_MAP_LIST',
13+
'TC_TO_PRIORITY_GROUP_MAP_LIST',
14+
'TC_TO_QUEUE_MAP_LIST',
15+
'MAP_PFC_PRIORITY_TO_QUEUE_LIST',
16+
'PFC_PRIORITY_TO_PRIORITY_GROUP_MAP_LIST',
17+
'DSCP_TO_FC_MAP_LIST',
18+
'EXP_TO_FC_MAP_LIST']
2019

2120
"""
2221
This is the Exception thrown out of all public function of this class.
@@ -416,15 +415,15 @@ def _yangConvert(val):
416415
return vValue
417416

418417
"""
419-
Xlate a Maps list
418+
Xlate a Type 1 map list
420419
This function will xlate from a dict in config DB to a Yang JSON list
421420
using yang model. Output will be go in self.xlateJson
422421
423422
Note: Exceptions from this function are collected in exceptionList and
424423
are displayed only when an entry is not xlated properly from ConfigDB
425424
to sonic_yang.json.
426425
427-
QOS MAPS Yang has inner list, which is diffrent from config DB.
426+
Type 1 map Yang has inner list, which is diffrent from config DB.
428427
Each field value in config db should be converted to inner list with
429428
key and value.
430429
Example:
@@ -468,7 +467,7 @@ def _yangConvert(val):
468467
}
469468
}
470469
"""
471-
def _xlateMapList(self, model, yang, config, table, exceptionList):
470+
def _xlateType1MapList(self, model, yang, config, table, exceptionList):
472471

473472
#create a dict to map each key under primary key with a dict yang model.
474473
#This is done to improve performance of mapping from values of TABLEs in
@@ -528,11 +527,11 @@ def _xlateMapList(self, model, yang, config, table, exceptionList):
528527
"""
529528
def _xlateList(self, model, yang, config, table, exceptionList):
530529

531-
#Qos Map lists needs special handling because of inner yang list and
532-
#config db format.
533-
if model['@name'] in qos_maps_model or model['@name'] in cbf_maps_model:
534-
self.sysLog(msg="_xlateMapList: {}".format(model['@name']))
535-
self._xlateMapList(model, yang, config, table, exceptionList)
530+
# Type 1 lists need special handling because of inner yang list and
531+
# config db format.
532+
if model['@name'] in Type_1_list_maps_model:
533+
self.sysLog(msg="_xlateType1MapList: {}".format(model['@name']))
534+
self._xlateType1MapList(model, yang, config, table, exceptionList)
536535
return
537536

538537
#create a dict to map each key under primary key with a dict yang model.
@@ -747,7 +746,7 @@ def _revYangConvert(val):
747746

748747
"""
749748
Rev xlate from <TABLE>_LIST to table in config DB
750-
QOS MAP Yang has inner list, each inner list key:val should
749+
Type 1 MAPs Yang has inner list, each inner list key:val should
751750
be mapped to field:value in Config DB.
752751
Example:
753752
@@ -791,7 +790,7 @@ def _revYangConvert(val):
791790
}
792791
"""
793792

794-
def _revMapXlateList(self, model, yang, config, table):
793+
def _revXlateType1MapList(self, model, yang, config, table):
795794
# get keys from YANG model list itself
796795
listKeys = model['key']['@value']
797796
# create a dict to map each key under primary key with a dict yang model.
@@ -828,9 +827,9 @@ def _revMapXlateList(self, model, yang, config, table):
828827
"""
829828
def _revXlateList(self, model, yang, config, table):
830829

831-
# special processing for QOS Map table.
832-
if model['@name'] in qos_maps_model or model['@name'] in cbf_maps_model:
833-
self._revMapXlateList(model, yang, config, table)
830+
# special processing for Type 1 Map tables.
831+
if model['@name'] in Type_1_list_maps_model:
832+
self._revXlateType1MapList(model, yang, config, table)
834833
return
835834

836835
# get keys from YANG model list itself

0 commit comments

Comments
 (0)