cloudstack_helper is a simple ruby library that helps making request to CloudStack API easier. With cloudstack_helper, you only have to specify the command and the parameters for the request, and it will handle everything for you.

Library Usage

     require 'cloudstack_helper'

     API_URL = "http://mycloudstack:8080/client/api"
     API_KEY = "WiUVlx74PpVE8w7z7hasgJjiOQvMsMWLFL3A054D_IPeSxxcm1PoNlpYlA2ujGSJBGiS2uBcG0GoLwLisosDCA"
     SECRET_KEY = "uqzgrfMXnYSVvUi2XahgiDgvtXBemILs_npqi90KiYw0OKjyETOvQTtYg093EUrHSLZJEnI3lV1z9PrQmv2SxQ"
     cs_helper = => API_KEY, :secret_key => SECRET_KEY, :api_url => API_URL)

     params = {:command => "listZones"}
     puts cs_helper.get(params).body

     params[:response] = "json"
     puts cs_helper.get(params).body

Script Usage

    Usage: cloudstack_rb -c conf -x command param1=value1 param2=value2
      -x, --execute COMMAND    command to execute. See CloudStack API for list of commands.
      -c, --conf FILE          YAML config file that stores api and secret key
      -h, --help               Show this message.


    cloudstack_rb -x listUsers domainid=1
    cloudstack_rb -x listUsers domainid=1 response=json
    cloudstack_rb -x deployVirtualMachine serviceofferingid=12 templateid=4 zoneid=1 displayname=ohyea


By default, if you don't specify a config file, cloudstack_rb assumes there is a config file in the current working directory under the name 'cloudstack.yaml' The config file should look like this

    api_url: "http://mycloudstack:8080/client/api"
    api_key: "WiUVlx74PpVE8w7z7J7gtojiOQasdaFL3A054D_IPeSxxcm1PadgasdgujGSJBGiS2uBcG0GoLwLisosDCA"
    secret_key: "uqzgrfMXnYSVvUiasdgj0DgvtXBemILs_npqi90Ki0xigOKjagvQTtYg093EUrHSLZJEnI3lV1z9PrQmv2SxQ"