Skip to content

Commit

Permalink
Host aggregate configuration throws exception
Browse files Browse the repository at this point in the history
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
  • Loading branch information
gkotton committed Oct 1, 2013
1 parent a6bc12c commit 93695e6
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 54 deletions.
6 changes: 6 additions & 0 deletions nova/compute/manager.py
Expand Up @@ -4996,6 +4996,9 @@ def add_aggregate_host(self, context, host, slave_info=None,
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(
Expand All @@ -5013,6 +5016,9 @@ def remove_aggregate_host(self, context, host, slave_info=None,
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():
Expand Down
21 changes: 0 additions & 21 deletions nova/tests/virt/powervm/test_powervm.py
Expand Up @@ -797,27 +797,6 @@ def test_get_host_uptime(self):
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
Expand Down
6 changes: 0 additions & 6 deletions nova/virt/fake.py
Expand Up @@ -440,12 +440,6 @@ def set_host_enabled(self, host, enabled):
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'}

Expand Down
14 changes: 0 additions & 14 deletions nova/virt/libvirt/driver.py
Expand Up @@ -4668,20 +4668,6 @@ def get_io_devices(xml_doc):
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)
Expand Down
13 changes: 0 additions & 13 deletions nova/virt/powervm/driver.py
Expand Up @@ -333,16 +333,3 @@ def finish_revert_migration(self, instance, network_info,

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

0 comments on commit 93695e6

Please sign in to comment.