diff options
| author | Kevin L. Mitchell <kevin.mitchell@rackspace.com> | 2011-03-18 02:09:46 +0000 |
|---|---|---|
| committer | Kevin L. Mitchell <kevin.mitchell@rackspace.com> | 2011-03-18 02:09:46 +0000 |
| commit | 4453021476fac599c0cee126b6eaa426d4878145 (patch) | |
| tree | 5477bc3acb6634d2ae61e04b085a2c7e34966900 /nova/db | |
| parent | 645bc7a7dea6ba01d76589632200636e243641ec (diff) | |
| download | nova-4453021476fac599c0cee126b6eaa426d4878145.tar.gz nova-4453021476fac599c0cee126b6eaa426d4878145.tar.xz nova-4453021476fac599c0cee126b6eaa426d4878145.zip | |
Copy over to current trunk my tests, the 401/500 fix, and a couple of
fixes to the committed fix which was actually brittle around the edges...
Diffstat (limited to 'nova/db')
| -rw-r--r-- | nova/db/api.py | 5 | ||||
| -rw-r--r-- | nova/db/sqlalchemy/api.py | 14 |
2 files changed, 17 insertions, 2 deletions
diff --git a/nova/db/api.py b/nova/db/api.py index 4c7eb857f..dcaf55e8f 100644 --- a/nova/db/api.py +++ b/nova/db/api.py @@ -640,6 +640,11 @@ def auth_token_get(context, token_hash): return IMPL.auth_token_get(context, token_hash) +def auth_token_update(context, token_hash, values): + """Updates a token given the hash representing it.""" + return IMPL.auth_token_update(context, token_hash, values) + + def auth_token_create(context, token): """Creates a new token.""" return IMPL.auth_token_create(context, token) diff --git a/nova/db/sqlalchemy/api.py b/nova/db/sqlalchemy/api.py index 0be08c4d1..6df2a8843 100644 --- a/nova/db/sqlalchemy/api.py +++ b/nova/db/sqlalchemy/api.py @@ -1270,8 +1270,9 @@ def auth_token_destroy(context, token_id): @require_admin_context -def auth_token_get(context, token_hash): - session = get_session() +def auth_token_get(context, token_hash, session=None): + if session is None: + session = get_session() tk = session.query(models.AuthToken).\ filter_by(token_hash=token_hash).\ filter_by(deleted=can_read_deleted(context)).\ @@ -1282,6 +1283,15 @@ def auth_token_get(context, token_hash): @require_admin_context +def auth_token_update(context, token_hash, values): + session = get_session() + with session.begin(): + token_ref = auth_token_get(context, token_hash, session=session) + token_ref.update(values) + token_ref.save(session=session) + + +@require_admin_context def auth_token_create(_context, token): tk = models.AuthToken() tk.update(token) |
