How-tos

Accessing Bluemix Object Storage using OpenStack Swift Client

You can access Bluemix Object Storage from any environment as long as the environment has internet access. Common use cases for Object Storage include:

  • Backing up volume data from your instances
  • Using as an intermediary location when transferring large amounts of data
  • Transferring data between environments that are not directly connected
  • Acting as a central repository

Bluemix Object Storage is based on OpenStack Swift and can be accessed using any compatible client application. This article describes how to use the Python Swift client to work with containers and files.

Installing the Swift client

Install the Python Swift client using Python pip::

$ sudo pip install python-keystoneclient
$ sudo pip install python-swiftclient

Setting up the client

The Swift client takes the authentication information from the environment variables ST_AUTH, ST_USER, and ST_KEY for the endpoint URL, username, and password respectively. If you’re accessing Object Storage from the IBM Cloud OpenStack Services guest network, make sure that you use the private endpoint which has a FQDN like this: .objectstorage.service.networklayer.com.
Set authentication information

$ export ST_AUTH=https://.objectstorage.service.networklayer.com/auth/v1.0/
$ export ST_USER=
$ export ST_KEY=Working with containers

Working with containers
Listing containers

$ swift list

Creating a new container

$ swift post

Listing the content of a container

$ swift list

Working with objects
Adding a file to a container

$ swift upload

If you are uploading a file that is larger than 5GB, you must split it into smaller chunks. You can instruct the Swift client to handle this by supplying the -segment-size parameter::

$ swift upload –segment-size

Each segment is uploaded in parallel into a separate container named _segments. Once all the segments are uploaded, Swift creates a manifest file so that the segments can be downloaded in a single file named .
Adding a directory to a container

$ swift upload

This will upload the full directory structure as a relative path. For example, if you specify /mnt/volume1, the directory structure mnt/volume1 will be attached to all the file names to indicate the directory structure.
Downloading a file

$ swift download

Downloading a directory

Swift does not have a true directory structure, but uses the naming to represent a directory layout. To download a directory structure, use the -prefix parameter to indicate the directory or directory structure you want to download.:

$ swift download –prefix

Deleting a file

$ swift delete

As you can see, it pretty easy to use Bluemix Object Storage using the OpenStack Swift Client. You can easily starts backing up files to the Cloud!

Next we will see how you can share the content you have uploaded into the cloud using temporary URLs.

Share this post:

Share on LinkedIn

Add Comment
No Comments

Leave a Reply

Your email address will not be published.Required fields are marked *

More How-tos Stories

Real-life production experience with Secure Gateway

When I need a secure way to connect Bluemix applications to remote locations on-premises or in the cloud, I use the Secure Gateway service. Setting up the Secure Gateway turns out to be really straightforward, especially when using the Docker-based gateway client. Yet, when it comes to deploying and running the Secure Gateway in a real production environment, you will be facing lots of questions from your infrastructure and security guys.  Does the gateway support load balancing? How do you guaranty an end-to-end secure connection? What about certificates? Which firewall rules do I need to set up? This post helps you get prepared by addressing most of them one-by-one!

Getting started with ASP.NET 5 in Bluemix

As the next step in this partnership, we’ve just released ASP.NET 5 as an experimental runtime in the Bluemix Labs Catalog, extending the Bluemix vision to the .NET community. In addition, we have also open sourced our ASP.NET 5 buildpack and made it available on GitHub. For all you .NET developers, this means building apps with Watson, Cloudant and more is right at your fingertips. More...

Node.js debugging with better logs and error filters

Trace is a utility included in App Management that allows you to trace logs and filter errors by the severity or category. If you would like to take advantage of these App Management utilities, this post explains how to enable each feature.