Prevent 404 error when adding reserved_host to aggregate
When host-failure occurs, masakari-engine adds reserve_host to aggregate. However, when masakari-engine adds reserved_host, masakari-engine passes an aggregate_name to novaclient. This patch is modified so that masakari-engine passes aggregate_id instead of aggregate_name to novaclient. Change-Id: I669b19dea04c8ebb3a27a8ae746ae4c3f88d66f0 Closes-Bug: #1667246
This commit is contained in:
parent
d9e35c603b
commit
7415951c46
|
@ -221,5 +221,5 @@ class API(object):
|
|||
nova = novaclient(context)
|
||||
msg = _LI("Call add_host command to add host '%(host_name)s' to "
|
||||
"aggregate '%(aggregate_name)s'.")
|
||||
LOG.info(msg, {'host_name': host, 'aggregate_name': aggregate})
|
||||
return nova.aggregates.add_host(aggregate, host)
|
||||
LOG.info(msg, {'host_name': host, 'aggregate_name': aggregate.name})
|
||||
return nova.aggregates.add_host(aggregate.id, host)
|
||||
|
|
|
@ -106,7 +106,7 @@ class EvacuateInstancesTask(base.MasakariTask):
|
|||
for aggregate in aggregates:
|
||||
if host_name in aggregate.hosts:
|
||||
self.novaclient.add_host_to_aggregate(
|
||||
context, reserved_host.name, aggregate.name)
|
||||
context, reserved_host.name, aggregate)
|
||||
# A failed compute host can be associated with
|
||||
# multiple aggregates but operators will not
|
||||
# associate it with multiple aggregates in real
|
||||
|
|
|
@ -254,7 +254,7 @@ class NovaApiTestCase(test.TestCase):
|
|||
mock_aggregates = mock.MagicMock()
|
||||
mock_novaclient.return_value = mock.MagicMock(
|
||||
aggregates=mock_aggregates)
|
||||
self.api.add_host_to_aggregate(self.ctx, 'fake_host', 'fake_aggregate')
|
||||
self.api.add_host_to_aggregate(self.ctx, 'fake_host', mock_aggregates)
|
||||
mock_novaclient.assert_called_once_with(self.ctx)
|
||||
mock_aggregates.add_host.assert_called_once_with(
|
||||
'fake_aggregate', 'fake_host')
|
||||
mock_aggregates.id, 'fake_host')
|
||||
|
|
|
@ -161,7 +161,7 @@ class HostFailureTestCase(test.TestCase):
|
|||
instance_list, reserved_host=reserved_host)
|
||||
self.assertEqual(1, mock_save.call_count)
|
||||
self.assertIn(reserved_host.name,
|
||||
self.fake_client.aggregates.get('fake_agg').hosts)
|
||||
self.fake_client.aggregates.get('1').hosts)
|
||||
|
||||
# execute ConfirmEvacuationTask
|
||||
self._test_confirm_evacuate_task(instance_list)
|
||||
|
|
|
@ -100,14 +100,14 @@ class FakeNovaClient(object):
|
|||
def list(self):
|
||||
return self.aggregates
|
||||
|
||||
def add_host(self, aggregate_name, host_name):
|
||||
aggregate = self.get(aggregate_name)
|
||||
def add_host(self, aggregate_id, host_name):
|
||||
aggregate = self.get(aggregate_id)
|
||||
if host_name not in aggregate.hosts:
|
||||
aggregate.hosts.append(host_name)
|
||||
|
||||
def get(self, name):
|
||||
def get(self, aggregate_id):
|
||||
for aggregate in self.aggregates:
|
||||
if aggregate.name == name:
|
||||
if aggregate.id == aggregate_id:
|
||||
return aggregate
|
||||
|
||||
class Service(object):
|
||||
|
|
Loading…
Reference in New Issue