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

B #5325 Fixed snapshot-delete problem (#454)

This commit is contained in:
Sergio Semedi Barranco 2017-09-07 11:36:50 +02:00 committed by Javi Fontan
parent 419193e467
commit ea065409b6
2 changed files with 24 additions and 4 deletions

View File

@ -192,6 +192,20 @@ class OneVMHelper < OpenNebulaHelper::OneHelper
end
end
def retrieve_snapshot_id(vm_id, id)
vm = retrieve_resource(vm_id)
vm.info
if !/\A\d+\z/.match(id)
ids = vm.retrieve_elements("/VM/TEMPLATE/SNAPSHOT[NAME='#{id}']/SNAPSHOT_ID")
return [-1, "#{id} not found or duplicated"] if ids.nil? || ids.size > 1
else
return [0, id.to_i]
end
[0, ids[0].to_i]
end
def format_pool(options)
config_file = self.class.table_conf

View File

@ -162,7 +162,9 @@ cmd=CommandParser::CmdParser.new(ARGV) do
end
set :format, :vmid, OneVMHelper.to_id_desc do |arg|
helper.to_id(arg)
tmp = helper.to_id(arg)
@current_vm = tmp[1]
tmp
end
set :format, :vmid_list, OneVMHelper.list_to_id_desc do |arg|
@ -181,6 +183,10 @@ cmd=CommandParser::CmdParser.new(ARGV) do
OpenNebulaHelper.size_in_mb(arg)
end
format :snapshot_id, "Snapshot identifier" do |arg|
helper.retrieve_snapshot_id(@current_vm, arg)
end
########################################################################
# Commands
########################################################################
@ -804,7 +810,7 @@ cmd=CommandParser::CmdParser.new(ARGV) do
command :"snapshot-delete", snapshot_delete_desc, :vmid, :snapshot_id do
helper.perform_action(args[0],options,"snapshot deleted") do |o|
o.snapshot_delete(args[1].to_i)
o.snapshot_delete(args[1])
end
end
@ -829,7 +835,7 @@ cmd=CommandParser::CmdParser.new(ARGV) do
EOT
command :"disk-snapshot-revert", disk_snapshot_revert_desc,
:vmid, :diskid, :snapshot_id do
:vmid, :diskid, :disk_snapshot_id do
helper.perform_action(args[0],options,"disk snapshot reverted") do |o|
o.disk_snapshot_revert(args[1].to_i, args[2].to_i)
end
@ -841,7 +847,7 @@ cmd=CommandParser::CmdParser.new(ARGV) do
States: RUNNING, POWEROFF, SUSPENDED
EOT
command :"disk-snapshot-delete", disk_snapshot_delete_desc,
:vmid, :diskid, :snapshot_id do
:vmid, :diskid, :disk_snapshot_id do
helper.perform_action(args[0],options,"disk snapshot deleted") do |o|
o.disk_snapshot_delete(args[1].to_i, args[2].to_i)
end