Automatically set CPU, Memory and Hostname of the virtual machines

This commit is contained in:
Bernhard Gschaider 2014-05-16 14:05:02 +02:00
parent ee28daa3a5
commit d64b2268b8
2 changed files with 32 additions and 1 deletions

View file

@ -32,6 +32,20 @@
to the sources if you want to edit there directly. Use with care
and don't compile in that directory unless you know what you're
doing
** Memory size and CPU-number
The number of CPUs in the virtual machine is determined by (the
first one that matches is used)
* If the variable =WM_VAGRANT_CPUS= exists then the number of CPUs
is set to this
* If the variable =WM_NCOMPPROCS= is set then the number of CPUs is
fixed with *half* that number (so that the virtual machine
doesn't make the machine unuable)
The amount of memory is set according to the number of CPUs:
$(1+N)*512$ Megabytes. This should allow half a Gigabyte for the OS
and half a Gigagbyte for each compiling process
The hostname of the virtual machine is the hostname of the host
machine prepended with =vagrant.=
* Virtual machines
Currently existing virtual machines are
- precise :: Latest LTS Ubuntu. Currently the default machine to use

View file

@ -4,12 +4,29 @@
Vagrant.configure("2") do |config|
config.vm.synced_folder "..", "/FOAM-sources"
config.vm.hostname="vagrant."+ENV["HOSTNAME"]
nrCPU=1
if ENV["WM_VAGRANT_CPUS"]
nrCPU=ENV["WM_VAGRANT_CPUS"].to_i
else
if ENV["WM_NCOMPPROCS"]
nrCPU=ENV["WM_NCOMPPROCS"].to_i/2
end
end
if nrCPU<1
nrCPU=1
end
config.vm.provider :virtualbox do |vb|
# # Don't boot with headless mode
# vb.gui = true
#
# # Use VBoxManage to customize the VM. For example to change memory:
vb.customize ["modifyvm", :id, "--memory", "1024"]
# vb.customize ["modifyvm", :id, "--memory", "1024"]
vb.cpus=nrCPU
# make sure each CPU has enough memory
vb.memory=512*(1+nrCPU)
end
# default