Add helper script get_all_ifaces_for_host

Returns an array of all ifaces of a
particular host matching a type.
0.18
Jon Bonilla 13 years ago
parent 183c61c49b
commit bf9515e9dc

@ -0,0 +1,22 @@
[%
# Returns the interface name with a certain type for a given host
#
# @param argv.host The hostname to get the interface from.
# @param argv.type The interface type
# One of: web_int, web_ext, sip_int, sip_ext, ...
# @return out The interface name
-%]
[% IF !hosts.${argv.host}.defined -%]
[% argv.host = 'self' -%]
[% END -%]
[% out = [] -%]
[% FOREACH iface IN hosts.${argv.host}.interfaces -%]
[% FOREACH realiface IN hosts.${argv.host}.keys -%]
[% IF realiface == iface -%]
[% IF hosts.${argv.host}.$realiface.type.grep('^' _ argv.type _ '$').size() -%]
[% out.push(realiface) -%]
[% END -%]
[% END -%]
[% END -%]
[% END -%]
Loading…
Cancel
Save