mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-21 14:50:08 +03:00
feature #3782: add snapshots to onevm show
This commit is contained in:
parent
e306680729
commit
986cf14c6b
@ -615,6 +615,12 @@ class OneVMHelper < OpenNebulaHelper::OneHelper
|
||||
end if !options[:all]
|
||||
end
|
||||
|
||||
if vm.has_elements?("/VM/SNAPSHOTS")
|
||||
puts
|
||||
CLIHelper.print_header(str_h1 % "VM DISK SNAPSHOTS",false)
|
||||
format_snapshots(vm)
|
||||
end
|
||||
|
||||
sg_nics = []
|
||||
|
||||
if (vm.has_elements?("/VM/TEMPLATE/NIC/SECURITY_GROUPS"))
|
||||
@ -941,4 +947,55 @@ class OneVMHelper < OpenNebulaHelper::OneHelper
|
||||
|
||||
table.show(history)
|
||||
end
|
||||
|
||||
def format_snapshots(vm)
|
||||
table=CLIHelper::ShowTable.new(nil, self) do
|
||||
column :AC , "Is active", :left, :size => 2 do |d|
|
||||
if d["ACTIVE"] == "YES"
|
||||
"=>"
|
||||
else
|
||||
""
|
||||
end
|
||||
end
|
||||
column :ID, "Snapshot ID", :size=>3 do |d|
|
||||
d["ID"]
|
||||
end
|
||||
|
||||
column :DISK, "Disk ID", :size=>4 do |d|
|
||||
d["DISK_ID"]
|
||||
end
|
||||
|
||||
column :PARENT, "Snapshot Parent ID", :size=>6 do |d|
|
||||
d["PARENT_ID"]
|
||||
end
|
||||
|
||||
column :TAG, "Snapshot Tag", :left, :size=>45 do |d|
|
||||
d["TAG"]
|
||||
end
|
||||
|
||||
column :DATE, "Snapshot creation date", :size=>15 do |d|
|
||||
OpenNebulaHelper.time_to_str(d["DATE"])
|
||||
end
|
||||
|
||||
default :AC, :ID, :DISK, :PARENT, :DATE, :TAG
|
||||
end
|
||||
|
||||
# Convert snapshot data to an array
|
||||
vm_hash = vm.to_hash
|
||||
vm_snapshots = [vm_hash['VM']['SNAPSHOTS']].flatten
|
||||
|
||||
snapshots = []
|
||||
|
||||
vm_snapshots.each do |disk|
|
||||
disk_id = disk['DISK_ID']
|
||||
|
||||
sshots = [disk['SNAPSHOT']].flatten
|
||||
sshots.each do |snapshot|
|
||||
data = snapshot.merge({ 'DISK_ID' => disk_id })
|
||||
snapshots << data
|
||||
end
|
||||
end
|
||||
|
||||
table.show(snapshots)
|
||||
end
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user