Class: VagrantPlugins::VagrantHyperV::Communicator::PowerShell

Inherits:
Object
  • Object
show all
Defined in:
lib/vagrant-windows-hyperv/communication/powershell.rb

Instance Method Summary collapse

Constructor Details

#initialize(machine) ⇒ PowerShell

Returns a new instance of PowerShell.



10
11
12
# File 'lib/vagrant-windows-hyperv/communication/powershell.rb', line 10

def initialize(machine)
  @machine = machine
end

Instance Method Details

#ready?Boolean

Returns:

  • (Boolean)


18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/vagrant-windows-hyperv/communication/powershell.rb', line 18

def ready?
  # Return True when the guest has enabled WinRM
  # In this case we can try any remote PowerShell commands to see if
  # further vagrant can be carried out using this communication
  if !@winrm_status
    @winrm_status = false
    response = @machine.provider.driver.check_winrm
    message = nil
    if response && response["message"]
      message = response["message"]
      @winrm_status = message == "Running"
    end
    raise Errors::WinRMNotReady, message: message if !@winrm_status
  end
  @winrm_status
end

#test(command, opts = nil) ⇒ Object



35
36
37
# File 'lib/vagrant-windows-hyperv/communication/powershell.rb', line 35

def test(command, opts=nil)
  true
end

#wait_for_ready(timeout) ⇒ Object



14
15
16
# File 'lib/vagrant-windows-hyperv/communication/powershell.rb', line 14

def wait_for_ready(timeout)
  ready?
end