mirror of
https://github.com/OpenNebula/one.git
synced 2025-01-12 09:17:41 +03:00
Feature #1483: onevm show lists scheduled actions in a table
This commit is contained in:
parent
e904781cf1
commit
a75c7e5fdd
@ -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."
|
||||
|
@ -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)
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user