From fead6dcd53e77240767063fc6e885f9c138c2776 Mon Sep 17 00:00:00 2001 From: Vishvananda Ishaya Date: Thu, 11 Oct 2012 11:59:47 -0700 Subject: Stops compute api import at import time There is an automatic import of compute.api at import time whenever anything under compute is imported. This leads to all sorts of weird dependency problems such as the one here: https://review.openstack.org/#/c/14170/ This modifies the import to happen when compute.API() is called, which is how we handle it for network and volume. A few imports were also modified to make it consistent with this new style. Change-Id: Ic748376510aa4cc48dfefc6ec36621d0ae498bfc --- nova/tests/api/openstack/fakes.py | 5 +++-- nova/tests/compute/test_compute.py | 8 ++++---- 2 files changed, 7 insertions(+), 6 deletions(-) (limited to 'nova/tests') diff --git a/nova/tests/api/openstack/fakes.py b/nova/tests/api/openstack/fakes.py index bb6542c16..dc83447e4 100644 --- a/nova/tests/api/openstack/fakes.py +++ b/nova/tests/api/openstack/fakes.py @@ -32,6 +32,7 @@ from nova.api.openstack.compute import versions from nova.api.openstack import urlmap from nova.api.openstack import volume from nova.api.openstack import wsgi as os_wsgi +from nova.compute import api as compute_api from nova.compute import instance_types from nova.compute import vm_states from nova import context @@ -160,7 +161,7 @@ def stub_out_compute_api_snapshot(stubs): return dict(id='123', status='ACTIVE', name=name, properties=extra_properties) - stubs.Set(nova.compute.API, 'snapshot', snapshot) + stubs.Set(compute_api.API, 'snapshot', snapshot) class stub_out_compute_api_backup(object): @@ -168,7 +169,7 @@ class stub_out_compute_api_backup(object): def __init__(self, stubs): self.stubs = stubs self.extra_props_last_call = None - stubs.Set(nova.compute.API, 'backup', self.backup) + stubs.Set(compute_api.API, 'backup', self.backup) def backup(self, context, instance, name, backup_type, rotation, extra_properties=None): diff --git a/nova/tests/compute/test_compute.py b/nova/tests/compute/test_compute.py index cad27b544..cf81c699d 100644 --- a/nova/tests/compute/test_compute.py +++ b/nova/tests/compute/test_compute.py @@ -218,7 +218,7 @@ class ComputeTestCase(BaseTestCase): self.stubs.Set(compute_utils, 'add_instance_fault_from_exc', did_it_add_fault) - @nova.compute.manager.wrap_instance_fault + @compute_manager.wrap_instance_fault def failer(self2, context, instance): raise NotImplementedError() @@ -238,7 +238,7 @@ class ComputeTestCase(BaseTestCase): self.stubs.Set(compute_utils, 'add_instance_fault_from_exc', did_it_add_fault) - @nova.compute.manager.wrap_instance_fault + @compute_manager.wrap_instance_fault def failer(self2, context, instance_uuid): raise exception.InstanceNotFound() @@ -2667,7 +2667,7 @@ class ComputeAPITestCase(BaseTestCase): super(ComputeAPITestCase, self).setUp() self.stubs.Set(network_api.API, 'get_instance_nw_info', fake_get_nw_info) - self.security_group_api = compute.api.SecurityGroupAPI() + self.security_group_api = compute_api.SecurityGroupAPI() self.compute_api = compute.API( security_group_api=self.security_group_api) self.fake_image = { @@ -4916,7 +4916,7 @@ class ComputePolicyTestCase(BaseTestCase): self.mox.StubOutWithMock(nova.policy, 'enforce') nova.policy.enforce(self.context, 'compute:reboot', {}) self.mox.ReplayAll() - nova.compute.api.check_policy(self.context, 'reboot', {}) + compute_api.check_policy(self.context, 'reboot', {}) def test_wrapped_method(self): instance = self._create_fake_instance(params={'host': None}) -- cgit