class SmartProxySaltCore::SaltRunner

Constants

DEFAULT_REFRESH_INTERVAL

Attributes

jid[R]

Public Class Methods

new(options, suspended_action:) click to toggle source
Calls superclass method
# 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

Public Instance Methods

kill() click to toggle source
# 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) click to toggle source
Calls superclass method
# 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) click to toggle source
Calls superclass method
# 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() click to toggle source
# 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

Private Instance Methods

generate_command() click to toggle source
# File lib/smart_proxy_salt_core/salt_runner.rb, line 41
def generate_command
  saltfile_path = SmartProxySaltCore.settings[:saltfile]
  command = %w(salt --show-jid)
  command << "--saltfile=#{saltfile_path}" if File.file?(saltfile_path)
  command << @options['name']
  command << 'state.template_str'
  command << @options['script']
  command
end