Class: VagrantWindows::Communication::WinRMFinder
- Inherits:
-
Object
- Object
- VagrantWindows::Communication::WinRMFinder
- Defined in:
- lib/vagrant-windows/communication/winrmfinder.rb
Instance Attribute Summary collapse
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
-
#machine ⇒ Object
readonly
Returns the value of attribute machine.
Instance Method Summary collapse
-
#initialize(machine) ⇒ WinRMFinder
constructor
A new instance of WinRMFinder.
- #winrm_host_address ⇒ Object
- #winrm_host_port ⇒ Object
Constructor Details
#initialize(machine) ⇒ WinRMFinder
Returns a new instance of WinRMFinder.
11 12 13 14 |
# File 'lib/vagrant-windows/communication/winrmfinder.rb', line 11 def initialize(machine) @machine = machine @logger = Log4r::Logger.new("vagrant_windows::communication::winrmfinder") end |
Instance Attribute Details
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
8 9 10 |
# File 'lib/vagrant-windows/communication/winrmfinder.rb', line 8 def logger @logger end |
#machine ⇒ Object (readonly)
Returns the value of attribute machine.
9 10 11 |
# File 'lib/vagrant-windows/communication/winrmfinder.rb', line 9 def machine @machine end |
Instance Method Details
#winrm_host_address ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/vagrant-windows/communication/winrmfinder.rb', line 16 def winrm_host_address # Get the SSH info for the machine, raise an exception if the # provider is saying that the machine is not ready. ssh_info = @machine.ssh_info raise VagrantWindows::Errors::WinRMNotReady if ssh_info.nil? # if the configuration has a host value, that takes precedence host = @machine.config.winrm.host || ssh_info[:host] @logger.info("WinRM host: #{host}") host end |
#winrm_host_port ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/vagrant-windows/communication/winrmfinder.rb', line 28 def winrm_host_port expected_guest_port = @machine.config.winrm.guest_port @logger.debug("Searching for WinRM port: #{expected_guest_port.inspect}") # Look for the forwarded port only by comparing the guest port begin @machine.provider.driver.read_forwarded_ports.each do |_, _, hostport, guestport| return hostport if guestport == expected_guest_port end rescue NoMethodError => e # VMWare provider doesn't support read_forwarded_ports @logger.debug(e.) end # We tried, give up and use the configured port as-is @machine.config.winrm.port end |