Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Python client library for the CloudStack API.

branch: master

Merge pull request #1 from bigkraig/master

Properly escape spaces in the URL. Client does not create a valid signature when spaces are in the URL.
latest commit f2e1e411bd
Jason Hancock authored October 19, 2012
Octocat-spinner-32 CloudStack At least on CloudStack 4, the API expects the signature to be encoded… September 26, 2012
Octocat-spinner-32 build Updates for cloudstack 3.0 February 28, 2012
Octocat-spinner-32 .gitignore Initial commit December 19, 2011
Octocat-spinner-32 LICENSE Initial commit December 19, 2011
Octocat-spinner-32 README.md Updates for cloudstack 3.0 February 28, 2012
Octocat-spinner-32 example1.py Initial commit December 19, 2011
Octocat-spinner-32 example2.py Initial commit December 19, 2011
Octocat-spinner-32 setup.py adding setup.py February 10, 2012
README.md

CloudStack Python Client

Python client library for the CloudStack User API v3.0.0. For older versions, see the tags.

Examples

List all virtual machines

#!/usr/bin/python

import CloudStack

api = 'http://example.com:8080/client/api'
apikey = 'API KEY'
secret = 'API SECRET'

cloudstack = CloudStack.Client(api, apikey, secret)

vms = cloudstack.listVirtualMachines()

for vm in vms:
    print "%s %s %s" % (vm['id'], vm['name'], vm['state'])

Asynchronous tasks

#!/usr/bin/python

import CloudStack

api = 'http://example.com:8080/client/api'
apikey = 'API KEY'
secret = 'API SECRET'

cloudstack = CloudStack.Client(api, apikey, secret)

job = cloudstack.deployVirtualMachine({
    'serviceofferingid': '2',
    'templateid':        '214',
    'zoneid':            '2'
})

print "VM being deployed. Job id = %s" % job['jobid']

print "All Jobs:"
jobs = cloudstack.listAsyncJobs({})
for job in jobs:
    print  "%s : %s, status = %s" % (job['jobid'], job['cmd'], job['jobstatus'])

TODO:

There is a lot to do to clean up the code and make it worthy of production. This was just a rough first pass.

Something went wrong with that request. Please try again.