Skip to content

Commit

Permalink
[yang-model] Using 'leafref' instead of 'must' for loopback (#9535)
Browse files Browse the repository at this point in the history
#### 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
  • Loading branch information
ghooo authored Dec 16, 2021
1 parent 6a0bb3a commit 2c5794f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -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.",
Expand Down
Original file line number Diff line number Diff line change
@@ -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": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 2c5794f

Please sign in to comment.