diff --git a/lib/vulcano/backend/ssh.rb b/lib/vulcano/backend/ssh.rb index 9c8371873..b4a1ea980 100644 --- a/lib/vulcano/backend/ssh.rb +++ b/lib/vulcano/backend/ssh.rb @@ -4,12 +4,14 @@ module Vulcano::Backends class SSH < Vulcano.backend(1) name 'ssh' + attr_reader :os def initialize(conf) @conf = conf @files = {} @conf['host'] || fail('You must specify a SSH host.') @ssh = start_ssh + @os = OS.new(self) end def file(path) @@ -22,9 +24,6 @@ module Vulcano::Backends cmd.force_encoding('binary') if cmd.respond_to?(:force_encoding) @ssh.open_channel do |channel| - channel.request_pty do |_, success| - abort 'Could not obtain pty on SSH channel ' if !success - end channel.exec(cmd) do |_, success| unless success abort 'Couldn\'t execute command on SSH.' @@ -84,6 +83,10 @@ module Vulcano::Backends user_known_hosts_file: '/dev/null', global_known_hosts_file: '/dev/null', number_of_password_prompts: 0, + keepalive: true, + keepalive_interval: 60, + compression: true, + compression_level: 6, password: @conf['password'] || ssh_config[:password], keys: keys, } @@ -91,5 +94,12 @@ module Vulcano::Backends validate_options(options) Net::SSH.start(host, user, options) end + + class OS < OSCommon + def initialize(backend) + super(backend, { family: 'unix' }) + end + end + end end diff --git a/test/runner/test_ssh.rb b/test/runner/test_ssh.rb index a0f721859..9c7b0a683 100644 --- a/test/runner/test_ssh.rb +++ b/test/runner/test_ssh.rb @@ -3,16 +3,21 @@ require_relative 'helper' require 'vulcano/backend' backends = {} +backend_conf = Vulcano::Backend.target_config({ + 'target' => 'ssh://vagrant@localhost', + 'key_file' => '/root/.ssh/id_rsa', +}) backends[:specinfra_ssh] = proc { - backend_conf = Vulcano::Backend.target_config({ - 'target' => 'ssh://vagrant@localhost', - 'key_file' => '/root/.ssh/id_rsa', - }) backend_class = Vulcano::Backend.registry['specinfra'] backend_class.new(backend_conf) } +backends[:ssh] = proc { + backend_class = Vulcano::Backend.registry['ssh'] + backend_class.new(backend_conf) +} + tests = ARGV backends.each do |type, get_backend|