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

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

Ahmed Elsamahy
Level 1
Level 1

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
Level 1
Level 1

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
Level 1
Level 1

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