Monday 20 April 2015

Using Apache LibCloud with the Dimension Data API

Apache have a project called 'libcloud', which is a multi-cloud library for python. Dimension Data Cloud (formerly known as OpSource cloud) has been a supported platform for many years.

Here is how you download and use libcloud with our API.

Install libcloud using PIP
>pip install apache-libcloud

Open up the Python shell
>python

import the libcloud project
>>>from pprint import pprint
>>>from libcloud.compute.types import Provider
>>>from libcloud.compute.providers import get_driver

Set the driver as OpSource (Dimension Data Cloud)
>>>cls = get_driver(Provider.OPSOURCE)

Turn off SSL validation for testing, or read https://libcloud.readthedocs.org/en/latest/other/ssl-certificate-validation.html
>>>import libcloud.security
>>>libcloud.security.VERIFY_SSL_CERT = False

Set your credentials
>>>driver = cls('myusername','mypassword')

List the servers in your account.
>>> pprint(driver.list_nodes())

[<Node: uuid=8fa6750b7829b224c6b1f252decfc80a61fae424, name=ExchN1, state=TERMINATED, public_ips=[], private_ips=10.172.
132.12, provider=Opsource ...>,
 <Node: uuid=db9505bf21d0811fc99d70c9a9ac72e0695a573d, name=ExchN2, state=TERMINATED, public_ips=[], private_ips=10.172.
132.14, provider=Opsource ...>,

Note: LibCloud only supports the NA region at present.

Further details are available on the libcloud website..
https://libcloud.readthedocs.org/en/latest/compute/index.html


No comments:

Post a Comment