-
Notifications
You must be signed in to change notification settings - Fork 669
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Run yang validation in db migrator #3102
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
8269002
Run yang validation in db migrator
ganglyu cb600ce
Merge branch 'sonic-net:master' into yang_validation
ganglyu 4196bb4
Fix ut error
ganglyu 92fd583
Improve validation logic
ganglyu 7fd1d2c
Replace mark file
ganglyu 8f7cb02
Check missing yang models
ganglyu 7fef5da
Merge branch 'master' into yang_validation
ganglyu 70ab939
Merge branch 'sonic-net:master' into yang_validation
ganglyu 22e52cd
Fix commit error
ganglyu d758e85
Merge branch 'sonic-net:master' into yang_validation
ganglyu b5708bf
Merge branch 'sonic-net:master' into yang_validation
ganglyu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
#!/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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could make it 100% in our StarLab DUT.
However, I suspect if we could cover it 100% in PROD devices. It will break the PROD workflow if not fully coverred in PROD.
I prefer we make the check as log_warning and not raise exception right now.