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
1.1 KiB
32 lines
1.1 KiB
[%
|
|
# Return an array of hashes with name and ip within a given type
|
|
# for all nodes.
|
|
#
|
|
# @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 array of hashes with fields "name" and "ip", e.g.:
|
|
# [
|
|
# {name=>'sp1', ip='192.168.255.251'},
|
|
# {name=>'sp2', ip='192.168.255.252'}
|
|
# ]
|
|
-%]
|
|
[% out = [] -%]
|
|
[% FOREACH host IN hosts.keys -%]
|
|
[% IF hosts.$host.role.grep('^' _ argv.role _ '$').size() -%]
|
|
[% FOREACH iface IN hosts.$host.interfaces -%]
|
|
[% FOREACH realiface IN hosts.$host.keys -%]
|
|
[% IF realiface == iface -%]
|
|
[% IF hosts.$host.$realiface.type.grep('^' _ argv.type _ '$').size() -%]
|
|
[% IF !out.grep('^' _ hosts.$host.$realiface.ip _ '$').size() -%]
|
|
[% out.push({ name = host, ip = hosts.$host.$realiface.ip }) -%]
|
|
[% END -%]
|
|
[% END -%]
|
|
[% END -%]
|
|
[% END -%]
|
|
[% END -%]
|
|
[% END -%]
|
|
[% END -%]
|