Class: Kitchen::Transport::Base::Connection
- Inherits:
-
Object
- Object
- Kitchen::Transport::Base::Connection
- Includes:
- Logging
- Defined in:
- lib/kitchen/transport/base.rb
Overview
A Connection instance can be generated and re-generated, given new connection details such as connection port, hostname, credentials, etc. This object is responsible for carrying out the actions on the remote host such as executing commands, transferring files, etc.
Direct Known Subclasses
Instance Method Summary collapse
-
#close ⇒ Object
Closes the session connection, if it is still active.
-
#execute(command) ⇒ Object
Execute a command on the remote host.
-
#initialize(options = {}) {|self| ... } ⇒ Connection
constructor
Create a new Connection instance.
-
#login_command ⇒ LoginCommand
Builds a LoginCommand which can be used to open an interactive session on the remote host.
-
#upload(locals, remote) ⇒ Object
Uploads local files or directories to remote host.
-
#wait_until_ready ⇒ Object
Block and return only when the remote host is prepared and ready to execute command and upload files.
Methods included from Logging
#banner, #debug, #error, #fatal, #info, #warn
Constructor Details
#initialize(options = {}) {|self| ... } ⇒ Connection
Create a new Connection instance.
82 83 84 85 86 87 88 |
# File 'lib/kitchen/transport/base.rb', line 82 def initialize( = {}) () if block_given? yield self end end |
Instance Method Details
#close ⇒ Object
Closes the session connection, if it is still active.
91 92 93 |
# File 'lib/kitchen/transport/base.rb', line 91 def close # this method may be left unimplemented if that is applicable end |
#execute(command) ⇒ Object
Execute a command on the remote host.
100 101 102 |
# File 'lib/kitchen/transport/base.rb', line 100 def execute(command) # rubocop:disable Lint/UnusedMethodArgument raise ClientError, "#{self.class}#execute must be implemented" end |
#login_command ⇒ LoginCommand
Builds a LoginCommand which can be used to open an interactive session on the remote host.
110 111 112 |
# File 'lib/kitchen/transport/base.rb', line 110 def login_command raise ActionFailed, "Remote login not supported in #{self.class}." end |
#upload(locals, remote) ⇒ Object
Uploads local files or directories to remote host.
120 121 122 |
# File 'lib/kitchen/transport/base.rb', line 120 def upload(locals, remote) # rubocop:disable Lint/UnusedMethodArgument raise ClientError, "#{self.class}#upload must be implemented" end |
#wait_until_ready ⇒ Object
Block and return only when the remote host is prepared and ready to execute command and upload files. The semantics and details will vary by implementation, but a round trip through the hosted service is preferred to simply waiting on a socket to become available.
129 130 131 |
# File 'lib/kitchen/transport/base.rb', line 129 def wait_until_ready # this method may be left unimplemented if that is applicable end |