Creating an Atmos subtenant in ECS

In order to connect to ECS through the Atmos protocol, you will first need to create a subtenant.  To do this, you will need to use the new "create subtenant" operation in the Atmos protocol.  This is implemented by issuing a PUT to /rest/subtenant.  When issuing this request, your x-emc-uid will be your ECS user (e.g. and you will use your ECS secret key.  Additionally, You can optionally specify subtenantid of the new Atmos subtenant to be created.  In the response, you will get a "subtenantID" response header with your new subtenant ID.


For example:


PUT /rest/subtenant HTTP/1.1
Date: Thu, 26 Sep 2013 21:16:59 UTC
x-emc-date: Thu, 26 Sep 2013 21:16:59 UTC
x-emc-signature: QJ+yHaB4u/78bMDF3tCZnRsFmDQ=
Content-Length: 0
Connection: Keep-Alive
User-Agent: Apache-HttpClient/4.2.1 (java 1.5)

HTTP/1.1 204 No Content
subtenantID: 5cc597535ed747f09b5d273154216339
Server: Jetty(7.6.4.v20120524)


You can also set optional subtenantid for new subtenant to be created via x-emc-subtenant-id header in request

x-emc-subtenant-id: 43bbfd19e2434e9d84249955ae245e8f

After you've created your subtenant, you can use it to access Atmos as normal.  Your x-emc-uid will be the subtenant ID concatenated to your user ID with a "/".  In this case, the new x-emc-uid would be 5cc597535ed747f09b5d273154216339/


The latest version of the ECS Java SDK also supports the new createSubtenant command.  In this case, you will

            AtmosConfig config = new AtmosConfig(user, secretKey, new URI("http://" + dataNode + ":9022/"));
            AtmosApi atmos = new AtmosApiClient(config);
            ServiceInformation si = atmos.getServiceInformation();
            CreateSubtenantRequest req = new CreateSubtenantRequest();
            // it's optional to set subtenantid 
            // req.setCustomSubtenantId("a1b21dd07f3d4b0581425282c8e08738");
            String subtenantId = atmos.createSubtenant(req);

After creating your subtenant, you will then recreate your AtmosConfig with the subtenantId, e.g.

            AtmosConfig config = new AtmosConfig(subtenantId + "/" + user, secretKey, new URI("http://" + dataNode + ":9022/"));
            AtmosApi atmos = new AtmosApiClient(config);
            ServiceInformation si = atmos.getServiceInformation();



Note that like the create bucket operation in S3 and the create container operation in Swift, there is an optional header you can pass with the request: x-emc-vpool.  This header allows you to set the Replication Group to use instead of the default defined on the namespace.  When setting this header, you will use the URN identifier of the Replication Group, not the name.


If you're not using Java, you can also use the following (also attached) shell script to create the subtenant:


# Set up uid, key, and endpoint
uid="<your user@domain>"
key="<your secret key>"
# leave blank to generate a new subtenantid or name subtenantid as you wish
subtenantid="<your subtenantid on atmos>"

# Build and send the Atmos request
date=`date -u +"%a, %d %b %Y %H:%M:%S GMT"`

if [ ! -z "$subtenantid" ]; then
sig=$(python -c "import base64, hmac, sha; print base64.b64encode(\"$key\"), \"$signstr\", sha).digest())")

if [ ! -z "$subtidheader" ]; then
    curl -v -i -X PUT -H "Content-Type:$contentType" -H "x-emc-date:$date" -H "$subtidheader" -H "x-emc-uid:$uid" -H "x-emc-signature:$sig" ${endpoint}${atmos_path}
    curl -v -i -X PUT -H "Content-Type:$contentType" -H "x-emc-date:$date" -H "x-emc-uid:$uid" -H "x-emc-signature:$sig" ${endpoint}${atmos_path}