Merge "Fix handle_delete of HostAggregate resource"

This commit is contained in:
Jenkins
2016-03-28 17:10:11 +00:00
committed by Gerrit Code Review
2 changed files with 11 additions and 3 deletions

View File

@@ -121,9 +121,10 @@ class HostAggregate(resource.Resource):
if self.resource_id is None:
return
aggregate = self.client().aggregates.get(self.resource_id)
for host in aggregate.hosts:
aggregate.remove_host(host)
with self.client_plugin().ignore_not_found:
aggregate = self.client().aggregates.get(self.resource_id)
for host in aggregate.hosts:
aggregate.remove_host(host)
super(HostAggregate, self).handle_delete()

View File

@@ -108,6 +108,13 @@ class NovaHostAggregateTest(common.HeatTestCase):
self.assertEqual(0, ag.remove_host.call_count)
ag.set_metadata.assert_called_once_with(set_metadata_expected)
def test_aggregate_handle_delete_not_found(self):
ag = mock.MagicMock()
ag.id = '927202df-1afb-497f-8368-9c2d2f26e5db'
ag.hosts = ['host_1']
self.aggregates.get.side_effect = [nova.exceptions.NotFound(404)]
self.my_aggregate.handle_delete()
def test_aggregate_handle_delete(self):
ag = mock.MagicMock()
ag.id = '927202df-1afb-497f-8368-9c2d2f26e5db'