Support reformatting of IPv6 addresses in TT2 helper scripts

mr3.2.1
Richard Fuchs 12 years ago
parent 847647f444
commit f3fc3dc558
Notes: Jenkins User 10 years ago
jenkins_trigger: false

@ -7,6 +7,7 @@
# @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 = {} -%]
@ -20,6 +21,14 @@
[% 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 -%]

@ -3,6 +3,7 @@
#
# @param argv.host The host to get all shared IPs for.
# @param argv.type The interface type or empty string for all types.
# @param argv.format Optional reformatting of IPv6 addresses
# @return out The array of shared ips
-%]
[% IF !hosts.${argv.host}.defined -%][% argv.host = 'self' -%][% END -%]
@ -13,6 +14,14 @@
[% IF realiface == iface -%]
[% IF hosts.${argv.host}.$realiface.type.grep('^' _ argv.type _ '$').size() -%]
[% FOREACH ip IN hosts.${argv.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 -%]

Loading…
Cancel
Save