mirror of https://github.com/sipwise/ngcpcfg.git
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.
32 lines
929 B
32 lines
929 B
[%
|
|
# vi: ft=tt2
|
|
|
|
# Return a hash of IPs from the interface of a given type for all nodes
|
|
# which act as a given role dbnode value of that host.
|
|
#
|
|
# @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 IP
|
|
# from, one of:
|
|
# web_int, web_ext, sip_int, sip_ext, ...
|
|
# @return out The hash of ips and dbnode values.
|
|
|
|
out = {};
|
|
FOREACH host IN hosts.keys;
|
|
NEXT UNLESS hosts.$host.role.grep('^' _ argv.role _ '$').size();
|
|
|
|
FOREACH iface IN hosts.$host.interfaces;
|
|
FOREACH realiface IN hosts.$host.keys;
|
|
NEXT IF realiface != iface;
|
|
NEXT UNLESS hosts.$host.$realiface.type.grep('^' _ argv.type _ '$').size();
|
|
|
|
ip = hosts.$host.$realiface.ip;
|
|
NEXT IF out.exists($ip);
|
|
|
|
out.$ip = hosts.$host.dbnode;
|
|
END;
|
|
END;
|
|
END;
|
|
|
|
-%]
|