-
Notifications
You must be signed in to change notification settings - Fork 897
/
Copy pathautomation_task.rb
39 lines (32 loc) · 1.15 KB
/
automation_task.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
class AutomationTask < MiqRequestTask
alias_attribute :automation_request, :miq_request
has_one :container_deployment
AUTOMATE_DRIVES = false
def self.get_description(_request_obj)
"Automation Task"
end
def self.base_model
AutomationTask
end
def do_request
args = {}
args[:object_type] = self.class.name
args[:object_id] = id
args[:attrs] = options[:attrs]
args[:namespace] = options[:namespace]
args[:class_name] = options[:class_name]
args[:instance_name] = options[:instance_name]
args[:user_id] = options[:user_id]
args[:automate_message] = options[:message]
MiqAeEngine.deliver(args)
end
def after_ae_delivery(ae_result)
_log.info("ae_result=#{ae_result.inspect}")
return if ae_result == 'retry' || miq_request.state == 'finished'
if ae_result == 'ok'
update_and_notify_parent(:state => "finished", :status => "Ok", :message => "#{request_class::TASK_DESCRIPTION} completed")
else
update_and_notify_parent(:state => "finished", :status => "Error", :message => "#{request_class::TASK_DESCRIPTION} failed")
end
end
end