From 718fcf584c4f8444bceda9b0da75279de1439ebd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=98=D0=B3=D0=BE=D1=80=D1=8C?= <67561108+none0nfg@users.noreply.github.com> Date: Thu, 4 Mar 2021 12:46:16 +0300 Subject: [PATCH] Update onecluster_helper.rb Added description of cluster resources (cherry picked from commit e48be29da1e3e6a8921d2a8fe0fd1b5c63aa0633) (cherry picked from commit c1c4fd12a1755d2b06d9ae82ad9480a02566783b) --- src/cli/one_helper/onecluster_helper.rb | 29 +++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/src/cli/one_helper/onecluster_helper.rb b/src/cli/one_helper/onecluster_helper.rb index 20fac9f029..3bf234857f 100644 --- a/src/cli/one_helper/onecluster_helper.rb +++ b/src/cli/one_helper/onecluster_helper.rb @@ -102,13 +102,38 @@ class OneClusterHelper < OpenNebulaHelper::OneHelper CLIHelper.print_header(str_h1 % "CLUSTER #{cluster['ID']} INFORMATION") puts str % ["ID", cluster.id.to_s] puts str % ["NAME", cluster.name] + puts + 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'] + hosts.each do |h| + h = OpenNebula::Host.new_with_id(h, @client) + h.info! + h = h.to_hash + 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 + end + puts "TOTAL CPUs: "+total_cpu.to_s + puts "OCCUPIED CPUs: "+used_cpu.to_s + puts "AVAILABLE CPUs: "+(total_cpu - used_cpu).to_s + puts + puts "TOTAL RAM: "+total_ram.to_s + puts "OCCUPIED RAM: "+used_ram.to_s + puts "AVAILABLE RAM: "+(total_ram - used_ram).to_s + puts CLIHelper.print_header(str_h1 % "CLUSTER TEMPLATE", false) puts cluster.template_str - puts - + puts CLIHelper.print_header("%-15s" % ["HOSTS"]) cluster.host_ids.each do |id| puts "%-15s" % [id]