The virtualbox-COM
ruby gem is a library which focus on the
direct mapping of the VirtualBox API and allows anyone to control
VirtualBox from ruby code! Create, destroy, start, stop, suspend, and
resume virtual machines. Also list virtual machines, list hard
drives, network devices, etc.
If you need a high level API take a look at virtualbox-ruby which rely on this gem but provide a more rubyish interface.
First you need to install VirtualBox which is available for Windows, Linux, and OS X. After installation, install the gem:
sudo gem install virtualbox-com
The gem uses the native COM interface which VirtualBox provides to
communicate with it. The gem talk to the VirtualBox dynamic library,
and all the mapping as been generated from the VirtualBox.xidl
.
No configuration should be necessary to use this gem, but if
the dynamic library is not found, you can set the environment
variable VBOX_APP_HOME
to the full library path.
You can refer to the VirtualBox SDK knowning that in this gem
- classes are not prefixed with the
I
(IMachine
=>Machine
) - methods have been uncamelized (
canShowConsoleWindow
=>can_show_console_window
) - when calling a method you only specify the in parameters, all the out (including the default return) are being returned in an array if there is more than one, directly otherwise
require 'virtualbox-com'
lib = VirtualBox::COM
lib.virtualbox.machines.each {|vm|
puts "%s: %s" % [ vm.bame, vm.state ]
}
You can find more examples in the examples
directory
Please use the issue tracker.
Improve documentation, re-implement a test-suite
If you'd like to contribute to VirtualBox, the first step to developing is to clone this repo, get bundler if you don't have it already, and do the following:
bundle install --relock
rake
This will run the test suite, which should come back all green! Then you're good to go!
First thanks goes to Mitchell Hashimoto for its release of the first ruby binding to virtualbox from which part of this code is inspired.
These folks went above and beyond with contributions to the virtualbox gem, and for that, I have to say "thanks!"
- INSA-Lyon