Class: Kitchen::Driver::SSHBase

Inherits:
Base
  • Object
show all
Defined in:
lib/kitchen/driver/ssh_base.rb

Overview

Base class for a driver that uses SSH to communication with an instance. A subclass must implement the following methods:

  • #create(state)
  • #destroy(state)

Direct Known Subclasses

Proxy

Instance Attribute Summary

Attributes inherited from Base

#instance

Instance Method Summary collapse

Methods inherited from Base

#[], #config_keys, #diagnose, #initialize, #name, #validate_config!, #verify_dependencies

Methods included from ShellOut

#run_command

Constructor Details

This class inherits a constructor from Kitchen::Driver::Base

Instance Method Details

#converge(state) ⇒ Object



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/kitchen/driver/ssh_base.rb', line 38

def converge(state)
  provisioner = instance.provisioner
  provisioner.create_sandbox
  sandbox_dirs = Dir.glob("#{provisioner.sandbox_path}/*")

  Kitchen::SSH.new(*build_ssh_args(state)) do |conn|
    run_remote(provisioner.install_command, conn)
    run_remote(provisioner.init_command, conn)
    transfer_path(sandbox_dirs, provisioner[:root_path], conn)
    run_remote(provisioner.prepare_command, conn)
    run_remote(provisioner.run_command, conn)
  end
ensure
  provisioner && provisioner.cleanup_sandbox
end

#create(state) ⇒ Object

Raises:



34
35
36
# File 'lib/kitchen/driver/ssh_base.rb', line 34

def create(state)
  raise ClientError, "#{self.class}#create must be implemented"
end

#destroy(state) ⇒ Object

Raises:



67
68
69
# File 'lib/kitchen/driver/ssh_base.rb', line 67

def destroy(state)
  raise ClientError, "#{self.class}#destroy must be implemented"
end

#login_command(state) ⇒ Object



71
72
73
# File 'lib/kitchen/driver/ssh_base.rb', line 71

def (state)
  SSH.new(*build_ssh_args(state)).
end

#setup(state) ⇒ Object



54
55
56
57
58
# File 'lib/kitchen/driver/ssh_base.rb', line 54

def setup(state)
  Kitchen::SSH.new(*build_ssh_args(state)) do |conn|
    run_remote(busser_setup_cmd, conn)
  end
end

#ssh(ssh_args, command) ⇒ Object



75
76
77
78
79
# File 'lib/kitchen/driver/ssh_base.rb', line 75

def ssh(ssh_args, command)
  Kitchen::SSH.new(*ssh_args) do |conn|
    run_remote(command, conn)
  end
end

#verify(state) ⇒ Object



60
61
62
63
64
65
# File 'lib/kitchen/driver/ssh_base.rb', line 60

def verify(state)
  Kitchen::SSH.new(*build_ssh_args(state)) do |conn|
    run_remote(busser_sync_cmd, conn)
    run_remote(busser_run_cmd, conn)
  end
end