cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
964
Views
0
Helpful
3
Replies

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

Ahmed Elsamahy
Beginner
Beginner

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
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
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!

Thanks Senha . I will try it and send you feedback

thanks Sneha
Getting Started

Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the NSO Developer community:

Recognize Your Peers