1
0
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:
ArnauGabrielAtienza 2024-09-16 11:14:44 +02:00 committed by GitHub
parent a00ac1822c
commit 263cba6749
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 29 additions and 0 deletions

View File

@ -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|

View File

@ -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