Ask Your Question
0

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' http://127.0.0.1:8081/auth/v1.0

but I am getting error

 HTTP/1.1 401 Unauthorized ....

I want to know how do I use Swift and http://127.0.0.1:8081/auth/v1.0 is keystone's IP or what?

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
1

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 .access.token.id 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:

http://10.15.0.2:8080/v1/AUTH_c84fde6252d047c380e47b6c868d09e3

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

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Get to know Ask OpenStack

Resources for moderators

Question Tools

1 follower

Stats

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

Seen: 272 times

Last updated: Apr 14 '14