Class: NodeSpec::CommunicationAdapters::WinrmCommunicator
- Inherits:
-
Object
- Object
- NodeSpec::CommunicationAdapters::WinrmCommunicator
- Includes:
- RemoteBackend, VerboseOutput
- Defined in:
- lib/nodespec/communication_adapters/winrm_communicator.rb
Constant Summary collapse
- DEFAULT_PORT =
5985- DEFAULT_TRANSPORT =
:plaintext- DEFAULT_TRANSPORT_OPTIONS =
{disable_sspi: true}
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(hostname, os = nil, options = {}) ⇒ WinrmCommunicator
constructor
A new instance of WinrmCommunicator.
Methods included from VerboseOutput
Methods included from RemoteBackend
Constructor Details
#initialize(hostname, os = nil, options = {}) ⇒ WinrmCommunicator
Returns a new instance of WinrmCommunicator.
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/nodespec/communication_adapters/winrm_communicator.rb', line 16 def initialize(hostname, os = nil, = {}) @os = os @hostname = hostname opts = .dup port = opts.delete('port') || DEFAULT_PORT @endpoint = "http://#{hostname}:#{port}/wsman" if opts.has_key?('transport') @transport = opts.delete('transport').to_sym @options = opts else @transport = DEFAULT_TRANSPORT @options = DEFAULT_TRANSPORT_OPTIONS.merge(opts) end @options = @options.inject({}) {|h,(k,v)| h[k.to_sym] = v; h} end |
Instance Attribute Details
#os ⇒ Object (readonly)
Returns the value of attribute os.
14 15 16 |
# File 'lib/nodespec/communication_adapters/winrm_communicator.rb', line 14 def os @os end |
#session ⇒ Object (readonly)
Returns the value of attribute session.
14 15 16 |
# File 'lib/nodespec/communication_adapters/winrm_communicator.rb', line 14 def session @session end |
Instance Method Details
#bind_to(configuration) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/nodespec/communication_adapters/winrm_communicator.rb', line 33 def bind_to(configuration) if configuration.ssh close_ssh_session(configuration.ssh) configuration.ssh = nil end current_session = configuration.winrm if current_session.nil? || current_session.endpoint != @endpoint current_session = start_winrm_session configuration.winrm = current_session configuration.host = @hostname end @session = current_session end |