To access the ECC, you need to sign up following the instructions here. Once you are signed up, you will be able to download a zip file containing the necessary credentials for accessing the ECC. If you unzip that file somewhere on your local filesystem you will find, among other things, a file called eucarc. The contents of that file will look something like this:
To get things to work seamlessly in boto, you need to copy a few pieces of information from the eucarc file to your boto config file, which is normally found in ~/.boto. Here's the info you need to add. The actual values, of course, should be the ones from your own eucarc file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Credentials] | |
... | |
euca_access_key_id=999999999999999999999999999999999999 | |
euca_secret_access_key=00000000000000000000000000000000000000 | |
... | |
[Boto] | |
... | |
eucalyptus_host =173.205.188.130 | |
walrus_host = 173.205.188.130 | |
... |
Notice that the values needed for eucalyptus_host and walrus_host are just the hostname or ip address of the server as specified in the EC2_HOST and S3_HOST variables. You don't have to include the port number or the http prefix. Having edited your boto config file, you can now easily access the ECC services in boto.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ python | |
Python 2.7.1 (r271:86832, Jun 16 2011, 16:59:05) | |
[GCC 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00)] on darwin | |
Type "help", "copyright", "credits" or "license" for more information. | |
>>> import boto | |
>>> euca = boto.connect_euca() | |
>>> euca.get_all_images() | |
[Image:emi-DFEA10FF, Image:emi-DF0A1104, Image:emi-0CC81777, Image:emi-DF5F1113, Image:emi-DF0B1106, Image:emi-E9E51553, | |
... | |
Image:emi-169215C7, Image:emi-622216BC, Image:emi-E4C11567, Image:emi-B153146A, Image:emi-81BC1332] | |
>>> walrus = boto.connect_walrus() | |
>>> walrus.get_all_buckets() | |
[] | |
>>> |
This example assumes you are using the latest version of boto from github or the release candidate for version 2.1 of boto.
Thanks for the script you provided. I couldn't find it elsewhere and I was almost losing hope.
ReplyDeleteThis is very useful in our company's processes. Thanks for sharing this script.
ReplyDeleteHi Mitch,
ReplyDeleteI am trying to get this working with boto 1.9b but fail to do a
boto.connect_euca()
any pointers?
Thanks,
Deependra
Hi -
ReplyDeleteThe connect_euca method is only available in boto 2.x. If you are using 1.9b, you should be able to connect to Eucalyptus like this (https://gist.github.com/464743).
Mitch
Thanks Mitch that worked like a charm :)
ReplyDeleteThis comment has been removed by a blog administrator.
ReplyDelete