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

28 lines
711 B

[%
# vi: ft=tt2
# Returns the interface name of a given IP address.
#
# @param argv.host The current host for IP interface name mapping.
# @param argv.ip The IP address to map.
# @return out The 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;
-%]