cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
68
Views
0
Helpful
1
Replies
Highlighted
Cisco Employee

YANG: how to reference to device-group members

How can I reference to devices which are members of a specific member-group? I want to limit a service to a group of devices instead of all devices (like MPLS VPN services to MPLS PE devices)

Instead of the usual leafref reference:

type leafref {

  path "/ncs:devices/ncs:device/ncs:name";

}

I would like to use something like this:

type leafref {

  path "/ncs:devices/ncs:device-group[ncs:name='MPLS-PE']/ncs:device-name";

}

But I get compiler error message: "l3vpn.yang:53: error: bad value "/ncs:devices/ncs:device-group[ncs:name='MPLS-PE']/ncs:device-name" (should be path-arg)”

Everyone's tags (3)
1 ACCEPTED SOLUTION

Accepted Solutions
Cisco Employee

Re: YANG: how to reference to device-group members

This has been a very popular question lately, I have got the same question from at least three different groups the last week. ;-)

In YANG, leafrefs are only allowed to use a limited form of XPATH, “path-arg", so the predicate (expression in [ ] ) is not allowed here. Instead, keep the leafref as you had on top, and add a must expression that enforces the rule in the lower expression.

Something like this:

leaf member-device {

    type leafref {

        path “/ncs:devices/ncs:device/ncs:name”;

    }

    must “/ncs:devices/ncs:device-group[ncs:name=‘MPLS-PE’]/ncs:device-name[.=current()]” {

        tailf:dependency “/ncs:devices/ncs:device/ncs:name”;

        tailf:dependency “/ncs:devices/ncs:device-group/ncs:device-name”;

    }

}

1 REPLY 1
Cisco Employee

Re: YANG: how to reference to device-group members

This has been a very popular question lately, I have got the same question from at least three different groups the last week. ;-)

In YANG, leafrefs are only allowed to use a limited form of XPATH, “path-arg", so the predicate (expression in [ ] ) is not allowed here. Instead, keep the leafref as you had on top, and add a must expression that enforces the rule in the lower expression.

Something like this:

leaf member-device {

    type leafref {

        path “/ncs:devices/ncs:device/ncs:name”;

    }

    must “/ncs:devices/ncs:device-group[ncs:name=‘MPLS-PE’]/ncs:device-name[.=current()]” {

        tailf:dependency “/ncs:devices/ncs:device/ncs:name”;

        tailf:dependency “/ncs:devices/ncs:device-group/ncs:device-name”;

    }

}

Content for Community-Ad
August's Community Spotlight Awards