Skip to content

Commit

Permalink
Merge pull request #19281 from agrare/add_job_queue_signal
Browse files Browse the repository at this point in the history
Add a base Job#queue_signal method
  • Loading branch information
chessbyte authored Oct 22, 2019
2 parents 2aa26d6 + d7a4804 commit b5c6cd2
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 43 deletions.
12 changes: 1 addition & 11 deletions app/models/infra_conversion_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -239,17 +239,7 @@ def polling_timeout
end

def queue_signal(*args, deliver_on: nil)
MiqQueue.put(
:class_name => self.class.name,
:method_name => "signal",
:instance_id => id,
:role => "ems_operations",
:zone => zone,
:task_id => guid,
:args => args,
:deliver_on => deliver_on,
:server_guid => MiqServer.my_server.guid
)
super(*args, :role => "ems_operations", :deliver_on => deliver_on, :server_guid => MiqServer.my_server.guid)
end

def prep_message(contents)
Expand Down
15 changes: 15 additions & 0 deletions app/models/job/state_machine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,19 @@ def signal(signal, *args)
raise _("%{signal} is not permitted at state %{state}") % {:signal => signal, :state => state}
end
end

def queue_signal(*args, priority: MiqQueue::NORMAL_PRIORITY, role: nil, deliver_on: nil, server_guid: nil)
MiqQueue.put(
:class_name => self.class.name,
:method_name => "signal",
:instance_id => id,
:priority => priority,
:role => role,
:zone => zone,
:task_id => guid,
:args => args,
:deliver_on => deliver_on,
:server_guid => server_guid
)
end
end
13 changes: 1 addition & 12 deletions app/models/manageiq/providers/ansible_runner_workflow.rb
Original file line number Diff line number Diff line change
Expand Up @@ -95,18 +95,7 @@ def queue_signal(*args, deliver_on: nil)
role = options[:role] || "ems_operations"
priority = options[:priority] || MiqQueue::NORMAL_PRIORITY

MiqQueue.put(
:class_name => self.class.name,
:method_name => "signal",
:instance_id => id,
:priority => priority,
:role => role,
:zone => zone,
:task_id => guid,
:args => args,
:deliver_on => deliver_on,
:server_guid => MiqServer.my_server.guid
)
super(*args, :priority => priority, :role => role, :deliver_on => deliver_on, :server_guid => MiqServer.my_server.guid)
end

def deliver_on
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,15 +153,7 @@ def my_signal(no_queue, action, *args, deliver_on: nil)
def queue_signal(*args, deliver_on: nil)
priority = options[:priority] || MiqQueue::NORMAL_PRIORITY

MiqQueue.put(
:class_name => self.class.name,
:method_name => "signal",
:instance_id => id,
:priority => priority,
:role => 'embedded_ansible',
:args => args,
:deliver_on => deliver_on
)
super(*args, :priority => priority, :role => "embedded_ansible", :deliver_on => deliver_on)
end

def temp_configuration_script
Expand Down
12 changes: 1 addition & 11 deletions app/models/manageiq/providers/ems_refresh_workflow.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,17 +58,7 @@ def queue_signal(*args, deliver_on: nil)
role = options[:role] || "ems_operations"
priority = options[:priority] || MiqQueue::NORMAL_PRIORITY

MiqQueue.put(
:class_name => self.class.name,
:method_name => "signal",
:instance_id => id,
:priority => priority,
:role => role,
:zone => zone,
:task_id => guid,
:args => args,
:deliver_on => deliver_on
)
super(*args, :role => role, :priority => priority, :deliver_on => deliver_on)
end

alias_method :initializing, :dispatch_start
Expand Down

0 comments on commit b5c6cd2

Please sign in to comment.