From d70793b5bb86b91ab6ad2a3e03832f1f6171c081 Mon Sep 17 00:00:00 2001 From: Chris Behrens Date: Sat, 21 Jan 2012 07:40:24 +0000 Subject: Refactor compute api messaging calls to compute manager API's calls to compute manager all use instance_uuid now. That allows us to refactor _cast_compute_message and make everything use it. This removes an extra DB call in a lot of cases where we already had the instance object, but then passed an instance_uuid into _cast_compute_message with no host, where it would look the object up again. Change-Id: Ia0739efcab0ca362c5bb89cd45c920bf762098f3 --- nova/tests/api/openstack/compute/test_server_actions.py | 2 +- nova/tests/api/openstack/compute/test_servers.py | 5 ----- nova/tests/test_compute.py | 5 +++++ 3 files changed, 6 insertions(+), 6 deletions(-) (limited to 'nova/tests') diff --git a/nova/tests/api/openstack/compute/test_server_actions.py b/nova/tests/api/openstack/compute/test_server_actions.py index a0c4c390e..08612adb1 100644 --- a/nova/tests/api/openstack/compute/test_server_actions.py +++ b/nova/tests/api/openstack/compute/test_server_actions.py @@ -102,7 +102,7 @@ def stub_instance(id, metadata=None, image_ref="10", flavor_id="1", "vcpus": 0, "local_gb": 0, "hostname": "", - "host": "", + "host": "fake_host", "instance_type": dict(inst_type), "user_data": "", "reservation_id": "", diff --git a/nova/tests/api/openstack/compute/test_servers.py b/nova/tests/api/openstack/compute/test_servers.py index 0fafa1e77..f545aeaec 100644 --- a/nova/tests/api/openstack/compute/test_servers.py +++ b/nova/tests/api/openstack/compute/test_servers.py @@ -150,10 +150,6 @@ def fake_compute_api(cls, req, id): return True -def find_host(self, context, instance_id): - return "nova" - - class MockSetAdminPassword(object): def __init__(self): self.instance_id = None @@ -1564,7 +1560,6 @@ class ServersControllerCreateTest(test.TestCase): self.stubs.Set(nova.db, 'queue_get_for', queue_get_for) self.stubs.Set(nova.network.manager.VlanManager, 'allocate_fixed_ip', fake_method) - self.stubs.Set(nova.compute.api.API, "_find_host", find_host) def _test_create_instance(self): image_uuid = 'c905cedb-7281-47e4-8a62-f26bc5fc4c77' diff --git a/nova/tests/test_compute.py b/nova/tests/test_compute.py index 421a0ef89..79e9f8272 100644 --- a/nova/tests/test_compute.py +++ b/nova/tests/test_compute.py @@ -147,6 +147,7 @@ class BaseTestCase(test.TestCase): inst['launch_time'] = '10' inst['user_id'] = self.user_id inst['project_id'] = self.project_id + inst['host'] = 'fake_host' type_id = instance_types.get_instance_type_by_name(type_name)['id'] inst['instance_type_id'] = type_id inst['ami_launch_index'] = 0 @@ -3017,6 +3018,10 @@ class ComputePolicyTestCase(BaseTestCase): def test_wrapped_method(self): instance = self._create_fake_instance() + # Reset this to None for this policy check. If it's set, it + # tries to do a compute_api.update() and we're not testing for + # that here. + instance['host'] = None self.compute.run_instance(self.context, instance['uuid']) # force delete to fail -- cgit