Skip to content

Commit

Permalink
[config] Enable YANG validation for override
Browse files Browse the repository at this point in the history
  • Loading branch information
wen587 committed Feb 5, 2024
1 parent 3d45c0c commit 605f14d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 15 deletions.
10 changes: 6 additions & 4 deletions config/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -1954,7 +1954,9 @@ def override_config_table(db, input_config_db, dry_run):
updated_config = update_config(current_config, ns_config_input)

yang_enabled = device_info.is_yang_config_validation_enabled(config_db)
if yang_enabled:

# Always enable YANG check
if yang_enabled or True:
# The ConfigMgmt will load YANG and running
# config during initialization.
try:
Expand All @@ -1963,9 +1965,9 @@ def override_config_table(db, input_config_db, dry_run):
except Exception as ex:
click.secho("Failed to validate running config. Error: {}".format(ex), fg="magenta")
sys.exit(1)

# Validate input config
validate_config_by_cm(cm, ns_config_input, "config_input")
#skip input override config check since it is missing YANG dependencies
## Validate input config
#validate_config_by_cm(cm, ns_config_input, "config_input")
# Validate updated whole config
validate_config_by_cm(cm, updated_config, "updated_config")

Expand Down
11 changes: 0 additions & 11 deletions tests/config_override_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,17 +211,6 @@ def is_yang_config_validation_enabled_side_effect(filename):
self.check_yang_verification_failure(
db, config, read_data['running_config'], read_data['golden_config'], "running config")

def test_golden_input_yang_failure(self):
def is_yang_config_validation_enabled_side_effect(filename):
return True
db = Db()
with open(GOLDEN_INPUT_YANG_FAILURE, "r") as f:
read_data = json.load(f)
with mock.patch('config.main.device_info.is_yang_config_validation_enabled',
mock.MagicMock(side_effect=is_yang_config_validation_enabled_side_effect)):
self.check_yang_verification_failure(
db, config, read_data['running_config'], read_data['golden_config'], "config_input")

def test_final_config_yang_failure(self):
def is_yang_config_validation_enabled_side_effect(filename):
return True
Expand Down

0 comments on commit 605f14d

Please sign in to comment.