We use proprietary and third party's cookies to improve your experience and our services, identifying your Internet Browsing preferences on our website; develop analytic activities and display advertising based on your preferences. If you keep browsing, you accept its use. You can get more information on our Cookie Policy
Cookies Policy
Object Storage - User and Programmers Guide (CDMI) - FIWARE Forge Wiki

Object Storage - User and Programmers Guide (CDMI)

From FIWARE Forge Wiki

Jump to: navigation, search

**Please note that the recommended API for accessing the Object Storage GE will transition from CDMI to the native OpenStack Swift API in the coming weeks - May 2015. It is planned that the CDMI interface will then be deprecated for the Object Storage GE.**


Contents

Introduction

Welcome to the User and Programmer Guide for the Object Storage Generic Enabler. This generic enabler is built on an Open Source project, the CDMI API for OpenStack, and so where possible this guide points to the appropriate online content that has been created for this project. The online documents are being continuously updated and improved, and so will be the most appropriate place to get the most up to date information on installation and administration.

Background and Detail

This User and Programmers Guide relates to the Object Storage GE which is part of the Cloud Hosting chapter. Please find more information about this Generic Enabler in the following Open Specification.

User Guide

The Object Storage Generic Enabler is a back-end component that provides object storage capabilities which software developers can incorporate into their applications. It is not designed for direct manipulation by end users. However, as this generic enabler is built on top of OpenStack Swift, the OpenStack Horizon user interface can also be used to manipulate the Object Storage system. Detailed Horizon user interface instructions are outside the scope of this generic enabler, but comprehensive OpenStack documentation is available online[1].

Programmer Guide

Introduction

The Object Storage Generic Enabler exposes Object Storage functionality via a standard API: CDMI.

The complete CDMI specification is freely available online from the Storage Networking Industry Association (SNIA)[2].

CDMI is a RESTful API and so just like OCCI it is built on well-known HTTP operations such as PUT, POST, GET and DELETE. For example, to retrieve a data object from a CDMI container a simple HTTP GET command is used.

For example, the following request:

GET /MyContainer/MyDataObject.txt HTTP/1.1
Host: cloud.example.com
Accept: application/cdmi-object
X-CDMI-Specification-Version: 1.0.1
X-Auth-Token: 0cc2bab32f3246919c2d2cbea314d850

will generally return a response similar to:

HTTP/1.1 200 OK
X-CDMI-Specification-Version: 1.0.1
Content-Type: application/cdmi-object
{
    "objectType" : "application/cdmi-object",
    "objectID" : "0000706D0010B84FAD185C425D8B537E",
    "objectName" : "MyDataObject.txt",
    "parentURI" : "/MyContainer/",
    "parentID" : "00007E7F00102E230ED82694DAA975D2", 
    "domainURI" : "/cdmi_domains/MyDomain/",
    "capabilitiesURI" : "/cdmi_capabilities/dataobject/",
    "completionStatus" : "Complete",
    "mimetype" : "text/plain",
    "metadata" : {
        "cdmi_size" : "37" 
    },
    "valuerange" : "0-36",
    "valuetransferencoding" : "utf-8",
    "value" : "This is the Value of this Data Object"
}

In this case the CDMI specific media-types are used. Others can be used too if the HTTP mime-types are used appropriately.

HTTP commands can be constructed and sent from all modern programming languages. They can also be invoked using a command line utility such as curl[3].

Authentication

A valid token is required to access an object store. This section describes how to get a valid token assuming an identity management system compatible with OpenStack Keystone is being used. If the username, password and tenant details are known, only step 3 is required. If only the username and password are known then all three steps must be executed in order.

The examples in this section point to the identity management system on the FI-LAB infrastructure.

1. Authentication to get initial token

The response to the following command includes an initial token.

curl -d '{"auth": {"passwordCredentials": {"username":"email@company.com", "password":"mypassword"}}}' \
    -H 'Content-type: aplication/json' \
    http://cloud.lab.fi-ware.org:4730/v2.0/tokens \
    -vvv

The following bash script illustrates how the initial token can be retrieved and stored in a variable $token1.

username='email@company.com'
password='mypassword'
curl -d '{"auth": {"passwordCredentials": {"username":"'$username'", "password":"'$password'"}}}' \
    -H 'Content-type: aplication/json' \
    http://cloud.lab.fi-ware.org:4730/v2.0/tokens \
    > auth_token1.dat
token1=$(awk -F"[,:]" '{for(i=1;i<=NF;i++)
                       {if($i~/id\042/)
                         {print $(i+1)} 
                       }
                     }' auth_token1.dat | awk -F'"' '{print $2; exit}')

In python this can be achieved as follows.

   import httplib
   import json
   username='email@company.com'
   password='mypassword'
   conn = httplib.HTTPConnection('cloud.lab.fi-ware.org:4730')
   headers = {'Content-Type': 'application/json'}
   body = '{"auth": {"passwordCredentials":{"username": "'+username+'", "password": "'+password+'"}}}'
   conn.request("POST", "/v2.0/tokens", body, headers)
   response = conn.getresponse()
   data = response.read()
   datajson = json.loads(data)
   token1 = datajson['access']['token']['id']

2. Use initial token to get tenant

The response to the following command includes tenant details.

curl -H 'x-auth-token: KUcmesWXA0QfEFf1Vb4AoCdx8ZBS9YzKQiqaCRUHNrxWNYKtqgtyeLEGdstjlXyxFqx_4WbkjFZ3tw9_8_KlZA' \
    http://cloud.lab.fi-ware.org:4730/v2.0/tenants \
    -vvv

The following bash script illustrates how the tenant details can be retrieved and stored in a variable $tenantName. The script assumes a variable $token1 includes a valid token - as per step one.

curl -H 'x-auth-token: '$token1 \
      http://cloud.lab.fi-ware.org:4730/v2.0/tenants \
      > auth_tenant.dat
tenantName=$(awk -F"[,:]" '{for(i=1;i<=NF;i++)
                       {if($i~/id\042/)
                         {print $(i+1)} 
                       }
                     }' auth_tenant.dat | awk -F'"' '{print $2; exit}')

In python this can be achieved as follows. The code assumes token1 includes a valid token - as per step one.

   headers = {'x-auth-token': token1}
   conn.request("GET", "/v2.0/tenants", None, headers)
   response = conn.getresponse()
   data = response.read()
   datajson = json.loads(data)
   tenant = datajson['tenants'][0]['id']

3. Authenticate tenant to get token for Object Storage

The response to the following command includes the token to access the object store, and the string necessary to refer to the users object storage space.

curl -d '{"auth": {"passwordCredentials": {"username":"email@company.com", "password":"mypassword"},"tenantName":"00000000000000000000000000000150"}}' \
    -H 'Content-type: aplication/json' \
    http://cloud.lab.fi-ware.org:4730/v2.0/tokens \
    -vvv

The following bash script illustrates how the required token and auth string can be retrieved and stored in a variables $token and $auth. The script assumes variables $username, $password and $tenantName have been initialized as per step one and two.

curl -v \
    -d '{ "auth" : 
          { "passwordCredentials" : 
            { "username" : "'$username'" , "password" : "'$password'" },
          "tenantName" : "'$tenantName'" } 
        }' \
    -H "Content-Type: application/json" \
     http://cloud.lab.fi-ware.org:4730/v2.0/tokens \
     > auth_token2.dat
token=$(awk -F"[,:]" '{for(i=1;i<=NF;i++)
                       {if($i~/id\042/)
                         {print $(i+1)} 
                       }
                     }' auth_token2.dat | awk -F'"' '{print $2; exit}')
auth=$(awk -F"[,:]" '{for(i=1;i<=NF;i++)
                      {if($i~/publicURL\042/)
                        {print $(i+3)}
                      }
                    }' auth_token2.dat | \
  grep  "v1/AUTH" | awk -F'"}]' '{print $1;}' | awk -F"/" '{print $3;}' )

In python this can be achieved as follows. The code assumes tenant is a valid tenant - as per step two.

   headers = {'Content-Type': 'application/json'}
   body = '{"auth": {"tenantName": "'+tenant+'", "passwordCredentials":{"username": "'+username+'", "password": "'+password+'"}}}'
   conn.request("POST", "/v2.0/tokens", body, headers)
   response = conn.getresponse()
   data = response.read()
   datajson = json.loads(data)
   token = datajson['access']['token']['id']
   for i in auth_reponse['access']['serviceCatalog']:
       if i['name'] == 'swift':
           auth_url = i['endpoints'][0]['publicURL']
           break
   auth = auth_url[auth_url.find("AUTH_"):]

Programming against CDMI

The CDMI interface is built upon the HTTP protocol and so can be manipulated by any programming language that can manipulate HTTP calls.

Once authenticated, the various CDMI commands as defined in the CDMI specification can be invoked. For example, the following Python code illustrates how to create a container:

   conn = httplib.HTTPConnection('130.206.82.9:8080')
   headers = {"X-Auth-Token": token,
              "Content-Type": "application/cdmi-container",
              "Accept": "application/cdmi-container",
              "X-CDMI-Specification-Version": "1.0.1"}
   conn.request('PUT', "/cdmi/" +  auth + "/ContainerName/", None, headers)
   response = conn.getresponse()
   result = "Status: " + str(response.status) + ", Reason: " + response.reason + ", Body: " +  response.read()	
   conn.close()

Example Python

The following python illustrates some basic operations against object storage.

#!/usr/bin/env python
'''
Example python to authenticate against an object store, create a new container, store text object, retrieve it, delete object, delete container.
'''
 
import httplib
import json
import sys
import time
import os
import logging
 
# Init a simple logger...
logging.basicConfig(level=logging.INFO)
console = logging.StreamHandler()
console.setLevel(logging.DEBUG)
logger = logging.getLogger()
logger.addHandler(console)
 
# hosts
HOST_AUTH = 'cloud.lab.fi-ware.org:4730'
HOST_CDMI = '130.206.82.9:8080'
 
TEST_CONTAINER_NAME = 'TestContainerPython'
TEST_OBJECT_NAME = 'TestObjectPython.txt'
TEST_TEXT = 'Hello CDMI World'
 
def authentication_request(username, password):
    '''
    Request authentication of user
    '''
    conn = httplib.HTTPConnection(HOST_AUTH)
 
    # retrieve initial token
    headers = {'Content-Type': 'application/json'}
    body = '{"auth": {"passwordCredentials":{"username": "'+username+'", "password": "'+password+'"}}}'
    conn.request("POST", "/v2.0/tokens", body, headers)
    response = conn.getresponse()
    data = response.read()
    datajson = json.loads(data)
    initialtoken = datajson['access']['token']['id']
 
    logger.info('Initial Token is: ' + initialtoken)
 
    # retrieve tenant
    headers = {'x-auth-token': initialtoken}
    conn.request("GET", "/v2.0/tenants", None, headers)
    response = conn.getresponse()
    data = response.read()
    datajson = json.loads(data)
    tenant = datajson['tenants'][0]['id']
 
    logger.info('Tenant is: ' + tenant)
 
    # retrieve authentication json
    headers = {'Content-Type': 'application/json'}
    body = '{"auth": {"tenantName": "'+tenant+'", "passwordCredentials":{"username": "'+username+'", "password": "'+password+'"}}}'
    conn.request("POST", "/v2.0/tokens", body, headers)
    response = conn.getresponse()
    data = response.read()
 
    return json.loads(data)
 
 
def cdmi_request(verb, resource, headers, body):
    '''
    Do a HTTP request defined by HTTP verb, a Url, a dict of headers and a body.
    '''
    conn = httplib.HTTPConnection(HOST_CDMI)
    conn.request(verb, "/cdmi/" + resource, body, headers)
    response = conn.getresponse()
 
    if response.status not in [200, 201, 202, 204]:
        logger.error(response.reason)
        logger.warn(response.read())
        sys.exit(1)
 
    result = "Status: " + str(response.status) + ", Reason: " + response.reason + ", Body: " +  response.read()	
 
    conn.close()
 
    return result
 
 
def check_capabilities(token, auth):
    headers = {"X-Auth-Token": token,
               "Accept": "application/cdmi-capability",
               "X-CDMI-Specification-Version": "1.0.1"}
    body = None
    url = auth + "/cdmi_capabilities/"
 
    return cdmi_request('GET', url, headers, body)
 
 
def create_container(token, auth, name):
    headers = {"X-Auth-Token": token,
               "Content-Type": "application/cdmi-container",
               "Accept": "application/cdmi-container",
               "X-CDMI-Specification-Version": "1.0.1"}
    body = None
    url = auth + "/" + name + "/"
 
    return cdmi_request('PUT', url, headers, body)
 
 
def list_container(token, auth, name):
    headers = {"X-Auth-Token": token,
               "Content-Type": "application/cdmi-container",
               "Accept": "*/*",
               "X-CDMI-Specification-Version": "1.0.1"}
    body = None
    url = auth + "/" + name + "/"
 
    return cdmi_request('GET', url, headers, body)
 
 
def store_text(token, auth, container_name, object_name, object_text):
    headers = {"X-Auth-Token": token,
               "Content-Type": "application/cdmi-object",
               "Accept": "application/cdmi-object",
               "X-CDMI-Specification-Version": "1.0.1"}
    body = '{"mimetype":"text/plain", "metadata":{}, "value" : "' + object_text + '"}'
    url = auth + "/" + container_name + "/" + object_name
 
    return cdmi_request('PUT', url, headers, body)
 
 
def retrieve_text(token, auth, container_name, object_name):
    headers = {"X-Auth-Token": token,
               "Content-Type": "application/cdmi-object",
               "Accept": "*/*",
               "X-CDMI-Specification-Version": "1.0.1"}
    body = None
    url = auth + "/" + container_name + "/" + object_name
 
    return cdmi_request('GET', url, headers, body)
 
 
def delete_object(token, auth, container_name, object_name):
    headers = {"X-Auth-Token": token,
               "Content-Type": "application/cdmi-object",
               "X-CDMI-Specification-Version": "1.0.1"}
    body = None
    url = auth + "/" + container_name + "/" + object_name
 
    return cdmi_request('DELETE', url, headers, body)
 
 
def delete_container(token, auth, container_name):
    headers = {"X-Auth-Token": token,
               "Content-Type": "application/cdmi-container",
               "X-CDMI-Specification-Version": "1.0.1"}
    body = None
    url = auth + "/" + container_name
 
    return cdmi_request('DELETE', url, headers, body)
 
 
if __name__ == '__main__':
    if len(sys.argv) < 3:
        print 'Usage: cdmi_demo.py <username> <password>'
        sys.exit(128)
 
    username = sys.argv[1]
    password = sys.argv[2]
 
    # display basic info
    logger.info('CDMI host is: ' + HOST_CDMI)
    logger.info('Authorisation host is: ' + HOST_AUTH)
 
    # get authentication response
    auth_reponse = authentication_request(username, password)
 
    # extract token
    token = auth_reponse['access']['token']['id']
    logger.info('Security token is: ' + token)
 
    # extract authentication string required for addressing users resources
    for i in auth_reponse['access']['serviceCatalog']:
	if i['name'] == 'swift':
		auth_url = i['endpoints'][0]['publicURL']
 		break
 
    auth = auth_url[auth_url.find("AUTH_"):]
    logger.info('Authentication string is: ' + auth)
 
    # perform some basic Object Store operations
 
    response = check_capabilities(token, auth)    
    logger.info('Object Store capabilties: ' + response)
 
    response = create_container(token, auth, TEST_CONTAINER_NAME)
    logger.info('Create Container Response: ' + response)
 
    response = list_container(token, auth, TEST_CONTAINER_NAME)
    logger.info('List Container Response: ' + response)
 
    response = store_text(token, auth, TEST_CONTAINER_NAME, TEST_OBJECT_NAME, TEST_TEXT)
    logger.info('Store Text Response: ' + response)
 
    response = list_container(token, auth, TEST_CONTAINER_NAME)
    logger.info('List Container Response: ' + response)
 
    response = retrieve_text(token, auth, TEST_CONTAINER_NAME, TEST_OBJECT_NAME)
    logger.info('Retrieve Text Response: ' + response)
 
    response = delete_object(token, auth, TEST_CONTAINER_NAME, TEST_OBJECT_NAME)
    logger.info('Delete Object Response: ' + response)
 
    response = list_container(token, auth, TEST_CONTAINER_NAME)
    logger.info('List Container Response: ' + response)
 
    response = delete_container(token, auth, TEST_CONTAINER_NAME)
    logger.info('Delete Container Response: ' + response)

Command Line Interface to CDMI

For ad-hoc manipulation of the Object Storage generic enabler the command line interface can be used. The curl tool available for many operating systems allows HTTP commands to be sent and received from the command line.

Individual Commands

The following examples in curl illustrate some basic object storage manipulation commands. The examples assume that three variables are assigned containing appropriate values for the IP address of the object storage CDMI interface, a valid object storage token, and the auth string to help construct the users object storage url. The token and auth variables are populated during the authentication process.

node_cdmi='130.206.82.9'
token='730ff2774823b49e3916ecaa59cd4640'
auth='AUTH_00000000000000000000000000000150'

List Capabilities of the Object Store

curl -v \
    -X GET \
    -H 'X-Auth-Token: '$token \
    -H 'Accept: application/cdmi-capability' \
    -H 'X-CDMI-Specification-Version: 1.0.1' \
     http://$node_cdmi:8080/cdmi/$auth/cdmi_capabilities/

Create a container

curl -v -X PUT \
    -H 'X-Auth-Token: '$token \
    -H 'Content-Type: application/cdmi-container' \
    -H 'Accept: application/cdmi-container' \
    -d '{"metadata": {}}' \
     http://$node_cdmi:8080/cdmi/$auth/mynewcontainer/

List capabilities of the container

curl -v \
    -X GET \
    -H 'X-Auth-Token: '$token \
    -H 'Accept: application/cdmi-capability' \
    -H 'X-CDMI-Specification-Version: 1.0.1' \
     http://$node_cdmi:8080/cdmi/$auth/cdmi_capabilities/container/mynewcontainer/ 

Store simple text in a container

curl -v -X PUT \
    -H 'X-Auth-Token: '$token \
    -H 'Accept: application/cdmi-object' \
    -H 'Content-Type: application/cdmi-object' \
    -d '{"mimetype":"text/plain", "metadata":{}, "value" : "Hello CDMI World"}' \
     http://$node_cdmi:8080/cdmi/$auth/mynewcontainer/mydata 

List contents of a container

curl -v \
    -X GET \
    -H 'X-Auth-Token: '$token \
    -H 'Content-Type: application/cdmi-container' \
    -H 'Accept: */*' \
    -H 'X-CDMI-Specification-Version: 1.0.1' \
     http://$node_cdmi:8080/cdmi/$auth/mynewcontainer/ 

Retrieve object from a container

curl -v \
    -X GET \
    -H 'X-Auth-Token: '$token \
    -H 'Accept: application/cdmi-object' \
    -H 'X-CDMI-Specification-Version: 1.0.1' \
     http://$node_cdmi:8080/cdmi/$auth/mynewcontainer/mydata 

Retrieve only the value of an object from a container

curl -v \
    -X GET \
    -H 'X-Auth-Token: '$token \
     http://$node_cdmi:8080/cdmi/$auth/mynewcontainer/mydata 

Delete an object from the object store

curl -v \
    -X DELETE \
    -H 'X-Auth-Token: '$token \
    -H 'Content-Type: application/cdmi-object' \
    -H 'X-CDMI-Specification-Version: 1.0.1' \
     http://$node_cdmi:8080/cdmi/$auth/mynewcontainer/mydata 

Store a file on the object store

myobject='CDMI_object_test_data.dat'
curl -v \
    -X PUT \
    -H 'X-Auth-Token: '$token \
    -H 'Content-Type: application/stream-octet' \
    -H 'Accept: */*' \
    --data-binary "@$myobject" \
    http://$node_cdmi:8080/cdmi/$auth/mynewcontainer/mybinaryobject

Retrieve file from object store

myobjectreceived='CDMI_object_test_data_received.dat'
curl -X GET \
    -H 'X-Auth-Token: '$token \
    http://$node_cdmi:8080/cdmi/$auth/mynewcontainer/mybinaryobject \
     --output $myobjectreceived

Example Script

The following bash script illustrates curl commands that authenticate and perform basic manipulation of the object store. It assumes there is a file called CDMI_object_test_data.dat in the local directory that contains some data to store.

#!/bin/bash
 #
 # Simple script to illustrate accessing CDMI using curl
 #
 # Basic flow is :
 #   Retrieve token
 #   Check container 'capabilities'
 #   Create a container, check it
 #   Put an object in the container, read it, delete it - simple data
 #   Put an object in the container, read it, delete it - user supplied data file
 #   Delete the container
 #
 # There are some pauses in case the user wants to check container using the web
 # portal
 #
 #
 #-------------------------------------------------------------------------------
 #
 #
 # Configuration settings
 #
 node_auth='cloud.lab.fi-ware.org'
 node_cdmi='130.206.82.9'     #Spain
 mycontainer=CDMI_TEST
 mydata='HelloWorld.txt'
 myobject='CDMI_object_test_data.dat'
 myobjectreceived='CDMI_object_test_data_received.dat'
 #
 # Prompt user for account details
 #
 read -p "Please enter your username (typically an email address): " username
 read -s -p "Please enter your password: " password
 #
 #
 # Initialisation check
 #
 echo " "
 echo " "
 if [ -f $myobject ]
 then
     echo "Initialisation check complete"   
 else
     echo "Please create a file " $myobject " containing some test content."
     exit
 fi
 #
 #
 # Note .. assume write access to local directory
 #
 # Get initial token for the username/password combination
 #
 echo " "
 echo " "
 curl -d '{"auth": {"passwordCredentials": {"username":"'$username'", "password":"'$password'"}}}' \
      -H 'Content-type: aplication/json' \
      http://$node_auth:4730/v2.0/tokens \
      > auth_token1.dat    
 #
 token1=$(awk -F"[,:]" '{for(i=1;i<=NF;i++)
                         {if($i~/id\042/)
                           {print $(i+1)}
                         }
                       }' auth_token1.dat | awk -F'"' '{print $2; exit}')
 #
 echo " "
 echo " "
 echo "Initial token: $token1"
 #
 # Now get a valid tenantName for this token
 #
 echo " "
 echo " "
 curl -H 'x-auth-token: '$token1 \
       http://$node_auth:4730/v2.0/tenants \
       > auth_tenant.dat
 #
 tenantName=$(awk -F"[,:]" '{for(i=1;i<=NF;i++)
                         {if($i~/id\042/)
                           {print $(i+1)}
                         }
                       }' auth_tenant.dat | awk -F'"' '{print $2; exit}')
 #
 echo " "
 echo " "
 echo "Tenant name: $tenantName"
 auth="AUTH_"
 auth+=$tenantName
 #
 # Now get valid token for user/password/tenant combination
 #
 echo " "
 echo " "
 curl -v \
      -d '{ "auth" :
            { "passwordCredentials" :
              { "username" : "'$username'" , "password" : "'$password'" },
            "tenantName" : "'$tenantName'" }
          }' \
      -H "Content-Type: application/json" \
      http://$node_auth:4730/v2.0/tokens \
      > auth_token2.dat
 #
 token=$(awk -F"[,:]" '{for(i=1;i<=NF;i++)
                        {if($i~/id\042/)
                          {print $(i+1)}
                        }
                      }' auth_token2.dat | awk -F'"' '{print $2; exit}')
 
 # Note that with the addition of json parsing the public URL could also be retrieved from
 # auth_token2.dat, but that would require extra dependencies and is out of scope for this example. 
 #
 # We need both token and auth for access to the CDMI proxy
 #
 echo " "
 echo " "
 echo "TOKEN is : $token"
 echo "AUTH is  : $auth"
 export token auth
 echo " "
 echo " "
 echo -n "Authentication phase complete. Press Enter to continue (or Ctrl-C to abort)."
 read
 echo " "
 echo " "
 #
 # Now use acquired info to enquire the cdmi capabilities
 #
 echo "*** Enquire CDMI Capabilities"
 curl -v \
     -X GET \
     -H 'X-Auth-Token: '$token \
     -H 'Accept: application/cdmi-capability' \
     -H 'X-CDMI-Specification-Version: 1.0.1' \
      http://$node_cdmi:8080/cdmi/$auth/cdmi_capabilities/
 #
 #
 echo " "
 echo " "
 echo "*** Create a new Container"
 curl -v -X PUT \
     -H 'X-Auth-Token: '$token \
     -H 'Content-Type: application/cdmi-container' \
     -H 'Accept: application/cdmi-container' \
     -d '{"metadata": {}}' \
      http://$node_cdmi:8080/cdmi/$auth/$mycontainer/
 #
 #
 echo " "
 echo " "
 echo "*** Check the 'capabilities' on the container"
 curl -v \
     -X GET \
     -H 'X-Auth-Token: '$token \
     -H 'Accept: application/cdmi-capability' \
     -H 'X-CDMI-Specification-Version: 1.0.1' \
      http://$node_cdmi:8080/cdmi/$auth/cdmi_capabilities/container/$mycontainer/
 #
 #
 echo " "
 echo " "
 echo "*** Place a Data Object in the container"
 curl -v -X PUT \
     -H 'X-Auth-Token: '$token \
     -H 'Accept: application/cdmi-object' \
     -H 'Content-Type: application/cdmi-object' \
     -d '{"mimetype":"text/plain", "metadata":{}, "value" : "Hello CDMI World"}' \
      http://$node_cdmi:8080/cdmi/$auth/$mycontainer/$mydata
 #
 #
 echo " "
 echo " "
 echo "*** List Contents of a container"
 curl -v \
     -X GET \
     -H 'X-Auth-Token: '$token \
     -H 'Content-Type: application/cdmi-container' \
     -H 'Accept: */*' \
     -H 'X-CDMI-Specification-Version: 1.0.1' \
      http://$node_cdmi:8080/cdmi/$auth/$mycontainer/
 #
 #
 echo " "
 echo " "
 echo -n "There should now be an object in the container. Press Enter to continue."
 read
 #
 #
 echo " "
 echo " "
 echo "*** Read Contents of Data Object"
 curl -v \
     -X GET \
     -H 'X-Auth-Token: '$token \
     -H 'Accept: application/cdmi-object' \
     -H 'X-CDMI-Specification-Version: 1.0.1' \
      http://$node_cdmi:8080/cdmi/$auth/$mycontainer/$mydata
 #
 #
 echo " "
 echo " "
 echo "*** Read only the Value of a Data Object"
 curl -v \
     -X GET \
     -H 'X-Auth-Token: '$token \
      http://$node_cdmi:8080/cdmi/$auth/$mycontainer/$mydata
 #
 #
 echo " "
 echo " "
 echo "*** Delete the Data Object"
 curl -v \
     -X DELETE \
     -H 'X-Auth-Token: '$token \
     -H 'Content-Type: application/cdmi-object' \
     -H 'X-CDMI-Specification-Version: 1.0.1' \
      http://$node_cdmi:8080/cdmi/$auth/$mycontainer/$mydata
 #
 #
 echo " "
 echo " "
 echo "*** List Contents of a container"
 curl -v \
     -X GET \
     -H 'X-Auth-Token: '$token \
     -H 'Content-Type: application/cdmi-container' \
     -H 'Accept: */*' \
     -H 'X-CDMI-Specification-Version: 1.0.1' \
      http://$node_cdmi:8080/cdmi/$auth/$mycontainer/
 #
 #
 echo " "
 echo " "
 echo -n "The container should now be empty. Press Enter to continue."
 read
 #
 #
 echo " "
 echo " "
 echo "*** Copy a file up to the Data Object"
 curl -v \
     -X PUT \
     -H 'X-Auth-Token: '$token \
     -H 'Content-Type: application/stream-octet' \
     -H 'Accept: */*' \
     --data-binary "@$myobject" \
     http://$node_cdmi:8080/cdmi/$auth/$mycontainer/$myobject
 #
 #
 echo " "
 echo " "
 echo "*** List Contents of a container"
 curl -v \
     -X GET \
     -H 'X-Auth-Token: '$token \
     -H 'Content-Type: application/cdmi-container' \
     -H 'Accept: */*' \
     -H 'X-CDMI-Specification-Version: 1.0.1' \
      http://$node_cdmi:8080/cdmi/$auth/$mycontainer/
 #
 #
 echo " "
 echo " "
 echo -n "There should now be an object in the container. Press Enter to continue."
 read
 #
 #
 echo " "
 echo " "
 echo "*** Read Data back from Data Object"
 curl -X GET \
     -H 'X-Auth-Token: '$token \
     http://$node_cdmi:8080/cdmi/$auth/$mycontainer/$myobject \
      --output $myobjectreceived
 #
 #
 echo " "
 echo " "
 echo "*** Delete the Data Object, tidy up"
 curl -v \
     -X DELETE \
     -H 'X-Auth-Token: '$token \
     -H 'Content-Type: application/cdmi-object' \
     -H 'X-CDMI-Specification-Version: 1.0.1' \
      http://$node_cdmi:8080/cdmi/$auth/$mycontainer/$myobject
 #
 #
 echo " "
 echo " "
 echo "*** Delete the Container, tidy up"
 curl -v \
     -X DELETE \
     -H 'X-Auth-Token: '$token \
     -H 'Content-Type: application/cdmi-object' \
     -H 'X-CDMI-Specification-Version: 1.0.1' \
      http://$node_cdmi:8080/cdmi/$auth/$mycontainer
 #
 #
 echo " "
 echo "*** Done"
 exit

References

  1. http://docs.openstack.org/developer/horizon/
  2. http://www.snia.org/cdmi
  3. http://curl.haxx.se/
Personal tools
Create a book