diff --git a/scripts/config_validator.py b/scripts/config_validator.py deleted file mode 100755 index ee5789e95a..0000000000 --- a/scripts/config_validator.py +++ /dev/null @@ -1,44 +0,0 @@ -#!/usr/bin/env python3 -import json -import argparse -import sonic_yang - -from sonic_py_common import logger - -YANG_MODELS_DIR = "/usr/local/yang-models" -SYSLOG_IDENTIFIER = 'config_validator' - -# Global logger instance -log = logger.Logger(SYSLOG_IDENTIFIER) - - -def main(): - parser = argparse.ArgumentParser() - parser.add_argument('-c', - dest='config', - metavar='config file', - type=str, - required=True, - help='the config file to be validated', - default=None) - - args = parser.parse_args() - config_file = args.config - with open(config_file) as fp: - config = json.load(fp) - # Run yang validation - yang_parser = sonic_yang.SonicYang(YANG_MODELS_DIR) - yang_parser.loadYangModel() - try: - yang_parser.loadData(configdbJson=config) - yang_parser.validate_data_tree() - except sonic_yang.SonicYangException as e: - log.log_error("Yang validation failed: " + str(e)) - raise - if len(yang_parser.tablesWithOutYang): - log.log_error("Tables without yang models: " + str(yang_parser.tablesWithOutYang)) - raise Exception("Tables without yang models: " + str(yang_parser.tablesWithOutYang)) - - -if __name__ == "__main__": - main() diff --git a/scripts/db_migrator.py b/scripts/db_migrator.py index c7d4bd2c21..f50eb9cab0 100755 --- a/scripts/db_migrator.py +++ b/scripts/db_migrator.py @@ -6,7 +6,6 @@ import sys import traceback import re -import subprocess from sonic_py_common import device_info, logger from swsscommon.swsscommon import SonicV2Connector, ConfigDBConnector, SonicDBConfig @@ -1368,34 +1367,6 @@ def migrate(self): version = next_version # Perform common migration ops self.common_migration_ops() - # Perform yang validation - self.validate() - - def validate(self): - config = self.configDB.get_config() - # Fix table key in tuple - for table_name, table in config.items(): - new_table = {} - hit = False - for table_key, table_val in table.items(): - if isinstance(table_key, tuple): - new_key = "|".join(table_key) - new_table[new_key] = table_val - hit = True - else: - new_table[table_key] = table_val - if hit: - config[table_name] = new_table - config_file = "/tmp/validate.json" - with open(config_file, 'w') as fp: - json.dump(config, fp) - process = subprocess.Popen(["config_validator.py", "-c", config_file]) - # Check validation result for unit test - # Check validation result for end to end test - mark_file = "/etc/sonic/mgmt_test_mark" - if os.environ.get("UTILITIES_UNIT_TESTING", "0") == "2" or os.path.exists(mark_file): - ret = process.wait() - assert ret == 0, "Yang validation failed" def main(): try: diff --git a/setup.py b/setup.py index 597dfadbfb..8b465bda95 100644 --- a/setup.py +++ b/setup.py @@ -116,7 +116,6 @@ 'scripts/buffershow', 'scripts/coredump-compress', 'scripts/configlet', - 'scripts/config_validator.py', 'scripts/db_migrator.py', 'scripts/decode-syseeprom', 'scripts/dropcheck',