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_shared_names_by_role

40 lines
982 B

[%
# vi: ft=tt2
# Return an array of Carrier nodes shared names with a given role
#
# @param argv.role The role of the node to process, one of:
# proxy, lb, mgmt
# @param argv.status node status [ online, offline, inactive ]
# default value: ['online', 'inactive']
# @return out The array of shared names, e.g.:
# [ 'prx01', 'prx02', 'prx05' ]
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;
blktmp.processed_hosts = {};
out = [];
FOREACH host IN hosts.keys.sort;
NEXT UNLESS status.item(hosts.$host.status);
NEXT IF blktmp.processed_hosts.$host.defined;
NEXT UNLESS ngcp.has_role(host, argv.role);
peer = hosts.$host.peer;
blktmp.processed_hosts.$peer = 1;
matches = host.match('^(\w+[0-9])[ab]$');
out.push(matches.0);
END;
out = out.sort;
-%]