1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-03-22 18:50:08 +03:00

M #-: fix minor bug in onecluster helper (#1194)

(cherry picked from commit 390a4373b7d27100fcdb7b70bd4847cea108bc26)
This commit is contained in:
Alejandro Huertas Herrero 2021-05-07 10:19:35 +02:00 committed by Ruben S. Montero
parent 7f0816fb9e
commit a2f6375b44
No known key found for this signature in database
GPG Key ID: A0CEA6FA880A1D87

View File

@ -105,30 +105,37 @@ class OneClusterHelper < OpenNebulaHelper::OneHelper
CLIHelper.print_header(str_h1 % 'CLUSTER RESOURCES', false)
cluster.info!
total_cpu = 0
used_cpu = 0
total_ram = 0
used_ram = 0
hosts = cluster.to_hash['CLUSTER']['HOSTS']['ID']
cluster.to_hash['CLUSTER']['HOSTS']['ID'].each do |h|
h = OpenNebula::Host.new_with_id(h, @client)
h.info!
h = h.to_hash
if hosts
total_cpu = 0
used_cpu = 0
total_ram = 0
used_ram = 0
total_cpu += h['HOST']['HOST_SHARE']['TOTAL_CPU'].to_i / 100
used_cpu += h['HOST']['HOST_SHARE']['CPU_USAGE'].to_i / 100
total_ram += h['HOST']['HOST_SHARE']['TOTAL_MEM'].to_i / 1024 / 1024
used_ram += h['HOST']['HOST_SHARE']['MEM_USAGE'].to_i / 1024 / 1024
hosts.each do |h|
h = OpenNebula::Host.new_with_id(h, @client)
h.info!
h = h.to_hash
h = h['HOST']['HOST_SHARE']
total_cpu += h['TOTAL_CPU'].to_i / 100
used_cpu += h['CPU_USAGE'].to_i / 100
total_ram += h['TOTAL_MEM'].to_i / 1024 / 1024
used_ram += h['MEM_USAGE'].to_i / 1024 / 1024
end
puts "TOTAL CPUs: #{total_cpu}"
puts "OCCUPIED CPUs: #{used_cpu}"
puts "AVAILABLE CPUs: #{total_cpu - used_cpu}"
puts
puts "TOTAL RAM: #{total_ram}"
puts "OCCUPIED RAM: #{used_ram}"
puts "AVAILABLE RAM: #{total_ram - used_ram}"
end
puts "TOTAL CPUs: #{total_cpu}"
puts "OCCUPIED CPUs: #{used_cpu}"
puts "AVAILABLE CPUs: #{total_cpu - used_cpu}"
puts
puts "TOTAL RAM: #{total_ram}"
puts "OCCUPIED RAM: #{used_ram}"
puts "AVAILABLE RAM: #{total_ram - used_ram}"
puts
CLIHelper.print_header(str_h1 % 'CLUSTER TEMPLATE', false)
puts cluster.template_str