New EC2 interface to CloudStack
// Latest blog entries
EC2stack
CloudStack features an EC2 query interface that can be run on the management server. This is great, but written in Java and using axis can be a bit difficult to hack on and improve. EC2stack is a new project by CloudStack committer Ian Duffy and a buddy of his Darren Brogan from Dublin City University. They did this as part of their third year school project. Building on their previous experience with gstack, a GCE interface to CloudStack, they wrote a brand new EC2 interface to CloudStack.
The interface uses Flask microframework and is written 100% in Python. It also features a vagrant box for easy testing, lots of unittests and automatic build tests (pep8, pylint and coverage) via Travis CI. All around a pretty tight project. They did it on github and not directy in the Apache CloudStack trunk because it was a graded project. They did get permission to put it on github but could not accept pull requests :)
Getting Started with the vagrant box
Clone the repo and launch the vagrant box:
git clone https://github.com/imduffy15/ec2stack.git cd ec2stack vagrant up
Within the VM you can now configure ec2stack
:
mkvirtualenv ec2stack cd /vagrant python setup.py develop
Getting Started without vagrant
Just install ec2stack
with:
sudo python ./setup.py install
You might want to do it within a virtualenv
environment.
Configuration
In the vagrant box, create a virtual environment, and install the server, then configure it and run.
mkvirtualenv ec2stack cd /vagrant python setup.py develop ec2stack-configure ec2stack
On your localmachine, you just need to configure and run the server with:
ec2stack-configure ec2stack
The configuration file will be store in ~/.ec2stack/ec2stack.conf
and can be edited by hand as well. In order to verify the signature coming from any EC2 client and forward an authenticated request to your CloudStack enpoint we need to register the API access/secret keys. Currently this can be done with a curl
command like so:
curl -d AWSSecretKey=aHuDB2ewpgxVuNNRC5NR5cUjEg -d AWSAccessKeyId=PQogHs2skbVdNPUn-mg -d Action=RegisterSecretKey http://localhost:5000
A nicer solution is being worked on. You are now ready to use ec2stack with your favorite EC2 client.
Using the AWS cli
If you are not using the vagrant box and installed everything on your local machine, you can then use the AWS CLI
sudo pip install aws-cli
Set your keys in the /.aws/config
file or run aws configure
. The region needs to be a valid AWS region. With the keys set you are now ready to use the aws cli
, you just need to specify the endpoint of ec2stack
aws ec2 describe-images --endpoint=http://localhost:5000 aws ec2 describe-key-pairs --endpoint=http://localhost:5000 aws ec2 create-key-pair --endpoint=http://localhost:5000 --key-name=test
And so on, have a look at it, create security groups and start instances.
API coverage
Looking at the code only the following AWS APIs are covered:
def _get_action(action): actions = { 'AttachVolume': volumes.attach_volume, 'AuthorizeSecurityGroupEgress': security_groups.authenticate_security_group_egress, 'AuthorizeSecurityGroupIngress': security_groups.authenticate_security_group_ingress, 'CreateKeyPair': keypairs.create_keypair, 'CreateSecurityGroup': security_groups.create_security_group, 'CreateVolume': volumes.create_volume, 'DeleteKeyPair': keypairs.delete_keypair, 'DeleteSecurityGroup': security_groups.delete_security_group, 'DeleteVolume': volumes.delete_volume, 'DescribeAvailabilityZones': zones.describe_zones, 'DescribeImageAttribute': images.describe_image_attribute, 'DescribeImages': images.describe_images, 'DescribeInstanceAttribute': instances.describe_instance_attribute, 'DescribeInstances': instances.describe_instances, 'DescribeKeyPairs': keypairs.describe_keypairs, 'DescribeSecurityGroups': security_groups.describe_security_groups, 'DescribeVolumes': volumes.describe_volumes, 'DetachVolume': volumes.detach_volume, 'GetPasswordData': passwords.get_password_data, 'ImportKeyPair': keypairs.import_keypair, 'RebootInstances': instances.reboot_instance, 'RegisterSecretKey': register_secret_key, 'RemoveSecretKey': remove_secret_key, 'RevokeSecurityGroupEgress': security_groups.revoke_security_group_egress, 'RevokeSecurityGroupIngress': security_groups.revoke_security_group_ingress, 'StartInstances': instances.start_instance, 'StopInstances': instances.stop_instance, 'TerminateInstances': instances.terminate_instance, }
The code is super clean and it will be easy to add more actions and provide a much better coverage really soon, pull request welcome as soon as Ian and Darren get their grades in :)
----
Shared via my feedly reader
No comments:
Post a Comment