Class: Chimp::ExecSSH

Inherits:
Executor show all
Defined in:
lib/right_chimp/exec/exec_ssh.rb

Constant Summary

Constants inherited from Executor

Chimp::Executor::STATUS_DONE, Chimp::Executor::STATUS_ERROR, Chimp::Executor::STATUS_HOLDING, Chimp::Executor::STATUS_NONE, Chimp::Executor::STATUS_RETRYING, Chimp::Executor::STATUS_RUNNING

Instance Attribute Summary collapse

Attributes inherited from Executor

#array, #concurrency, #delay, #dry_run, #error, #exec, #group, #inputs, #job_id, #job_notes, #job_uuid, #owner, #quiet, #results, #retry_count, #retry_sleep, #server, #status, #template, #time_end, #time_start, #timeout, #verbose

Instance Method Summary collapse

Methods inherited from Executor

#cancel, #get_total_exec_time, #queue, #requeue

Constructor Details

#initialize(h = {}) ⇒ ExecSSH

Returns a new instance of ExecSSH.



8
9
10
11
# File 'lib/right_chimp/exec/exec_ssh.rb', line 8

def initialize(h={})
  super(h)
  @ssh_user = h[:ssh_user]
end

Instance Attribute Details

#ssh_userObject

Returns the value of attribute ssh_user.



6
7
8
# File 'lib/right_chimp/exec/exec_ssh.rb', line 6

def ssh_user
  @ssh_user
end

Instance Method Details

#describe_workObject



27
28
29
# File 'lib/right_chimp/exec/exec_ssh.rb', line 27

def describe_work
  return "ExecSSH job_id=#{@job_id} command=\"#{@exec}\" server=\"#{@server.nickname}\""
end

#infoObject



31
32
33
# File 'lib/right_chimp/exec/exec_ssh.rb', line 31

def info
  return @exec.to_s
end

#runObject



13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/right_chimp/exec/exec_ssh.rb', line 13

def run
  host = @server.ip_address || nil
  @ssh_user ||= "root"

  run_with_retry do
    Log.debug "ssh #{@ssh_user}@#{host} \"#{@exec}\""
    success = system("ssh -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no #{@ssh_user}@#{host} \"#{@exec}\"")
    
    if not $?.success?
      raise "SSH failed with status: #{$?}"
    end
  end
end

#targetObject



35
36
37
# File 'lib/right_chimp/exec/exec_ssh.rb', line 35

def target
  return @server.nickname
end