Skip to content

Commit

Permalink
Merge pull request #17687 from bzwei/miq_request_cancel
Browse files Browse the repository at this point in the history
Support cancellation for miq_request and miq_request_task
  • Loading branch information
gmcculloug authored Jul 11, 2018
2 parents a72b40d + 674d86c commit d676ff5
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 0 deletions.
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

0 comments on commit d676ff5

Please sign in to comment.