@@ -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-
1280112714class 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
0 commit comments