2c5794f62d
#### 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
104 lines
2.7 KiB
YANG
104 lines
2.7 KiB
YANG
module sonic-loopback-interface {
|
|
|
|
yang-version 1.1;
|
|
|
|
namespace "http://github.com/Azure/sonic-loopback-interface";
|
|
prefix lointf;
|
|
|
|
import sonic-types {
|
|
prefix stypes;
|
|
}
|
|
|
|
import sonic-extension {
|
|
prefix ext;
|
|
}
|
|
|
|
import sonic-vrf {
|
|
prefix vrf;
|
|
}
|
|
|
|
description
|
|
"SONIC LOOPBACK INTERFACE";
|
|
|
|
revision 2021-04-05 {
|
|
description "Modify the type of vrf name";
|
|
}
|
|
|
|
revision 2020-02-05 {
|
|
description "First Revision";
|
|
}
|
|
|
|
container sonic-loopback-interface {
|
|
|
|
container LOOPBACK_INTERFACE {
|
|
|
|
list LOOPBACK_INTERFACE_LIST {
|
|
key "name";
|
|
|
|
leaf name{
|
|
type string;
|
|
}
|
|
|
|
leaf vrf_name {
|
|
type leafref {
|
|
path "/vrf:sonic-vrf/vrf:VRF/vrf:VRF_LIST/vrf:name";
|
|
}
|
|
}
|
|
|
|
leaf nat_zone {
|
|
description "NAT Zone for the loopback interface";
|
|
type uint8 {
|
|
range "0..3" {
|
|
error-message "Invalid nat zone for the loopback interface.";
|
|
error-app-tag nat-zone-invalid;
|
|
}
|
|
}
|
|
default "0";
|
|
}
|
|
}
|
|
/* end of LOOPBACK_INTERFACE_LIST */
|
|
|
|
list LOOPBACK_INTERFACE_IPPREFIX_LIST {
|
|
|
|
key "name ip-prefix";
|
|
|
|
leaf name{
|
|
description "Loopback interface name";
|
|
|
|
type leafref {
|
|
path "../../LOOPBACK_INTERFACE_LIST/name";
|
|
}
|
|
}
|
|
|
|
leaf ip-prefix {
|
|
type union {
|
|
type stypes:sonic-ip4-prefix;
|
|
type stypes:sonic-ip6-prefix;
|
|
}
|
|
}
|
|
|
|
leaf scope {
|
|
type enumeration {
|
|
enum global;
|
|
enum local;
|
|
}
|
|
}
|
|
|
|
leaf family {
|
|
|
|
/* family leaf needed for backward compatibility
|
|
Both ip4 and ip6 address are string in IETF RFC 6021,
|
|
so must statement can check based on : or ., family
|
|
should be IPv4 or IPv6 according.
|
|
*/
|
|
|
|
must "(contains(../ip-prefix, ':') and current()='IPv6') or
|
|
(contains(../ip-prefix, '.') and current()='IPv4')";
|
|
type stypes:ip-family;
|
|
}
|
|
}
|
|
}
|
|
/* end of LOOPBACK_INTERFACE_IPPREFIX_LIST */
|
|
}
|
|
}
|