[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 Judy Joseph
parent 3af0f6ab0c
commit 013413d9ce
3 changed files with 8 additions and 9 deletions

View File

@ -1,7 +1,7 @@
{
"LOOPBACK_IPPREFIX_PORT_MUST_CONDITION_FALSE": {
"desc": "Loopback Ip-prefix port-name must condition failure.",
"eStrKey" : "Must"
"LOOPBACK_IPPREFIX_PORT_FOR_NON_EXIST_INTERFACE": {
"desc": "Configure Loopback Ip-prefix for non-existing Loopback interface.",
"eStrKey" : "LeafRef"
},
"LOOPBACK_INTERFACE_WRONG_NAT_ZONE_RANGE": {
"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:LOOPBACK_INTERFACE": {
"LOOPBACK_INTERFACE_IPPREFIX_LIST": [

View File

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