Download - CloudStack EC2 Configuration

Transcript
Page 1: CloudStack EC2 Configuration

CloudStack EC2 configuration

Sebastien GoasguenAugust 14th

Page 2: CloudStack EC2 Configuration

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

Page 3: CloudStack EC2 Configuration

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)

Page 4: CloudStack EC2 Configuration

Enabling EC2 and S3

• Via the GUI

• Via API call on integration API port 8096http://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

Page 5: CloudStack EC2 Configuration

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’})

Page 6: CloudStack EC2 Configuration

Generate Keys

• Via the GUI

Page 7: CloudStack EC2 Configuration

Generate Keys

• Via the API:http://localhost:8096/client/api?command=registerUserKeys&id=<id of the user>

Page 8: CloudStack EC2 Configuration

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

Page 9: CloudStack EC2 Configuration

Provide “Amazon” instance types• You can rename using the API, but the easiest

is to go via the GUI

Page 10: CloudStack EC2 Configuration

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_MWhij3w

• Get the ec2 commands binaries for api version 2010-11-15

• You are now ready to use the ec2-* commands

Page 11: CloudStack EC2 Configuration

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

Page 12: CloudStack EC2 Configuration

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'])

Page 13: CloudStack EC2 Configuration

• Join the discussion on the future of the EC2/S3 compatibility of CloudStack

[email protected]#cloudstack on irc.freenode.net@CloudStack on Twitter