Class: NodeSpec::BackendProxy::Ssh

Inherits:
Base
  • Object
show all
Includes:
UnixshellUtility
Defined in:
lib/nodespec/backend_proxy/ssh.rb

Constant Summary collapse

ROOT_USER =
'root'

Constants included from UnixshellUtility

UnixshellUtility::SUDO_PREFIX, UnixshellUtility::TEMP_DIR

Instance Method Summary collapse

Methods included from UnixshellUtility

#cmd_create_directory, #cmd_create_file, #run_as_sudo, #temp_directory

Methods included from CommandExecution

#execute_within_timeout

Methods included from VerboseOutput

#verbose_puts

Constructor Details

#initialize(ssh) ⇒ Ssh

Returns a new instance of Ssh.



11
12
13
# File 'lib/nodespec/backend_proxy/ssh.rb', line 11

def initialize(ssh)
  @ssh_session = ssh
end

Instance Method Details

#execute(command) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
# File 'lib/nodespec/backend_proxy/ssh.rb', line 15

def execute(command)
  command = run_as_sudo(command) if @ssh_session.options[:user] != ROOT_USER
  execute_within_timeout(command) do
    success = true
    @ssh_session.exec!(command) do |ch, stream, data|
      verbose_puts(data)
      success = stream != :stderr
    end
    success
  end
end