diff --git a/lib/get_all_ips_for_instance b/lib/get_all_ips_for_instance index 58c03db7..1db0a167 100644 --- a/lib/get_all_ips_for_instance +++ b/lib/get_all_ips_for_instance @@ -1,10 +1,9 @@ [% # vi: ft=tt2 -# Return an array of IPs from the interface of a given type for all nodes -# which act as a given role. -# @param argv.instance instance name -# +# Return an array of IPs from the interface of a given type +# for an instance. +# @param argv.instance instance # @param argv.type The interface type of a node to extract the IP # from, one of: # web_int, web_ext, sip_int, sip_ext, ... diff --git a/lib/get_all_v6ips_for_instance b/lib/get_all_v6ips_for_instance new file mode 100644 index 00000000..f46d729c --- /dev/null +++ b/lib/get_all_v6ips_for_instance @@ -0,0 +1,44 @@ +[% +# vi: ft=tt2 + +# Return an array of IPv6s from the interface of a given type +# for an instance. +# @param argv.instance instance +# @param argv.type The interface type of a node to extract the IP +# from, one of: +# web_int, web_ext, sip_int, sip_ext, ... +# @param argv.format Optional reformatting of IPv6 addresses. +# @param argv.status node status [ online, offline, inactive ] +# default value: ['online', 'inactive'] +# @return out The array of IPs. + +IF !argv.status.size; + argv.status = ['online', 'inactive']; +END; + +status = { + online = 0 + offline = 0 + inactive = 0 +}; +FOREACH val IN argv.status; + status.$val = 1; +END; + +out = []; +RETURN UNLESS status.item(argv.instance.status); + +FOREACH iface IN argv.instance.interfaces; + NEXT UNLESS iface.type.grep('^' _ argv.type _ '$').size(); + NEXT UNLESS iface.v6ip; + IF argv.format == 'expand'; + ip = ngcp.net_ip_expand(iface.v6ip); + ELSE; + ip = iface.v6ip; + END; + out.push(ip); +END; + +out = out.sort.unique; + +-%]