Skip to content

Commit 78d6839

Browse files
author
Praveen Chaudhary
authored
[_sonic_yang_ext.py]: Added support to allow or deny extra tables. (sonic-net#34)
This change will have corresponding changes in sonic-utilities. Note: these changes in sonic-buildimage are safe to merge even without sonic-utilities changes.
1 parent e540c31 commit 78d6839

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/sonic-yang-mgmt/_sonic_yang_ext.py

+7-4
Original file line numberDiff line numberDiff line change
@@ -112,11 +112,14 @@ def get_module_TLC_container(self, table):
112112
This Function crops from config only those TABLEs, for which yang models is
113113
provided.
114114
"""
115-
def cropConfigDB(self, croppedFile=None):
115+
def cropConfigDB(self, croppedFile=None, allowExtraTables=True):
116116

117117
for table in self.jIn.keys():
118118
if table not in self.confDbYangMap:
119-
del self.jIn[table]
119+
if allowExtraTables:
120+
del self.jIn[table]
121+
else:
122+
raise(Exception("No Yang Model Exist for {}".format(table)))
120123

121124
if croppedFile:
122125
with open(croppedFile, 'w') as f:
@@ -565,14 +568,14 @@ def findXpathList(self, xpath, list, keys):
565568
input: data
566569
returns: True - success False - failed
567570
"""
568-
def load_data(self, configdbJson):
571+
def load_data(self, configdbJson, allowExtraTables=True):
569572

570573
try:
571574
self.jIn = configdbJson
572575
# reset xlate
573576
self.xlateJson = dict()
574577
# self.jIn will be cropped
575-
self.cropConfigDB("cropped.json")
578+
self.cropConfigDB("cropped.json", allowExtraTables)
576579
# xlated result will be in self.xlateJson
577580
self.xlateConfigDB()
578581
#print(self.xlateJson)

0 commit comments

Comments
 (0)