diff --git a/heat/engine/resources/neutron/loadbalancer.py b/heat/engine/resources/neutron/loadbalancer.py index 32f220cfe4..257ac38292 100644 --- a/heat/engine/resources/neutron/loadbalancer.py +++ b/heat/engine/resources/neutron/loadbalancer.py @@ -382,8 +382,8 @@ class Pool(neutron.NeutronResource): def handle_update(self, json_snippet, tmpl_diff, prop_diff): if prop_diff: client = self.neutron() - monitors = set(prop_diff.pop(self.MONITORS, [])) - if monitors: + if self.MONITORS in prop_diff: + monitors = set(prop_diff.pop(self.MONITORS)) old_monitors = set(self.properties[self.MONITORS]) for monitor in old_monitors - monitors: client.disassociate_health_monitor(self.resource_id, diff --git a/heat/tests/test_neutron_loadbalancer.py b/heat/tests/test_neutron_loadbalancer.py index beb6eea7be..d75d73fe80 100644 --- a/heat/tests/test_neutron_loadbalancer.py +++ b/heat/tests/test_neutron_loadbalancer.py @@ -990,8 +990,7 @@ class PoolUpdateHealthMonitorsTest(HeatTestCase): self.m.StubOutWithMock(clients.OpenStackClients, 'keystone') utils.setup_dummy_db() - @utils.stack_delete_after - def test_update_pool_with_references_to_health_monitors(self): + def _create_pool_with_health_monitors(self): clients.OpenStackClients.keystone().MultipleTimes().AndReturn( fakes.FakeKeystoneClient()) neutronclient.Client.create_health_monitor({ @@ -1026,6 +1025,10 @@ class PoolUpdateHealthMonitorsTest(HeatTestCase): neutronclient.Client.show_vip('xyz').AndReturn( {'vip': {'status': 'ACTIVE'}}) + @utils.stack_delete_after + def test_update_pool_with_references_to_health_monitors(self): + self._create_pool_with_health_monitors() + neutronclient.Client.disassociate_health_monitor( '5678', mox.IsA(unicode)) @@ -1043,3 +1046,49 @@ class PoolUpdateHealthMonitorsTest(HeatTestCase): self.assertEqual((self.stack.UPDATE, self.stack.COMPLETE), self.stack.state) self.m.VerifyAll() + + @utils.stack_delete_after + def test_update_pool_with_empty_list_of_health_monitors(self): + self._create_pool_with_health_monitors() + + neutronclient.Client.disassociate_health_monitor( + '5678', '5555').InAnyOrder() + neutronclient.Client.disassociate_health_monitor( + '5678', '6666').InAnyOrder() + + self.m.ReplayAll() + snippet = template_format.parse(pool_with_health_monitors_template) + self.stack = utils.parse_stack(snippet) + self.stack.create() + self.assertEqual((self.stack.CREATE, self.stack.COMPLETE), + self.stack.state) + + snippet['Resources']['pool']['Properties']['monitors'] = [] + updated_stack = utils.parse_stack(snippet) + self.stack.update(updated_stack) + self.assertEqual((self.stack.UPDATE, self.stack.COMPLETE), + self.stack.state) + self.m.VerifyAll() + + @utils.stack_delete_after + def test_update_pool_without_health_monitors(self): + self._create_pool_with_health_monitors() + + neutronclient.Client.disassociate_health_monitor( + '5678', '5555').InAnyOrder() + neutronclient.Client.disassociate_health_monitor( + '5678', '6666').InAnyOrder() + + self.m.ReplayAll() + snippet = template_format.parse(pool_with_health_monitors_template) + self.stack = utils.parse_stack(snippet) + self.stack.create() + self.assertEqual((self.stack.CREATE, self.stack.COMPLETE), + self.stack.state) + + snippet['Resources']['pool']['Properties'].pop('monitors') + updated_stack = utils.parse_stack(snippet) + self.stack.update(updated_stack) + self.assertEqual((self.stack.UPDATE, self.stack.COMPLETE), + self.stack.state) + self.m.VerifyAll()