Class: Proxy::Salt::SaltRunner
- Inherits:
-
Dynflow::Runner::CommandRunner
- Object
- Dynflow::Runner::CommandRunner
- Proxy::Salt::SaltRunner
- Defined in:
- lib/smart_proxy_salt/salt_runner.rb
Overview
Implements the SaltRunner to be used by foreman_remote_execution
Constant Summary collapse
- DEFAULT_REFRESH_INTERVAL =
1
Instance Attribute Summary collapse
-
#jid ⇒ Object
readonly
Returns the value of attribute jid.
Instance Method Summary collapse
-
#initialize(options, suspended_action) ⇒ SaltRunner
constructor
A new instance of SaltRunner.
- #kill ⇒ Object
- #publish_data(data, type) ⇒ Object
- #publish_exit_status(status) ⇒ Object
- #start ⇒ Object
Constructor Details
#initialize(options, suspended_action) ⇒ SaltRunner
Returns a new instance of SaltRunner.
14 15 16 17 |
# File 'lib/smart_proxy_salt/salt_runner.rb', line 14 def initialize(, suspended_action) super(, :suspended_action => suspended_action) @options = end |
Instance Attribute Details
#jid ⇒ Object (readonly)
Returns the value of attribute jid.
12 13 14 |
# File 'lib/smart_proxy_salt/salt_runner.rb', line 12 def jid @jid end |
Instance Method Details
#kill ⇒ Object
25 26 27 28 29 |
# File 'lib/smart_proxy_salt/salt_runner.rb', line 25 def kill publish_data('== TASK ABORTED BY USER ==', 'stdout') publish_exit_status(1) ::Process.kill('SIGTERM', @command_pid) end |
#publish_data(data, type) ⇒ Object
31 32 33 34 35 36 |
# File 'lib/smart_proxy_salt/salt_runner.rb', line 31 def publish_data(data, type) if @jid.nil? && (match = data.match(/jid: ([0-9]+)/)) @jid = match[1] end super end |
#publish_exit_status(status) ⇒ Object
38 39 40 41 42 |
# File 'lib/smart_proxy_salt/salt_runner.rb', line 38 def publish_exit_status(status) # If there was no salt job associated with this run, mark the job as failed status = 1 if @jid.nil? super status end |
#start ⇒ Object
19 20 21 22 23 |
# File 'lib/smart_proxy_salt/salt_runner.rb', line 19 def start command = generate_command logger.debug("Running command '#{command.join(' ')}'") initialize_command(*command) end |