Eucalyptus

Eutester Basics Part II: Setting up a development environment

Installing dependencies on system

  1. Check that Python 2.6 or greater is installed, in my case (Ubuntu 11.10) Python 2.7 is installed by default
  2. Install python setup-tools and python-virtualenv
apt-get install python-setuptools python-virtualenv git

Creating your virtualenv and installing required modules

  1. First create a fresh virtual Python environment in order to keep unwanted changes out of the main Python installation.  In my case I named it “eutester-dev”.
    • virtualenv eutester-dev
  2. In order to enter the environment that was just created for you enter the following command
    • source eutester-dev/bin/activate
  3. Now that we are in the virtualenv we can install the modules necessary for eutester
    • easy_install boto paramiko
  4. Download eutester from githuband install it in the virtualenv
    • git clone git://github.com/eucalyptus/eutester.git
    • cd eutester
    • python setup.py install

Setting up your Eucarc file

  1. If you are testing against Eucalyptus the credentials that were downloaded from the cloud are sufficient. Take note of the directory where the zip file was unzipped (ie the place where the eucarc file now resides). This path will be the “credpath” argument to the construction of your eutester or eucaops object.
  2. If you are testing against a different AWS compatibile cloud the following must be provided in a file named eucarc:
    • export EC2_URL=http://mycloud.hostname.com:8773/services/Eucalyptus
    • export S3_URL=http://mywalrus.hostname.com:8773/services/Walrus
    • export EC2_ACCESS_KEY=’XXXXXXXXXXXXXXXX’
    • export EC2_SECRET_KEY=’XXXXXxXXXXXXXXXXXXXXXXX’
  3. Make sure to put the correct hostnames for the EC2 and S3 URLs as well as the correct Secret and Access keys.

Max Spevack put together a great tutorial on setting up your environment for testing against EC2.

Configuring Python shell for tab complete and history

You should now be able to use your Python environment with eutester but in order to make development and testing easier you can use the Python shell with tab completion. To achieve this we will create a .pythonrc file in our users home directory that will allow setup the shell for us with tab complete every time we start it. Your ~/.pythonrc file should look something like this:

import atexit
import os
import readline
import rlcompleter

history = os.path.expanduser('~/.python_history')
readline.read_history_file(history)
readline.parse_and_bind('tab: complete')
atexit.register(readline.write_history_file, history)

Now add the PYTHONSTARTUP variable to your .bashrc (or equivalent) file and source the .bashrc:

echo "export PYTHONSTARTUP=~/.pythonrc" >> ~/.bashrc
source ~/.bashrc

Next well need to create the file to log our shell history:

touch ~/.python_history

Start the virtual Python environment shell using a call directly to the Python binary

~/eutester-dev/bin/python

You should now be able to hit TAB twice to see the available namespaces that you can use within the Python shell. For example, load up the Eucaops class then create a tester object, then type “tester.” and hit TAB twice. You should see a list of the properties and methods provided by the Eucaops class

ubuntu@ip-192-168-165-22:~$ ./eutester-dev/bin/python
Python 2.7.2+ (default, Oct 4 2011, 20:06:09)
[GCC 4.6.1] on linux2
Type “help”, “copyright”, “credits” or “license” for more information.
>>> from eucaops import Eucaops
>>> tester = Eucaops(credpath=”~/.euca”)

About these ads
Standard

9 thoughts on “Eutester Basics Part II: Setting up a development environment

  1. Pingback: Euca School, first day of class! « Greg DeKoenigsberg Speaks

  2. hspencer77 says:

    This is good stuff man. Can’t wait for the first day of class. Thanks again for your work on this. Look forward to contributing.

  3. hspencer77 says:

    Just wanted to give some additional information concerning setting eutester up on Debian. I am using Debian 6.0 (python 2.6.6). I needed to install the additional dependencies to prepare for installing boto and paramiko. Instead of running:

    apt-get install python-setuptools python-virtualenv git

    I had to run this:

    python-setuptools python-virtualenv git gcc python-crypto

    Thanks again for the blog. Once I installed those additional dependencies, everything installed great and I was able to write my first eutester script…:-)

  4. Pingback: On Cloud 10: Eutester, MacPorts and Mac OS X Lion « More Mind Spew-age from Harold Spencer Jr.

  5. John D says:

    I followed the setup until I imported the creds. “b13″ is a directory that contains the eucarc files:

    >>> tester = Eucaops(credpath=”b13″)
    [2012-11-29 11:41:00,332] [EUTESTER] [DEBUG]: Extracting keys from b13
    [2012-11-29 11:41:00,332] [EUTESTER] [DEBUG]: Attempting to create ec2 connection to 10.101.1.13
    [2012-11-29 11:41:00,333] [EUTESTER] [DEBUG]: Attempting to create S3 connection to 10.101.1.13
    [2012-11-29 11:41:00,334] [EUTESTER] [DEBUG]: Attempting to create IAM connection to 10.101.1.13
    [2012-11-29 11:41:00,334] [EUTESTER] [DEBUG]: Attempting to create STS connection to 10.101.1.13
    [2012-11-29 11:41:00,334] [EUTESTER] [CRITICAL]: Was unable to create STS connection because of exception: __init__() got an unexpected keyword argument ‘host’
    >>>

    jd

    • Hey John,

      You are on the right track, the critical error there is only in setting up the STS connection. There was a bug that should be now fixed. Either way you should be able to use 99% of that Eucaops api without seeing any issues.

      Let me know if it works.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s