diff options
| author | Jenkins <jenkins@review.openstack.org> | 2012-02-29 22:48:08 +0000 |
|---|---|---|
| committer | Gerrit Code Review <review@openstack.org> | 2012-02-29 22:48:08 +0000 |
| commit | 873830948c19012931a5b220f7e7f1089149b538 (patch) | |
| tree | 7b679f8230b1853a316747ec5a854d342e2a18bf | |
| parent | 07c85f5a835a93a2b4a828510a09adbc30505761 (diff) | |
| parent | ff95c90f51d1d1e70a247cb7e94bb7cb757ac37d (diff) | |
| download | nova-873830948c19012931a5b220f7e7f1089149b538.tar.gz nova-873830948c19012931a5b220f7e7f1089149b538.tar.xz nova-873830948c19012931a5b220f7e7f1089149b538.zip | |
Merge "Ensure that context read_deleted is only one of 'no', 'yes' or 'only'"
| -rw-r--r-- | nova/compute/manager.py | 2 | ||||
| -rw-r--r-- | nova/context.py | 4 | ||||
| -rw-r--r-- | nova/tests/test_context.py | 13 |
3 files changed, 18 insertions, 1 deletions
diff --git a/nova/compute/manager.py b/nova/compute/manager.py index a4a18f1f8..5aac65a54 100644 --- a/nova/compute/manager.py +++ b/nova/compute/manager.py @@ -401,7 +401,7 @@ class ComputeManager(manager.SchedulerDependentManager): LOG.info(_("Instance %(instance_uuid)s did not exist in the " "DB, but I will shut it down anyway using a special " "context") % locals()) - ctxt = nova.context.get_admin_context(True) + ctxt = nova.context.get_admin_context('yes') self.terminate_instance(ctxt, instance_uuid) except Exception as ex: LOG.info(_("exception terminating the instance " diff --git a/nova/context.py b/nova/context.py index 58deb1318..8ec4a30ec 100644 --- a/nova/context.py +++ b/nova/context.py @@ -48,6 +48,10 @@ class RequestContext(object): :param overwrite: Set to False to ensure that the greenthread local copy of the index is not overwritten. """ + if read_deleted not in ('no', 'yes', 'only'): + raise ValueError(_("read_deleted can only be one of 'no', " + "'yes' or 'only', not %r") % read_deleted) + self.user_id = user_id self.project_id = project_id self.roles = roles or [] diff --git a/nova/tests/test_context.py b/nova/tests/test_context.py index b2507fa59..7fceb2421 100644 --- a/nova/tests/test_context.py +++ b/nova/tests/test_context.py @@ -31,3 +31,16 @@ class ContextTestCase(test.TestCase): '222', roles=['Admin', 'weasel']) self.assertEquals(ctxt.is_admin, True) + + def test_request_context_read_deleted(self): + ctxt = context.RequestContext('111', + '222', + read_deleted='yes') + self.assertEquals(ctxt.read_deleted, 'yes') + + def test_request_context_read_deleted_invalid(self): + self.assertRaises(ValueError, + context.RequestContext, + '111', + '222', + read_deleted=True) |
