From 28003004d8b1f142a4ed150177e19112cba8d595 Mon Sep 17 00:00:00 2001 From: liyi Date: Wed, 20 Jun 2018 13:20:48 +0800 Subject: [PATCH] Fix stack delete error with none cluster Before stack delete, I delete cluster first, and then stack delete failed. Change-Id: I523575668e5f52728116c68761aa221cb27fa132 Story: #2002623 Task: 22253 --- heat/engine/clients/os/openstacksdk.py | 2 +- heat/tests/clients/test_sdk_client.py | 17 +++++++++++++---- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/heat/engine/clients/os/openstacksdk.py b/heat/engine/clients/os/openstacksdk.py index a1ad0e2031..56c17b45bf 100644 --- a/heat/engine/clients/os/openstacksdk.py +++ b/heat/engine/clients/os/openstacksdk.py @@ -67,7 +67,7 @@ class OpenStackSDKPlugin(client_plugin.ClientPlugin): return interfaces def is_not_found(self, ex): - return isinstance(ex, exceptions.ResourceNotFound) + return isinstance(ex, exceptions.NotFoundException) def find_network_segment(self, value): return self.client().network.find_segment(value).id diff --git a/heat/tests/clients/test_sdk_client.py b/heat/tests/clients/test_sdk_client.py index 45935b13ca..98f40af07e 100644 --- a/heat/tests/clients/test_sdk_client.py +++ b/heat/tests/clients/test_sdk_client.py @@ -21,14 +21,23 @@ from heat.tests import utils class OpenStackSDKPluginTest(common.HeatTestCase): - @mock.patch('openstack.connection.Connection') - def test_create(self, mock_connection): + def setUp(self, mock_connection): + super(OpenStackSDKPluginTest, self).setUp() context = utils.dummy_context() - plugin = context.clients.client_plugin('openstack') - client = plugin.client() + self.plugin = context.clients.client_plugin('openstack') + + def test_create(self): + client = self.plugin.client() self.assertIsNotNone(client.network.segments) + def test_is_not_found(self): + self.assertFalse(self.plugin.is_not_found( + exceptions.HttpException(http_status=400))) + self.assertFalse(self.plugin.is_not_found(Exception)) + self.assertTrue(self.plugin.is_not_found( + exceptions.NotFoundException(http_status=404))) + class SegmentConstraintTest(common.HeatTestCase):