From 355a98b51ff883a7495976c9373dd40ff41ed1ef Mon Sep 17 00:00:00 2001 From: Sylvain Baubeau Date: Tue, 10 Feb 2015 09:17:46 +0100 Subject: [PATCH 1/3] Use upstream version of ncw/swift --- Gomfile | 2 +- swift/public.go | 2 +- swift/public_test.go | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Gomfile b/Gomfile index 1f6c47d0..6757f35a 100644 --- a/Gomfile +++ b/Gomfile @@ -11,7 +11,7 @@ gom 'github.com/julienschmidt/httprouter', :commit => '46807412fe50aaceb73bb5706 gom 'github.com/mattn/go-shellwords', :commit => 'c7ca6f94add751566a61cf2199e1de78d4c3eee4' gom 'github.com/mitchellh/goamz/s3', :commit => 'e7664b32019f31fd1bdf33f9e85f28722f700405' gom 'github.com/mkrautz/goar', :commit => '36eb5f3452b1283a211fa35bc00c646fd0db5c4b' -gom 'github.com/lebauce/swift', :commit => '075195d7dd6167c2d4eeb1bd04daef806bdbbc81' +gom 'github.com/ncw/swift', :commit => '1ba06e828dbd125ece563f8ed0aaa5c6037b28e2' gom 'github.com/smira/commander', :commit => 'f408b00e68d5d6e21b9f18bd310978dafc604e47' gom 'github.com/smira/flag', :commit => '357ed3e599ffcbd4aeaa828e1d10da2df3ea5107' gom 'github.com/smira/go-ftp-protocol/protocol', :commit => '066b75c2b70dca7ae10b1b88b47534a3c31ccfaa' diff --git a/swift/public.go b/swift/public.go index 1ccd540f..6861ad35 100644 --- a/swift/public.go +++ b/swift/public.go @@ -2,7 +2,7 @@ package swift import ( "fmt" - "github.com/lebauce/swift" + "github.com/ncw/swift" "github.com/smira/aptly/aptly" "github.com/smira/aptly/files" "time" diff --git a/swift/public_test.go b/swift/public_test.go index f455d310..c38e546f 100644 --- a/swift/public_test.go +++ b/swift/public_test.go @@ -2,7 +2,7 @@ package swift import ( "github.com/smira/aptly/files" - "github.com/lebauce/swift" + "github.com/ncw/swift/swifttest" "io/ioutil" "os" @@ -20,7 +20,7 @@ const ( ) type PublishedStorageSuite struct { - srv *swift.SwiftServer + srv *swifttest.SwiftServer storage, prefixedStorage *PublishedStorage } @@ -28,7 +28,7 @@ var _ = Suite(&PublishedStorageSuite{}) func (s *PublishedStorageSuite) SetUpTest(c *C) { var err error - s.srv, err = swift.NewSwiftServer(TEST_ADDRESS) + s.srv, err = swifttest.NewSwiftServer(TEST_ADDRESS) c.Assert(err, IsNil) c.Assert(s.srv, NotNil) From 20adfd49a7a23bedccc9b9e93bf953921a1e6399 Mon Sep 17 00:00:00 2001 From: Sebastien Badia Date: Tue, 10 Feb 2015 11:46:11 +0100 Subject: [PATCH 2/3] 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: From 26a65b2336dfa7eaf389afbbd3e2851caa4566c5 Mon Sep 17 00:00:00 2001 From: Sebastien Badia Date: Tue, 10 Feb 2015 12:19:34 +0100 Subject: [PATCH 3/3] swift: Fallback to TempAuth --- swift/public.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/swift/public.go b/swift/public.go index 6861ad35..b46d104a 100644 --- a/swift/public.go +++ b/swift/public.go @@ -31,13 +31,19 @@ var ( // keys, tenant and tenantId func NewPublishedStorage(username string, password string, authUrl string, tenant string, tenantId string, container string, prefix string) (*PublishedStorage, error) { if username == "" { - username = os.Getenv("OS_USERNAME") + if username = os.Getenv("OS_USERNAME"); username == "" { + username = os.Getenv("ST_USER") + } } if password == "" { - password = os.Getenv("OS_PASSWORD") + if password = os.Getenv("OS_PASSWORD"); password == "" { + password = os.Getenv("ST_KEY") + } } if authUrl == "" { - authUrl = os.Getenv("OS_AUTH_URL") + if authUrl = os.Getenv("OS_AUTH_URL"); authUrl == "" { + authUrl = os.Getenv("ST_AUTH") + } } if tenant == "" { tenant = os.Getenv("OS_TENANT_NAME")