In my last post I demonstrated how to use the openstack nova client to control rackspace servers from the command line.

It is also possible to control your rackspace cloud files using the openstack swift client, the first thing we need to do is install the package (again these examples are using fedora 17)

> yum install openstack-swift

Next we need to create the file ~/rackspacerc_cloudfiles, this file will be used to setup our environment anytime we want to use swift, it should look something like this

export OS_USERNAME=MossoCloudFS_1234567890-1234-1234-12345-123454321:myusername
export OS_PASSWORD=mypassword
export OS_AUTH_URL=

If you worked through my last post you’ll notice some differences about this file, two differences we should note

OS_TENANT_NAME : for the version of swift client I am using this is absent but in future versions it may be back again, in which case os_tenant_name should be set to the tenant name and the value for OS_USERNAME should not contain the tenant name

OS_USERNAME : this contains the tenant name, in addition to the user name but it is not the same as the tenant name we used for nova. On rackspace a different tenant is used for cloud servers and cloud files. What we need to do is get the tenant name for our cloud files account. In order to get this you can run the command below (replace the username and password in the command)

> curl -d '{"auth":{"passwordCredentials":{"username": "myusername", "password": "mypassword"}}}' -H "Content-type: application/json"

A load of JSON should be returned, in there somewhere you’ll see a piece that looks like this


Note : If Using Use in both curl command and in ~/rackspacerc_cloudfiles

Now armed with your new found tenantId and username update the file  ~/rackspacerc_cloudfiles

We source the file to set the environment variables in our current terminal (Note : you have to run this command in any new terminals you want to use Swift in)

> source ~/rackspacerc_cloudfiles

then start using the swift client

> swift list
> swift upload container1 file2upload
> swift list

Please follow and like us: