Ruby interface to the VMware vSphere API. vmware/rbvmomi is the official repo.
Ruby Shell
Latest commit 5dc0ca3 Mar 20, 2012 Rich Lane handle empty result from ExecuteSoap
Failed to load latest commit information.
bin fix pretty printer for Ruby 1.8 Jan 17, 2012
devel improve benchmark script Nov 23, 2011
examples remote debug log Apr 8, 2011
lib handle empty result from ExecuteSoap Mar 20, 2012
test support serializing managed and data objects to anyType fields Mar 20, 2012
.gitignore add code coverage to test suite Nov 6, 2011
.yardopts add todo to document trollop extensions Feb 21, 2011
LICENSE add licensing stuff Oct 21, 2010
README.rdoc add IRC channel to readme Dec 4, 2011
VERSION Version bump to 1.5.1 Mar 12, 2012
vmodl.db expose internal vds opaque channel configuration apis Nov 16, 2011




RbVmomi is a Ruby interface to the vSphere API. Like the Perl and Java SDKs, you can use it to manage ESX and VirtualCenter servers. The current release supports the vSphere 5.0 API. RbVmomi specific documentation is online and is meant to be used alongside the official documentation.


gem install rbvmomi


A simple example of turning on a VM:

require 'rbvmomi'
vim = RbVmomi::VIM.connect host: 'foo', user: 'bar', password: 'baz'
dc = vim.serviceInstance.find_datacenter("mydatacenter") or fail "datacenter not found"
vm = dc.find_vm("myvm") or fail "VM not found"

This code uses several RbVmomi extensions to the vSphere API for concision. The expanded snippet below uses only standard API calls and should be familiar to users of the Java SDK:

require 'rbvmomi'
vim = RbVmomi::VIM.connect host: 'foo', user: 'bar', password: 'baz'
rootFolder = vim.serviceInstance.content.rootFolder
dc = rootFolder.childEntity.grep(RbVmomi::VIM::Datacenter).find { |x| == "mydatacenter" } or fail "datacenter not found"
vm = dc.vmFolder.childEntity.grep(RbVmomi::VIM::VirtualMachine).find { |x| == "myvm" } or fail "VM not found"
task = vm.PowerOnVM_Task
filter = vim.propertyCollector.CreateFilter(
  spec: {
    propSet: [{ type: 'Task', all: false, pathSet: ['info.state']}],
    objectSet: [{ obj: task }]
  partialUpdates: false
ver = ''
while true
  result = vim.propertyCollector.WaitForUpdates(version: ver)
  ver = result.version
  break if ['success', 'error'].member?
raise if == 'error'

As you can see, the extensions RbVmomi adds can dramatically decrease the code needed to perform simple tasks while still letting you use the full power of the API when necessary. RbVmomi extensions are often more efficient than a naive implementation; for example, the find_vm method on VIM::Datacenter used in the first example uses the SearchIndex for fast lookups.

A few important points:

  • All class, method, parameter, and property names match the official documentation.

  • Properties are exposed as accessor methods.

  • Data object types can usually be inferred from context, so you may use a hash instead.

  • Enumeration values are simply strings.

  • Example code is included in the examples/ directory.

  • A set of helper methods for Trollop is included to speed up development of command line apps. See the included examples for usage.

  • If you don't have trusted SSL certificates installed on the host you're connecting to, you'll get an +OpenSSL::SSL::SSLError+ “certificate verify failed”. You can work around this by using the :insecure option to +RbVmomi::VIM.connect+.

  • This is a side project of a VMware employee and is entirely unsupported by VMware.

Built-in extensions are under lib/rbvmomi/vim/. You are encouraged to reopen VIM classes in your applications and add extensions of your own. If you write something generally useful please send it to me and I'll add it in.


Fork the project on Github and send me a merge request, or send a patch to RbVmomi developers hang out in #rbvmomi on Freenode.