class Blender::Driver::Ssh

Attributes

user[R]

Public Class Methods

new(config = {}) click to toggle source
Calls superclass method Blender::Driver::Base::new
# File lib/blender/drivers/ssh.rb, line 29
def initialize(config = {})
  cfg = config.dup
  @user = cfg.delete(:user) || ENV['USER']
  super(cfg)
end

Public Instance Methods

execute(tasks, hosts) click to toggle source
# File lib/blender/drivers/ssh.rb, line 35
def execute(tasks, hosts)
  Log.debug("SSH execution tasks [#{Array(tasks).size}]")
  Log.debug("SSH on hosts [#{hosts.join(",")}]")
  Array(hosts).each do |host|
    session = create_session(host)
    Array(tasks).each do |task|
      cmd = run_command(task.command, session)
      if cmd.exitstatus != 0 and !task.metadata[:ignore_failure]
        raise ExecutionFailed, cmd.stderr
      end
    end
    session.loop
  end
end
run_command(command, session) click to toggle source
# File lib/blender/drivers/ssh.rb, line 50
def run_command(command, session)
  exit_status = remote_exec(command, session)
  ExecOutput.new(exit_status, stdout, stderr)
end

Private Instance Methods

create_session(host) click to toggle source
# File lib/blender/drivers/ssh.rb, line 57
def create_session(host)
  Log.debug("Invoking ssh: #{user}@#{host}")
  Net::SSH.start(host, user, config)
end