diff options
author | Russell Bryant <rbryant@redhat.com> | 2012-11-05 14:42:21 -0500 |
---|---|---|
committer | Russell Bryant <rbryant@redhat.com> | 2012-11-08 09:34:24 -0500 |
commit | 1a3ac5aa659c2fc9b6b90a0f49caadc7f967ec2b (patch) | |
tree | 06914965fd67287573455d0e365cf12defa6d448 | |
parent | 53edd1ef81820f948ed2ba4818667836be50d0ea (diff) | |
download | nova-1a3ac5aa659c2fc9b6b90a0f49caadc7f967ec2b.tar.gz nova-1a3ac5aa659c2fc9b6b90a0f49caadc7f967ec2b.tar.xz nova-1a3ac5aa659c2fc9b6b90a0f49caadc7f967ec2b.zip |
Send all aggregate data to remove_aggregate_host.
Update the remove_aggregate_host method of the compute rpc api to take
in all of the aggregate data instead of looking it up from the db in the
compute manager. This removes a db read from the nova-compute service.
Part of blueprint no-db-compute.
Change-Id: I8da3da264e358c14df97ba34d250e46c6cb577e2
-rw-r--r-- | nova/compute/api.py | 3 | ||||
-rw-r--r-- | nova/compute/manager.py | 12 | ||||
-rw-r--r-- | nova/compute/rpcapi.py | 8 | ||||
-rw-r--r-- | nova/tests/compute/test_compute.py | 8 | ||||
-rw-r--r-- | nova/tests/compute/test_rpcapi.py | 4 |
5 files changed, 21 insertions, 14 deletions
diff --git a/nova/compute/api.py b/nova/compute/api.py index 46f30e10b..9ee384393 100644 --- a/nova/compute/api.py +++ b/nova/compute/api.py @@ -2188,9 +2188,10 @@ class AggregateAPI(base.Base): """Removes host from the aggregate.""" # validates the host; ComputeHostNotFound is raised if invalid service = self.db.service_get_all_compute_by_host(context, host)[0] + aggregate = self.db.aggregate_get(context, aggregate_id) self.db.aggregate_host_delete(context, aggregate_id, host) self.compute_rpcapi.remove_aggregate_host(context, - aggregate_id=aggregate_id, host_param=host, host=host) + aggregate=aggregate, host_param=host, host=host) return self.get_aggregate(context, aggregate_id) def _get_aggregate_info(self, context, aggregate): diff --git a/nova/compute/manager.py b/nova/compute/manager.py index c7b63df27..642769dfe 100644 --- a/nova/compute/manager.py +++ b/nova/compute/manager.py @@ -230,7 +230,7 @@ class ComputeVirtAPI(virtapi.VirtAPI): class ComputeManager(manager.SchedulerDependentManager): """Manages the running instances from creation to destruction.""" - RPC_API_VERSION = '2.14' + RPC_API_VERSION = '2.15' def __init__(self, compute_driver=None, *args, **kwargs): """Load configuration options and connect to the hypervisor.""" @@ -3131,10 +3131,12 @@ class ComputeManager(manager.SchedulerDependentManager): aggregate['id'], host) @exception.wrap_exception(notifier=notifier, publisher_id=publisher_id()) - def remove_aggregate_host(self, context, aggregate_id, - host, slave_info=None): + def remove_aggregate_host(self, context, host, slave_info=None, + aggregate=None, aggregate_id=None): """Removes a host from a physical hypervisor pool.""" - aggregate = self.db.aggregate_get(context, aggregate_id) + if not aggregate: + aggregate = self.db.aggregate_get(context, aggregate_id) + try: self.driver.remove_from_aggregate(context, aggregate, host, slave_info=slave_info) @@ -3143,7 +3145,7 @@ class ComputeManager(manager.SchedulerDependentManager): with excutils.save_and_reraise_exception(): self.driver.undo_aggregate_operation( context, self.db.aggregate_host_add, - aggregate.id, host, + aggregate['id'], host, isinstance(e, exception.AggregateError)) @manager.periodic_task( diff --git a/nova/compute/rpcapi.py b/nova/compute/rpcapi.py index 5bf17adcd..ba67b1fa3 100644 --- a/nova/compute/rpcapi.py +++ b/nova/compute/rpcapi.py @@ -142,6 +142,7 @@ class ComputeAPI(nova.openstack.common.rpc.proxy.RpcProxy): 2.12 - Remove migration_id, add migration to revert_resize 2.13 - Remove migration_id, add migration to finish_revert_resize 2.14 - Remove aggregate_id, add aggregate to add_aggregate_host + 2.15 - Remove aggregate_id, add aggregate to remove_aggregate_host ''' # @@ -389,7 +390,7 @@ class ComputeAPI(nova.openstack.common.rpc.proxy.RpcProxy): self.cast(ctxt, self.make_msg('refresh_provider_fw_rules'), _compute_topic(self.topic, ctxt, host, None)) - def remove_aggregate_host(self, ctxt, aggregate_id, host_param, host, + def remove_aggregate_host(self, ctxt, aggregate, host_param, host, slave_info=None): '''Remove aggregate host. @@ -400,11 +401,12 @@ class ComputeAPI(nova.openstack.common.rpc.proxy.RpcProxy): :param host: This is the host to send the message to. ''' + aggregate_p = jsonutils.to_primitive(aggregate) self.cast(ctxt, self.make_msg('remove_aggregate_host', - aggregate_id=aggregate_id, host=host_param, + aggregate=aggregate_p, host=host_param, slave_info=slave_info), topic=_compute_topic(self.topic, ctxt, host, None), - version='2.2') + version='2.15') def remove_fixed_ip_from_instance(self, ctxt, instance, address): instance_p = jsonutils.to_primitive(instance) diff --git a/nova/tests/compute/test_compute.py b/nova/tests/compute/test_compute.py index 1c5be489d..c69970ec8 100644 --- a/nova/tests/compute/test_compute.py +++ b/nova/tests/compute/test_compute.py @@ -5165,7 +5165,8 @@ class ComputeAggrTestCase(BaseTestCase): self.stubs.Set(self.compute.driver, "remove_from_aggregate", fake_driver_remove_from_aggregate) - self.compute.remove_aggregate_host(self.context, self.aggr.id, "host") + self.compute.remove_aggregate_host(self.context, + aggregate=jsonutils.to_primitive(self.aggr), host="host") self.assertTrue(fake_driver_remove_from_aggregate.called) def test_add_aggregate_host_passes_slave_info_to_driver(self): @@ -5185,7 +5186,7 @@ class ComputeAggrTestCase(BaseTestCase): def test_remove_from_aggregate_passes_slave_info_to_driver(self): def driver_remove_from_aggregate(context, aggregate, host, **kwargs): self.assertEquals(self.context, context) - self.assertEquals(aggregate.id, self.aggr.id) + self.assertEquals(aggregate['id'], self.aggr.id) self.assertEquals(host, "the_host") self.assertEquals("SLAVE_INFO", kwargs.get("slave_info")) @@ -5193,7 +5194,8 @@ class ComputeAggrTestCase(BaseTestCase): driver_remove_from_aggregate) self.compute.remove_aggregate_host(self.context, - self.aggr.id, "the_host", slave_info="SLAVE_INFO") + aggregate=jsonutils.to_primitive(self.aggr), host="the_host", + slave_info="SLAVE_INFO") class ComputePolicyTestCase(BaseTestCase): diff --git a/nova/tests/compute/test_rpcapi.py b/nova/tests/compute/test_rpcapi.py index 1edfa771f..db53af8e1 100644 --- a/nova/tests/compute/test_rpcapi.py +++ b/nova/tests/compute/test_rpcapi.py @@ -264,8 +264,8 @@ class ComputeRpcAPITestCase(test.TestCase): def test_remove_aggregate_host(self): self._test_compute_api('remove_aggregate_host', 'cast', - aggregate_id='id', host_param='host', host='host', - slave_info={}, version='2.2') + aggregate={'id': 'fake_id'}, host_param='host', host='host', + slave_info={}, version='2.15') def test_remove_fixed_ip_from_instance(self): self._test_compute_api('remove_fixed_ip_from_instance', 'cast', |