Class: NodeSpec::CommunicationAdapters::SshCommunicator
- Inherits:
-
Object
- Object
- NodeSpec::CommunicationAdapters::SshCommunicator
- Includes:
- RemoteBackend, VerboseOutput
- Defined in:
- lib/nodespec/communication_adapters/ssh_communicator.rb
Instance Attribute Summary collapse
-
#os ⇒ Object
readonly
Returns the value of attribute os.
-
#session ⇒ Object
readonly
Returns the value of attribute session.
Instance Method Summary collapse
- #bind_to(configuration) ⇒ Object
-
#initialize(host, os = nil, options = {}) ⇒ SshCommunicator
constructor
A new instance of SshCommunicator.
Methods included from RemoteBackend
Methods included from VerboseOutput
Constructor Details
#initialize(host, os = nil, options = {}) ⇒ SshCommunicator
Returns a new instance of SshCommunicator.
12 13 14 15 16 17 18 19 20 |
# File 'lib/nodespec/communication_adapters/ssh_communicator.rb', line 12 def initialize(host, os = nil, = {}) @host = host @os = os @ssh_options = Net::SSH.configuration_for(@host) @user = ['user'] || @ssh_options[:user] %w[port password keys].each do |param| @ssh_options[param.to_sym] = [param] if [param] end end |
Instance Attribute Details
#os ⇒ Object (readonly)
Returns the value of attribute os.
10 11 12 |
# File 'lib/nodespec/communication_adapters/ssh_communicator.rb', line 10 def os @os end |
#session ⇒ Object (readonly)
Returns the value of attribute session.
10 11 12 |
# File 'lib/nodespec/communication_adapters/ssh_communicator.rb', line 10 def session @session end |
Instance Method Details
#bind_to(configuration) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/nodespec/communication_adapters/ssh_communicator.rb', line 22 def bind_to(configuration) configuration.winrm = nil if configuration.winrm current_session = configuration.ssh close_ssh_session(current_session) if current_session && (current_session.host != @host || current_session.[:port] != @ssh_options[:port]) if current_session.nil? || current_session.closed? current_session = start_new_ssh_session configuration.host = @host configuration.ssh = current_session end @session = current_session end |