You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ngcpcfg/lib/get_all_shared_ips

56 lines
1.6 KiB

[%
# vi: ft=tt2
# Return an array of shared IPs from the interface of a given type for all
# nodes which act as a given role.
#
# @param argv.site The site to use, default value: current.
# @param argv.role The role of the node to process, one of:
# proxy, lb, mgmt
# @param argv.type The interface type of a node to extract the shared
# IP from, one of:
# web_int, web_ext, sip_int, sip_ext, ...
# @param argv.status node status [ online, offline, inactive ]
# default value: ['online', 'inactive']
# @return out The array of shared IPs.
IF !argv.site.length;
argv.site = 'current';
END;
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;
blktmp.processed_hosts = {};
out = [];
FOREACH host IN sites.${argv.site}.hosts.keys.sort;
NEXT UNLESS status.item(sites.${argv.site}.hosts.$host.status);
NEXT UNLESS ngcp.has_role(host, argv.role);
NEXT IF blktmp.processed_hosts.$host.defined;
FOREACH iface IN sites.${argv.site}.hosts.$host.interfaces;
NEXT UNLESS sites.${argv.site}.hosts.$host.exists(iface);
NEXT UNLESS sites.${argv.site}.hosts.$host.$iface.type.grep('^' _ argv.type _ '$').size();
peer = sites.${argv.site}.hosts.$host.peer;
blktmp.processed_hosts.$peer = 1;
FOREACH ip IN sites.${argv.site}.hosts.$host.$iface.shared_ip;
NEXT UNLESS ip;
out.push(ip);
END;
END;
END;
out = out.sort;
-%]