Class: SmartProxySaltCore::SaltRunner
- Inherits:
-
ForemanTasksCore::Runner::CommandRunner
- Object
- ForemanTasksCore::Runner::CommandRunner
- SmartProxySaltCore::SaltRunner
- Defined in:
- lib/smart_proxy_salt_core/salt_runner.rb
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.
9 10 11 12 |
# File 'lib/smart_proxy_salt_core/salt_runner.rb', line 9 def initialize(, suspended_action:) super(, :suspended_action => suspended_action) = end |
Instance Attribute Details
#jid ⇒ Object (readonly)
Returns the value of attribute jid.
7 8 9 |
# File 'lib/smart_proxy_salt_core/salt_runner.rb', line 7 def jid @jid end |
Instance Method Details
#kill ⇒ Object
20 21 22 23 24 |
# File 'lib/smart_proxy_salt_core/salt_runner.rb', line 20 def kill publish_data('== TASK ABORTED BY USER ==', 'stdout') publish_exit_status(1) ::Process.kill('SIGTERM', @command_pid) end |
#publish_data(data, type) ⇒ Object
26 27 28 29 30 31 |
# File 'lib/smart_proxy_salt_core/salt_runner.rb', line 26 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
33 34 35 36 37 |
# File 'lib/smart_proxy_salt_core/salt_runner.rb', line 33 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
14 15 16 17 18 |
# File 'lib/smart_proxy_salt_core/salt_runner.rb', line 14 def start command = generate_command logger.debug("Running command '#{command.join(' ')}'") initialize_command(*command) end |