Class: Train::Plugins::Transport::BaseConnection
- Inherits:
-
Object
- Object
- Train::Plugins::Transport::BaseConnection
- Includes:
- Extras
- Defined in:
- lib/train/plugins/base_connection.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.
Instance Method Summary collapse
-
#close ⇒ Object
Closes the session connection, if it is still active.
-
#file(_path, *_args) ⇒ FileCommon
Interact with files on the target.
-
#initialize(options = nil) {|self| ... } ⇒ BaseConnection
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.
-
#os ⇒ OSCommon
Get information on the operating system which this transport connects to.
-
#run_command(_command) ⇒ CommandResult
Execute a command using this connection.
-
#wait_until_ready ⇒ Object
Block and return only when the remote host is prepared and ready to execute command and upload files.
Constructor Details
#initialize(options = nil) {|self| ... } ⇒ BaseConnection
Create a new Connection instance.
25 26 27 28 |
# File 'lib/train/plugins/base_connection.rb', line 25 def initialize( = nil) @options = || {} @logger = @options.delete(:logger) || Logger.new(STDOUT) end |
Instance Method Details
#close ⇒ Object
Closes the session connection, if it is still active.
31 32 33 |
# File 'lib/train/plugins/base_connection.rb', line 31 def close # this method may be left unimplemented if that is applicable end |
#file(_path, *_args) ⇒ FileCommon
Interact with files on the target. Read, write, and get metadata from files via the transport.
55 56 57 |
# File 'lib/train/plugins/base_connection.rb', line 55 def file(_path, *_args) fail Train::ClientError, "#{self.class} does not implement #file(...)" end |
#login_command ⇒ LoginCommand
Builds a LoginCommand which can be used to open an interactive session on the remote host.
63 64 65 |
# File 'lib/train/plugins/base_connection.rb', line 63 def login_command fail Train::ClientError, "#{self.class} does not implement #run_command()" end |
#os ⇒ OSCommon
Get information on the operating system which this transport connects to.
46 47 48 |
# File 'lib/train/plugins/base_connection.rb', line 46 def os fail Train::ClientError, "#{self.class} does not implement #os()" end |
#run_command(_command) ⇒ CommandResult
Execute a command using this connection.
39 40 41 |
# File 'lib/train/plugins/base_connection.rb', line 39 def run_command(_command) fail Train::ClientError, "#{self.class} does not implement #run_command()" 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.
72 73 74 |
# File 'lib/train/plugins/base_connection.rb', line 72 def wait_until_ready # this method may be left unimplemented if that is applicablelog end |