cloudmonkey ruby interface
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


CloudMonkey-Ruby is a simple ruby library that interfaces with the Apache cloudmonkey command line client to interact with a CloudStack management server. Its primary purpose is to "Ruby-ify" CloudStack API commands and use cloudmonkey to do all the heavy lifting of actually connecting to the management server and parsing responses.


CloudMonkey-ruby is published as a Ruby gem, so it is installed with:

gem install cloudmonkey

After this, it can be accessed in your code by:

require 'cm'

Basic Usage

The library uses Ruby magic to take method calls and turn them into cloudmonkey API commands. For example, to list users:

require 'cm'

client = => 'myapikey', :secretkey => 'mysecretkey')
users = client.list_users
puts users[:count]
puts users[:user][0][:username]

# Or to search for a single user named "admin"
users = client.list_users(:username => 'admin')
puts users[:count]
puts users[:user][0][:username]

This will output something like


on a fresh CloudStack installation. The responses returned by the commands follow the slightly odd Cloudstack format of having the list results wrapped in a named property, which is why the user list is accessed by a :user symbol above.

All parameters and responses are symbolized.


At minimum, the constructor for CMClient requires :apikey and :secretkey. By default, the library will try to connect to localhost on port 8080. These can be changed by setting :host and :port:

client =
	:apikey => 'myapikey',
	:secretkey => 'mysecretkey',
	:host => 'myhost',
	:port => 8081

The configuration for the library is isolated from the default CloudMonkey installation. By default it puts its information in ~/.cloudmonkey-cmrb. This location can be controlled with the :conf_dir parameter.


CMHelper is a class that wraps around the CMClient and provides some special methods that make it easier to deal with certain CloudStack tasks, especially ones that require multiple API commands.


Features to be implemented:

  • Utilize the cloudmonkey cache to check if API calls from the missing_method interceptor are valid.
  • Allow querying of config options.