From 20adfd49a7a23bedccc9b9e93bf953921a1e6399 Mon Sep 17 00:00:00 2001 From: Sebastien Badia Date: Tue, 10 Feb 2015 11:46:11 +0100 Subject: [PATCH] swift: Add support for Swift API v1 (without Keystone) This commit also add a workaround for bug/feature[1] the password is changed every time :-) [1]https://github.com/ccollicutt/docker-swift-onlyone/commit/c9f5e41b745eee18e7ddc807481bc9729d8cdac0 --- .swift.sh | 10 +++++----- system/swift_lib.py | 7 +++++++ 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/.swift.sh b/.swift.sh index 654fb6b0..3f578707 100755 --- a/.swift.sh +++ b/.swift.sh @@ -1,6 +1,6 @@ -export OS_AUTH_URL=http://127.0.0.1:8181/v2.0/ -export OS_USERNAME=user_test -export OS_PASSWORD=tester -export OS_TENANT_NAME=testing +export ST_AUTH=http://127.0.0.1:8181/auth/v1.0 +export ST_USER=test:tester +ID=`docker run -d -p 8080:8080 serverascode/swift-onlyone` +sleep 10 # Give the script that change the passwords some time +export ST_KEY=`docker logs $ID | grep "user_test_tester =" | cut -d " " -f 3` pip install python-keystoneclient python-swiftclient -docker run -d -p 8080:8080 serverascode/swift-onlyone \ No newline at end of file diff --git a/system/swift_lib.py b/system/swift_lib.py index 1deef72d..5b2f05db 100644 --- a/system/swift_lib.py +++ b/system/swift_lib.py @@ -15,6 +15,13 @@ try: account_username = "%s:%s" % (auth_tenant, auth_username) swift_conn = swiftclient.Connection(auth_url, account_username, auth_password, auth_version=2) + elif 'ST_USER' in os.environ and 'ST_KEY' in os.environ: + auth_username = os.environ.get('ST_USER') + auth_password = os.environ.get('ST_KEY') + auth_url = os.environ.get('ST_AUTH') + # Using auth version 1 (/auth/v1.0) + swift_conn = swiftclient.Connection(auth_url, auth_username, + auth_password, auth_version=1) else: swift_conn = None except ImportError: