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_v6ips

40 lines
1.3 KiB

[%
# Return an array of shared IPv6 addresses from the interface of a given
# type for all nodes which act as a given role
#
# @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.format Optional reformatting of IPv6 addresses
# @return out The array of shared IPv6 addresses
-%]
[% blktmp.processed_hosts = {} -%]
[% out = [] -%]
[% FOREACH host IN hosts.keys -%]
[% IF hosts.$host.role.grep('^' _ argv.role _ '$').size() && !blktmp.processed_hosts.$host.defined -%]
[% FOREACH iface IN hosts.$host.interfaces -%]
[% FOREACH realiface IN hosts.$host.keys -%]
[% IF realiface == iface -%]
[% IF hosts.$host.$realiface.type.grep('^' _ argv.type _ '$').size() -%]
[% peer = hosts.$host.peer -%]
[% blktmp.processed_hosts.$peer = 1 -%]
[% FOREACH ip IN hosts.$host.$realiface.shared_v6ip -%]
[% IF argv.format == 'expand' -%]
[% WHILE ip.match('::') && ip.match(':', 1).size < 8 -%]
[% ip = ip.replace('::', '::0:') -%]
[% END -%]
[% ip = ip.replace('::', ':') -%]
[% ip = ip.replace('^:', '0:') -%]
[% ip = ip.replace(':$', ':0') -%]
[% END -%]
[% out.push(ip) -%]
[% END -%]
[% END -%]
[% END -%]
[% END -%]
[% END -%]
[% END -%]
[% END -%]