Class: Bolt::Transport::WinRM

Inherits:
Simple show all
Defined in:
lib/bolt/transport/winrm.rb,
lib/bolt/transport/winrm/connection.rb

Defined Under Namespace

Classes: Connection

Instance Attribute Summary

Attributes inherited from Base

#logger

Instance Method Summary collapse

Methods inherited from Simple

#connected?, #download, #run_command, #run_script, #run_task, #upload

Methods inherited from Base

#assert_batch_size_one, #batch_command, #batch_connected?, #batch_download, #batch_script, #batch_task, #batch_task_with, #batch_upload, #batches, #connected?, #default_input_method, #download, #provided_features, #run_command, #run_script, #run_task, #select_implementation, #select_interpreter, #unwrap_sensitive_args, #upload, #with_events

Constructor Details

#initializeWinRM

Returns a new instance of WinRM.


9
10
11
12
13
14
15
16
# File 'lib/bolt/transport/winrm.rb', line 9

def initialize
  super
  require 'winrm'
  require 'winrm-fs'

  @transport_logger = Bolt::Logger.logger(::WinRM)
  @transport_logger.level = :warn
end

Instance Method Details

#with_connection(target) ⇒ Object


18
19
20
21
22
23
24
25
26
27
28
# File 'lib/bolt/transport/winrm.rb', line 18

def with_connection(target)
  conn = Connection.new(target, @transport_logger)
  conn.connect
  yield conn
ensure
  begin
    conn&.disconnect
  rescue StandardError => e
    logger.info("Failed to close connection to #{target.safe_name} : #{e.message}")
  end
end