Class: Vagrant::Guest::Windows
- Inherits:
-
Base
- Object
- Base
- Vagrant::Guest::Windows
- Defined in:
- lib/vagrant-windows/guest/windows.rb
Overview
A general Vagrant system implementation for “windows”.
Contributed by Chris McClimans <[email protected]>
Defined Under Namespace
Classes: WindowsError
Instance Method Summary collapse
- #change_host_name(name) ⇒ Object
- #halt ⇒ Object
- #mount_shared_folder(name, guestpath, options) ⇒ Object
- #windows_path(path) ⇒ Object
Instance Method Details
#change_host_name(name) ⇒ Object
13 14 15 16 |
# File 'lib/vagrant-windows/guest/windows.rb', line 13 def change_host_name(name) #### on windows, renaming a computer seems to require a reboot vm.channel.execute("wmic computersystem where name=\"%COMPUTERNAME%\" call rename name=\"#{name}\"") end |
#halt ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/vagrant-windows/guest/windows.rb', line 18 def halt @vm.channel.execute("shutdown /s /t 1 /c \"Vagrant Halt\" /f /d p:4:1") # Wait until the VM's state is actually powered off. If this doesn't # occur within a reasonable amount of time (15 seconds by default), # then simply return and allow Vagrant to kill the machine. count = 0 while @vm.state != :poweroff count += 1 return if count >= @vm.config.linux.halt_timeout sleep @vm.config.windows.halt_check_interval end end |
#mount_shared_folder(name, guestpath, options) ⇒ Object
33 34 35 36 37 38 |
# File 'lib/vagrant-windows/guest/windows.rb', line 33 def mount_shared_folder(name, guestpath, ) mount_script = TemplateRenderer.render(File.("#{File.dirname(__FILE__)}/../scripts/mount_volume.ps1"), :options => {:mount_point => guestpath, :name => name}) @vm.channel.execute(mount_script,{:shell => :powershell}) end |
#windows_path(path) ⇒ Object
40 41 42 43 44 45 46 47 48 |
# File 'lib/vagrant-windows/guest/windows.rb', line 40 def windows_path(path) p = '' if path =~ /^\// p << 'C:\\' end p << path p.gsub! /\//, "\\" p.gsub /\\\\{0,}/, "\\" end |