Ask Your Question
1

How to create Swift Connection using python API on HP Cloud

asked 2014-06-04 02:24:14 -0500

Dhana gravatar image

updated 2014-06-06 17:35:39 -0500

smaffulli gravatar image

Hi, I am working with HP Openstack. I am trying to get create a Swift Connection and then add a container. How can I do that through Python API.

I wrote the following code which ends up saying :-

swiftclient.exceptions.ClientException:
Auth GET failed:
https://region-a.geo-1.identity.hpcloudsvc.com:35357/v2.0/ 405 Method Not Allowed

Code:-

__author__ = 'Dhana'

import swiftclient.client as swift_client
import os


def get_swift_creds():
    return {'user': os.environ['OS_USERNAME'], 'key': os.environ['OS_PASSWORD'],
            'authurl': os.environ['OS_AUTH_URL'], 'tenant_name': os.environ['OS_TENANT_NAME']}

if __name__ == '__main__':
    creds = get_swift_creds()
    conn = swift_client.Connection(**creds)
    conn.post_container('MyContainer', None)
    print 'Container success!'
    conn.close()
edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
2

answered 2014-06-09 03:42:04 -0500

Dhana gravatar image

Hi, I figured out the problem. It is just adding the version attribute. Change the method as follows:-

def get_swift_creds():
    return {'user': os.environ['OS_USERNAME'], 'key': os.environ['OS_PASSWORD'],
            'authurl': os.environ['OS_AUTH_URL'],
            'tenant_name': os.environ['OS_TENANT_NAME'],
            'auth_version': '2.0'
           }
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

[hide preview]

Get to know Ask OpenStack

Resources for moderators

Question Tools

Follow
2 followers

Stats

Asked: 2014-06-04 02:24:14 -0500

Seen: 205 times

Last updated: Jun 09 '14