From 6e8f23beeb3e916741882dcd6066500d73dc4f8a Mon Sep 17 00:00:00 2001 From: Fabien Dupont Date: Wed, 14 Aug 2019 21:16:37 +0200 Subject: [PATCH 1/3] Add VmOrTemplate.remove_all_snapshots_queue --- app/models/vm_or_template/operations/snapshot.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/app/models/vm_or_template/operations/snapshot.rb b/app/models/vm_or_template/operations/snapshot.rb index 46dcf42f44c..4392bdd2e10 100644 --- a/app/models/vm_or_template/operations/snapshot.rb +++ b/app/models/vm_or_template/operations/snapshot.rb @@ -150,6 +150,18 @@ def remove_all_snapshots raw_remove_all_snapshots end + def remove_all_snapshots_queue(task_id = nil) + MiqQueue.put_unless_exists( + :class_name => self.class.name, + :instance_id => id, + :method_name => 'remove_all_snapshots', + :args => [], + :role => "ems_operations", + :zone => my_zone, + :task_id => task_id + ) + end + def raw_revert_to_snapshot(snapshot_id) raise MiqException::MiqVmError, unsupported_reason(:revert_to_snapshot) unless supports_revert_to_snapshot? snapshot = snapshots.find_by(:id => snapshot_id) From 46adc56d6263425f951c691d722f3bd5a8258eff Mon Sep 17 00:00:00 2001 From: Fabien Dupont Date: Wed, 14 Aug 2019 21:41:56 +0200 Subject: [PATCH 2/3] Use MiqTask.generic_action_with_callback --- .../vm_or_template/operations/snapshot.rb | 22 ++++++++++++------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/app/models/vm_or_template/operations/snapshot.rb b/app/models/vm_or_template/operations/snapshot.rb index 4392bdd2e10..619fd540133 100644 --- a/app/models/vm_or_template/operations/snapshot.rb +++ b/app/models/vm_or_template/operations/snapshot.rb @@ -150,16 +150,22 @@ def remove_all_snapshots raw_remove_all_snapshots end - def remove_all_snapshots_queue(task_id = nil) - MiqQueue.put_unless_exists( + def remove_all_snapshots_queue(userid) + task_opts = { + :name => "Removing all snapshots for #{name}", + :userid => userid + } + + queue_opts = { :class_name => self.class.name, - :instance_id => id, :method_name => 'remove_all_snapshots', - :args => [], - :role => "ems_operations", - :zone => my_zone, - :task_id => task_id - ) + :instance_id => id, + :role => 'ems_operations', + :zone => ext_management_system.my_zone, + :args => [] + } + + MiqTask.generic_action_with_callback(task_opts, queue_opts) end def raw_revert_to_snapshot(snapshot_id) From fa38dfecb5cba0e1b084dd594fb01df4cd86ecf8 Mon Sep 17 00:00:00 2001 From: Fabien Dupont Date: Wed, 14 Aug 2019 21:46:27 +0200 Subject: [PATCH 3/3] Fix rubocop --- app/models/vm_or_template/operations/snapshot.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/vm_or_template/operations/snapshot.rb b/app/models/vm_or_template/operations/snapshot.rb index 619fd540133..49d7eb49904 100644 --- a/app/models/vm_or_template/operations/snapshot.rb +++ b/app/models/vm_or_template/operations/snapshot.rb @@ -152,7 +152,7 @@ def remove_all_snapshots def remove_all_snapshots_queue(userid) task_opts = { - :name => "Removing all snapshots for #{name}", + :name => "Removing all snapshots for #{name}", :userid => userid }