From 93695e60ec6136688fe5ca2d6d8494dcfd71eb22 Mon Sep 17 00:00:00 2001 From: Gary Kotton Date: Wed, 25 Sep 2013 11:58:17 -0700 Subject: [PATCH] Host aggregate configuration throws exception If the virtualization driver did not implement the host aggregate support functions (add_to_aggregate, remove_from_aggregate and undo_aggregate_operation) then an exception is thrown when a host aggregate was created/deleted. Configuration of the host aggregates breaks tempest tests when the underlying driver does not have these methods implemented. The only driver that actually uses this is the Xen driver. The solution enables all drivers to support this without having to add in specific code. More specifically, the compute manager will not raise NotImplementedError. Closes-Bug: 1229912 Closes-Bug: 1229911 Change-Id: Iee69e45d94047742b6a499a139bac96ad9dd971f --- nova/compute/manager.py | 6 ++++++ nova/tests/virt/powervm/test_powervm.py | 21 --------------------- nova/virt/fake.py | 6 ------ nova/virt/libvirt/driver.py | 14 -------------- nova/virt/powervm/driver.py | 13 ------------- 5 files changed, 6 insertions(+), 54 deletions(-) diff --git a/nova/compute/manager.py b/nova/compute/manager.py index 99655a08b56e..8c221c6fc871 100644 --- a/nova/compute/manager.py +++ b/nova/compute/manager.py @@ -4996,6 +4996,9 @@ class ComputeManager(manager.SchedulerDependentManager): try: self.driver.add_to_aggregate(context, aggregate, host, slave_info=slave_info) + except NotImplementedError: + LOG.debug(_('Hypervisor driver does not support ' + 'add_aggregate_host')) except exception.AggregateError: with excutils.save_and_reraise_exception(): self.driver.undo_aggregate_operation( @@ -5013,6 +5016,9 @@ class ComputeManager(manager.SchedulerDependentManager): try: self.driver.remove_from_aggregate(context, aggregate, host, slave_info=slave_info) + except NotImplementedError: + LOG.debug(_('Hypervisor driver does not support ' + 'remove_aggregate_host')) except (exception.AggregateError, exception.InvalidAggregateAction) as e: with excutils.save_and_reraise_exception(): diff --git a/nova/tests/virt/powervm/test_powervm.py b/nova/tests/virt/powervm/test_powervm.py index 9747537741a2..64ef2f331659 100644 --- a/nova/tests/virt/powervm/test_powervm.py +++ b/nova/tests/virt/powervm/test_powervm.py @@ -797,27 +797,6 @@ class PowerVMDriverTestCase(test.TestCase): uptime = self.powervm_connection.get_host_uptime(None) self.assertEquals(output[0], uptime) - def test_add_to_aggregate(self): - # Simple test to make sure the unimplemented method passes. - self.powervm_connection.add_to_aggregate(context.get_admin_context(), - aggregate={'name': 'foo'}, - host='fake') - - def test_remove_from_aggregate(self): - # Simple test to make sure the unimplemented method passes. - self.powervm_connection.remove_from_aggregate( - context.get_admin_context(), aggregate={'name': 'foo'}, - host='fake') - - def test_undo_aggregate_operation(self): - # Simple test to make sure the unimplemented method passes. - def fake_operation(*args, **kwargs): - pass - - self.powervm_connection.undo_aggregate_operation( - context.get_admin_context(), op=fake_operation, - aggregate={'name': 'foo'}, host='fake') - def test_plug_vifs(self): # Check to make sure the method passes (does nothing) since # it simply passes in the powervm driver but it raises a diff --git a/nova/virt/fake.py b/nova/virt/fake.py index 31fa481feebb..ca7de878e87c 100644 --- a/nova/virt/fake.py +++ b/nova/virt/fake.py @@ -440,12 +440,6 @@ class FakeDriver(driver.ComputeDriver): def get_disk_available_least(self): pass - def add_to_aggregate(self, context, aggregate, host, **kwargs): - pass - - def remove_from_aggregate(self, context, aggregate, host, **kwargs): - pass - def get_volume_connector(self, instance): return {'ip': '127.0.0.1', 'initiator': 'fake', 'host': 'fakehost'} diff --git a/nova/virt/libvirt/driver.py b/nova/virt/libvirt/driver.py index 5eedc0e657e0..f71a92a59f4d 100644 --- a/nova/virt/libvirt/driver.py +++ b/nova/virt/libvirt/driver.py @@ -4668,20 +4668,6 @@ class LibvirtDriver(driver.ComputeDriver): pass return output - def add_to_aggregate(self, context, aggregate, host, **kwargs): - """Add a compute host to an aggregate.""" - #NOTE(jogo) Currently only used for XenAPI-Pool - pass - - def remove_from_aggregate(self, context, aggregate, host, **kwargs): - """Remove a compute host from an aggregate.""" - pass - - def undo_aggregate_operation(self, context, op, aggregate, - host, set_error=True): - """only used for Resource Pools.""" - pass - def instance_on_disk(self, instance): # ensure directories exist and are writable instance_path = libvirt_utils.get_instance_path(instance) diff --git a/nova/virt/powervm/driver.py b/nova/virt/powervm/driver.py index f746cc147481..b1865871251e 100644 --- a/nova/virt/powervm/driver.py +++ b/nova/virt/powervm/driver.py @@ -333,16 +333,3 @@ class PowerVMDriver(driver.ComputeDriver): if power_on: self._powervm.power_on(instance['name']) - - def add_to_aggregate(self, context, aggregate, host, **kwargs): - """Add a compute host to an aggregate.""" - pass - - def remove_from_aggregate(self, context, aggregate, host, **kwargs): - """Remove a compute host from an aggregate.""" - pass - - def undo_aggregate_operation(self, context, op, aggregate, - host, set_error=True): - """Undo for Resource Pools.""" - pass