forked from tinova/one-tools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
onereport
executable file
·34 lines (29 loc) · 853 Bytes
/
onereport
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
#!/usr/bin/env ruby
require 'rexml/document'
require 'pp'
vmpool_x = `onevm list -x`
vmpool = REXML::Document.new(vmpool_x).root
first = true
if vmpool
vmpool.elements.each("VM") do |vm|
puts unless first
first = false if first
puts "VM: " + vm.elements["ID"].text
puts "NAME: " + vm.elements["NAME"].text
if hostname = vm.elements["HISTORY_RECORDS/HISTORY/HOSTNAME"].text
puts "HOSTNAME: " + hostname
end
vm.elements.each("TEMPLATE/GRAPHICS") do |vnc|
if vnc_port = vnc.elements["PORT"]
puts "VNC PORT: " + vnc_port.text
end
end
vm.elements.each("TEMPLATE/NIC") do |nic|
if ip = nic.elements["IP"]
puts "IP: " + ip.text
end
end
end
else
puts "Empty Cloud"
end