Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Virtual drivers for windows #629

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions lib/veewee/definition.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class Definition
attr_accessor :ssh_login_timeout, :ssh_user, :ssh_password, :ssh_key, :ssh_host_port, :ssh_guest_port

attr_accessor :winrm_login_timeout, :winrm_user, :winrm_password, :winrm_host_port, :winrm_guest_port
attr_accessor :windows_drivers_version

attr_accessor :sudo_cmd
attr_accessor :shutdown_cmd
Expand Down Expand Up @@ -99,6 +100,7 @@ def initialize(name, path, env)
# :kickstart_file => nil,
@winrm_host_port = "5985" ; @winrm_guest_port = "5985"
@winrm_login_timeout = "10000"
@windows_drivers_version = "0.1-52"
@boot_cmd_sequence = [] # Empty list by default

@virtualbox = { :vm_options => {} }
Expand Down
13 changes: 9 additions & 4 deletions lib/veewee/provider/core/box.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,20 @@ def gem_available?(gemname)
return available
end

def windows_guest?
return @definition.os_type_id.start_with?('Windows')
end

def windows_host?
return (RbConfig::CONFIG['host_os'] =~ /mswin|mingw|cygwin/)
end

def set_definition(definition_name)
@definition=env.definitions[definition_name]

unless @definition.nil?
# We check for windows as em-winrm is not available on ruby1.9
is_windows = @definition.os_type_id.start_with?('Windows')

# On windows systems
if is_windows
if self.windows_guest?
# Check if winrm is available
if gem_available?('em-winrm')
require 'veewee/provider/core/box/winrm'
Expand Down
1 change: 1 addition & 0 deletions lib/veewee/provider/virtualbox/box.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
require 'veewee/provider/virtualbox/box/helper/ssh_options'
require 'veewee/provider/virtualbox/box/helper/winrm_options'
require 'veewee/provider/virtualbox/box/helper/guest_additions'
require 'veewee/provider/virtualbox/box/helper/windows_drivers'
require 'veewee/provider/virtualbox/box/helper/status'
require 'veewee/provider/virtualbox/box/helper/version'
require 'veewee/provider/virtualbox/box/helper/buildinfo'
Expand Down
1 change: 1 addition & 0 deletions lib/veewee/provider/virtualbox/box/build.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ module BoxCommand
def build(options={})

download_vbox_guest_additions_iso(options)
download_windows_drivers_iso(options) if self.windows_guest?

super(options)

Expand Down
1 change: 1 addition & 0 deletions lib/veewee/provider/virtualbox/box/create.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ def create(options={})
end
self.attach_isofile(isofile_ide_device_number)
self.attach_guest_additions
self.attach_windows_drivers if self.windows_guest?

self.create_floppy("virtualfloppy.vfd")

Expand Down
3 changes: 1 addition & 2 deletions lib/veewee/provider/virtualbox/box/export_vagrant.rb
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,7 @@ def export_vagrant(options)
ui.info "Packaging the box"
FileUtils.cd(tmp_dir)
command_box_path = box_path
is_windows = (RbConfig::CONFIG['host_os'] =~ /mswin|mingw|cygwin/)
if is_windows
if self.windows_host?
command_box_path = command_box_path.gsub(/^([A-Z])\:\/(.*)$/, '/\1/\2')
end
command = "tar -cvf '#{command_box_path}' ."
Expand Down
6 changes: 6 additions & 0 deletions lib/veewee/provider/virtualbox/box/helper/create.rb
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,12 @@ def attach_guest_additions
shell_exec("#{command}")
end

def attach_windows_drivers
full_iso_file=File.join(env.config.veewee.iso_dir,"#{self.windows_drivers_isoname}")
ui.info "Mounting virtualbox drivers: #{full_iso_file}"
command ="#{@vboxcmd} storageattach \"#{name}\" --storagectl \"IDE Controller\" --type dvddrive --port 1 --device 1 --medium \"#{full_iso_file}\""
shell_exec("#{command}")
end

def add_floppy_controller
# Create floppy controller
Expand Down
3 changes: 1 addition & 2 deletions lib/veewee/provider/virtualbox/box/helper/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ module BoxCommand
def vbox_version
command="#{@vboxcmd} --version"
stderr = "/dev/null"
is_windows = (RbConfig::CONFIG['host_os'] =~ /mswin|mingw|cygwin/)
stderr = "nul" if is_windows
stderr = "nul" if self.windows_host?
shell_results=shell_exec("#{command}",{:mute => true, :stderr => stderr})
version=shell_results.stdout.strip.split(/[^0-9\.]/)[0]
return version
Expand Down
24 changes: 24 additions & 0 deletions lib/veewee/provider/virtualbox/box/helper/windows_drivers.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
module Veewee
module Provider
module Virtualbox
module BoxCommand

def windows_drivers_version
return definition.windows_drivers_version
end

def windows_drivers_isoname
return "virtio-win-#{self.windows_drivers_version}.iso"
end

def download_windows_drivers_iso(options)
version=self.windows_drivers_version
isofile=self.windows_drivers_isoname
url="http://alt.fedoraproject.org/pub/alt/virtio-win/latest/images/bin/#{isofile}"
ui.info "Downloading virtualbox drivers iso #{version} - #{url}"
download_iso(url,isofile)
end
end
end
end
end