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
This commit is contained in:
Dan Smith 2013-10-08 13:10:55 -07:00
parent f2f58eef93
commit f900f2ace3
8 changed files with 27 additions and 110 deletions

View File

@ -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)

View File

@ -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,

View File

@ -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(),

View File

@ -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',

View File

@ -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'})

View File

@ -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."""

View File

@ -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'])

View File

@ -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