...
Deployment - Solution to be installable via a self contained virtual system server within a CloudStack management server.
The S3 API is an optional Technology Preview solution which may be enabled at user discretion.
...
Ability to process requests for the services listed above using the documented HTTP requests formats and undertake the CRUD actions implied by those requests
Ability to process the correct controls, viz holding the public-private key pair of the user, preserving granter-grantee relationships for bucket or object resources, managing ACLs.
Ability to provide responses, including XML response bodies where necessary, which are sufficiently accurate to follow the Amazon S3 spec.
Provide a robust implementation for holding the operational metadata, together with an Object-Model mapping of this. Also allow the XML content of the web service request to include large binary stream content via optimised transmission (MTOM), supported by the Apache AXIOM library employing pull parsing. This list of critical capabilities has already been developed in 2011.
To allow the above to be configurable to the resources, especially simple storage resources, at a given cloud management installation.
No SOAP - SOAP API will be deprecated in the S3 translation layer: resulting in an explanatory message and a 501.
No internationalization - Messages returned in responses available in (American) English only, identical to those in amazonaws wherever possible.
No regions – The Amazon AWS S3 provision for geographic regions, plus additionally a default ‘US Standard’ pan-regional option, will not be present in this design. Consequently when a location constraint is processed it will be ignored and, if created, will be empty by default.
The list of supported operations will not be fully coextensive with those at s3.amazonaws.com at this release. A list of Amazon S3 operations which are not supported within the current release are as follows.
...
Lexical rules for hosts and buckets are to be strict DNS compatible naming, i.e. not relaxed to allow mixed case or underscores. The latter is allowed by AWS console creation in the case of the ‘US Standard’ pan-regional option but is not adopted in this solution because it has no cross-region portability.
Supposing the S3 API Technology Preview solution is to be enabled at user discretion, then there are some possible debugging steps.
...
Developers who wish to run the S3 API stack inside eclipse may take advantage of remote application debugging. To do this run the JPDA configuration of the tomcat application, e.g. $CATALINA_HOME/bin/catalina.sh jpda start. If the defaults have been accepted this will run a debug version of the application on port 8787 and a Remote Application listener can be configured on the application at port 8000 (by default) so as to step through chosen Java components. Both the Helios and Indigo releases of eclipse are suitable choices for running this debug activity.
Enable the S3 API by setting the flag enable.s3.api to 'true' in the configuration table. This can be done via the UI or directly in MySQL:
...
./cloudstack-aws-api-register -u http://localhost:8080/awsapi/rest/AmazonS3 -a MyAccessIDKey -s MySecretKey openssl_generated.mycert.pem
The capabilities of the S3 API are intended to satisfy the following use cases. For an overview of the expected capabilities, see docs.amazonwebservices.com/AmazonS3/latest/API/APIRest.htm.
*List All Buckets,
Example using the simplest GET request, http://myhost:8080/awsapi/rest/AmazonS3
Specified at docs.amazonwebservices.com/AmazonS3/latest/API/RESTServiceGET.htm
*GET Bucket's Objects,
Example using GET http://myhost:8080/awsapi/rest/AmazonS3/mybucket1
Specified at docs.amazonwebservices.com/AmazonS3/latest/API/RESTBucketGET.htm
*GET a Bucket
Example using GET http://myhost:8080/awsapi/rest/AmazonS3/mybucket1?max-keys=10
Specified at docs.amazonwebservices.com/AmazonS3/latest/API/RESTServiceGET.htm
*GET Bucket acl,
Example using GET http://myhost:8080/awsapi/rest/AmazonS3/mybucket1/?acl
Specified at docs.amazonwebservices.com/AmazonS3/latest/API/RESTBucketGETacl.html
*List a Bucket's versions,
Example using HEAD http://myhost:8080/awsapi/rest/AmazonS3/mybucket3/?versions&max-keys=999
Specified at docs.amazonwebservices.com/AmazonS3/latest/API/RESTBucketGETVersion.html
*GET Bucket versioning status,
Example using GET http://myhost:8080/awsapi/rest/AmazonS3/mybucket1/?versioning
Specified at docs.amazonwebservices.com/AmazonS3/latest/API/RESTBucketGETversioningStatus.html
*Retrieve a Bucket's metadata,
Example using HEAD http://myhost:8080/awsapi/rest/AmazonS3/mybucket1/?keyname3
Specified at docs.amazonwebservices.com/AmazonS3/latest/API/RESTBucketHEAD.html
*List Multipart Uploads,
Example using GET http://myhost:8080/awsapi/rest/AmazonS3/mybucket1/my_upload_1?uploadId=6
Specified at docs.amazonwebservices.com/AmazonS3/latest/API/mpUploadListParts.html
*PUT Bucket,
Example using PUT http://myhost:8080/awsapi/rest/AmazonS3/mybucket1
Specified at docs.amazonwebservices.com/AmazonS3/latest/API/RESTBucketPUT.html
*PUT Bucket acl,
Example using PUT http://myhost:8080/awsapi/rest/AmazonS3/mybucket1/?acl
Specified at docs.amazonwebservices.com/AmazonS3/latest/API/RESTBucketPUTacl.html
*PUT Bucket versioning status,
Example using PUT http://myhost:8080/awsapi/rest/AmazonS3/mybucket2/?versioning
Specified at docs.amazonwebservices.com/AmazonS3/latest/API/RESTBucketPUTVersioningStatus.html
*DELETE Bucket,
Example using DELETE http://myhost:8080/awsapi/rest/AmazonS3/mybucket2
Specified at docs.amazonwebservices.com/AmazonS3/latest/API/RESTBucketDELETE.html
*GET a Bucket's Objects,
Example using GET http://myhost:8080/awsapi/rest/AmazonS3/mybucket1
Specified at docs.amazonwebservices.com/AmazonS3/latest/API/RESTBucketGET.htm
*GET an Object from a Bucket,
Example using GET http:/myhost:8080/awsapi/rest/AmazonS3/mybucket2/keyname1
Specified at docs.amazonwebservices.com/AmazonS3/latest/API/RESTObjectGET.html
*GET Object acl,
Example using GET http://myhost:8080./awsapi/rest/AmazonS3/mybucket1/?acl
Specified at docs.amazonwebservices.com/AmazonS3/latest/API/RESTBucketGETacl.html
*PUT an Object into a Bucket,
Example using PUT http://myhost:8080/awsapi/rest/AmazonS3/mybucket2/keyname1
Specified at docs.amazonwebservices.com/AmazonS3/latest/API/RESTObjectPUT.html
*POST a file Object into a Bucket,
Example using example HTML forms to send, POST http://myhost:8080/awsapi/rest/AmazonS3
Specified at docs.amazonwebservices.com/AmazonS3/latest/API/RESTObjectPOST.html
*PUT Object acl,
Example using PUT http://myhost:8080/awsapi/rest/AmazonS3/mybucket4/thirdk4?acl
Specified at docs.amazonwebservices.com/AmazonS3/latest/API/RESTObjectPUTacl.html
*Initiate Multipart Upload,
Example using POST http://myhost:8080/awsapi/rest/AmazonS3/mybucket1/my_upload_1?uploads
Specified at docs.amazonwebservices.com/AmazonS3/latest/API/mpUploadInitiate.html
*Upload Part,
Example using PUT http://myhost:8080/awsapi/rest/AmazonS3/mybucket1/my_upload_1?uploadId=6&partNumber=1
Specified at docs.amazonwebservices.com/AmazonS3/latest/API/mpUploadUploadPart.html
*Complete Multipart Upload,
Example using POST http://myhost:8080/awsapi/rest/AmazonS3/mybucket1/my_upload_1?uploadId=6
Specified at docs.amazonwebservices.com/AmazonS3/latest/API/mpUploadComplete.html
*Abort Multipart Upload,
Example using DELETE http://myhost:8080/awsapi/rest/AmazonS3/mybucket1/my_upload_1?uploadId=6
Specified at docs.amazonwebservices.com/AmazonS3/latest/API/mpUploadAbort.html
*List Parts for Upload,
Example using GET http://myhost:8080/awsapi/rest/AmazonS3/mybucket1/my_upload_1?uploadId=6
Specified at docs.amazonwebservices.com/AmazonS3/latest/API/mpUploadListParts.html
*DELETE Object,
Example using DELETE http://myhost:8080/awsapi/rest/AmazonS3/mybucket1/?key_name_01
Specified at docs.amazonwebservices.com/AmazonS3/latest/API/RESTObjectDELETE.html
*Delete Multiple Objects in one command,
Example using POST http://myhost:8080/awsapi/rest/AmazonS3/mybucket3/?delete
Specified at aws.amazon.com/releasenotes/Amazon-S3/7816383882128829
*Copy an Object between Buckets,
Example using PUT http://myhost:8080/awsapi/rest/AmazonS3/mybucket2/key_k1b1
Specified at docs.amazonwebservices.com/AmazonS3/latest/API/RESTObjectCopy.html
The design establishes an Axis2 webservice acting as a REST servlet, taking lawful HTTP requests such as those validated by the tools discussed previously and providing the HTTP response in accordance with doc.s3.amazonaws.com/2006-03-01/.
...
The lawful use of the storage service is governed by the status of each incoming request and certain business logic steps governed by access control and also granter-grantee rights are implemented as part of the actions on S3 Buckets and S3 Objects. Unlawful requests result in a REST error response. Unimplemented functions result in a form of REST error response indicating that it is a service limitation.
The use of the 14 database tables is critical to the design.
...
A user such as cloud, password cloud, shall be given all read-write privileges at deployment time. See also Appendix 1.
The design imposes a service lifecycle in which
The #The incoming request is interpreted.
The #The authentication of the request is appended to it.
The #The service which processes the request provides a response.
The #The informational response is returned if successful or an error response provided otherwise, in accordance with http://docs.amazonwebservices.com/AmazonS3/latest/dev/UsingRESTError.html.
To validate the request data structure (termed the canonical string) the following rules are enforced by the design:
List #List 4 properties of the request delimited by \n: HTTP verb, MD5 hash of uploaded data, content type of uploaded data, datetimestamp for request might be time request will expire. All except MD5 hash are mandatory. Datetimestamp has to be Rfc2616 compliant indicating the ISO 8601 format.
Add #Add x-amz- headers to description in alpha order, converting to lowercase.
Add #Add path component of URI without any parameters.
Include #Include query parameters iff they are mandatory to identify the resource: specifically acl, torrent, logging and location.
In processing the URI, three formats can be distinguished:
uri #uri including default service hostname, with bucket name and object name (if any) in path
uri #uri with bucket name prepended the service hostname, i.e. subdomain style
uri #uri with virtual hostname matching bucket name, providing that the bucket name is a DNS entry providing a CNAME for the entry as if it were a subdomain.
In the current implementation of the solution we are concentrating on the first two of these.
The processing of buckets and objects is critically dependent on rights ascribed the requester via ACLs. By default every resource has an ACL: associated at create or update time. The default ACL marks the resources as private, i.e. owner has full control. ACL can be updated by owner. Each ACL can attach 100 grant rules.
A grant rule defines a grantee with specific permission value. There are canned ACLs to make the rules easier. An ACL document provides a user or group grantee type with canonical string descriptions. Groups are pre-established organizational units: public, any account holder, bucket access loggers, identified by xsi: type. Five types of permission may be granted: READ, WRITE, READ_ACP, WRITE_ACP, FULL_CONTROL.
Code packaging - Currently the code is organized into a package tree rooted in the cloud.com overall package. It is organized into subdivisions of cloud.com.bridge packages, to distinguish these packages from com.cloud.stack related ones.
The main subdivisions are
lifecycle - controls the start and stop of Axis2
auth - map a client signature to a valid user credential, looked up by an instance of type UserCredentialDao
service - the key definitions for interacting with REST requests and providing their responses
io - helper classes concerned with the intimate details of file, input, output and streaming behaviour and its processing in memory
until - other helper classes, defining and manipulating object structures to be used by the services
model - the classes which the services instantiate to get S3 operation metadata: the master and slave hosts in use, the acls created, the user credentials registered, the representations of buckets and their objects together with user-generated metadata and object items during assembly via multipart upload
persist - the lookup of attributes from the MySQL database tables mentioned above, using the hibernate ORM framework
...
A hibernate layer coordinates between the business logic executed in the rest servlet and the SQL definitions in the MySQL database. See also Appendix 2.
Get #Get CloudStack running on the latest 3.0.x series
Enable #Enable the S3 API by setting the flag enable.s3.api to 'true' in the configuration table. This can be done through the UI or directly in MySQL:
update configuration set value='true' where name='enable.s3.api';
Choose #Choose a local filesystem path where the objects will be stored. We can mount an NFS store or use the local filesystem. E.g,:
*mkdir -p /mnt/s3
*Ensure that the 'cloud' user can write to this directory
Edit #Edit the file $TOMCAT_HOME/conf/cloud-bridge.properties:
host=http://localhost:8080/awsapi
storage.multipartDir=_multipartuploads_
bucket.dns=false
storage.root=<mount point or filesystem path>
serviceEndpoint=localhost:8080
Restart #Restart CloudStack.
Obtain #Obtain API and secret keys for a user (available in the Admin ui under Accounts -> Users)
*CloudStack Api key = this is the same as the AWS access key id
*CloudStack Secret key = this is the same as the AWS secret access key
Generate #Generate a private key and a self-signed X.509 certificate. Substitute your own desired storage location for /path/to/… below.
*$ openssl req -x509 -nodes -days 365 -newkey rsa:2048 <http://rsa:2048/> -keyout /path/to/private_key.pem -out /path/to/cert.pem
Register #Register the mapping from the X.509 certificate to your accounts API keys with CloudStack.
*$ cloudstack-aws-api-register --apikey=<User’s Cloudstack API key> --secretkey=<User’s CloudStack Secret key> --cert=</path/to/cert.pem> --url=http://<cloudstack-server>:8080/awsapi/rest/AmazonS3
Configure #Configure the boto S3Connection object as follows:
...
connection = S3Connection(aws_access_key_id=<your api key>,
aws_secret_access_key=<your secret key>
is_secure=False,
host='<cloudstack-server>',
port=7080,
calling_format=calling_format,
path="/awsapi/rest/AmazonS3")
CLOUDBRIDGE data definitions
acl
------------------------------------------------------------+
...
------------------------------------------------------+
OR mapping definitions
Appendix2-S3-FS -2012-04-04.pdf