Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Python client library for the CloudStack API.
Python
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
@jasonhancock authored
Failed to load latest commit information.
CloudStack
build Updates for cloudstack 3.0
.gitignore Initial commit
LICENSE Initial commit
README.md Updates for cloudstack 3.0
example1.py Initial commit
example2.py Initial commit
setup.py adding setup.py

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.