You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ngcpcfg/lib/get_iface_for_ip

22 lines
620 B

[%
# Returns the interface name of a given ip address
#
# @param argv.host Current host for ip interface name mapping
# @param argv.ip Ip address to map
# @return out Interface name of the given ip
out = '';
FOREACH key IN hosts.${argv.host}.keys;
IF hosts.${argv.host}.${key}.ip.defined && hosts.${argv.host}.${key}.ip == argv.ip;
out = "$key";
RETURN;
ELSIF hosts.${argv.host}.${key}.shared_ip.defined && hosts.${argv.host}.${key}.shared_ip.size > 0;
FOREACH shared_ip IN hosts.${argv.host}.${key}.shared_ip;
IF shared_ip == argv.ip;
out = "$key:$loop.index";
RETURN;
END;
END;
END;
END;
-%]