clojure cloudstack client
Switch branches/tags
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.

clostack: clojure cloudstack client

Build Status

A simple clojure cloudstack client.


This client provides two ways to query the cloudstack HTTP API.

  • A standard synchronous way, which still pools outgoing requests.
  • A lower level access to the internal HTTP asynchronous client.


Client are created with the http-client which takes an optional argument map:

  • config: a map of three keys:
    • api-key: cloustack api key
    • api-secret: cloustack api secret
    • endpoint: URL where cloudstack lives
  • client: a netty HTTP client, as provided by

The api-key, api-secret and endpoint may also be fetched from the environment or a configuration file.

The environment takes precedence over the configuration file. When looking for environment variables, both actual environment variables and JVM system properties will be looked up.

The following system properties or environment variables can be used to provide settings:

clostack.api.keyCLOSTACK_API_KEYCloudstack API key
clostack.api.secretCLOSTACK_API_SECRETCloudstack API secret
clostack.endpointCLOSTACK_ENDPOINTCloudstack API endpoint

The configuration file allows for different profiles, two additional relevant variables may be set:

clostack.profileCLOSTACK_PROFILEConfiguration profile name
clostack.config.fileCLOSTACK_CONFIG_FILEConfiguration file location

A typical configuration will have the following aspect:

{:default :prod
 :prod    {:api-key    "xxxx"
           :api-secret "xxxx"
           :endpoint   "https://..."}
 :staging {:api-key    "xxxx"
           :api-secret "xxxx"
           :endpoint   "https://..."}}

In this configuration, we define two cloudstack installations, by default the production credentials will be used, setting clostack.profile to staging would switch this mode of operation.

Using in your project

The easiest way to use clostack in your own projects is via Leiningen. Add the following dependency to your project.clj file:

[spootnik/clostack "0.2.9"]

Building Documentation

run lein doc

Sample Code

(def client (http-client {}))

;; Simple requests
(request client :list-virtual-machines {})
(request client :list-zones {})

;; Provide a callback to execute when response comes back
(async-request client :list-service-offerings {} (fn [resp] ...))

;; Page through all records and return a consistent lazy map
(paging-request client :list-events {})

;; Execute body when response comes back
(with-response [resp client :list-events]
  (println (pr-str resp)))