From 1030182d04de3e78e07ded08059899ae3dcf59da Mon Sep 17 00:00:00 2001 From: Donat Zenichev Date: Wed, 19 Jan 2022 14:03:19 +0100 Subject: [PATCH] TT#157251 Add 'get_all_adv_ips_for_instance' script We need to add a new script, which finds and grabs a list needed advertised ip addresses for a particular instance. Change-Id: Id33c4e2d4de071c5feb34dd9346a33ef4a61381b --- lib/get_all_adv_ips_for_instance | 40 ++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 lib/get_all_adv_ips_for_instance diff --git a/lib/get_all_adv_ips_for_instance b/lib/get_all_adv_ips_for_instance new file mode 100644 index 00000000..62cefd3b --- /dev/null +++ b/lib/get_all_adv_ips_for_instance @@ -0,0 +1,40 @@ +[% +# 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; + +-%]