Skip to content

Commit

Permalink
the virtualbox guest additions iso is now downloaded via the host and…
Browse files Browse the repository at this point in the history
… stored in the iso-dir. When the machine is build and ssh is up, the iso will be uploaded for further use
  • Loading branch information
jedi4ever committed Nov 26, 2011
1 parent 85e1c34 commit e4e4585
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 5 deletions.
2 changes: 2 additions & 0 deletions lib/veewee/provider/core/box.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
require 'veewee/provider/core/helper/ssh'
require 'veewee/provider/core/helper/web'
require 'veewee/provider/core/helper/shell'
require 'veewee/provider/core/helper/iso'

require 'veewee/provider/core/box/build'
require 'veewee/provider/core/box/scp'
Expand All @@ -22,6 +23,7 @@ class Box
include ::Veewee::Provider::Core::Helper::Web
include ::Veewee::Provider::Core::Helper::Shell
include ::Veewee::Provider::Core::Helper::Ssh
include ::Veewee::Provider::Core::Helper::Iso

include ::Veewee::Provider::Core::BoxCommand

Expand Down
21 changes: 16 additions & 5 deletions lib/veewee/provider/core/helper/iso.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,21 @@ module Iso
require 'highline/import'
require 'digest/md5'

def download_iso(url,filename)
if !File.exists?(env.config.veewee.iso_dir)
env.ui.info "Creating an iso directory"
FileUtils.mkdir(env.config.veewee.iso_dir)
end
env.ui.info "Checking if isofile #{filename} already exists."
full_path=File.join(env.config.veewee.iso_dir,filename)
if File.exists?(full_path)
env.ui.info ""
env.ui.info "The isofile #{filename} already exists."
else
download_progress(url,filename)
end
end

def download_progress(url,localfile)
pbar = nil
URI.parse(url).open(
Expand Down Expand Up @@ -80,12 +95,8 @@ def verify_iso(options)
end

if answer.downcase == "yes"
if !File.exists?(env.config.veewee.iso_dir)
env.ui.info "Creating an iso directory"
FileUtils.mkdir(env.config.veewee.iso_dir)
end
begin
download_progress(self.iso_src,full_path)
download_iso(self.iso_src,full_path)
rescue OpenURI::HTTPError => ex
env.ui.error "There was an error downloading #{self.iso_src}:"
env.ui.error "#{ex}"
Expand Down
23 changes: 23 additions & 0 deletions lib/veewee/provider/virtualbox/box.rb
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,19 @@ def halt(options={})

end

def build(options={})
download_vbox_guest_additions_iso(options)
super(options)
end

def download_vbox_guest_additions_iso(options)
version="#{VirtualBox::Global.global.lib.virtualbox.version.split('_')[0]}"
isofile="VBoxGuestAdditions_#{version}.iso"
url="http://download.virtualbox.org/virtualbox/#{version}/#{isofile}"
env.ui.info "Downloading vbox guest additions iso v #{version} - #{url}"
download_iso(url,isofile)
end

# Get the IP address of the box
def ip_address
return "127.0.0.1"
Expand Down Expand Up @@ -157,6 +170,16 @@ def build_info
:content => "#{VirtualBox::Global.global.lib.virtualbox.version.split('_')[0]}" }
end

# Transfer information provide by the provider to the box
#
#
def transfer_buildinfo(options)
super(options)
iso_image="VBoxGuestAdditions_#{VirtualBox::Global.global.lib.virtualbox.version.split('_')[0]}.iso"
env.logger.info "About to transfer virtualbox guest additions iso to the box #{name} - #{ip_address} - #{ssh_options}"
self.scp("#{File.join(env.config.veewee.iso_dir,iso_image)}",File.basename(iso_image))
end



end # End Class
Expand Down

0 comments on commit e4e4585

Please sign in to comment.