TT#167950 Add new helper script get_all_v6ips_for_instance

Return an array of IPv6s from the interface of a given type
for an instance

Change-Id: If748fec8fc6dd381d4d87a5a1c118fe970bd6578
mr10.4
Marco Capetta 4 years ago
parent 3c631379d3
commit aec2f54e75

@ -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, ...

@ -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;
-%]
Loading…
Cancel
Save