This is a presentation of the Amazon Web Service compatible EC2 interface to CloudStack. AWS EC2 is the de facto standard for compute clouds whether they are private or public. EC2 has a multiple client libraries and tools that can be used to provision virtual machine instances.
In this talk we walk through how to enable an EC2 like service in a CloudStack based cloud, how to register the users and how to use clients to talk to CloudStack the same way you would talk to the AWS EC2 public clouds.
2. Introduction
• CloudStack provides an EC2 compatible interface
• In Apache CloudStack 4.0 (soon out), Cloudbridge
is now an integral part of the management server
and not a separate server.
• SOAP and Query interface are supported. SOAP
may be dropped soon.
• Query interface under heavy
development/testing
3. Steps to use EC2/S3 in CloudStack
• Enable the service via global configuration
settings
• Generate API keys for the user(s)
• Register the user and associate a certificate
(for SOAP).
• Provide compute offering that matches the
name of Amazon instance types (e.g
m1.small…)
• Setup environment variables (e.g $EC2_URL)
4. Enabling EC2 and S3
• Via the GUI
• Via API call on integration API port 8096
http://localhost:8096/client/api?
command=updateConfiguration&name=enable.s3.api&value=true
http://localhost:8096/client/api?
command=updateConfiguration&name=enable.ec2.api&value=true
5. Enabling EC2 and S3
• Via an authenticated API call on port 8080 (e.g
using a Python client)
apiurl = 'http://localhost:8080/client/api’
cloudstack = CloudStack.Client(apiurl,apikey,secretkey)
cloudstack.updateConfiguration
({‘name’:’enable.ec2.api’,’value’:’true’})
7. Generate Keys
• Via the API:
http://localhost:8096/client/api?
command=registerUserKeys&id=<id of
the user>
8. Register the user
• Get the script from the source at
/path/to/source/awsapi-
setup/setup/cloudstack-aws-api-
register
cloud-bridge-register --apikey=<User’s Cloudstack API key>
--secretkey=<User’s CloudStack Secret key>
--cert=</path/to/cert.pem> --url=http://<cloudstack-server-
ip>:8080/awsapi
10. Setup shell environment
• export EC2_PRIVATE_KEY=</path/to/userkey.pem>
• export EC2_CERT=</path/to/cert.pem>
• export EC2_URL=http://<cloudstack-server->:8080/awsapi
• export AWS_ACCESS_KEY_ID=J8HFx6wHYl_qTvMcSA3fe3ZugR-
gcy3ldZ21wPezwbj9Cy1-bnlhdsBAS0JcYrZ8vw3ra-gsu4-Ke_uH1rKTKQ
• export AWS_SECRET_KEY_ID=NzS9akD_8TzYWJsv-
x6QXIg6M4pzWlhp6EFMbY34Ue0D9WA64yZ7qmHhbkut5o6GpG8CNZ8LRtNgiL_M
Whij3w
• Get the ec2 commands binaries for api version
2010-11-15
• You are now ready to use the ec2-*
commands
11. EC2 Boto example 1/2
• Specify the region:
region = boto.ec2.regioninfo.RegionInfo
(name="ROOT",endpoint=”<cloudstack-server-ip>")
• Establish a connection:
conn =boto.connect_ec2(aws_access_key_id=apikey,
aws_secret_access_key=secretkey,
is_secure=False,
region=region,
port=8080,
path="/awsapi",
api_version="2010-11-15")
Note the API version, expect to see support for a
newer API soon. Contributions welcome
12. EC2 Boto example 2/2
• Find your image and start it:
images = conn.get_all_images()
myimage = images[0]
'''Pick an instance type present in your compute
offering''’
vm_type='m1.small'
reservation = myimage.run
(instance_type=vm_type,security_groups=['default']
)
13. • Join the discussion on the future of the EC2/S3
compatibility of CloudStack
cloudstack-dev@incubator.apache.org
#cloudstack on irc.freenode.net
@CloudStack on Twitter