From f5289971b7da19111ca6a68bb46c1108ea46664b Mon Sep 17 00:00:00 2001 From: Russell Bryant Date: Fri, 20 Jul 2012 13:50:00 -0400 Subject: Don't use rpc to lock/unlock an instance. Instead of converting this method to send a full instance over rpc instead of just an instance UUID, this patch removes the usage of rpc for this operation entirely. All it's doing is a database update. RPC is expensive, so cut out the middle-man. One functional difference with this approach is that the db update is now synchronous on the API node, instead of kicking off an async message to a compute node to handle it. This seems fine, though. Part of blueprint no-db-messaging. Change-Id: I15ceb7625425ab097eebd5b7dd3606a171329f97 --- nova/tests/compute/test_compute.py | 5 +++-- nova/tests/compute/test_rpcapi.py | 8 -------- 2 files changed, 3 insertions(+), 10 deletions(-) (limited to 'nova/tests') diff --git a/nova/tests/compute/test_compute.py b/nova/tests/compute/test_compute.py index 93eb644c6..c9110176d 100644 --- a/nova/tests/compute/test_compute.py +++ b/nova/tests/compute/test_compute.py @@ -213,6 +213,7 @@ class ComputeTestCase(BaseTestCase): fake_get_nw_info) self.stubs.Set(nova.network.API, 'allocate_for_instance', fake_get_nw_info) + self.compute_api = compute.API() def tearDown(self): super(ComputeTestCase, self).tearDown() @@ -1038,13 +1039,13 @@ class ComputeTestCase(BaseTestCase): is_admin=False) # decorator should return False (fail) with locked nonadmin context - self.compute.lock_instance(self.context, instance_uuid) + self.compute_api.lock(self.context, instance) ret_val = self.compute.reboot_instance(non_admin_context, instance=jsonutils.to_primitive(instance)) self.assertEqual(ret_val, False) # decorator should return None (success) with unlocked nonadmin context - self.compute.unlock_instance(self.context, instance_uuid) + self.compute_api.unlock(self.context, instance) ret_val = self.compute.reboot_instance(non_admin_context, instance=jsonutils.to_primitive(instance)) self.assertEqual(ret_val, None) diff --git a/nova/tests/compute/test_rpcapi.py b/nova/tests/compute/test_rpcapi.py index 080128f47..488119116 100644 --- a/nova/tests/compute/test_rpcapi.py +++ b/nova/tests/compute/test_rpcapi.py @@ -195,10 +195,6 @@ class ComputeRpcAPITestCase(test.TestCase): self._test_compute_api('inject_network_info', 'cast', instance=self.fake_instance) - def test_lock_instance(self): - self._test_compute_api('lock_instance', 'cast', - instance=self.fake_instance) - def test_post_live_migration_at_destination(self): self._test_compute_api('post_live_migration_at_destination', 'call', instance=self.fake_instance, block_migration='block_migration', @@ -318,10 +314,6 @@ class ComputeRpcAPITestCase(test.TestCase): self._test_compute_api('terminate_instance', 'cast', instance=self.fake_instance) - def test_unlock_instance(self): - self._test_compute_api('unlock_instance', 'cast', - instance=self.fake_instance) - def test_unpause_instance(self): self._test_compute_api('unpause_instance', 'cast', instance=self.fake_instance) -- cgit