Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move snapshot_delete to core CloudVolumeSnapshot model #15624

Merged
merged 1 commit into from
Sep 18, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions app/models/cloud_volume_snapshot.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,40 @@ def self.my_zone(ems)
def my_zone
self.class.my_zone(ext_management_system)
end

def delete_snapshot_queue(userid = "system", _options = {})
task_opts = {
:action => "deleting volume snapshot #{inspect} in #{ext_management_system.inspect}",
:userid => userid
}

queue_opts = {
:class_name => self.class.name,
:instance_id => id,
:method_name => 'delete_snapshot',
:priority => MiqQueue::HIGH_PRIORITY,
:role => 'ems_operations',
:zone => my_zone,
:args => []
}

MiqTask.generic_action_with_callback(task_opts, queue_opts)
end

def delete_snapshot
raw_delete_snapshot
rescue => e
notification_options = {
:snapshot_op => 'delete',
:subject => "[#{name}]",
:error => e.to_s
}
Notification.create(:type => :vm_snapshot_failure, :options => notification_options)

raise e
end

def raw_delete_snapshot
raise NotImplementedError, _("raw_delete_snapshot must be implemented in a subclass")
end
end