From f900f2ace36eced5dd4615216184445fe7ba0c64 Mon Sep 17 00:00:00 2001 From: Dan Smith Date: Tue, 8 Oct 2013 13:10:55 -0700 Subject: [PATCH] Remove aggregate metadata methods from conductor and virtapi The aggregate_metadata_add() and aggregate_metadata_remove() methods are no longer needed in virtapi and conductor. This patch removes them from the former and deprecates them in the latter. Also, aggregate_get_by_host() is no longer needed in virtapi, so remove it from there. Related to blueprint compute-manager-objects Change-Id: Ia057dcc43c555187a4a1466a9e748b978c46d4a4 --- nova/compute/manager.py | 13 -------- nova/conductor/api.py | 11 ------- nova/conductor/manager.py | 6 +++- nova/conductor/rpcapi.py | 17 +---------- nova/tests/compute/test_virtapi.py | 11 ------- nova/tests/conductor/test_conductor.py | 42 +++++++++++++------------- nova/virt/fake.py | 11 ------- nova/virt/virtapi.py | 26 ---------------- 8 files changed, 27 insertions(+), 110 deletions(-) diff --git a/nova/compute/manager.py b/nova/compute/manager.py index d31f66e4e6a9..2ff984327c3b 100644 --- a/nova/compute/manager.py +++ b/nova/compute/manager.py @@ -388,19 +388,6 @@ class ComputeVirtAPI(virtapi.VirtAPI): instance_uuid, **updates) - def aggregate_get_by_host(self, context, host, key=None): - return self._compute.conductor_api.aggregate_get_by_host(context, - host, key=key) - - def aggregate_metadata_add(self, context, aggregate, metadata, - set_delete=False): - return self._compute.conductor_api.aggregate_metadata_add( - context, aggregate, metadata, set_delete=set_delete) - - def aggregate_metadata_delete(self, context, aggregate, key): - return self._compute.conductor_api.aggregate_metadata_delete( - context, aggregate, key) - def security_group_get_by_instance(self, context, instance): return self._compute.conductor_api.security_group_get_by_instance( context, instance) diff --git a/nova/conductor/api.py b/nova/conductor/api.py index 938cf3c213df..931524c86b0a 100644 --- a/nova/conductor/api.py +++ b/nova/conductor/api.py @@ -126,17 +126,6 @@ class LocalAPI(object): def aggregate_get_by_host(self, context, host, key=None): return self._manager.aggregate_get_by_host(context, host, key) - def aggregate_metadata_add(self, context, aggregate, metadata, - set_delete=False): - return self._manager.aggregate_metadata_add(context, aggregate, - metadata, - set_delete) - - def aggregate_metadata_delete(self, context, aggregate, key): - return self._manager.aggregate_metadata_delete(context, - aggregate, - key) - def aggregate_metadata_get_by_host(self, context, host, key='availability_zone'): return self._manager.aggregate_metadata_get_by_host(context, diff --git a/nova/conductor/manager.py b/nova/conductor/manager.py index 0100633fdba5..221be9d900f1 100644 --- a/nova/conductor/manager.py +++ b/nova/conductor/manager.py @@ -74,7 +74,7 @@ class ConductorManager(manager.Manager): namespace. See the ComputeTaskManager class for details. """ - RPC_API_VERSION = '1.58' + RPC_API_VERSION = '1.60' def __init__(self, *args, **kwargs): super(ConductorManager, self).__init__(service_name='conductor', @@ -218,6 +218,8 @@ class ConductorManager(manager.Manager): host, key) return jsonutils.to_primitive(aggregates) + # NOTE(danms): This method is now deprecated and can be removed in + # version 2.0 of the RPC API def aggregate_metadata_add(self, context, aggregate, metadata, set_delete=False): new_metadata = self.db.aggregate_metadata_add(context.elevated(), @@ -225,6 +227,8 @@ class ConductorManager(manager.Manager): metadata, set_delete) return jsonutils.to_primitive(new_metadata) + # NOTE(danms): This method is now deprecated and can be removed in + # version 2.0 of the RPC API @rpc_common.client_exceptions(exception.AggregateMetadataNotFound) def aggregate_metadata_delete(self, context, aggregate, key): self.db.aggregate_metadata_delete(context.elevated(), diff --git a/nova/conductor/rpcapi.py b/nova/conductor/rpcapi.py index 1f123d2b9790..03c74c43f8b2 100644 --- a/nova/conductor/rpcapi.py +++ b/nova/conductor/rpcapi.py @@ -111,6 +111,7 @@ class ConductorAPI(rpcclient.RpcProxy): 1.57 - Remove migration_create() 1.58 - Remove migration_get() 1.59 - Remove instance_info_cache_update() + 1.60 - Remove aggregate_metadata_add() and aggregate_metadata_delete() """ BASE_RPC_API_VERSION = '1.0' @@ -190,22 +191,6 @@ class ConductorAPI(rpcclient.RpcProxy): cctxt = self.client.prepare(version='1.7') return cctxt.call(context, 'aggregate_get_by_host', host=host, key=key) - def aggregate_metadata_add(self, context, aggregate, metadata, - set_delete=False): - aggregate_p = jsonutils.to_primitive(aggregate) - cctxt = self.client.prepare(version='1.7') - return cctxt.call(context, 'aggregate_metadata_add', - aggregate=aggregate_p, - metadata=metadata, - set_delete=set_delete) - - def aggregate_metadata_delete(self, context, aggregate, key): - aggregate_p = jsonutils.to_primitive(aggregate) - cctxt = self.client.prepare(version='1.7') - return cctxt.call(context, 'aggregate_metadata_delete', - aggregate=aggregate_p, - key=key) - def aggregate_metadata_get_by_host(self, context, host, key): cctxt = self.client.prepare(version='1.42') return cctxt.call(context, 'aggregate_metadata_get_by_host', diff --git a/nova/tests/compute/test_virtapi.py b/nova/tests/compute/test_virtapi.py index 9bf5175f0641..8cc86fa253ac 100644 --- a/nova/tests/compute/test_virtapi.py +++ b/nova/tests/compute/test_virtapi.py @@ -45,17 +45,6 @@ class VirtAPIBaseTest(test.NoDBTestCase, test.APICoverage): self.assertExpected('instance_update', 'fake-uuid', dict(host='foohost')) - def test_aggregate_get_by_host(self): - self.assertExpected('aggregate_get_by_host', 'fake-host', key=None) - - def test_aggregate_metadata_add(self): - self.assertExpected('aggregate_metadata_add', {'id': 'fake'}, - {'foo': 'bar'}, set_delete=False) - - def test_aggregate_metadata_delete(self): - self.assertExpected('aggregate_metadata_delete', {'id': 'fake'}, - 'foo') - def test_security_group_get_by_instance(self): self.assertExpected('security_group_get_by_instance', {'uuid': 'fake-id'}) diff --git a/nova/tests/conductor/test_conductor.py b/nova/tests/conductor/test_conductor.py index 599c857116c2..cbb1fcbb49d6 100644 --- a/nova/tests/conductor/test_conductor.py +++ b/nova/tests/conductor/test_conductor.py @@ -198,27 +198,6 @@ class _BaseTestCase(object): aggregates = self.conductor.aggregate_get_by_host(self.context, 'bar') self.assertEqual(aggregates[0]['availability_zone'], 'foo') - def test_aggregate_metadata_add(self): - aggregate = {'name': 'fake aggregate', 'id': 'fake-id'} - metadata = {'foo': 'bar'} - self.mox.StubOutWithMock(db, 'aggregate_metadata_add') - db.aggregate_metadata_add( - mox.IgnoreArg(), aggregate['id'], metadata, False).AndReturn( - metadata) - self.mox.ReplayAll() - result = self.conductor.aggregate_metadata_add(self.context, - aggregate, - metadata) - self.assertEqual(result, metadata) - - def test_aggregate_metadata_delete(self): - aggregate = {'name': 'fake aggregate', 'id': 'fake-id'} - self.mox.StubOutWithMock(db, 'aggregate_metadata_delete') - db.aggregate_metadata_delete(mox.IgnoreArg(), aggregate['id'], 'fake') - self.mox.ReplayAll() - self.conductor.aggregate_metadata_delete(self.context, aggregate, - 'fake') - def test_aggregate_metadata_get_by_host(self): self.mox.StubOutWithMock(db, 'aggregate_metadata_get_by_host') db.aggregate_metadata_get_by_host(self.context, 'host', @@ -885,6 +864,27 @@ class ConductorTestCase(_BaseTestCase, test.TestCase): self.assertIn('dict', updates) self.assertEqual({'foo': 'bar'}, updates['dict']) + def test_aggregate_metadata_add(self): + aggregate = {'name': 'fake aggregate', 'id': 'fake-id'} + metadata = {'foo': 'bar'} + self.mox.StubOutWithMock(db, 'aggregate_metadata_add') + db.aggregate_metadata_add( + mox.IgnoreArg(), aggregate['id'], metadata, False).AndReturn( + metadata) + self.mox.ReplayAll() + result = self.conductor.aggregate_metadata_add(self.context, + aggregate, + metadata) + self.assertEqual(result, metadata) + + def test_aggregate_metadata_delete(self): + aggregate = {'name': 'fake aggregate', 'id': 'fake-id'} + self.mox.StubOutWithMock(db, 'aggregate_metadata_delete') + db.aggregate_metadata_delete(mox.IgnoreArg(), aggregate['id'], 'fake') + self.mox.ReplayAll() + self.conductor.aggregate_metadata_delete(self.context, aggregate, + 'fake') + class ConductorRPCAPITestCase(_BaseTestCase, test.TestCase): """Conductor RPC API Tests.""" diff --git a/nova/virt/fake.py b/nova/virt/fake.py index 7baa271275fa..9f479c95cae0 100644 --- a/nova/virt/fake.py +++ b/nova/virt/fake.py @@ -457,17 +457,6 @@ class FakeVirtAPI(virtapi.VirtAPI): instance_uuid, updates) - def aggregate_get_by_host(self, context, host, key=None): - return db.aggregate_get_by_host(context, host, key=key) - - def aggregate_metadata_add(self, context, aggregate, metadata, - set_delete=False): - return db.aggregate_metadata_add(context, aggregate['id'], metadata, - set_delete=set_delete) - - def aggregate_metadata_delete(self, context, aggregate, key): - return db.aggregate_metadata_delete(context, aggregate['id'], key) - def security_group_get_by_instance(self, context, instance): return db.security_group_get_by_instance(context, instance['uuid']) diff --git a/nova/virt/virtapi.py b/nova/virt/virtapi.py index afbd68c13e8d..0646484e840b 100644 --- a/nova/virt/virtapi.py +++ b/nova/virt/virtapi.py @@ -26,32 +26,6 @@ class VirtAPI(object): """ raise NotImplementedError() - def aggregate_get_by_host(self, context, host, key=None): - """Get a list of aggregates to which the specified host belongs - :param context: security context - :param host: the host for which aggregates should be returned - :param key: optionally filter by hosts with the given metadata key - """ - raise NotImplementedError() - - def aggregate_metadata_add(self, context, aggregate, metadata, - set_delete=False): - """Add/update metadata for specified aggregate - :param context: security context - :param aggregate: aggregate on which to update metadata - :param metadata: dict of metadata to add/update - :param set_delete: if True, only add - """ - raise NotImplementedError() - - def aggregate_metadata_delete(self, context, aggregate, key): - """Delete the given metadata key from specified aggregate - :param context: security context - :param aggregate: aggregate from which to delete metadata - :param key: metadata key to delete - """ - raise NotImplementedError() - def security_group_get_by_instance(self, context, instance): """Get the security group for a specified instance :param context: security context