Class: VagrantWindows::WindowsMachine
- Inherits:
-
Object
- Object
- VagrantWindows::WindowsMachine
- Defined in:
- lib/vagrant-windows/windows_machine.rb
Overview
Provides a wrapper around the Vagrant machine object
Instance Attribute Summary collapse
-
#machine ⇒ Object
readonly
Returns the value of attribute machine.
Class Method Summary collapse
-
.is_windows?(machine) ⇒ Boolean
Returns true if the specifed Vagrant machine is a Windows guest, otherwise false.
Instance Method Summary collapse
-
#initialize(machine) ⇒ WindowsMachine
constructor
A new instance of WindowsMachine.
-
#is_parallels? ⇒ Boolean
Checks to see if the machine is using Parallels Desktop.
-
#is_rebooting? ⇒ Boolean
Checks to see if the machine is rebooting or has a scheduled reboot.
-
#is_virtualbox? ⇒ Boolean
Checks to see if the machine is using Oracle VirtualBox.
-
#is_vmware? ⇒ Boolean
Checks to see if the machine is using VMWare Fusion or Workstation.
-
#is_windows? ⇒ Boolean
Returns true if this Vagrant machine is a Windows guest, otherwise false.
-
#read_forwarded_ports ⇒ Array<Array>
Returns a list of forwarded ports for a VM.
-
#read_mac_addresses ⇒ Hash
Reads the machine’s MAC addresses keyed by interface index.
-
#reinitialize_network_shares ⇒ Object
Re-establishes our symbolic links if they were created between now and a reboot Fixes issue #119.
-
#ssh_info ⇒ Hash
Returns the SSH config for this machine.
- #windows_config ⇒ Object
- #winrm_config ⇒ Object
-
#winrmshell ⇒ WinRMShell
Returns the active WinRMShell for the guest.
Constructor Details
#initialize(machine) ⇒ WindowsMachine
Returns a new instance of WindowsMachine.
17 18 19 20 |
# File 'lib/vagrant-windows/windows_machine.rb', line 17 def initialize(machine) @machine = machine @logger = Log4r::Logger.new("vagrant_windows::windows_machine") end |
Instance Attribute Details
#machine ⇒ Object (readonly)
Returns the value of attribute machine.
6 7 8 |
# File 'lib/vagrant-windows/windows_machine.rb', line 6 def machine @machine end |
Class Method Details
.is_windows?(machine) ⇒ Boolean
Returns true if the specifed Vagrant machine is a Windows guest, otherwise false.
12 13 14 |
# File 'lib/vagrant-windows/windows_machine.rb', line 12 def self.is_windows?(machine) machine.config.vm.guest.eql? :windows end |
Instance Method Details
#is_parallels? ⇒ Boolean
Checks to see if the machine is using Parallels Desktop.
39 40 41 |
# File 'lib/vagrant-windows/windows_machine.rb', line 39 def is_parallels?() @machine.provider_name.to_s().start_with?('parallels') end |
#is_rebooting? ⇒ Boolean
Checks to see if the machine is rebooting or has a scheduled reboot.
53 54 55 56 |
# File 'lib/vagrant-windows/windows_machine.rb', line 53 def is_rebooting?() reboot_detect_script = VagrantWindows.load_script('reboot_detect.ps1') @machine.communicate.execute(reboot_detect_script, :error_check => false) != 0 end |
#is_virtualbox? ⇒ Boolean
Checks to see if the machine is using Oracle VirtualBox.
46 47 48 |
# File 'lib/vagrant-windows/windows_machine.rb', line 46 def is_virtualbox?() @machine.provider_name.to_s().start_with?('virtualbox') end |
#is_vmware? ⇒ Boolean
Checks to see if the machine is using VMWare Fusion or Workstation.
32 33 34 |
# File 'lib/vagrant-windows/windows_machine.rb', line 32 def is_vmware?() @machine.provider_name.to_s().start_with?('vmware') end |
#is_windows? ⇒ Boolean
Returns true if this Vagrant machine is a Windows guest, otherwise false.
25 26 27 |
# File 'lib/vagrant-windows/windows_machine.rb', line 25 def is_windows?() WindowsMachine.is_windows?(@machine) end |
#read_forwarded_ports ⇒ Array<Array>
Returns a list of forwarded ports for a VM. NOTE: Only the VBox provider currently supports this method
83 84 85 86 87 88 89 |
# File 'lib/vagrant-windows/windows_machine.rb', line 83 def read_forwarded_ports() if is_virtualbox?() @machine.provider.driver.read_forwarded_ports else [] end end |
#read_mac_addresses ⇒ Hash
Reads the machine’s MAC addresses keyed by interface index. 2=>“08002757E68A”
75 76 77 |
# File 'lib/vagrant-windows/windows_machine.rb', line 75 def read_mac_addresses() @machine.provider.driver.read_mac_addresses end |
#reinitialize_network_shares ⇒ Object
Re-establishes our symbolic links if they were created between now and a reboot Fixes issue #119
67 68 69 |
# File 'lib/vagrant-windows/windows_machine.rb', line 67 def reinitialize_network_shares() winrmshell.powershell('& net use a-non-existant-share') end |
#ssh_info ⇒ Hash
Returns the SSH config for this machine.
94 95 96 |
# File 'lib/vagrant-windows/windows_machine.rb', line 94 def ssh_info() @machine.ssh_info end |
#windows_config ⇒ Object
98 99 100 |
# File 'lib/vagrant-windows/windows_machine.rb', line 98 def windows_config() @machine.config.windows end |
#winrm_config ⇒ Object
102 103 104 |
# File 'lib/vagrant-windows/windows_machine.rb', line 102 def winrm_config() @machine.config.winrm end |
#winrmshell ⇒ WinRMShell
Returns the active WinRMShell for the guest.
61 62 63 |
# File 'lib/vagrant-windows/windows_machine.rb', line 61 def winrmshell() @machine.communicate.winrmshell end |