forked from auser/poolparty
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcloud-list
executable file
·47 lines (37 loc) · 1.13 KB
/
cloud-list
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/usr/bin/env ruby
$:.unshift(File.dirname(__FILE__) + "/../lib")
require "poolparty"
require 'git-style-binary/command'
GitStyleBinary.command do
banner <<-EOS
Usage: #{$0} #{all_options_string}
List the clouds and their nodes
e.g. show a list of the current instances on the cloud
EOS
opt :instance_id, "Describe a specific instance", :type => String, :default => nil
short_desc "show a list of the current instances on the clouds"
run do |command|
puts "#{pool.name}"
puts "==="
@loaded_clouds.each do |cld|
if command[:instance_id]
require 'pp'
pp result = cld.nodes(:instance_id=>command[:instance_id])
else
msg = ["* #{cld.name} cloud, #{cld.image_id}, #{cld.instance_type}"]
hsh = {}
cld.all_nodes.each do |n|
(hsh[n.status] ||= []) << n
end
hsh.each do |k,v|
msg << " - #{k} nodes"
v.each do |a|
msg << " - #{a.instance_id}\t#{a.status}\t#{a.public_ip}\t#{a.private_ip}\t#{a.zone}"
end
msg << ""
end
puts msg
end
end
end
end