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

Support cancellation for miq_request and miq_request_task #17687

Merged
merged 1 commit into from
Jul 11, 2018
Merged
Show file tree
Hide file tree
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
8 changes: 8 additions & 0 deletions app/models/miq_request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -590,6 +590,14 @@ def self.display_name(number = 1)
n_('Request', 'Requests', number)
end

def cancel
raise _("Cancel operation is not supported for #{self.class.name}")
end

def canceling?
false
end

private

def clean_up_keys_for_request_task
Expand Down
8 changes: 8 additions & 0 deletions app/models/miq_request_task.rb
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,14 @@ def self.display_name(number = 1)
n_('Request Task', 'Request Tasks', number)
end

def cancel
raise _("Cancel operation is not supported for #{self.class.name}")
end

def canceling?
false
end

private

def validate_request_type
Expand Down
10 changes: 10 additions & 0 deletions app/models/service_template_transformation_plan_request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,14 @@ def validate_vm(_vm_id)
def approve_vm(vm_id)
vm_resources.find_by(:resource_id => vm_id).update_attributes!(:status => ServiceResource::STATUS_APPROVED)
end

def cancel
options['cancel_requested'] = true
save!
miq_request_tasks.each(&:cancel)
end

def canceling?
options['cancel_requested']
end
end
9 changes: 9 additions & 0 deletions app/models/service_template_transformation_plan_task.rb
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,15 @@ def transformation_log_queue(userid = nil)
MiqTask.generic_action_with_callback(options, queue_options)
end

def cancel
options['cancel_requested'] = true
save!
end

def canceling?
options['cancel_requested']
end

private

def vm_resource
Expand Down