Friday, May 6, 2011

Managing OpenStack using libcloud and lc-tools

OpenStack is getting more and more popular and number of its installation increases day by day. We've got one as well. :-) While there are quite a number of bindings and tools to connecting to its API I prefer use familiar proven tools like libcloud and lc-tools. And since OpenStack supports both EC2-compatible and Rackspace-compatible APIs, there are two ways connecting to it.

EC2 API


To use EC2-compatible API, pick EUCALYPTUS driver like that:



You need to define EC2_ACCESS_KEY and EC2_SECRET_KEY variables to match your setup. Hostname, port and path arguments which are passed to constructor could be extracted from your EC2_URL environment variable.

Note: if you're not using trunk version of libcloud, you will need to adjust imports a little, i.e. strip compute. part from them.

Rackspace API


To use Rackspace-compatible API you will to check out trunk version of libcloud (please refer here to obtain it) which provides OPENSTACK driver, which could be used in a similar fashion:



Again, here you will need to redefine NOVA_API_KEY and NOVA_USERNAME for your setup and grab host and port from NOVA_URL.

Let me remind you once again that you need trunk version of libcloud to make it working. One more thing: OpenStack is not fully compatible with Rackspace API, so not everything will work smooth.

lc-tools


lc-tools is a set of command line tools on top of libcloud to manage your cloud servers. Git version of lc-tools supports working with OpenStack both through EC2 and Rackspace compatible APIs. Here's config samples for both:


[ec2compat]
driver = eucalyptus
access_id = CHANGE_ME
secret_key = CHANGE_ME
extra = { "host": "127.0.0.1", "secure": False, "port": 8773, "path": "/services/Cloud" }

[rscompat]
driver = openstack
access_id = nova_admin
secret_key = CHANGE_ME
extra = {"host": "127.0.0.1", "port": 8774}


And just check if it works by executing lc-node-list -p ec2compat and lc-node-list -p rscompat.

References

* libcloud
* lc-tools

1 comment: