cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Announcements
863
Views
0
Helpful
3
Replies
Ahmed Elsamahy
Beginner

How can i use leaf ref to choose a device from specific group of devices?

I want to use leaf ref to make it possible to make dropdown list of devices in a specific group and choose one to configur ?

1 ACCEPTED SOLUTION

Accepted Solutions
SnehaAnn
Beginner

Hi Ahmed,
One solution can be where you hard-code your group-name as a leaf in your yang and then another leaf for your devices referring to the "group-name" leaf in the yang. This can be a user input(more dynamic) or defaulted (static)

Here's a pattern for reference
leaf group-name {
type string {
pattern "MY GROUP";
}
default "MY GROUP";
tailf:info "desired group name";
description "desired group name";
}
leaf device-name {
type leafref {
path "/ncs:devices/ncs:device-group[ncs:name=current()/../group-name]/ncs:device-name";
}
tailf:info "MY GROUP devices";
description "MY GROUP devices";
}


Hope this helps!

View solution in original post

3 REPLIES 3
SnehaAnn
Beginner

Hi Ahmed,
One solution can be where you hard-code your group-name as a leaf in your yang and then another leaf for your devices referring to the "group-name" leaf in the yang. This can be a user input(more dynamic) or defaulted (static)

Here's a pattern for reference
leaf group-name {
type string {
pattern "MY GROUP";
}
default "MY GROUP";
tailf:info "desired group name";
description "desired group name";
}
leaf device-name {
type leafref {
path "/ncs:devices/ncs:device-group[ncs:name=current()/../group-name]/ncs:device-name";
}
tailf:info "MY GROUP devices";
description "MY GROUP devices";
}


Hope this helps!

View solution in original post

Thanks Senha . I will try it and send you feedback

thanks Sneha