I'm trying to get the value of a set policer depending on what encapsulation is set on a unit. Since family inet has not encapsulation set, I've used the if clause below to set family to 'inet' if no encapsulation is set. This works well.
var $family = {
if ($top/interfaces/interface[name == $phyifname]/unit[name == $unit]/encapsulation) {
expr $top/interfaces/interface[name == $phyifname]/unit[name == $unit]/encapsulation;
} else {
expr "inet";
}
}
var $policer_in = $top/interfaces/interface[name == $phyifname]/unit[name == $unit]/family[name == $family]/policer/input;
var $policer_out = $top/interfaces/interface[name == $phyifname]/unit[name == $unit]/family[name == $family]/policer/output;
The problem comes in the last two lines. The 'family[name == $family]' doesn't work as I'd expect. I believe this is because family xxx is its own node (whats the right term for this?), as opposed to a node that expects an argument (ie, name in slax)
Can someone set me in the right direction on this?