diff options
author | Jenkins <jenkins@review.openstack.org> | 2012-06-18 18:28:04 +0000 |
---|---|---|
committer | Gerrit Code Review <review@openstack.org> | 2012-06-18 18:28:04 +0000 |
commit | 56e7cb1c43c64669fb2ffb2decdb35ef37535995 (patch) | |
tree | 3042a66f6589b8ddf8d572db97f46279bc4ecf3f | |
parent | c547b7161afe42b8e3872926633fc550cc1db4b3 (diff) | |
parent | a717e4704af172f4d9711fc59f1d1785582e0d44 (diff) | |
download | nova-56e7cb1c43c64669fb2ffb2decdb35ef37535995.tar.gz nova-56e7cb1c43c64669fb2ffb2decdb35ef37535995.tar.xz nova-56e7cb1c43c64669fb2ffb2decdb35ef37535995.zip |
Merge "Enforce an instance uuid for instance_test_and_set."
-rw-r--r-- | nova/db/api.py | 6 | ||||
-rw-r--r-- | nova/db/sqlalchemy/api.py | 8 |
2 files changed, 7 insertions, 7 deletions
diff --git a/nova/db/api.py b/nova/db/api.py index a7d5d215b..025a5848f 100644 --- a/nova/db/api.py +++ b/nova/db/api.py @@ -621,13 +621,13 @@ def instance_get_all_hung_in_rebooting(context, reboot_window): return IMPL.instance_get_all_hung_in_rebooting(context, reboot_window) -def instance_test_and_set(context, instance_id, attr, ok_states, +def instance_test_and_set(context, instance_uuid, attr, ok_states, new_state): """Atomically check if an instance is in a valid state, and if it is, set the instance into a new state. """ - return IMPL.instance_test_and_set( - context, instance_id, attr, ok_states, new_state) + return IMPL.instance_test_and_set(context, instance_uuid, attr, + ok_states, new_state) def instance_update(context, instance_uuid, values): diff --git a/nova/db/sqlalchemy/api.py b/nova/db/sqlalchemy/api.py index 938a628ee..49f77aacc 100644 --- a/nova/db/sqlalchemy/api.py +++ b/nova/db/sqlalchemy/api.py @@ -1655,7 +1655,7 @@ def instance_get_all_hung_in_rebooting(context, reboot_window, session=None): @require_context -def instance_test_and_set(context, instance_id, attr, ok_states, +def instance_test_and_set(context, instance_uuid, attr, ok_states, new_state, session=None): """Atomically check if an instance is in a valid state, and if it is, set the instance into a new state. @@ -1667,10 +1667,10 @@ def instance_test_and_set(context, instance_id, attr, ok_states, query = model_query(context, models.Instance, session=session, project_only=True) - if utils.is_uuid_like(instance_id): - query = query.filter_by(uuid=instance_id) + if utils.is_uuid_like(instance_uuid): + query = query.filter_by(uuid=instance_uuid) else: - query = query.filter_by(id=instance_id) + raise exception.InvalidUUID(instance_uuid) # NOTE(vish): if with_lockmode isn't supported, as in sqlite, # then this has concurrency issues |