mirror of https://github.com/sipwise/ngcpcfg.git
Return an array of IPv6s from the interface of a given type for an instance Change-Id: If748fec8fc6dd381d4d87a5a1c118fe970bd6578mr10.4
parent
3c631379d3
commit
aec2f54e75
@ -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…
Reference in new issue