Skip to content
Ruby library to interact with the CloudStack API
Ruby
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
bin
data
lib
test
.gitignore
.travis.yml
Gemfile
Gemfile.lock
LICENSE.txt
README.md
Rakefile
cloudstack_client.gemspec

README.md

cloudstack_client

Gem Version Build Status

A CloudStack API client written in Ruby.

Installation

Install the cloudstack_client gem:

$ gem install cloudstack_client

Features

  • Interactive console for playing with the CloudStack API: cloudstack_client console
  • Dynamically builds API methods based on the listApis function of CloudStack
  • Command names are converted to match Ruby naming conventions (i.e. ListVirtualMachines becomes list_virtual_machines)
  • Accepts Ruby Hash arguments passed to commands as options (i.e. list_all: true becomes listall=true)
  • Makes sure all required arguments are passed
  • Removes unsupported arguments and arguments with nil values from commands

Usage

Basic usage

require "cloudstack_client"

cs = CloudstackClient::Client.new(
  "https://cloudstack.local/client/api",
  "API_KEY",
  "SECRET_KEY"
)

cs.list_virtual_machines(state: "running").each do |server|
  puts server["name"]
end

Initialize with options

Load API definition file from a alternative path and set the version:

cs = CloudstackClient::Client.new(
  "https://cloudstack.local/client/api",
  "API_KEY",
  "SECRET_KEY",
  {
    api_path: "~/cloudstack",
    api_version: "4.6"
  }
)

..or load the API definition directly from a file:

cs = CloudstackClient::Client.new(
  "https://cloudstack.local/client/api",
  "API_KEY",
  "API_SECRET",
  { api_file: "~/cloudstack/4.6.json.gz" }
)

Interactive Console

cloudstack_client comes with an interactive shell to test the client.

Example:

$ cloudstack_client console -e prod
prod >> list_virtual_machines

Development

Generate/Update API versions

New API configs can be generated using the list_apis command.

Example:

# running against an CloudStack 4.5 API endpoint:
$ cloudstack_client list_apis > data/4.5.json
$ gzip data/4.5.json

References

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

License

Copyright (c) 2014-2016, Nik Wolfgramm

Released under the MIT License. See the LICENSE file for further details.

Something went wrong with that request. Please try again.