From a0ceabade66f8d122f08ac393a16bdb0fb046899 Mon Sep 17 00:00:00 2001 From: David Miller Date: Mon, 8 Apr 2013 13:57:49 -0400 Subject: [PATCH 1/2] decouple cpu and mem from build and export for virtualbox/vagrant provider --- lib/veewee/definition.rb | 17 +++++++++++++++++ .../provider/virtualbox/box/export_vagrant.rb | 14 ++++++++++++++ .../definition.rb | 6 ++++++ 3 files changed, 37 insertions(+) diff --git a/lib/veewee/definition.rb b/lib/veewee/definition.rb index ba6b30da..431cdfc7 100644 --- a/lib/veewee/definition.rb +++ b/lib/veewee/definition.rb @@ -12,6 +12,7 @@ class Definition attr_accessor :params attr_writer :cpu_count, :memory_size + attr_writer :export_cpu_count, :export_memory_size attr_accessor :video_memory_size, :iso_file attr_accessor :disk_size, :disk_format, :disk_variant, :disk_count @@ -211,6 +212,14 @@ def memory_size end end + def export_memory_size + if ENV['VEEWEE_EXPORT_MEMORY_SIZE'].nil? + return @export_memory_size + else + return ENV['VEEWEE_EXPORT_MEMORY_SIZE'].to_i + end + end + def cpu_count if ENV['VEEWEE_CPU_COUNT'].nil? return @cpu_count @@ -219,6 +228,14 @@ def cpu_count end end + def export_cpu_count + if ENV['VEEWEE_EXPORT_CPU_COUNT'].nil? + return @export_cpu_count + else + return ENV['VEEWEE_EXPORT_CPU_COUNT'].to_i + end + end + private def ostype_valid? diff --git a/lib/veewee/provider/virtualbox/box/export_vagrant.rb b/lib/veewee/provider/virtualbox/box/export_vagrant.rb index b898b29f..18e03674 100644 --- a/lib/veewee/provider/virtualbox/box/export_vagrant.rb +++ b/lib/veewee/provider/virtualbox/box/export_vagrant.rb @@ -109,6 +109,20 @@ def export_vagrant(options) end end + if definition.export_cpu_count && definition.export_cpu_count != definition.cpu_count + ui.info "Changing CPU count before exporting the box" + command = "#{@vboxcmd} modifyvm #{name} --cpus #{definition.export_cpu_count}" + env.logger.debug("Command: #{command}") + shell_exec(command, {:mute => false}) + end + + if definition.export_memory_size && definition.export_memory_size != definition.memory_size + ui.info "Changing memory size before exporting the box" + command = "#{@vboxcmd} modifyvm #{name} --memory #{definition.export_memory_size}" + env.logger.debug("Command: #{command}") + shell_exec(command, {:mute => false}) + end + ui.info "Exporting the box" command = "#{@vboxcmd} export #{name} --output #{File.join(tmp_dir,'box.ovf')}" env.logger.debug("Command: #{command}") diff --git a/templates/gentoo-latest-i686-experimental/definition.rb b/templates/gentoo-latest-i686-experimental/definition.rb index 02b44fde..ce7be85c 100644 --- a/templates/gentoo-latest-i686-experimental/definition.rb +++ b/templates/gentoo-latest-i686-experimental/definition.rb @@ -7,6 +7,12 @@ Veewee::Definition.declare({ :cpu_count => 2, :memory_size => '1024', + + # set these if you would like the exported box + # to be different from the settings during build + :export_cpu_count => 1, + :export_memory_size => '384', + :disk_size => '20280', :disk_format => 'VDI', :hostiocache => 'off', From 3b60c2e378bf7e6c37d7ccf2bd32e80663a3372f Mon Sep 17 00:00:00 2001 From: David Miller Date: Thu, 11 Apr 2013 15:55:33 -0400 Subject: [PATCH 2/2] added export cpu and memory values to Gentoo amd64 template --- templates/gentoo-latest-x86_64-experimental/definition.rb | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/templates/gentoo-latest-x86_64-experimental/definition.rb b/templates/gentoo-latest-x86_64-experimental/definition.rb index c98202a9..9dd18fbc 100644 --- a/templates/gentoo-latest-x86_64-experimental/definition.rb +++ b/templates/gentoo-latest-x86_64-experimental/definition.rb @@ -7,6 +7,12 @@ Veewee::Definition.declare({ :cpu_count => 2, :memory_size => '1024', + + # set these if you would like the exported box + # to be different from the settings during build + :export_cpu_count => 1, + :export_memory_size => '384', + :disk_size => '20280', :disk_format => 'VDI', :hostiocache => 'off',