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

Decouple cpu mem build export #641

Open
wants to merge 2 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
17 changes: 17 additions & 0 deletions lib/veewee/definition.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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?
Expand Down
14 changes: 14 additions & 0 deletions lib/veewee/provider/virtualbox/box/export_vagrant.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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}")
Expand Down
6 changes: 6 additions & 0 deletions templates/gentoo-latest-i686-experimental/definition.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
6 changes: 6 additions & 0 deletions templates/gentoo-latest-x86_64-experimental/definition.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down