From 9679eccb068b1081f4bd436e10ddee28c09d90d1 Mon Sep 17 00:00:00 2001 From: Mike Fiedler Date: Fri, 10 Jan 2014 12:41:23 -0500 Subject: [PATCH] extend Virtualbox convenince methods In the vein of #2426, I too can never remember syntax, and end up hunting for either an exisiting Vagrantfile or starting to dig up details. --- plugins/providers/virtualbox/config.rb | 8 ++++++++ website/docs/source/v2/virtualbox/configuration.html.md | 4 ++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/plugins/providers/virtualbox/config.rb b/plugins/providers/virtualbox/config.rb index 0aa9bde1d..ba60e77e9 100644 --- a/plugins/providers/virtualbox/config.rb +++ b/plugins/providers/virtualbox/config.rb @@ -84,6 +84,14 @@ module VagrantPlugins customize("pre-boot", ["modifyvm", :id, "--memory", size.to_s]) end + # Shortcut for setting CPU count for the virtual machine. + # Calls #customize internally. + # + # @param count [Integer, String] the count of CPUs + def cpus=(count) + customize("pre-boot", ["modifyvm", :id, "--cpus", count.to_i]) + end + # This is the hook that is called to finalize the object before it # is put into use. def finalize! diff --git a/website/docs/source/v2/virtualbox/configuration.html.md b/website/docs/source/v2/virtualbox/configuration.html.md index 165368bb2..22cb2a6c5 100644 --- a/website/docs/source/v2/virtualbox/configuration.html.md +++ b/website/docs/source/v2/virtualbox/configuration.html.md @@ -62,11 +62,11 @@ more than 50% would be used on your own host machine. Some details: * Multiple `customize` directives can be used. They will be executed in the order given. -There is also a shortcut for specifying the memory size (MB) for the virtual -machine: +There are some convenience shortcuts for memory and CPU settings: ```ruby config.vm.provider "virtualbox" do |v| v.memory = 1024 + v.cpus = 2 end ```