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

Merge branch 'master' of git.opennebula.org:one

This commit is contained in:
Jaime Melis 2011-07-07 18:54:15 +02:00
commit efa6d8ff76

View File

@ -92,6 +92,13 @@ class OneVMHelper < OpenNebulaHelper::OneHelper
CLIHelper.print_header(str_h1 % "VIRTUAL MACHINE TEMPLATE",false)
puts vm.template_str
if vm['/VM/HISTORY_RECORDS/HISTORY']
puts
CLIHelper.print_header(str_h1 % "VIRTUAL MACHINE HISTORY",false)
format_history(vm)
end
end
def format_pool(pool, options, top=false)
@ -147,4 +154,53 @@ class OneVMHelper < OpenNebulaHelper::OneHelper
table.show(pool, options)
end
end
def format_history(vm)
table=CLIHelper::ShowTable.new(nil, self) do
column :SEQ, "Sequence number", :size=>4 do |d|
d["SEQ"]
end
column :HOSTNAME, "Host name", :size=>15 do |d|
d["HOSTNAME"]
end
column :REASON, "VM state change reason", :size=>6 do |d|
VirtualMachine.get_reason d["REASON"]
end
column :START, "Time when the state changed", :size=>15 do |d|
OpenNebulaHelper.time_to_str(d['STIME'])
end
column :TIME, "Total time in this state", :size=>11 do |d|
stime = Time.at(d["STIME"].to_i)
etime = d["ETIME"]=="0" ? Time.now : Time.at(d["ETIME"].to_i)
dtime = Time.at(etime-stime).getgm
"%02d %02d:%02d:%02d" % [dtime.yday-1, dtime.hour,
dtime.min, dtime.sec]
end
column :PTIME, "Prolog time for this state", :size=>11 do |d|
stime = Time.at(d["PSTIME"].to_i)
if d["PSTIME"]=="0"
etime=Time.at(0)
else
etime = d["PETIME"]=="0" ? Time.now :
Time.at(d["PETIME"].to_i)
end
dtime = Time.at(etime-stime).getgm
"%02d %02d:%02d:%02d" % [dtime.yday-1, dtime.hour,
dtime.min, dtime.sec]
end
default :SEQ, :HOSTNAME, :REASON, :START, :TIME, :PTIME
end
vm_hash=vm.to_hash
history=vm_hash['VM']['HISTORY_RECORDS']['HISTORY']
table.show(history)
end
end