Skip to content

Instantly share code, notes, and snippets.

@macros
Created November 6, 2009 18:08
Show Gist options
  • Save macros/228153 to your computer and use it in GitHub Desktop.
Save macros/228153 to your computer and use it in GitHub Desktop.
def ganglia_interface(host)
if host[:ganglia] && host[:ganglia][:cluster] && host[:ganglia][:cluster][:interface]
interface = host[:ganglia_cluster][:interface]
else
interface = host[:network][:default_interface]
end
end
def ganglia_ip(host)
interface = ganglia_interface(host)
host[:network][:interfaces][interface][:addresses].each do |addr,value|
if host[:network][:interfaces][interface][:addresses][addr][:family] == "inet"
return addr
end
end
end
def get_ips(cluster)
ips = []
search(:node, "*").each do |host|
if host[:ganglia] && host[:ganglia][:cluster] == cluster
ipaddr = ganglia_ip(host)
ips << ipaddr
end
end
return ips
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment