Ask Your Question

How to use Swift?

asked 2014-04-13 11:41:31 -0500

mani619cash gravatar image

I have installed OpenStack using DevStack and installed Swift using SAIO Installation

Now I want to use Swift's services.

I tried this command

curl -v -H 'X-Storage-User: swift' -H 'X-Storage-Pass: mani'

but I am getting error

 HTTP/1.1 401 Unauthorized ....

I want to know how do I use Swift and is keystone's IP or what?

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2014-04-14 13:08:04 -0500

larsks gravatar image

This section of the documentation discusses how to authenticate against Swift using your Keystone credentials.

You first need to authenticate to keystone, which will look something like this:

curl -H 'content-type: application/json'  \
  -d '{"auth":{"tenantName":"'"$OS_TENANT_NAME"'", 
  "passwordCredentials": {"username":"'"$OS_USERNAME"'",
  "password":"'"$OS_PASSWORD"'"}}}'  \
  http://localhost:5000/v2.0/tokens > keystone.json

This will return a big chunk of JSON; you want to extract the token id. A good for this is jq, which you could use like this:

token=$(jq -r keystone.json )

You will also want to retrieve your swift endpoint from the service catalog returned by keystone:

swift_url=$(jq '.access.serviceCatalog[] |
  select(.name == "swift") | .endpoints[0].publicURL' keystone.json)

Which is going to set swift_url to something like:

Now you can use this URL and your keystone token to create a container:

curl -i -H "x-auth-token: $token" \
  $swift_url/mycontainer -X PUT -H 'content-length: 0'

Which should respond:

HTTP/1.1 201 Created
Content-Length: 0
Content-Type: text/html; charset=UTF-8
Date: Mon, 14 Apr 2014 18:07:00 GMT

Additional examples are in the Object Storage API documentation.

edit flag offensive delete link more

Get to know Ask OpenStack

Resources for moderators

Question Tools

1 follower


Asked: 2014-04-13 11:41:31 -0500

Seen: 308 times

Last updated: Apr 14 '14