diff --git a/src/cli/one_helper/onevm_helper.rb b/src/cli/one_helper/onevm_helper.rb index 7ccfabfd50..dcd10bd9c8 100644 --- a/src/cli/one_helper/onevm_helper.rb +++ b/src/cli/one_helper/onevm_helper.rb @@ -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| diff --git a/src/cli/onevm b/src/cli/onevm index 04cad32c98..1326e82b58 100755 --- a/src/cli/onevm +++ b/src/cli/onevm @@ -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