MT#8503 Add helper to fetch cluster ips.

vseva/db_defaults
Andreas Granig 12 years ago
parent f5053150b2
commit 37b7d7a1ce

@ -0,0 +1,29 @@
[%
# Return an array of hashes, each hash containing dispatcher_id and ips,
# which is an array of ips, for a given cluster set type.
#
# @param argv.type The type of element we are interested in (rtp, lb)
# @return out The array of hashes
-%]
[%
out = [];
FOREACH set IN cluster_sets.keys;
set = cluster_sets.$set;
IF set.${argv.type}.defined;
theset = { dispatcher_id = set.dispatcher_id };
theset.ips = [];
FOREACH entry IN set.${argv.type};
iftype = entry.iface;
host = entry.host;
FOREACH iface IN hosts.$host.interfaces;
realiface = hosts.$host.$iface;
NEXT UNLESS realiface.type.grep('^' _ iftype _ '$').size();
theset.ips.push(realiface.ip);
END;
END;
IF theset.ips.size();
out.push(theset);
END;
END;
END;
-%]

@ -0,0 +1,34 @@
[%
# 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.
#
# @param argv.type The type of element we are interested in (rtp, lb)
# @return out The array of hashes
-%]
[%
blktmp.processed_hosts = {};
out = [];
FOREACH set IN cluster_sets.keys;
set = cluster_sets.$set;
IF set.${argv.type}.defined;
theset = { dispatcher_id = set.dispatcher_id };
theset.ips = [];
FOREACH entry IN set.${argv.type};
iftype = entry.iface;
host = entry.host;
NEXT IF blktmp.processed_hosts.$host.defined;
FOREACH iface IN hosts.$host.interfaces;
realiface = hosts.$host.$iface;
NEXT UNLESS realiface.type.grep('^' _ iftype _ '$').size();
blktmp.processed_hosts.$peer = 1;
FOREACH ip IN realiface.shared_ip;
theset.ips.push(ip);
END;
END;
END;
IF theset.ips.size();
out.push(theset);
END;
END;
END;
-%]
Loading…
Cancel
Save