57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
|
# File 'lib/smartos-manager/cli.rb', line 57
def list
registry = get_registry(cache_key: 'list')
ret = registry.list_vms()
rev_colors = ColorPicker.new
sysinfos = registry.sysinfo()
diags = registry.diag()
failures = registry.failed_connections()
unless failures.empty?
puts "Error while connecting to:".red()
failures.each do |s|
puts " - #{s.name} : #{s.address}".red()
end
puts ""
end
user_columns = registry.user_columns.keys.map{|s| humanize(s) }
p_vm_list("Memory", "Name (gray = online)", "Type", "UUID", "State", "Admin IP", "DD(GB)", *user_columns)
ret.each do |host, vms|
mem = sysinfos[host][:memory]
zfs_arc_reserved = sysinfos[host][:zfs_arc_reserved]
zfs_arc_current = sysinfos[host][:zfs_arc_current]
vm_memory = 0
vms.each{|vm| vm_memory += vm.memory }
avail = [1, (mem - vm_memory) - zfs_arc_current].max
dd = sysinfos[host][:disks].map{|_, d| "#{format_size(d[:size])} GB" }.join(" - ")
rev = sysinfos[host][:smartos_version]
puts "\nHardware: #{diags[host][:system_id]} (MAC: #{sysinfos[host][:mac0].upcase.white()}, IP: #{host.address.white()} )"
puts "HDD: #{sysinfos[host][:disks].keys.size} drives - #{dd}"
puts "#{host.name} [SmartOS: #{rev.send(rev_colors.get(rev))}] (Free RAM: #{avail.human_size(1).green}/#{mem.human_size(1)} [Free Slots: #{diags[host][:free_memory_banks]}], ZFS: #{format_size(zfs_arc_current)}G/#{format_size(zfs_arc_reserved)}G)"
vms.each do |vm|
user_columns = registry.user_columns.values.map{|key| vm[key] }
if vm.type == "KVM"
vm_disk = sysinfos[host][:zfs_volumes]["zones/#{vm.uuid}-disk0"]
vm_disk_label = "#{vm_disk[:size]}"
else
vm_disk = sysinfos[host][:zfs_volumes]["zones/#{vm.uuid}"]
vm_disk_label = "#{vm_disk[:quota]}"
end
if vm.
tmp = vm..human_size(1)
else
tmp = "-"
end
formatted_mem = "#{tmp.ljust(5)} / #{vm.memory.human_size(1).ljust(5)}"
p_vm_list(formatted_mem, vm.name, vm.type, vm.uuid, vm.state, vm.admin_ip, vm_disk_label, *user_columns)
end
if vms.empty?
puts " [ no VMS ]"
end
end
end
|