-
Notifications
You must be signed in to change notification settings - Fork 661
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
[sonic_cli_gen] Add YANG refine support #2804
[sonic_cli_gen] Add YANG refine support #2804
Conversation
@qiluo-msft could you please help to review? |
@qiluo-msft kindly reminder to review. |
@qiluo-msft any comments or we can go a head and merge? |
@@ -401,10 +402,10 @@ def get_mandatory(y_leaf: OrderedDict) -> bool: | |||
'leaf' 'mandatory' value | |||
""" | |||
|
|||
if y_leaf.get('mandatory') is not None: | |||
return True | |||
if y_leaf.get('mandatory') is None: |
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.
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.
This is not a bug fix.
I've changed the logic of this function because before YANG refine support feature extension
the YANG leaf[mandatory]
statement has only the true
value OR YANG leaf[mandatory]
doesn't exist at all
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.
Logic of both code is same.
Though, assume we have to wrap it in try-catch. In that case, what should be return value from catch block i.e. in exception case?
-- If false then current block is good.
-- If true then new block is good.
I prefer, false, because by default, each node is non mandatory.
Signed-off-by: vadymhlushko-mlnx <vadymh@nvidia.com>
f37bd24
to
ad4776f
Compare
@qiluo-msft will further check and merge. Thanks. |
@qiluo-msft since it has been approved, would you please help to merge it. |
enhancement, no for cherry-pick |
#### What I did Add [YANG "refine"](https://www.rfc-editor.org/rfc/rfc7950.html#section-7.13.2) support for the `sonic_cli_gen` utility. YANG refine is used to override the `description` and `mandatory` statements for YANG `grouping`. #### How I did it Modify the `sonic_cli_gen/yang_parser.py` #### How to verify it Modify the `sonic_cli_gen` UT
@StormLiangMS it should be cherry-picked to the |
@StormLiangMS This is not a feature enhancement but required for yang models that are backported as fix to use refine keyword. Please help to cherry-pick |
@StormLiangMS This change was not cherry-picked to 202305 but the label was added. Can you please check? |
#### What I did Add [YANG "refine"](https://www.rfc-editor.org/rfc/rfc7950.html#section-7.13.2) support for the `sonic_cli_gen` utility. YANG refine is used to override the `description` and `mandatory` statements for YANG `grouping`. #### How I did it Modify the `sonic_cli_gen/yang_parser.py` #### How to verify it Modify the `sonic_cli_gen` UT
What I did
Add YANG "refine" support for the
sonic_cli_gen
utility.YANG refine is used to override the
description
andmandatory
statements for YANGgrouping
.How I did it
Modify the
sonic_cli_gen/yang_parser.py
How to verify it
Modify the
sonic_cli_gen
UTPrevious command output (if the output of a command-line utility has changed)
New command output (if the output of a command-line utility has changed)