mirror of https://github.com/sipwise/ngcpcfg.git
41 lines
919 B
41 lines
919 B
[%
|
|
# vi: ft=tt2
|
|
|
|
# Return an advertised IP from the interface of a given LB instance
|
|
# @param argv.instance instance object
|
|
#
|
|
# @param argv.type The interface type of LB to extract the advertised IP
|
|
# from, one of:
|
|
# sip_int, sip_ext
|
|
# @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();
|
|
FOREACH adv IN iface.advertised_ip;
|
|
NEXT UNLESS adv;
|
|
out.push(adv);
|
|
END;
|
|
END;
|
|
|
|
out = out.sort.unique;
|
|
|
|
-%]
|