From a75c7e5fdd494230d5f5c81df65704acd432f11d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn?= Date: Tue, 5 Feb 2013 17:08:04 +0100 Subject: [PATCH] Feature #1483: onevm show lists scheduled actions in a table --- src/cli/cli_helper.rb | 3 +++ src/cli/one_helper.rb | 10 ++++++++-- src/cli/one_helper/onevm_helper.rb | 27 +++++++++++++++++++++++++++ 3 files changed, 38 insertions(+), 2 deletions(-) diff --git a/src/cli/cli_helper.rb b/src/cli/cli_helper.rb index ff095ffdc5..1fbd83b1f1 100644 --- a/src/cli/cli_helper.rb +++ b/src/cli/cli_helper.rb @@ -252,6 +252,9 @@ module CLIHelper if @columns[field] minus=( @columns[field][:left] ? "-" : "" ) size=@columns[field][:size] + if @columns[field][:donottruncate] + return "%#{minus}#{size}s" % [ data.to_s ] + end return "%#{minus}#{size}.#{size}s" % [ data.to_s ] else exit -1, "Column #{field} not defined." diff --git a/src/cli/one_helper.rb b/src/cli/one_helper.rb index 9b02938cb3..f812bc0de6 100644 --- a/src/cli/one_helper.rb +++ b/src/cli/one_helper.rb @@ -577,13 +577,19 @@ EOT end end - def OpenNebulaHelper.time_to_str(time) + def OpenNebulaHelper.time_to_str(time, print_seconds=true) value=time.to_i if value==0 value='-' else - value=Time.at(value).strftime("%m/%d %H:%M:%S") + if print_seconds + value=Time.at(value).strftime("%m/%d %H:%M:%S") + else + value=Time.at(value).strftime("%m/%d %H:%M") + end end + + return value end def OpenNebulaHelper.period_to_str(time, print_seconds=true) diff --git a/src/cli/one_helper/onevm_helper.rb b/src/cli/one_helper/onevm_helper.rb index d289d0d832..5ad3cd9481 100644 --- a/src/cli/one_helper/onevm_helper.rb +++ b/src/cli/one_helper/onevm_helper.rb @@ -241,12 +241,39 @@ class OneVMHelper < OpenNebulaHelper::OneHelper } puts + if vm.has_elements?("/VM/USER_TEMPLATE/SCHED_ACTION") + CLIHelper.print_header(str_h1 % "SCHEDULED ACTIONS",false) + + CLIHelper::ShowTable.new(nil, self) do + + column :"ACTION", "", :left, :size=>10 do |d| + d["ACTION"] if !d.nil? + end + + column :"SCHEDULED", "", :size=>12 do |d| + OpenNebulaHelper.time_to_str(d["TIME"], false) if !d.nil? + end + + column :"DONE", "", :size=>12 do |d| + OpenNebulaHelper.time_to_str(d["DONE"], false) if !d.nil? + end + + column :"MESSAGE", "", :left, :donottruncate, :size=>43 do |d| + d["MESSAGE"] if !d.nil? + end + end.show(vm.to_hash['VM']['USER_TEMPLATE']['SCHED_ACTION'], {}) + + puts + end + CLIHelper.print_header(str_h1 % "VIRTUAL MACHINE TEMPLATE",false) puts vm.template_str if vm.has_elements?("/VM/USER_TEMPLATE") puts + vm.delete_element("/VM/USER_TEMPLATE/SCHED_ACTION") + CLIHelper.print_header(str_h1 % "USER TEMPLATE",false) puts vm.template_like_str('USER_TEMPLATE') end