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.
48 lines
1.0 KiB
48 lines
1.0 KiB
[%
|
|
# vi: ft=tt2
|
|
|
|
# Return an array of advertised IPs for a given host.
|
|
#
|
|
# @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.status node status [ online, offline, inactive ]
|
|
# default value: ['online', 'inactive']
|
|
# @return out The array of advertised IPs.
|
|
|
|
IF !hosts.${argv.host}.defined;
|
|
argv.host = 'self';
|
|
END;
|
|
|
|
IF !argv.type.length;
|
|
argv.type = '.*';
|
|
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);
|
|
NEXT UNLESS hosts.${argv.host}.$iface.type.grep('^' _ argv.type _ '$').size();
|
|
|
|
FOREACH ip IN hosts.${argv.host}.$iface.advertised_ip;
|
|
NEXT UNLESS ip;
|
|
out.push(ip);
|
|
END;
|
|
END;
|
|
END;
|
|
out = out.sort;
|
|
|
|
-%]
|