Using OpenStack Swift

Exclusive offer: get 50% off this eBook here
Implementing Cloud Storage with OpenStack Swift

Implementing Cloud Storage with OpenStack Swift — Save 50%

Design, implement, and successfully manage your own cloud storage cluster using the popular OpenStack Swift software

€17.99    €9.00
by Amar Kapadia Kris Rajana Sreedhar Varma | May 2014 | Open Source

This article, by Amar Kapdia, Sreedhar Varma, and Kris Rajana, the authors of Implementing Cloud Storage with OpenStack Swift, explains the various mechanisms that are available to access OpenStack Swift. Using these mechanisms we will be able to authenticate accounts, list containers, create containers, create objects, delete objects, and so on. The various clients that are available to access OpenStack Swift are OpenStack Swift Client CLI, cURL client, HTTP REST API, JAVA libraries, .Ruby OpenStack libraries, Python libraries, and so on. In particular, we will be using OpenStack Swift client CLI, cURL and HTTP REST API to access OpenStack Swift and perform various operations on containers and objects. Also, we will be using EVault’s Long-Term Storage (LTS2) cloud storage to demonstrate the use of OpenStack Swift.

(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:


Implementing Cloud Storage with OpenStack Swift Design, implement, and successfully manage your own cloud storage cluster using the popular OpenStack Swift software
Published: May 2014
eBook Price: €17.99
Book Price: €29.99
See more
Select your format and quantity:

About the Author :


Amar Kapadia

Amar Kapadia is a storage technologist and blogger based in the San Francisco Bay Area. He is currently the Senior Director of Strategy for EVault's Long-Term Storage Service, a subsidiary of Seagate. With over 20 years of experience in storage, server, and I/O technologies at Emulex, Philips, and HP, Amar's current passion is cloud and object storage technologies based on OpenStack Swift. He holds a Master's degree in Electrical Engineering from the University of California, Berkeley.

When not working on OpenStack Swift, Amar can be found working on Open Compute Platform technologies, MongoDB, PHP, AJAX, or jQuery. Amar's blogs can be found at buildcloudstorage.com.

Kris Rajana

Kris Rajana is an entrepreneur, passionate in building globally distributed teams to develop and maintain innovative products and solutions. His areas of interests include tape, DAS, NAS, SAN, and fast emerging technologies (Cloud, SDN, SDS, and Flash Arrays). Kris has over 20 years of experience in managing engineering teams in areas including space and aviation at BFGoodrich Aerospace and storage at Snap Appliance (currently Overland Storage) Adaptec, Xyratex, and Sullego. Currently, as the CEO of Vedams, Kris takes immense pride in his team and its development that leads to execution excellence. Kris's current passion is application of Big Data concepts to improve reliability and uptime of systems.

Kris is a student and sevak at San Jose Chinmaya Mission. Kris also serves on the board of the Pratham Bay Area Chapter. Kris and Vedams sponsor the Pratham Urban Learning Center in Hyderabad.

Kris earned his doctorate in engineering science from the Pennsylvania State University and keeps abreast with emerging management methodologies through his affiliation with Stanford University.

Sreedhar Varma

Sreedhar Varma has more than 15 years of experience in the storage industry, developing storage software and solutions. He has worked on various storage technologies (such as SCSI, SAS, SATA, and FC), HBA drivers (Adaptec, Emulex, Qlogic, Promise, and so on), RAID, and storage stacks of various operating systems. He was involved in building system software for Stratus Fault Tolerant and High Availability systems. He has good working experience with SAN, NAS, and iSCSI networks as well as various storage arrays (Dothill, IBM, EMC, Hitachi, and Oracle Pillar). Sreedhar is currently involved with object storage implementations (Swift, Ceph) and developing software using corresponding REST APIs.

Sreedhar has a Master's degree in Computer Science from the University of Massachusetts.

He is presently working for Vedams Software (providing storage engineering services). In the past, he has worked for Stratus Technologies, Compaq, Digital Equipment Corp, and IBM.

Books From Packt


OpenStack Cloud Computing Cookbook
OpenStack Cloud Computing Cookbook

OpenStack Cloud Computing Cookbook - Second Edition
OpenStack Cloud Computing Cookbook - Second Edition

Apache CloudStack Cloud Computing
Apache CloudStack Cloud Computing

IBM® SmartCloud® Essentials
IBM® SmartCloud® Essentials

Getting Started with ownCloud
Getting Started with ownCloud

 Getting Started with Oracle Public Cloud
Getting Started with Oracle Public Cloud

OpenNebula 3 Cloud Computing
OpenNebula 3 Cloud Computing

Cloud Development and Deployment with CloudBees
Cloud Development and Deployment with CloudBees

Code Download and Errata
Packt Anytime, Anywhere
Register Books
Print Upgrades
eBook Downloads
Video Support
Contact Us
Awards Voting Nominations Previous Winners
Judges Open Source CMS Hall Of Fame CMS Most Promising Open Source Project Open Source E-Commerce Applications Open Source JavaScript Library Open Source Graphics Software
Resources
Open Source CMS Hall Of Fame CMS Most Promising Open Source Project Open Source E-Commerce Applications Open Source JavaScript Library Open Source Graphics Software