Class: Blender::Driver::Ssh
- Includes:
- SSHExec
- Defined in:
- lib/blender/drivers/ssh.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#user ⇒ Object
readonly
Returns the value of attribute user.
Attributes inherited from Base
#config, #events, #stderr, #stdout
Instance Method Summary collapse
- #execute(tasks, hosts) ⇒ Object
-
#initialize(config = {}) ⇒ Ssh
constructor
A new instance of Ssh.
- #run_command(command, session) ⇒ Object
Methods included from SSHExec
Constructor Details
#initialize(config = {}) ⇒ Ssh
Returns a new instance of Ssh.
29 30 31 32 33 |
# File 'lib/blender/drivers/ssh.rb', line 29 def initialize(config = {}) cfg = config.dup @user = cfg.delete(:user) || ENV['USER'] super(cfg) end |
Instance Attribute Details
#user ⇒ Object (readonly)
Returns the value of attribute user.
26 27 28 |
# File 'lib/blender/drivers/ssh.rb', line 26 def user @user end |
Instance Method Details
#execute(tasks, hosts) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# 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.[:ignore_failure] raise ExecutionFailed, cmd.stderr end end session.loop end end |
#run_command(command, session) ⇒ Object
50 51 52 53 |
# 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 |