Skip to content
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

Merged
merged 2 commits into from
Dec 16, 2021

Conversation

ghooo
Copy link
Contributor

@ghooo ghooo commented Dec 14, 2021

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 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

@ghooo ghooo requested a review from qiluo-msft as a code owner December 14, 2021 21:53
@ghooo ghooo force-pushed the dev/mghoneim/lo_leafref branch from b83699f to 1de5394 Compare December 14, 2021 21:55
Copy link
Collaborator

@qiluo-msft qiluo-msft left a 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";
Copy link
Member

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";

Copy link
Member

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

Copy link
Contributor Author

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";
                    }
                }

Copy link
Contributor Author

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

@ghooo ghooo merged commit 2c5794f into sonic-net:master Dec 16, 2021
@qiluo-msft qiluo-msft added Request for 202111 Branch For PRs being requested for 202111 branch YANG YANG model related changes labels Jan 5, 2022
judyjoseph pushed a commit that referenced this pull request Jan 9, 2022
#### 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Included in 202111 Branch Request for 202111 Branch For PRs being requested for 202111 branch YANG YANG model related changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants