Class: NodeSpec::CommunicationAdapters::SshCommunicator
- Inherits:
-
Object
- Object
- NodeSpec::CommunicationAdapters::SshCommunicator
- Includes:
- VerboseOutput
- Defined in:
- lib/nodespec/communication_adapters/ssh_communicator.rb
Instance Attribute Summary collapse
-
#session ⇒ Object
readonly
Returns the value of attribute session.
Instance Method Summary collapse
- #backend ⇒ Object
- #backend_proxy ⇒ Object
- #init_session(configuration) ⇒ Object
-
#initialize(host, options = {}) ⇒ SshCommunicator
constructor
A new instance of SshCommunicator.
Methods included from VerboseOutput
Constructor Details
#initialize(host, options = {}) ⇒ SshCommunicator
Returns a new instance of SshCommunicator.
11 12 13 14 15 16 17 18 |
# File 'lib/nodespec/communication_adapters/ssh_communicator.rb', line 11 def initialize(host, = {}) @host = host @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
#session ⇒ Object (readonly)
Returns the value of attribute session.
9 10 11 |
# File 'lib/nodespec/communication_adapters/ssh_communicator.rb', line 9 def session @session end |
Instance Method Details
#backend ⇒ Object
36 37 38 |
# File 'lib/nodespec/communication_adapters/ssh_communicator.rb', line 36 def backend :ssh end |
#backend_proxy ⇒ Object
32 33 34 |
# File 'lib/nodespec/communication_adapters/ssh_communicator.rb', line 32 def backend_proxy BackendProxy.create(:ssh, @session) end |
#init_session(configuration) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/nodespec/communication_adapters/ssh_communicator.rb', line 20 def init_session(configuration) configuration.unbind_winrm_session @session = configuration.bind_ssh_session_for({host: @host, port: @ssh_options[:port]}) do msg = "\nConnecting to #{@host}" msg << ":#{@ssh_options[:port]}" if @ssh_options[:port] msg << " as #{@user}..." verbose_puts msg Net::SSH.start(@host, @user, @ssh_options) end end |