From a196782cf080a1de97e480bc824d218aa6db87b0 Mon Sep 17 00:00:00 2001 From: Dan Smith Date: Wed, 5 Feb 2014 11:30:06 -0800 Subject: [PATCH] Deprecate conductor instance_type_get() and remove from VirtAPI The flavor_get() in VirtAPI and instance_type_get() in conductor are no longer needed by the virt drivers. This patch deprecates the function in conductor's API and removes it everywhere else. Related to blueprint compute-manager-objects Change-Id: I782ee449df98a198f625b946c650ebff56711b8e --- nova/compute/manager.py | 4 ---- nova/conductor/api.py | 3 --- nova/conductor/manager.py | 2 ++ nova/conductor/rpcapi.py | 6 +----- nova/tests/compute/test_virtapi.py | 13 ++----------- nova/tests/conductor/test_conductor.py | 7 ------- nova/virt/fake.py | 3 --- nova/virt/virtapi.py | 7 ------- 8 files changed, 5 insertions(+), 40 deletions(-) diff --git a/nova/compute/manager.py b/nova/compute/manager.py index c2087f0fb3..801f298ef2 100644 --- a/nova/compute/manager.py +++ b/nova/compute/manager.py @@ -401,10 +401,6 @@ class ComputeVirtAPI(virtapi.VirtAPI): return self._compute.conductor_api.agent_build_get_by_triple( context, hypervisor, os, architecture) - def flavor_get(self, context, flavor_id): - return self._compute.conductor_api.instance_type_get(context, - flavor_id) - def block_device_mapping_get_all_by_instance(self, context, instance, legacy=True): capi = self._compute.conductor_api diff --git a/nova/conductor/api.py b/nova/conductor/api.py index 6df70108ab..b5447dbd05 100644 --- a/nova/conductor/api.py +++ b/nova/conductor/api.py @@ -103,9 +103,6 @@ class LocalAPI(object): def instance_info_cache_delete(self, context, instance): return self._manager.instance_info_cache_delete(context, instance) - def instance_type_get(self, context, instance_type_id): - return self._manager.instance_type_get(context, instance_type_id) - def instance_fault_create(self, context, values): return self._manager.instance_fault_create(context, values) diff --git a/nova/conductor/manager.py b/nova/conductor/manager.py index 905edae22a..9a43c384c2 100644 --- a/nova/conductor/manager.py +++ b/nova/conductor/manager.py @@ -380,6 +380,8 @@ class ConductorManager(manager.Manager): self.db.instance_info_cache_update(context, instance['uuid'], values) + # NOTE(danms): This method is now deprecated and can be removed in + # version v2.0 of the RPC API. def instance_type_get(self, context, instance_type_id): result = self.db.flavor_get(context, instance_type_id) return jsonutils.to_primitive(result) diff --git a/nova/conductor/rpcapi.py b/nova/conductor/rpcapi.py index dc80e45b1d..0e20d3774c 100644 --- a/nova/conductor/rpcapi.py +++ b/nova/conductor/rpcapi.py @@ -125,6 +125,7 @@ class ConductorAPI(object): 1.63 - Changed the format of values['stats'] from a dict to a JSON string in compute_node_update() 1.64 - Added use_slave to instance_get_all_filters() + ... - Remove instance_type_get() """ VERSION_ALIASES = { @@ -306,11 +307,6 @@ class ConductorAPI(object): cctxt = self.client.prepare(version='1.17') cctxt.call(context, 'instance_info_cache_delete', instance=instance_p) - def instance_type_get(self, context, instance_type_id): - cctxt = self.client.prepare(version='1.18') - return cctxt.call(context, 'instance_type_get', - instance_type_id=instance_type_id) - def vol_get_usage_by_time(self, context, start_time): start_time_p = jsonutils.to_primitive(start_time) cctxt = self.client.prepare(version='1.19') diff --git a/nova/tests/compute/test_virtapi.py b/nova/tests/compute/test_virtapi.py index 3dffe3f72b..a4c98767ab 100644 --- a/nova/tests/compute/test_virtapi.py +++ b/nova/tests/compute/test_virtapi.py @@ -50,9 +50,6 @@ class VirtAPIBaseTest(test.NoDBTestCase, test.APICoverage): self.assertExpected('agent_build_get_by_triple', 'fake-hv', 'gnu/hurd', 'fake-arch') - def test_flavor_get(self): - self.assertExpected('flavor_get', 'fake-flavor') - def test_block_device_mapping_get_all_by_instance(self): self.assertExpected('block_device_mapping_get_all_by_instance', {'uuid': 'fake_uuid'}, legacy=False) @@ -117,14 +114,8 @@ class ComputeVirtAPITest(VirtAPIBaseTest): self.virtapi = compute_manager.ComputeVirtAPI(self.compute) def assertExpected(self, method, *args, **kwargs): - if method == 'flavor_get': - # TODO(mriedem): Remove this when conductor_api.instance_type_get - # is renamed to flavor_get. - cond_api_method = 'instance_type_get' - else: - cond_api_method = method - self.mox.StubOutWithMock(self.compute.conductor_api, cond_api_method) - getattr(self.compute.conductor_api, cond_api_method)( + self.mox.StubOutWithMock(self.compute.conductor_api, method) + getattr(self.compute.conductor_api, method)( self.context, *args, **kwargs).AndReturn('it worked') self.mox.ReplayAll() result = getattr(self.virtapi, method)(self.context, *args, **kwargs) diff --git a/nova/tests/conductor/test_conductor.py b/nova/tests/conductor/test_conductor.py index a872019b5f..cbd951c554 100644 --- a/nova/tests/conductor/test_conductor.py +++ b/nova/tests/conductor/test_conductor.py @@ -287,13 +287,6 @@ class _BaseTestCase(object): self.conductor.instance_info_cache_delete(self.context, {'uuid': 'fake-uuid'}) - def test_flavor_get(self): - self.mox.StubOutWithMock(db, 'flavor_get') - db.flavor_get(self.context, 'fake-id').AndReturn('fake-type') - self.mox.ReplayAll() - result = self.conductor.instance_type_get(self.context, 'fake-id') - self.assertEqual(result, 'fake-type') - def test_vol_get_usage_by_time(self): self.mox.StubOutWithMock(db, 'vol_get_usage_by_time') db.vol_get_usage_by_time(self.context, 'fake-time').AndReturn( diff --git a/nova/virt/fake.py b/nova/virt/fake.py index 9e62c6c979..a26b879467 100644 --- a/nova/virt/fake.py +++ b/nova/virt/fake.py @@ -479,9 +479,6 @@ class FakeVirtAPI(virtapi.VirtAPI): return db.agent_build_get_by_triple(context, hypervisor, os, architecture) - def flavor_get(self, context, flavor_id): - return db.flavor_get(context, flavor_id) - def block_device_mapping_get_all_by_instance(self, context, instance, legacy=True): bdms = db.block_device_mapping_get_all_by_instance(context, diff --git a/nova/virt/virtapi.py b/nova/virt/virtapi.py index 66e24a84b1..497133c2ce 100644 --- a/nova/virt/virtapi.py +++ b/nova/virt/virtapi.py @@ -40,13 +40,6 @@ class VirtAPI(object): """ raise NotImplementedError() - def flavor_get(self, context, flavor_id): - """Get information about a flavor - :param context: security context - :param flavor_id: the id of the flavor in question - """ - raise NotImplementedError() - def block_device_mapping_get_all_by_instance(self, context, instance, legacy=True): """Get block device mappings for an instance