-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
[yang-model] Using 'leafref' instead of 'must' for loopback #9535
Conversation
b83699f
to
1de5394
Compare
src/sonic-yang-models/tests/yang_model_tests/tests/loopback.json
Outdated
Show resolved
Hide resolved
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.
LGTM. Please wait a little longer for more eyes.
description "Loopback interface name"; | ||
|
||
type leafref { | ||
path "../../LOOPBACK_INTERFACE_LIST/name"; |
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.
Lets keep error-msg, something as below:
error-message "Loopback VRF interface must exist, Try adding lo<>: {}, Example: 'lo1': {}";
description "Loopback interface name";
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.
plz see if we must do similar changes in VLAN_INTERFACE and in INTERFACE. Thx
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.
I haven't seen error-message
used with leafref before in any sonic yang models. I think it is not supported:
libyang[0]: Invalid keyword "error-message". (path: /sonic-loopback-interface:sonic-loopback-interface/LOOPBACK_INTERFACE/LOOPBACK_INTERFACE_IPPREFIX_LIST/name)
Tried like this:
leaf name{
error-message "Loopback VRF interface must exist, Try adding lo<>: {}, Example: 'lo1': {}";
description "Loopback interface name";
type leafref {
path "../../LOOPBACK_INTERFACE_LIST/name";
}
}
and this:
leaf name{
description "Loopback interface name";
type leafref {
error-message "Loopback VRF interface must exist, Try adding lo<>: {}, Example: 'lo1': {}";
path "../../LOOPBACK_INTERFACE_LIST/name";
}
}
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.
plz see if we must do similar changes in VLAN_INTERFACE and in INTERFACE. Thx
Yes, we might need to fix these as well. I will start first by checking if we can can the referrers from must statements #9534
#### Why I did it Fix issue sonic-net/sonic-utilities#1962 The problem is current implementation of [sonic-yang-mgmt::find_data_dependencies](https://github.com/Azure/sonic-buildimage/blob/f2774b635dee2d5c0e30489632b47e0210a712dd/src/sonic-yang-mgmt/sonic_yang.py#L518) does not get referrers if they are using `must` statement, it has to use `leafref`. For now we can convert `must` to `leafref` if possible. In the future we will investigate get referrers by `must` statements as well #9534 #### How I did it Instead of `must` use `leafref` #### How to verify it unit-test #### Which release branch to backport (provide reason below if selected) - [ ] 201811 - [ ] 201911 - [ ] 202006 - [ ] 202012 - [ ] 202106
Why I did it
Fix issue sonic-net/sonic-utilities#1962
The problem is current implementation of sonic-yang-mgmt::find_data_dependencies does not get referrers if they are using
must
statement, it has to useleafref
.For now we can convert
must
toleafref
if possible. In the future we will investigate get referrers bymust
statements as well #9534How I did it
Instead of
must
useleafref
How to verify it
unit-test
Which release branch to backport (provide reason below if selected)