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_ifaces_for_host

42 lines
1.0 KiB

[%
# vi: ft=tt2
# 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, ...
# @param argv.status node status [ online, offline, inactive ]
# default value: ['online', 'inactive']
# @return out The interface name.
IF !hosts.${argv.host}.defined;
argv.host = 'self';
END;
IF !argv.status.size;
argv.status = ['online', 'inactive'];
END;
status = {
online = 0
offline = 0
inactive = 0
};
FOREACH val IN argv.status;
status.$val = 1;
END;
out = [];
IF status.item(hosts.${argv.host}.status);
FOREACH iface IN hosts.${argv.host}.interfaces;
NEXT UNLESS (hosts.${argv.host}.exists(iface) OR (iface.match('^neth[0-9]+$') AND hosts.${argv.host}.exists(iface.substr(1))));
NEXT UNLESS hosts.${argv.host}.$iface.type.grep('^' _ argv.type _ '$').size();
out.push(iface);
END;
END;
out = out.sort;
-%]