Skip to content

Commit 032a0e0

Browse files
authored
[config]Restrict YANG validation to Golden Config (#3656)
What I did The sonic vm image has yang validation issue with default config setup. Limit YANG check to golden config only before fix default factory config. How I did it Restrict YANG validation to golden config only. How to verify it Unit test and integration test.
1 parent 47b79be commit 032a0e0

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

config/main.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1830,7 +1830,7 @@ def reload(db, filename, yes, load_sysinfo, no_service_restart, force, file_form
18301830
if multi_asic.is_multi_asic():
18311831
# Multiasic has not 100% fully validated. Thus pass here.
18321832
pass
1833-
else:
1833+
elif "golden" in filename.lower():
18341834
config_file_yang_validation(filename)
18351835

18361836
#Stop services before config push

tests/config_test.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -1231,6 +1231,7 @@ def teardown_class(cls):
12311231

12321232
class TestReloadConfig(object):
12331233
dummy_cfg_file = os.path.join(os.sep, "tmp", "config.json")
1234+
dummy_golden_cfg_file = os.path.join(os.sep, "tmp", "golden_config.json")
12341235

12351236
@classmethod
12361237
def setup_class(cls):
@@ -1433,7 +1434,7 @@ def test_reload_yang_config(self, get_cmd_module,
14331434
== RELOAD_YANG_CFG_OUTPUT.format(config.SYSTEM_RELOAD_LOCK)
14341435

14351436
def test_reload_config_fails_yang_validation(self, get_cmd_module, setup_single_broadcom_asic):
1436-
with open(self.dummy_cfg_file, 'w') as f:
1437+
with open(self.dummy_golden_cfg_file, 'w') as f:
14371438
device_metadata = {
14381439
"DEVICE_METADATA": {
14391440
"localhost": {
@@ -1452,7 +1453,7 @@ def test_reload_config_fails_yang_validation(self, get_cmd_module, setup_single_
14521453

14531454
result = runner.invoke(
14541455
config.config.commands["reload"],
1455-
[self.dummy_cfg_file, '-y', '-f'])
1456+
[self.dummy_golden_cfg_file, '-y', '-f'])
14561457

14571458
print(result.exit_code)
14581459
print(result.output)
@@ -1464,6 +1465,7 @@ def test_reload_config_fails_yang_validation(self, get_cmd_module, setup_single_
14641465
def teardown_class(cls):
14651466
os.environ['UTILITIES_UNIT_TESTING'] = "0"
14661467
os.remove(cls.dummy_cfg_file)
1468+
os.remove(cls.dummy_golden_cfg_file)
14671469
print("TEARDOWN")
14681470

14691471

0 commit comments

Comments
 (0)