Class: SmartProxySaltCore::SaltRunner

Inherits:
ForemanTasksCore::Runner::CommandRunner
  • Object
show all
Defined in:
lib/smart_proxy_salt_core/salt_runner.rb

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.



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

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.



7
8
9
# File 'lib/smart_proxy_salt_core/salt_runner.rb', line 7

def jid
  @jid
end

Instance Method Details

#killObject



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

#startObject



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