Skip to content

Commit 83ae149

Browse files
committed
virt: Remove various aggregate APIs
These were used to broadcast aggregate changes to XenAPI pools and aren't used by any other in-tree driver. Remove them. Change-Id: I18a01032a89bff84d71e879c5207157393849b7e Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
1 parent caa5f9e commit 83ae149

File tree

7 files changed

+16
-189
lines changed

7 files changed

+16
-189
lines changed

nova/compute/api.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6212,8 +6212,6 @@ def add_host_to_aggregate(self, context, aggregate_id, host_name):
62126212
node_name, err)
62136213
self._update_az_cache_for_host(context, host_name, aggregate.metadata)
62146214
# NOTE(jogo): Send message to host to support resource pools
6215-
self.compute_rpcapi.add_aggregate_host(context,
6216-
aggregate=aggregate, host_param=host_name, host=host_name)
62176215
aggregate_payload.update({'name': aggregate.name})
62186216
compute_utils.notify_about_aggregate_update(context,
62196217
"addhost.end",
@@ -6266,8 +6264,6 @@ def remove_host_from_aggregate(self, context, aggregate_id, host_name):
62666264
aggregate.delete_host(host_name)
62676265
self.query_client.update_aggregates(context, [aggregate])
62686266
self._update_az_cache_for_host(context, host_name, aggregate.metadata)
6269-
self.compute_rpcapi.remove_aggregate_host(context,
6270-
aggregate=aggregate, host_param=host_name, host=host_name)
62716267
compute_utils.notify_about_aggregate_update(context,
62726268
"removehost.end",
62736269
aggregate_payload)

nova/compute/manager.py

Lines changed: 6 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -10092,39 +10092,17 @@ def _error_out_instance_on_exception(self, context, instance,
1009210092
# NOTE(mriedem): Why don't we pass clean_task_state=True here?
1009310093
self._set_instance_obj_error_state(instance)
1009410094

10095+
# TODO(stephenfin): Remove this once we bump the compute API to v6.0
1009510096
@wrap_exception()
1009610097
def add_aggregate_host(self, context, aggregate, host, slave_info):
10097-
"""Notify hypervisor of change (for hypervisor pools)."""
10098-
try:
10099-
self.driver.add_to_aggregate(context, aggregate, host,
10100-
slave_info=slave_info)
10101-
except NotImplementedError:
10102-
LOG.debug('Hypervisor driver does not support '
10103-
'add_aggregate_host')
10104-
except exception.AggregateError:
10105-
with excutils.save_and_reraise_exception():
10106-
self.driver.undo_aggregate_operation(
10107-
context,
10108-
aggregate.delete_host,
10109-
aggregate, host)
10098+
"""(REMOVED) Notify hypervisor of change (for hypervisor pools)."""
10099+
raise NotImplementedError()
1011010100

10101+
# TODO(stephenfin): Remove this once we bump the compute API to v6.0
1011110102
@wrap_exception()
1011210103
def remove_aggregate_host(self, context, host, slave_info, aggregate):
10113-
"""Removes a host from a physical hypervisor pool."""
10114-
try:
10115-
self.driver.remove_from_aggregate(context, aggregate, host,
10116-
slave_info=slave_info)
10117-
except NotImplementedError:
10118-
LOG.debug('Hypervisor driver does not support '
10119-
'remove_aggregate_host')
10120-
except (exception.AggregateError,
10121-
exception.InvalidAggregateAction) as e:
10122-
with excutils.save_and_reraise_exception():
10123-
self.driver.undo_aggregate_operation(
10124-
context,
10125-
aggregate.add_host,
10126-
aggregate, host,
10127-
isinstance(e, exception.AggregateError))
10104+
"""(REMOVED) Removes a host from a physical hypervisor pool."""
10105+
raise NotImplementedError()
1012810106

1012910107
def _process_instance_event(self, instance, event):
1013010108
_event = self.instance_events.pop_instance_event(instance, event)

nova/compute/rpcapi.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -511,6 +511,7 @@ def get_client(self, target, version_cap, serializer):
511511
serializer=serializer,
512512
call_monitor_timeout=cmt)
513513

514+
# TODO(stephenfin): This is no longer used and can be removed in v6.0
514515
def add_aggregate_host(self, ctxt, host, aggregate, host_param,
515516
slave_info=None):
516517
'''Add aggregate host.
@@ -1092,6 +1093,7 @@ def rebuild_instance(
10921093
recreate=recreate, on_shared_storage=on_shared_storage,
10931094
**msg_args)
10941095

1096+
# TODO(stephenfin): This is no longer used and can be removed in v6.0
10951097
def remove_aggregate_host(self, ctxt, host, aggregate, host_param,
10961098
slave_info=None):
10971099
'''Remove aggregate host.

nova/exception.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1243,12 +1243,6 @@ class PortLimitExceeded(QuotaError):
12431243
msg_fmt = _("Maximum number of ports exceeded")
12441244

12451245

1246-
# TODO(stephenfin): Remove this XenAPI relic
1247-
class AggregateError(NovaException):
1248-
msg_fmt = _("Aggregate %(aggregate_id)s: action '%(action)s' "
1249-
"caused an error: %(reason)s.")
1250-
1251-
12521246
class AggregateNotFound(NotFound):
12531247
msg_fmt = _("Aggregate %(aggregate_id)s could not be found.")
12541248

nova/tests/unit/compute/test_compute.py

Lines changed: 8 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -12247,13 +12247,6 @@ def test_add_host_to_aggregate(self, mock_az, mock_notify, mock_add_host,
1224712247
host=fake_host,
1224812248
hypervisor_hostname=fake_host)])
1224912249

12250-
def fake_add_aggregate_host(*args, **kwargs):
12251-
hosts = kwargs["aggregate"].hosts
12252-
self.assertIn(fake_host, hosts)
12253-
12254-
self.stub_out('nova.compute.rpcapi.ComputeAPI.add_aggregate_host',
12255-
fake_add_aggregate_host)
12256-
1225712250
fake_notifier.NOTIFICATIONS = []
1225812251
aggr = self.api.add_host_to_aggregate(self.context,
1225912252
aggr.id, fake_host)
@@ -12449,13 +12442,6 @@ def test_remove_host_from_aggregate_active(
1244912442
aggr.id, host)
1245012443
host_to_remove = values[0][1][0]
1245112444

12452-
def fake_remove_aggregate_host(*args, **kwargs):
12453-
hosts = kwargs["aggregate"].hosts
12454-
self.assertNotIn(host_to_remove, hosts)
12455-
12456-
self.stub_out('nova.compute.rpcapi.ComputeAPI.remove_aggregate_host',
12457-
fake_remove_aggregate_host)
12458-
1245912445
fake_notifier.NOTIFICATIONS = []
1246012446
mock_notify.reset_mock()
1246112447
mock_get_all_by_host.reset_mock()
@@ -12668,12 +12654,12 @@ def test_delete_aggregate(self, delete_aggregate):
1266812654
@mock.patch('nova.scheduler.client.report.SchedulerReportClient.'
1266912655
'aggregate_add_host')
1267012656
@mock.patch('nova.compute.utils.notify_about_aggregate_action')
12671-
@mock.patch('nova.compute.rpcapi.ComputeAPI.add_aggregate_host')
1267212657
@mock.patch('nova.scheduler.client.query.SchedulerQueryClient.'
1267312658
'update_aggregates')
12674-
def test_add_host_to_aggregate(self, update_aggregates, mock_add_agg,
12675-
mock_notify, mock_add_host,
12676-
mock_get_all_by_host):
12659+
def test_add_host_to_aggregate(
12660+
self, update_aggregates, mock_notify, mock_add_host,
12661+
mock_get_all_by_host,
12662+
):
1267712663
self.api.is_safe_to_update_az = mock.Mock()
1267812664
self.api._update_az_cache_for_host = mock.Mock()
1267912665
agg = objects.Aggregate(name='fake', metadata={}, uuid=uuids.agg)
@@ -12690,23 +12676,19 @@ def test_add_host_to_aggregate(self, update_aggregates, mock_add_agg,
1269012676
return_value=agg)):
1269112677
self.api.add_host_to_aggregate(self.context, 1, 'fakehost')
1269212678
update_aggregates.assert_called_once_with(self.context, [agg])
12693-
mock_add_agg.assert_called_once_with(self.context, aggregate=agg,
12694-
host_param='fakehost',
12695-
host='fakehost')
1269612679
mock_add_host.assert_called_once_with(
1269712680
self.context, agg.uuid, host_name='fakehost')
1269812681

1269912682
@mock.patch.object(objects.ComputeNodeList, 'get_all_by_host')
1270012683
@mock.patch('nova.scheduler.client.report.SchedulerReportClient.'
1270112684
'aggregate_remove_host')
1270212685
@mock.patch('nova.compute.utils.notify_about_aggregate_action')
12703-
@mock.patch('nova.compute.rpcapi.ComputeAPI.remove_aggregate_host')
1270412686
@mock.patch('nova.scheduler.client.query.SchedulerQueryClient.'
1270512687
'update_aggregates')
12706-
def test_remove_host_from_aggregate(self, update_aggregates,
12707-
mock_remove_agg, mock_notify,
12708-
mock_remove_host,
12709-
mock_get_all_by_host):
12688+
def test_remove_host_from_aggregate(
12689+
self, update_aggregates, mock_notify, mock_remove_host,
12690+
mock_get_all_by_host,
12691+
):
1271012692
self.api._update_az_cache_for_host = mock.Mock()
1271112693
agg = objects.Aggregate(name='fake', metadata={}, uuid=uuids.agg)
1271212694
agg.delete_host = mock.Mock()
@@ -12720,9 +12702,6 @@ def test_remove_host_from_aggregate(self, update_aggregates,
1272012702
return_value=agg)):
1272112703
self.api.remove_host_from_aggregate(self.context, 1, 'fakehost')
1272212704
update_aggregates.assert_called_once_with(self.context, [agg])
12723-
mock_remove_agg.assert_called_once_with(self.context, aggregate=agg,
12724-
host_param='fakehost',
12725-
host='fakehost')
1272612705
mock_notify.assert_has_calls([
1272712706
mock.call(context=self.context, aggregate=agg,
1272812707
action='remove_host', phase='start'),
@@ -12732,72 +12711,6 @@ def test_remove_host_from_aggregate(self, update_aggregates,
1273212711
self.context, agg.uuid, 'fakehost')
1273312712

1273412713

12735-
class ComputeAggrTestCase(BaseTestCase):
12736-
"""This is for unit coverage of aggregate-related methods
12737-
defined in nova.compute.manager.
12738-
"""
12739-
12740-
def setUp(self):
12741-
super(ComputeAggrTestCase, self).setUp()
12742-
self.context = context.get_admin_context()
12743-
az = {'availability_zone': 'test_zone'}
12744-
self.aggr = objects.Aggregate(self.context, name='test_aggr',
12745-
metadata=az)
12746-
self.aggr.create()
12747-
12748-
def test_add_aggregate_host(self):
12749-
def fake_driver_add_to_aggregate(self, context, aggregate, host,
12750-
**_ignore):
12751-
fake_driver_add_to_aggregate.called = True
12752-
return {"foo": "bar"}
12753-
self.stub_out("nova.virt.fake.FakeDriver.add_to_aggregate",
12754-
fake_driver_add_to_aggregate)
12755-
12756-
self.compute.add_aggregate_host(self.context, host="host",
12757-
aggregate=self.aggr, slave_info=None)
12758-
self.assertTrue(fake_driver_add_to_aggregate.called)
12759-
12760-
def test_remove_aggregate_host(self):
12761-
def fake_driver_remove_from_aggregate(cls, context, aggregate, host,
12762-
**_ignore):
12763-
fake_driver_remove_from_aggregate.called = True
12764-
self.assertEqual("host", host, "host")
12765-
return {"foo": "bar"}
12766-
self.stub_out("nova.virt.fake.FakeDriver.remove_from_aggregate",
12767-
fake_driver_remove_from_aggregate)
12768-
12769-
self.compute.remove_aggregate_host(self.context,
12770-
aggregate=self.aggr, host="host", slave_info=None)
12771-
self.assertTrue(fake_driver_remove_from_aggregate.called)
12772-
12773-
def test_add_aggregate_host_passes_slave_info_to_driver(self):
12774-
def driver_add_to_aggregate(cls, context, aggregate, host, **kwargs):
12775-
self.assertEqual(self.context, context)
12776-
self.assertEqual(aggregate.id, self.aggr.id)
12777-
self.assertEqual(host, "the_host")
12778-
self.assertEqual("SLAVE_INFO", kwargs.get("slave_info"))
12779-
12780-
self.stub_out("nova.virt.fake.FakeDriver.add_to_aggregate",
12781-
driver_add_to_aggregate)
12782-
12783-
self.compute.add_aggregate_host(self.context, host="the_host",
12784-
slave_info="SLAVE_INFO", aggregate=self.aggr)
12785-
12786-
def test_remove_from_aggregate_passes_slave_info_to_driver(self):
12787-
def driver_remove_from_aggregate(cls, context, aggregate, host,
12788-
**kwargs):
12789-
self.assertEqual(self.context, context)
12790-
self.assertEqual(aggregate.id, self.aggr.id)
12791-
self.assertEqual(host, "the_host")
12792-
self.assertEqual("SLAVE_INFO", kwargs.get("slave_info"))
12793-
12794-
self.stub_out("nova.virt.fake.FakeDriver.remove_from_aggregate",
12795-
driver_remove_from_aggregate)
12796-
12797-
self.compute.remove_aggregate_host(self.context,
12798-
aggregate=self.aggr, host="the_host", slave_info="SLAVE_INFO")
12799-
12800-
1280112714
class DisabledInstanceTypesTestCase(BaseTestCase):
1280212715
"""Some instance-types are marked 'disabled' which means that they will not
1280312716
show up in customer-facing listings. We do, however, want those

nova/tests/unit/virt/test_virt_drivers.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -650,14 +650,6 @@ def test_host_power_action_shutdown(self):
650650
def test_host_power_action_startup(self):
651651
self.connection.host_power_action('startup')
652652

653-
@catch_notimplementederror
654-
def test_add_to_aggregate(self):
655-
self.connection.add_to_aggregate(self.ctxt, 'aggregate', 'host')
656-
657-
@catch_notimplementederror
658-
def test_remove_from_aggregate(self):
659-
self.connection.remove_from_aggregate(self.ctxt, 'aggregate', 'host')
660-
661653
def test_events(self):
662654
got_events = []
663655

nova/virt/driver.py

Lines changed: 0 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1544,54 +1544,6 @@ def cache_image(self, context, image_id):
15441544
"""
15451545
raise NotImplementedError()
15461546

1547-
# TODO(stephenfin): This was only implemented (properly) for XenAPI and
1548-
# should be removed.
1549-
def add_to_aggregate(self, context, aggregate, host, **kwargs):
1550-
"""Add a compute host to an aggregate.
1551-
1552-
The counter action to this is :func:`remove_from_aggregate`
1553-
1554-
:param nova.context.RequestContext context:
1555-
The security context.
1556-
:param nova.objects.aggregate.Aggregate aggregate:
1557-
The aggregate which should add the given `host`
1558-
:param str host:
1559-
The name of the host to add to the given `aggregate`.
1560-
:param dict kwargs:
1561-
A free-form thingy...
1562-
1563-
:return: None
1564-
"""
1565-
# NOTE(jogo) Currently only used for XenAPI-Pool
1566-
raise NotImplementedError()
1567-
1568-
# TODO(stephenfin): This was only implemented (properly) for XenAPI and
1569-
# should be removed.
1570-
def remove_from_aggregate(self, context, aggregate, host, **kwargs):
1571-
"""Remove a compute host from an aggregate.
1572-
1573-
The counter action to this is :func:`add_to_aggregate`
1574-
1575-
:param nova.context.RequestContext context:
1576-
The security context.
1577-
:param nova.objects.aggregate.Aggregate aggregate:
1578-
The aggregate which should remove the given `host`
1579-
:param str host:
1580-
The name of the host to remove from the given `aggregate`.
1581-
:param dict kwargs:
1582-
A free-form thingy...
1583-
1584-
:return: None
1585-
"""
1586-
raise NotImplementedError()
1587-
1588-
# TODO(stephenfin): This was only implemented (properly) for XenAPI and
1589-
# should be removed.
1590-
def undo_aggregate_operation(self, context, op, aggregate,
1591-
host, set_error=True):
1592-
"""Undo for Resource Pools."""
1593-
raise NotImplementedError()
1594-
15951547
def get_volume_connector(self, instance):
15961548
"""Get connector information for the instance for attaching to volumes.
15971549

0 commit comments

Comments
 (0)