Class: Proxy::Salt::SaltRunner

Inherits:
Dynflow::Runner::CommandRunner
  • Object
show all
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

Instance Method Summary collapse

Constructor Details

#initialize(options, suspended_action) ⇒ SaltRunner

Returns a new instance of SaltRunner.



12
13
14
15
# File 'lib/smart_proxy_salt/salt_runner.rb', line 12

def initialize(options, suspended_action)
  super(options, :suspended_action => suspended_action)
  @options = options
end

Instance Attribute Details

#jidObject (readonly)

Returns the value of attribute jid.



10
11
12
# File 'lib/smart_proxy_salt/salt_runner.rb', line 10

def jid
  @jid
end

Instance Method Details

#killObject



23
24
25
26
27
# File 'lib/smart_proxy_salt/salt_runner.rb', line 23

def kill
  publish_data('== TASK ABORTED BY USER ==', 'stdout')
  publish_exit_status(1)
  ::Process.kill('SIGTERM', @command_pid)
end

#publish_data(data, type) ⇒ Object



29
30
31
32
33
34
# File 'lib/smart_proxy_salt/salt_runner.rb', line 29

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



36
37
38
39
40
# File 'lib/smart_proxy_salt/salt_runner.rb', line 36

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

#startObject



17
18
19
20
21
# File 'lib/smart_proxy_salt/salt_runner.rb', line 17

def start
  command = generate_command
  logger.debug("Running command '#{command.join(' ')}'")
  initialize_command(*command)
end