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:
The library uses Ruby magic to take method calls and turn them into cloudmonkey API commands. For example, to list users:
require 'cm' client = CloudMonkey::CMClient.new(:apikey => 'myapikey', :secretkey => 'mysecretkey') users = client.list_users puts users[:count] puts users[:user][:username] # Or to search for a single user named "admin" users = client.list_users(:username => 'admin') puts users[:count] puts users[:user][: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
:secretkey. By default, the library will try to connect to localhost
on port 8080. These can be changed by setting
client = CloudMonkey::CMClient.new( :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
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_methodinterceptor are valid.
- Allow querying of config options.