Class: Kitchen::Driver::SSHBase
- 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
Instance Attribute Summary
Attributes included from Configurable
Instance Method Summary collapse
-
#converge(state) ⇒ Object
Converges a running instance.
-
#create(state) ⇒ Object
Creates an instance.
-
#destroy(state) ⇒ Object
Destroys an instance.
-
#login_command(state) ⇒ LoginCommand
Returns the shell command that will log into an instance.
-
#remote_command(state, command) ⇒ Object
Executes an arbitrary command on an instance over an SSH connection.
-
#setup(state) ⇒ Object
Sets up an instance.
-
#ssh(ssh_args, command) ⇒ Object
deprecated
Deprecated.
This method should no longer be called directly and exists to support very old drivers. This will be removed in the future.
-
#verify(state) ⇒ Object
Verifies a converged instance.
Methods inherited from Base
#initialize, #name, no_parallel_for, #verify_dependencies
Methods included from Logging
#banner, #debug, #error, #fatal, #info, #warn
Methods included from Configurable
#[], #calculate_path, #config_keys, #diagnose, #finalize_config!, included
Methods included from ShellOut
Constructor Details
This class inherits a constructor from Kitchen::Driver::Base
Instance Method Details
#converge(state) ⇒ Object
Converges a running instance.
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/kitchen/driver/ssh_base.rb', line 40 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
Creates an instance.
35 36 37 |
# File 'lib/kitchen/driver/ssh_base.rb', line 35 def create(state) # rubocop:disable Lint/UnusedMethodArgument raise ClientError, "#{self.class}#create must be implemented" end |
#destroy(state) ⇒ Object
Destroys an instance.
72 73 74 |
# File 'lib/kitchen/driver/ssh_base.rb', line 72 def destroy(state) # rubocop:disable Lint/UnusedMethodArgument raise ClientError, "#{self.class}#destroy must be implemented" end |
#login_command(state) ⇒ LoginCommand
Returns the shell command that will log into an instance.
77 78 79 |
# File 'lib/kitchen/driver/ssh_base.rb', line 77 def login_command(state) SSH.new(*build_ssh_args(state)).login_command end |
#remote_command(state, command) ⇒ Object
Executes an arbitrary command on an instance over an SSH connection.
86 87 88 89 90 |
# File 'lib/kitchen/driver/ssh_base.rb', line 86 def remote_command(state, command) Kitchen::SSH.new(*build_ssh_args(state)) do |conn| run_remote(command, conn) end end |
#setup(state) ⇒ Object
Sets up an instance.
57 58 59 60 61 |
# File 'lib/kitchen/driver/ssh_base.rb', line 57 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
This method should no longer be called directly and exists to support very old drivers. This will be removed in the future.
(Deprecated) Executes a remote command over SSH.
98 99 100 101 102 |
# File 'lib/kitchen/driver/ssh_base.rb', line 98 def ssh(ssh_args, command) Kitchen::SSH.new(*ssh_args) do |conn| run_remote(command, conn) end end |
#verify(state) ⇒ Object
Verifies a converged instance.
64 65 66 67 68 69 |
# File 'lib/kitchen/driver/ssh_base.rb', line 64 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 |