Merge lp:~vishvananda/nova/fix-token into lp:~hudson-openstack/nova/trunk

Proposed by Vish Ishaya
Status: Merged
Approved by: Matt Dietz
Approved revision: 1082
Merged at revision: 1084
Proposed branch: lp:~vishvananda/nova/fix-token
Merge into: lp:~hudson-openstack/nova/trunk
Diff against target: 146 lines (+71/-11)
4 files modified
nova/api/openstack/auth.py (+7/-10)
nova/db/sqlalchemy/migrate_repo/versions/018_rename_server_management_url.py (+60/-0)
nova/db/sqlalchemy/models.py (+1/-1)
nova/tests/api/openstack/fakes.py (+3/-0)
To merge this branch: bzr merge lp:~vishvananda/nova/fix-token
Reviewer Review Type Date Requested Status
Matt Dietz (community) Approve
Dan Prince (community) Approve
Review via email: mp+61304@code.launchpad.net

Description of the change

Fixes the naming of the server_management_url in auth and tests.

To post a comment you must log in.
Revision history for this message
Dan Prince (dan-prince) wrote :

Hey Vish,

The number 017 for migrations was already taken today by '017_make_instance_type_id_an_integer.py'.

Can you bump this one to 18?

Dan

review: Needs Fixing
Revision history for this message
Vish Ishaya (vishvananda) wrote :

done
On May 17, 2011, at 1:47 PM, Dan Prince wrote:

> Review: Needs Fixing
> Hey Vish,
>
> The number 017 for migrations was already taken today by '017_make_instance_type_id_an_integer.py'.
>
> Can you bump this one to 18?
>
> Dan
> --
> https://code.launchpad.net/~vishvananda/nova/fix-token/+merge/61304
> You are the owner of lp:~vishvananda/nova/fix-token.

lp:~vishvananda/nova/fix-token updated
1081. By Vish Ishaya

move migration 017 to 018

1082. By Vish Ishaya

merged trunk

Revision history for this message
Dan Prince (dan-prince) wrote :

Looks good now.

review: Approve
Revision history for this message
Matt Dietz (cerberus) wrote :

lgtm.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'nova/api/openstack/auth.py'
2--- nova/api/openstack/auth.py 2011-04-15 19:01:17 +0000
3+++ nova/api/openstack/auth.py 2011-05-17 20:52:11 +0000
4@@ -17,7 +17,6 @@
5
6 import datetime
7 import hashlib
8-import json
9 import time
10
11 import webob.exc
12@@ -25,11 +24,9 @@
13
14 from nova import auth
15 from nova import context
16-from nova import db
17 from nova import exception
18 from nova import flags
19 from nova import log as logging
20-from nova import manager
21 from nova import utils
22 from nova import wsgi
23 from nova.api.openstack import faults
24@@ -102,11 +99,11 @@
25 token, user = self._authorize_user(username, key, req)
26 if user and token:
27 res = webob.Response()
28- res.headers['X-Auth-Token'] = token.token_hash
29+ res.headers['X-Auth-Token'] = token['token_hash']
30 res.headers['X-Server-Management-Url'] = \
31- token.server_management_url
32- res.headers['X-Storage-Url'] = token.storage_url
33- res.headers['X-CDN-Management-Url'] = token.cdn_management_url
34+ token['server_management_url']
35+ res.headers['X-Storage-Url'] = token['storage_url']
36+ res.headers['X-CDN-Management-Url'] = token['cdn_management_url']
37 res.content_type = 'text/plain'
38 res.status = '204'
39 LOG.debug(_("Successfully authenticated '%s'") % username)
40@@ -130,11 +127,11 @@
41 except exception.NotFound:
42 return None
43 if token:
44- delta = datetime.datetime.now() - token.created_at
45+ delta = datetime.datetime.utcnow() - token['created_at']
46 if delta.days >= 2:
47- self.db.auth_token_destroy(ctxt, token.token_hash)
48+ self.db.auth_token_destroy(ctxt, token['token_hash'])
49 else:
50- return self.auth.get_user(token.user_id)
51+ return self.auth.get_user(token['user_id'])
52 return None
53
54 def _authorize_user(self, username, key, req):
55
56=== added file 'nova/db/sqlalchemy/migrate_repo/versions/018_rename_server_management_url.py'
57--- nova/db/sqlalchemy/migrate_repo/versions/018_rename_server_management_url.py 1970-01-01 00:00:00 +0000
58+++ nova/db/sqlalchemy/migrate_repo/versions/018_rename_server_management_url.py 2011-05-17 20:52:11 +0000
59@@ -0,0 +1,60 @@
60+# vim: tabstop=4 shiftwidth=4 softtabstop=4
61+
62+# Copyright 2010 OpenStack LLC.
63+#
64+# Licensed under the Apache License, Version 2.0 (the "License"); you may
65+# not use this file except in compliance with the License. You may obtain
66+# a copy of the License at
67+#
68+# http://www.apache.org/licenses/LICENSE-2.0
69+#
70+# Unless required by applicable law or agreed to in writing, software
71+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
72+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
73+# License for the specific language governing permissions and limitations
74+# under the License.
75+
76+from sqlalchemy import Column, Integer, MetaData, String, Table
77+#from nova import log as logging
78+
79+meta = MetaData()
80+
81+c_manageent = Column('server_manageent_url',
82+ String(length=255, convert_unicode=False,
83+ assert_unicode=None, unicode_error=None,
84+ _warn_on_bytestring=False),
85+ nullable=True)
86+
87+c_management = Column('server_management_url',
88+ String(length=255, convert_unicode=False,
89+ assert_unicode=None, unicode_error=None,
90+ _warn_on_bytestring=False),
91+ nullable=True)
92+
93+
94+def upgrade(migrate_engine):
95+ # Upgrade operations go here. Don't create your own engine;
96+ # bind migrate_engine to your metadata
97+ meta.bind = migrate_engine
98+
99+ tokens = Table('auth_tokens', meta, autoload=True,
100+ autoload_with=migrate_engine)
101+
102+ tokens.create_column(c_management)
103+ migrate_engine.execute(tokens.update()
104+ .values(server_management_url=tokens.c.server_manageent_url))
105+
106+ tokens.c.server_manageent_url.drop()
107+
108+
109+def downgrade(migrate_engine):
110+ meta.bind = migrate_engine
111+
112+ tokens = Table('auth_tokens', meta, autoload=True,
113+ autoload_with=migrate_engine)
114+
115+ tokens.create_column(c_manageent)
116+ migrate_engine.execute(tokens.update()
117+ .values(server_manageent_url=tokens.c.server_management_url))
118+
119+ tokens.c.server_management_url.drop()
120
121=== modified file 'nova/db/sqlalchemy/models.py'
122--- nova/db/sqlalchemy/models.py 2011-05-17 15:41:58 +0000
123+++ nova/db/sqlalchemy/models.py 2011-05-17 20:52:11 +0000
124@@ -495,7 +495,7 @@
125 __tablename__ = 'auth_tokens'
126 token_hash = Column(String(255), primary_key=True)
127 user_id = Column(String(255))
128- server_manageent_url = Column(String(255))
129+ server_management_url = Column(String(255))
130 storage_url = Column(String(255))
131 cdn_management_url = Column(String(255))
132
133
134=== modified file 'nova/tests/api/openstack/fakes.py'
135--- nova/tests/api/openstack/fakes.py 2011-03-28 21:23:14 +0000
136+++ nova/tests/api/openstack/fakes.py 2011-05-17 20:52:11 +0000
137@@ -228,6 +228,9 @@
138 # FIXME(sirp): let's not use id here
139 id = 0
140
141+ def __getitem__(self, key):
142+ return getattr(self, key)
143+
144 def __init__(self, **kwargs):
145 FakeToken.id += 1
146 self.id = FakeToken.id