mirror of https://github.com/sipwise/ngcpcfg.git
Change-Id: I5b3f04a01a27b0dfe8d0c5372943d841eb7e50e4changes/90/290/5
parent
7800b2a060
commit
b196b6b04f
@ -1,29 +1,42 @@
|
|||||||
[%
|
[%
|
||||||
# Return an array of hashes, each hash containing dispatcher_id and ips,
|
# Return an array of hashes, each hash containing dispatcher_id and ips,
|
||||||
# which is an array of ips, for a given cluster set type.
|
# which is an array of ips, for a given cluster set type.
|
||||||
#
|
#
|
||||||
|
# @param argv.host If the cluster_set type is 'central; we need to filter by pair
|
||||||
# @param argv.type The type of element we are interested in (rtp, lb)
|
# @param argv.type The type of element we are interested in (rtp, lb)
|
||||||
# @return out The array of hashes
|
# @return out The array of hashes
|
||||||
-%]
|
-%]
|
||||||
[%
|
[%
|
||||||
|
IF !hosts.${argv.host}.defined;
|
||||||
|
argv.host = 'self';
|
||||||
|
END;
|
||||||
|
-%]
|
||||||
|
[%
|
||||||
out = [];
|
out = [];
|
||||||
|
|
||||||
|
IF cluster_sets.type == 'central';
|
||||||
|
set_hosts = [ hosts.$host, hosts.$host.peer ];
|
||||||
|
ELSE;
|
||||||
|
set_hosts = hosts.keys;
|
||||||
|
END;
|
||||||
|
|
||||||
|
|
||||||
FOREACH set IN cluster_sets.keys;
|
FOREACH set IN cluster_sets.keys;
|
||||||
set = cluster_sets.$set;
|
NEXT IF (set == 'default_set' || set == 'type');
|
||||||
IF set.${argv.type}.defined;
|
theset = { dispatcher_id = cluster_sets.$set.dispatcher_id };
|
||||||
theset = { dispatcher_id = set.dispatcher_id };
|
theset.ips = [];
|
||||||
theset.ips = [];
|
|
||||||
FOREACH entry IN set.${argv.type};
|
FOREACH host IN set_hosts;
|
||||||
iftype = entry.iface;
|
NEXT UNLESS hosts.$host.role.grep('^' _ argv.type _ '$').size();
|
||||||
host = entry.host;
|
FOREACH iface IN hosts.$host.interfaces;
|
||||||
FOREACH iface IN hosts.$host.interfaces;
|
NEXT UNLESS hosts.$host.$iface.cluster_sets.grep('^' _ set _ '$').size();
|
||||||
realiface = hosts.$host.$iface;
|
theset.ips.push(hosts.$host.$iface.ip);
|
||||||
NEXT UNLESS realiface.type.grep('^' _ iftype _ '$').size();
|
|
||||||
theset.ips.push(realiface.ip);
|
|
||||||
END;
|
|
||||||
END;
|
|
||||||
IF theset.ips.size();
|
|
||||||
out.push(theset);
|
|
||||||
END;
|
END;
|
||||||
END;
|
END;
|
||||||
|
|
||||||
|
IF theset.ips.size();
|
||||||
|
out.push(theset);
|
||||||
|
END;
|
||||||
|
|
||||||
END;
|
END;
|
||||||
-%]
|
-%]
|
||||||
|
@ -1,34 +1,48 @@
|
|||||||
[%
|
[%
|
||||||
# Return an array of hashes, each hash containing dispatcher_id and ips,
|
# Return an array of hashes, each hash containing dispatcher_id and ips,
|
||||||
# which is an array of shared ips, for a given cluster set type.
|
# which is an array of shared ips, for a given cluster set type.
|
||||||
#
|
#
|
||||||
|
# @param argv.host If the cluster_set type is 'central; we need to filter by pair
|
||||||
# @param argv.type The type of element we are interested in (rtp, lb)
|
# @param argv.type The type of element we are interested in (rtp, lb)
|
||||||
# @return out The array of hashes
|
# @return out The array of hashes
|
||||||
-%]
|
-%]
|
||||||
[%
|
[%
|
||||||
blktmp.processed_hosts = {};
|
IF !hosts.${argv.host}.defined;
|
||||||
|
argv.host = 'self';
|
||||||
|
END;
|
||||||
|
-%]
|
||||||
|
[%
|
||||||
out = [];
|
out = [];
|
||||||
|
|
||||||
|
IF cluster_sets.type == 'central';
|
||||||
|
set_hosts = [ hosts.$host, hosts.$host.peer ];
|
||||||
|
ELSE;
|
||||||
|
set_hosts = hosts.keys;
|
||||||
|
END;
|
||||||
|
|
||||||
|
|
||||||
FOREACH set IN cluster_sets.keys;
|
FOREACH set IN cluster_sets.keys;
|
||||||
set = cluster_sets.$set;
|
NEXT IF (set == "default_set" || set == "type");
|
||||||
IF set.${argv.type}.defined;
|
blktmp.processed_hosts = {};
|
||||||
theset = { dispatcher_id = set.dispatcher_id };
|
theset = { dispatcher_id = cluster_sets.$set.dispatcher_id };
|
||||||
theset.ips = [];
|
theset.ips = [];
|
||||||
FOREACH entry IN set.${argv.type};
|
|
||||||
iftype = entry.iface;
|
FOREACH host IN set_hosts;
|
||||||
host = entry.host;
|
NEXT UNLESS blktmp.processed_hosts.$host.defined;
|
||||||
NEXT IF blktmp.processed_hosts.$host.defined;
|
NEXT UNLESS hosts.$host.role.grep('^' _ argv.type _ '$').size();
|
||||||
FOREACH iface IN hosts.$host.interfaces;
|
FOREACH iface IN hosts.$host.interfaces;
|
||||||
realiface = hosts.$host.$iface;
|
NEXT UNLESS hosts.$host.$iface.cluster_sets.grep('^' _ set _ '$').size();
|
||||||
NEXT UNLESS realiface.type.grep('^' _ iftype _ '$').size();
|
blktmp.processed_hosts.$peer = 1;
|
||||||
blktmp.processed_hosts.$peer = 1;
|
theset.ips.push(hosts.$host.$iface.ip);
|
||||||
FOREACH ip IN realiface.shared_ip;
|
FOREACH ip IN hosts.$host.$iface.shared_ip;
|
||||||
theset.ips.push(ip);
|
theset.ips.push(ip);
|
||||||
END;
|
|
||||||
END;
|
END;
|
||||||
END;
|
END;
|
||||||
IF theset.ips.size();
|
|
||||||
out.push(theset);
|
|
||||||
END;
|
|
||||||
END;
|
END;
|
||||||
|
|
||||||
|
IF theset.ips.size();
|
||||||
|
out.push(theset);
|
||||||
|
END;
|
||||||
|
|
||||||
END;
|
END;
|
||||||
-%]
|
-%]
|
||||||
|
Loading…
Reference in new issue