(For more resources related to this topic, see here.)
Installing the clients
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
- REST API Client – To access OpenStack Swift services via REST API, we can use third party tools like Fiddler web debugger which supports REST architecture.
Creating Token by using Authentication
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
EVault LTS2 authentication
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.
Displaying meta-data information for Account, Container, Object
This section describes how we can obtain information about the account, container or object.
Using OpenStack Swift Client CLI
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
Using cURL
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
Using REST API
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
Listing Containers
This section describes how to obtain information about the containers present in an account.
Using OpenStack Swift Client CLI
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
Using cURL
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
Using REST API
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
Summary
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.
Resources for Article:
Further resources on this subject:
- Securing vCloud Using the vCloud Networking and Security App Firewall [Article]
- Introduction to Cloud Computing with Microsoft Azure [Article]
- Troubleshooting in OpenStack Cloud Computing [Article]