diff --git a/app/models/miq_request.rb b/app/models/miq_request.rb index 8608963093a9..ca1cfa0f0fb9 100644 --- a/app/models/miq_request.rb +++ b/app/models/miq_request.rb @@ -590,6 +590,14 @@ def self.display_name(number = 1) n_('Request', 'Requests', number) end + def cancel_request + raise raise _("This type of request cannot be canceled.") + end + + def canceling? + false + end + private def clean_up_keys_for_request_task diff --git a/app/models/miq_request_task.rb b/app/models/miq_request_task.rb index 07dae68f7bf7..396fb4118370 100644 --- a/app/models/miq_request_task.rb +++ b/app/models/miq_request_task.rb @@ -206,6 +206,14 @@ def self.display_name(number = 1) n_('Request Task', 'Request Tasks', number) end + def cancel_task + raise _("This type of task cannot be canceled") + end + + def canceling? + false + end + private def validate_request_type diff --git a/app/models/service_template_transformation_plan_request.rb b/app/models/service_template_transformation_plan_request.rb index 5632a47f3158..44ded372f116 100644 --- a/app/models/service_template_transformation_plan_request.rb +++ b/app/models/service_template_transformation_plan_request.rb @@ -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_request + options['cancel_requested'] = true + save! + miq_request_tasks.each(&:cancel_task) + end + + def canceling? + options['cancel_requested'] + end end diff --git a/app/models/service_template_transformation_plan_task.rb b/app/models/service_template_transformation_plan_task.rb index 3e5f88f623dd..fd1803734fbc 100644 --- a/app/models/service_template_transformation_plan_task.rb +++ b/app/models/service_template_transformation_plan_task.rb @@ -102,6 +102,15 @@ def transformation_log_queue(userid = nil) MiqTask.generic_action_with_callback(options, queue_options) end + def cancel_task + options['cancel_requested'] = true + save! + end + + def canceling? + options['cancel_requested'] + end + private def vm_resource