mirror of
https://github.com/OpenNebula/one.git
synced 2025-01-20 14:03:36 +03:00
F OpenNebula/one#6624: Add list list-disk-snapshots (#3228)
in onevm for a specific disk Signed-off-by: ArnauGabrielAtienza <agabriel@opennebula.io>
This commit is contained in:
parent
a00ac1822c
commit
263cba6749
@ -1398,6 +1398,8 @@ class OneVMHelper < OpenNebulaHelper::OneHelper
|
||||
table.show(history)
|
||||
end
|
||||
|
||||
public
|
||||
|
||||
def format_snapshots(vm)
|
||||
table = CLIHelper::ShowTable.new(nil, self) do
|
||||
column :AC, 'Is active', :left, :size => 2 do |d|
|
||||
|
@ -1282,6 +1282,33 @@ CommandParser::CmdParser.new(ARGV) do
|
||||
helper.show_resource(args[0], options)
|
||||
end
|
||||
|
||||
disk_snapshot_list_desc = <<-EOT.unindent
|
||||
Lists the snapshots of a disk
|
||||
EOT
|
||||
|
||||
command :"disk-snapshot-list", disk_snapshot_list_desc, :vmid, :diskid do
|
||||
vm = helper.retrieve_resource(args[0])
|
||||
vm.info
|
||||
|
||||
filtered = []
|
||||
vm_hash = vm.to_hash
|
||||
vm_snapshots = [vm_hash['VM']['SNAPSHOTS']].flatten
|
||||
|
||||
vm_snapshots.each do |snap|
|
||||
if snap['DISK_ID'] == args[1]
|
||||
filtered << snap
|
||||
end
|
||||
end
|
||||
|
||||
vm_hash['VM']['SNAPSHOTS'] = filtered
|
||||
|
||||
if vm.has_elements?('/VM/SNAPSHOTS')
|
||||
CLIHelper.print_header('VM DISK SNAPSHOTS'.ljust(80), false)
|
||||
helper.format_snapshots(vm_hash)
|
||||
end
|
||||
0
|
||||
end
|
||||
|
||||
top_desc = <<-EOT.unindent
|
||||
Lists Images continuously
|
||||
EOT
|
||||
|
Loading…
x
Reference in New Issue
Block a user