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
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.",
ghooo marked this conversation as resolved.
Show resolved Hide resolved
"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 @@ -64,11 +64,10 @@ module sonic-loopback-interface {

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': {}";
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

description "Loopback interface name";
}
type string;
}

leaf ip-prefix {
Expand Down