Merge lp:~redbo/swift/swauthdelim into lp:~hudson-openstack/swift/trunk

Proposed by Mike Barton
Status: Merged
Approved by: gholt
Approved revision: 174
Merged at revision: 176
Proposed branch: lp:~redbo/swift/swauthdelim
Merge into: lp:~hudson-openstack/swift/trunk
Diff against target: 161 lines (+31/-32)
5 files modified
doc/source/deployment_guide.rst (+1/-1)
doc/source/howto_installmultinode.rst (+2/-2)
etc/proxy-server.conf-sample (+4/-4)
swift/common/middleware/swauth.py (+15/-16)
test/unit/common/middleware/test_swauth.py (+9/-9)
To merge this branch: bzr merge lp:~redbo/swift/swauthdelim
Reviewer Review Type Date Requested Status
gholt (community) Approve
Chuck Thier (community) Approve
Review via email: mp+46536@code.launchpad.net

Description of the change

modify default_swift_cluster option format

To post a comment you must log in.
Revision history for this message
Chuck Thier (cthier) wrote :

# it is

review: Approve
Revision history for this message
gholt (gholt) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'doc/source/deployment_guide.rst'
2--- doc/source/deployment_guide.rst 2011-01-11 01:22:33 +0000
3+++ doc/source/deployment_guide.rst 2011-01-17 21:48:59 +0000
4@@ -515,7 +515,7 @@
5 reserves anything
6 beginning with the
7 letter `v`.
8-default_swift_cluster local:http://127.0.0.1:8080/v1 The default Swift
9+default_swift_cluster local#http://127.0.0.1:8080/v1 The default Swift
10 cluster to place newly
11 created accounts on.
12 token_life 86400 The number of seconds a
13
14=== modified file 'doc/source/howto_installmultinode.rst'
15--- doc/source/howto_installmultinode.rst 2010-12-10 01:57:26 +0000
16+++ doc/source/howto_installmultinode.rst 2011-01-17 21:48:59 +0000
17@@ -138,7 +138,7 @@
18 # Only needed for Swauth
19 [filter:swauth]
20 use = egg:swift#swauth
21- default_swift_cluster = https://<PROXY_LOCAL_NET_IP>:8080/v1
22+ default_swift_cluster = local#https://<PROXY_LOCAL_NET_IP>:8080/v1
23 # Highly recommended to change this key to something else!
24 super_admin_key = swauthkey
25
26@@ -437,7 +437,7 @@
27 # For Swauth, in /etc/swift/proxy-server.conf
28 [filter:swauth]
29 use = egg:swift#swauth
30- default_swift_cluster = local:http://<LOAD_BALANCER_HOSTNAME>/v1
31+ default_swift_cluster = local#http://<LOAD_BALANCER_HOSTNAME>/v1
32 # Highly recommended to change this key to something else!
33 super_admin_key = swauthkey
34
35
36=== modified file 'etc/proxy-server.conf-sample'
37--- etc/proxy-server.conf-sample 2011-01-10 16:43:38 +0000
38+++ etc/proxy-server.conf-sample 2011-01-17 21:48:59 +0000
39@@ -66,15 +66,15 @@
40 # The auth prefix will cause requests beginning with this prefix to be routed
41 # to the auth subsystem, for granting tokens, creating accounts, users, etc.
42 # auth_prefix = /auth/
43-# Cluster strings are of the format name:url where name is a short name for the
44+# Cluster strings are of the format name#url where name is a short name for the
45 # Swift cluster and url is the url to the proxy server(s) for the cluster.
46-# default_swift_cluster = local:http://127.0.0.1:8080/v1
47-# You may also use the format name::url::url where the first url is the one
48+# default_swift_cluster = local#http://127.0.0.1:8080/v1
49+# You may also use the format name#url#url where the first url is the one
50 # given to users to access their account (public url) and the second is the one
51 # used by swauth itself to create and delete accounts (private url). This is
52 # useful when a load balancer url should be used by users, but swauth itself is
53 # behind the load balancer. Example:
54-# default_swift_cluster = local::https://public.com:8080/v1::http://private.com:8080/v1
55+# default_swift_cluster = local#https://public.com:8080/v1#http://private.com:8080/v1
56 # token_life = 86400
57 # node_timeout = 10
58 # Highly recommended to change this.
59
60=== modified file 'swift/common/middleware/swauth.py'
61--- swift/common/middleware/swauth.py 2011-01-10 19:33:19 +0000
62+++ swift/common/middleware/swauth.py 2011-01-17 21:48:59 +0000
63@@ -61,24 +61,23 @@
64 self.auth_prefix += '/'
65 self.auth_account = '%s.auth' % self.reseller_prefix
66 self.default_swift_cluster = conf.get('default_swift_cluster',
67- 'local:http://127.0.0.1:8080/v1')
68+ 'local#http://127.0.0.1:8080/v1')
69 # This setting is a little messy because of the options it has to
70- # provide. The basic format is cluster_name:url, such as the default
71- # value of local:http://127.0.0.1:8080/v1. But, often the url given to
72- # the user needs to be different than the url used by Swauth to
73- # create/delete accounts. So there's a more complex format of
74- # cluster_name::url::url, such as
75- # local::https://public.com:8080/v1::http://private.com:8080/v1.
76- # The double colon is what sets the two apart.
77- if '::' in self.default_swift_cluster:
78- self.dsc_name, self.dsc_url, self.dsc_url2 = \
79- self.default_swift_cluster.split('::', 2)
80- self.dsc_url = self.dsc_url.rstrip('/')
81- self.dsc_url2 = self.dsc_url2.rstrip('/')
82+ # provide. The basic format is cluster_name#url, such as the default
83+ # value of local#http://127.0.0.1:8080/v1.
84+ # If the URL given to the user needs to differ from the url used by
85+ # Swauth to create/delete accounts, there's a more complex format:
86+ # cluster_name#url#url, such as
87+ # local#https://public.com:8080/v1#http://private.com:8080/v1.
88+ cluster_parts = self.default_swift_cluster.split('#', 2)
89+ self.dsc_name = cluster_parts[0]
90+ if len(cluster_parts) == 3:
91+ self.dsc_url = cluster_parts[1].rstrip('/')
92+ self.dsc_url2 = cluster_parts[2].rstrip('/')
93+ elif len(cluster_parts) == 2:
94+ self.dsc_url = self.dsc_url2 = cluster_parts[1].rstrip('/')
95 else:
96- self.dsc_name, self.dsc_url = \
97- self.default_swift_cluster.split(':', 1)
98- self.dsc_url = self.dsc_url2 = self.dsc_url.rstrip('/')
99+ raise Exception('Invalid cluster format')
100 self.dsc_parsed = urlparse(self.dsc_url)
101 if self.dsc_parsed.scheme not in ('http', 'https'):
102 raise Exception('Cannot handle protocol scheme %s for url %s' %
103
104=== modified file 'test/unit/common/middleware/test_swauth.py'
105--- test/unit/common/middleware/test_swauth.py 2011-01-10 16:43:38 +0000
106+++ test/unit/common/middleware/test_swauth.py 2011-01-17 21:48:59 +0000
107@@ -151,21 +151,21 @@
108 app = FakeApp()
109 self.assertRaises(Exception, auth.filter_factory({
110 'super_admin_key': 'supertest',
111- 'default_swift_cluster': 'local:badscheme://host/path'}), app)
112+ 'default_swift_cluster': 'local#badscheme://host/path'}), app)
113 ath = auth.filter_factory({'super_admin_key': 'supertest'})(app)
114 self.assertEquals(ath.default_swift_cluster,
115- 'local:http://127.0.0.1:8080/v1')
116+ 'local#http://127.0.0.1:8080/v1')
117 ath = auth.filter_factory({'super_admin_key': 'supertest',
118- 'default_swift_cluster': 'local:http://host/path'})(app)
119+ 'default_swift_cluster': 'local#http://host/path'})(app)
120 self.assertEquals(ath.default_swift_cluster,
121- 'local:http://host/path')
122+ 'local#http://host/path')
123 ath = auth.filter_factory({'super_admin_key': 'supertest',
124- 'default_swift_cluster': 'local:https://host/path/'})(app)
125+ 'default_swift_cluster': 'local#https://host/path/'})(app)
126 self.assertEquals(ath.dsc_url, 'https://host/path')
127 self.assertEquals(ath.dsc_url2, 'https://host/path')
128 ath = auth.filter_factory({'super_admin_key': 'supertest',
129 'default_swift_cluster':
130- 'local::https://host/path/::http://host2/path2/'})(app)
131+ 'local#https://host/path/#http://host2/path2/'})(app)
132 self.assertEquals(ath.dsc_url, 'https://host/path')
133 self.assertEquals(ath.dsc_url2, 'http://host2/path2')
134
135@@ -2882,7 +2882,7 @@
136
137 def test_get_conn_default_https(self):
138 local_auth = auth.filter_factory({'super_admin_key': 'supertest',
139- 'default_swift_cluster': 'local:https://1.2.3.4/v1'})(FakeApp())
140+ 'default_swift_cluster': 'local#https://1.2.3.4/v1'})(FakeApp())
141 conn = local_auth.get_conn()
142 self.assertEquals(conn.__class__, auth.HTTPSConnection)
143 self.assertEquals(conn.host, '1.2.3.4')
144@@ -2890,7 +2890,7 @@
145
146 def test_get_conn_overridden(self):
147 local_auth = auth.filter_factory({'super_admin_key': 'supertest',
148- 'default_swift_cluster': 'local:https://1.2.3.4/v1'})(FakeApp())
149+ 'default_swift_cluster': 'local#https://1.2.3.4/v1'})(FakeApp())
150 conn = \
151 local_auth.get_conn(urlparsed=auth.urlparse('http://5.6.7.8/v1'))
152 self.assertEquals(conn.__class__, auth.HTTPConnection)
153@@ -2899,7 +2899,7 @@
154
155 def test_get_conn_overridden_https(self):
156 local_auth = auth.filter_factory({'super_admin_key': 'supertest',
157- 'default_swift_cluster': 'local:http://1.2.3.4/v1'})(FakeApp())
158+ 'default_swift_cluster': 'local#http://1.2.3.4/v1'})(FakeApp())
159 conn = \
160 local_auth.get_conn(urlparsed=auth.urlparse('https://5.6.7.8/v1'))
161 self.assertEquals(conn.__class__, auth.HTTPSConnection)