[yang-model] Using 'leafref' instead of 'must' for loopback (#9535)

#### Why I did it
Fix issue https://github.com/Azure/sonic-utilities/issues/1962

The problem is current implementation of [sonic-yang-mgmt::find_data_dependencies](f2774b635d/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 https://github.com/Azure/sonic-buildimage/issues/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
This commit is contained in:
Mohamed Ghoneim 2021-12-15 17:19:57 -08:00 committed by GitHub
parent 6a0bb3a2af
commit 2c5794f62d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 9 deletions

View File

@ -1,7 +1,7 @@
{ {
"LOOPBACK_IPPREFIX_PORT_MUST_CONDITION_FALSE": { "LOOPBACK_IPPREFIX_PORT_FOR_NON_EXIST_INTERFACE": {
"desc": "Loopback Ip-prefix port-name must condition failure.", "desc": "Configure Loopback Ip-prefix for non-existing Loopback interface.",
"eStrKey" : "Must" "eStrKey" : "LeafRef"
}, },
"LOOPBACK_INTERFACE_WRONG_NAT_ZONE_RANGE": { "LOOPBACK_INTERFACE_WRONG_NAT_ZONE_RANGE": {
"desc": "Configure wrong value for nat zone.", "desc": "Configure wrong value for nat zone.",

View File

@ -1,5 +1,5 @@
{ {
"LOOPBACK_IPPREFIX_PORT_MUST_CONDITION_FALSE": { "LOOPBACK_IPPREFIX_PORT_FOR_NON_EXIST_INTERFACE": {
"sonic-loopback-interface:sonic-loopback-interface": { "sonic-loopback-interface:sonic-loopback-interface": {
"sonic-loopback-interface:LOOPBACK_INTERFACE": { "sonic-loopback-interface:LOOPBACK_INTERFACE": {
"LOOPBACK_INTERFACE_IPPREFIX_LIST": [ "LOOPBACK_INTERFACE_IPPREFIX_LIST": [

View File

@ -63,12 +63,11 @@ module sonic-loopback-interface {
key "name ip-prefix"; key "name ip-prefix";
leaf name{ leaf name{
/* This node must be present in LOOPBACK_INTERFACE_LIST */ description "Loopback interface name";
must "(current() = ../../LOOPBACK_INTERFACE_LIST[name=current()]/name)"
{ type leafref {
error-message "Must condition not satisfied, Try adding lo<>: {}, Example: 'lo1': {}"; path "../../LOOPBACK_INTERFACE_LIST/name";
} }
type string;
} }
leaf ip-prefix { leaf ip-prefix {