




















































(For more resources related to this topic, see here.)
This section talks about installing the cURL command line tool.
cURL – It is a command line tool which can be used to transfer data using various protocols.
We install cURL using the following command
$ apt-get install curl
OpenStack Swift Client CLI – This tool is installed by the following command.
$ apt-get install python-swiftclient
The first step in order to access containers or objects is to authenticate the user by sending a request to the authentication service and get a valid token that can then be used in subsequent commands to perform various operations as follows:
curl -X POST -i https://auth.lts2.evault.com/v2.0/Tokens -H '
Content-type: application/json' -d '{"auth":{"passwordCredentials":
{"username":"user","password":"password"},"tenantName":"admin"}}'
The token that is generated is given below. It has been truncated for better readability.
token = MIIGIwYJKoZIhvcNAQcCoIIGFDCCBhACAQExCTAHBgUrDgMCGjC CBHkGCSqGSIb3DQEHAaCCBGoEggRme…yJhY2Nlc3MiOiB7InRva2VuIjoge yJpc3N1ZWRfYXQiOiAiMjAxMy0xMS0yNlQwNjoxODo0Mi4zNTA0NTciLCU+ KNYN20G7KJO05bXbbpSAWw+5Vfl8zl6JqAKKWENTrlKBvsFzO-peLBwcKZX TpfJkJxqK7Vpzc-NIygSwPWjODs--0WTes+CyoRD
The EVault LTS2 OpenStack Swift cluster provides its own private authentication service which returns back the token. This generated token will be passed as the token parameter in subsequent commands.
This section describes how we can obtain information about the account, container or object.
The OpenStack Swift client CLI stat command is used to get information about the account, container or object. The name of the container should be provided after the stat command for getting container information. The name of the container and object should be provided after the stat command for getting object information.
Make the following request to display the account status.
# swift --os-auth-token=token --os-storage-url=
https://storage.lts2.evault.com/v1/26cef4782cca4e5aabbb9497b8c1ee1b stat
Where token is the generated token as described in the previous section and 26cef4782cca4e5aabbb9497b8c1ee1b is the account name.
The response shows the information about the account.
Account: 26cef4782cca4e5aabbb9497b8c1ee1b Containers: 2 Objects: 6 Bytes: 17 Accept-Ranges: bytes Server: nginx/1.4.1
The following shows how to obtain the same information using cURL. It shows that the account contains 2 containers and 1243 objects.
Make the following request:
curl -X HEAD -i
https://storage.lts2.evault.com/v1/26cef4782cca4e5aabbb9497b8c1ee1b
-H 'X-Auth-Token: token' -H 'Content-type: application/json'
The response is as follows:
HTTP/1.1 204 No Content Server: nginx/1.4.1 Date: Wed, 04 Dec 2013 06:53:13 GMT Content-Type: text/html; charset=UTF-8 Content-Length: 0 X-Account-Bytes-Used: 3439364822 X-Account-Container-Count: 2 X-Account-Object-Count: 6
The same information can be obtained using the following REST API method.
Make the following request:
Method : HEAD URL: https://storage.lts2.evault.com/v1/26cef4782cca4e5aabbb9497b8c1ee1b
Header : X-Auth-Token: token Data : No data The response is as follows:HTTP/1.1 204 No Content Server: nginx/1.4.1 Date: Wed, 04 Dec 2013 06:47:17 GMT Content-Type: text/html; charset=UTF-8 Content-Length: 0 X-Account-Bytes-Used: 3439364822 X-Account-Container-Count: 2 X-Account-Object-Count: 6
This section describes how to obtain information about the containers present in an account.
Make the following request:
swift --os-auth-token=token --os-storage-url
= https://storage.lts2.evault.com/v1/26cef4782cca4e5aabbb9497b8c1ee1b list
The response is as follows:
cities countries
The following shows how to obtain the same information using cURL. It shows that the account contains 2 containers and 1243 objects.
Make the following request:
curl -X GET –i
https://storage.lts2.evault.com/v1/26cef4782cca4e5aabbb9497b8c1ee1b
-H 'X-Auth_token: token'
The response is as follows:
HTTP/1.1 200 OK X-Account-Container-Count: 2 X-Account-Object-Count: 6 cities countries
Make the following request:
Method : GET URL :
https://storage.lts2.evault.com/v1/26cef4782cca4e5aabbb9497b8c1ee1b Header : X-Auth-Token: token Data : No data
The response is as follows:
X-Account-Container-Count: 2 X-Account-Object-Count: 6 cities countries
This article has thus explained various mechanisms that are available to access OpenStack Swift and how by using these mechanisms we will be able to authenticate accounts and list containers.
Further resources on this subject: