class VagrantVbguest::Installers::Windows
Public Class Methods
match?(vm)
click to toggle source
# File lib/vagrant-vbguest/installers/windows.rb, line 7 def self.match?(vm) raise Error, _key: :do_not_inherit_match_method if self != Windows communicate_to(vm).test("(Get-WMIObject win32_operatingsystem).name") end
os_release(vm)
click to toggle source
# File lib/vagrant-vbguest/installers/windows.rb, line 12 def self.os_release(vm) @@os_release_info ||= {} if !@@os_release_info.has_key?(vm_id(vm)) && communicate_to(vm).test("(Get-WMIObject win32_operatingsystem).Name") communicate.execute("(Get-WMIObject win32_operatingsystem).Name") do |type, data| @@os_release_info[vm_id(vm)] = data end end @@os_release_info[vm_id(vm)] end
Public Instance Methods
cleanup(opts = nil, &block)
click to toggle source
Calls superclass method
VagrantVbguest::Installers::Base#cleanup
# File lib/vagrant-vbguest/installers/windows.rb, line 119 def cleanup(opts = nil, &block) unless options[:no_cleanup] unmount_iso(opts, &block) super end end
execute_installer(opts = nil, &block)
click to toggle source
# File lib/vagrant-vbguest/installers/windows.rb, line 84 def execute_installer(opts = nil, &block) cert_dir = File.join("#{mount_point}:", 'cert') installer = File.join("#{mount_point}:", "VBoxWindowsAdditions.exe") yield_installation_warning(installer) opts = { elevated: true }.merge(opts || {}) # ignore "CRYPT_E_EXISTS" error when re-installing communicate.execute(<<-SHELL, opts.merge(error_check: false), &block) cd #{cert_dir}; ./VBoxCertUtil.exe add-trusted-publisher *.cer --root *.cer SHELL exit_status = communicate.execute(<<-SHELL, opts, &block) cd #{cert_dir}; #{installer} /S SHELL yield_installation_error_warning(installer) unless exit_status == 0 exit_status end
guest_version(reload = false)
click to toggle source
Calls superclass method
VagrantVbguest::Installers::Base#guest_version
# File lib/vagrant-vbguest/installers/windows.rb, line 64 def guest_version(reload = false) return @guest_version if @guest_version && !reload driver_version = VagrantVbguest::Version(super) communicate.execute("VBoxService --version", error_check: false) do |type,data| service_version = VagrantVbguest::Version(data) if service_version if driver_version != service_version @env.ui.warn(I18n.t( "vagrant_vbguest.guest_version_reports_differ", driver: driver_version, service: service_version )) end @guest_version = service_version end end @guest_version end
install(opts = nil, &block)
click to toggle source
# File lib/vagrant-vbguest/installers/windows.rb, line 50 def install(opts = nil, &block) upload(iso_file) mount_iso(opts, &block) execute_installer(opts, &block) end
installer_version(path_to_installer)
click to toggle source
# File lib/vagrant-vbguest/installers/windows.rb, line 40 def installer_version(path_to_installer) version = nil communicate.execute("(get-item #{path_to_installer}).VersionInfo.ProductVersion") do |type, data| if (v = data.to_s.match(/(\d+\.\d+.\d+)/i)) version = v[1] end end version end
mount_iso(opts = nil, &block)
click to toggle source
# File lib/vagrant-vbguest/installers/windows.rb, line 104 def mount_iso(opts = nil, &block) communicate.execute("Mount-DiskImage -ImagePath #{tmp_path}", opts, &block) env.ui.info(I18n.t("vagrant_vbguest.mounting_iso", mount_point: mount_point)) @mounted = true end
mount_point()
click to toggle source
# File lib/vagrant-vbguest/installers/windows.rb, line 30 def mount_point communicate.execute(<<-SHELL) do |type, data| (Get-DiskImage -DevicePath ( Get-DiskImage -ImagePath #{tmp_path} ).DevicePath | Get-Volume).DriveLetter SHELL return data.strip end end
os_release()
click to toggle source
# File lib/vagrant-vbguest/installers/windows.rb, line 22 def os_release self.class.os_release(vm) end
reboot_after_install?(opts = nil, &block)
click to toggle source
# File lib/vagrant-vbguest/installers/windows.rb, line 56 def reboot_after_install?(opts = nil, &block) true end
running?(opts = nil, &block)
click to toggle source
# File lib/vagrant-vbguest/installers/windows.rb, line 60 def running?(opts = nil, &block) communicate.test("'Running' -eq (Get-Service VBoxService)") end
tmp_path()
click to toggle source
# File lib/vagrant-vbguest/installers/windows.rb, line 26 def tmp_path options[:iso_upload_path] || "$env:TEMP/VBoxGuestAdditions.iso" end
unmount_iso(opts = nil, &block)
click to toggle source
# File lib/vagrant-vbguest/installers/windows.rb, line 110 def unmount_iso(opts = nil, &block) return unless @mounted env.ui.info(I18n.t("vagrant_vbguest.unmounting_iso",mount_point: mount_point)) opts = (opts || {}).merge(:error_check => false) communicate.execute("Dismount-DiskImage -ImagePath #{tmp_path}", opts, &block) communicate.execute("Remove-Item -Path #{tmp_path}", opts, &block) @mounted = false end
yield_installation_error_warning(path_to_installer)
click to toggle source
# File lib/vagrant-vbguest/installers/windows.rb, line 126 def yield_installation_error_warning(path_to_installer) @env.ui.warn I18n.t( "vagrant_vbguest.windows.install_error", installer_version: installer_version(path_to_installer) || I18n.t("vagrant_vbguest.unknown") ) end