diff options
author | Ethan Lynn <xjunlin@cn.ibm.com> | 2015-02-03 14:15:40 +0800 |
---|---|---|
committer | Steven Hardy <shardy@redhat.com> | 2015-02-17 11:57:44 +0000 |
commit | 848c59ba1c4978040d82566c0f8667623a04b93f (patch) | |
tree | ac19cb403623d60400544cf76a0adf0bd3d4452a | |
parent | a314229e2bc4c347e6f50d7595b990a441a36d67 (diff) | |
download | heat-848c59ba1c4978040d82566c0f8667623a04b93f.tar.gz |
Catch notfound exception when deleting project
When heat trying to delete a non-exist project, will catch a
notfound error, original code place the catcher in the wrong
place, this patch fixes it.
Change-Id: I68269838d1cef311c3f41f5846deae4ed94aef4c
Closes-Bug: #1410698
(cherry picked from commit 6046182dfad858349fa647b8777657f535a629c7)
-rw-r--r-- | heat/common/heat_keystoneclient.py | 2 | ||||
-rw-r--r-- | heat/tests/test_heatclient.py | 13 |
2 files changed, 4 insertions, 11 deletions
diff --git a/heat/common/heat_keystoneclient.py b/heat/common/heat_keystoneclient.py index 16c87ba96..1a426cff0 100644 --- a/heat/common/heat_keystoneclient.py +++ b/heat/common/heat_keystoneclient.py @@ -525,6 +525,8 @@ class KeystoneClientV3(object): # to get the project, so again we should do nothing try: project = self.domain_admin_client.projects.get(project=project_id) + except kc_exception.NotFound: + return except kc_exception.Forbidden: LOG.warning(_('Unable to get details for project %s, not deleting') % project_id) diff --git a/heat/tests/test_heatclient.py b/heat/tests/test_heatclient.py index 885fc8b82..da2dcb839 100644 --- a/heat/tests/test_heatclient.py +++ b/heat/tests/test_heatclient.py @@ -1305,12 +1305,8 @@ class KeystoneClientTest(HeatTestCase): self._stub_domain_admin_client() self.mock_admin_client.projects = self.m.CreateMockAnything() - dummy = self.m.CreateMockAnything() - dummy.id = 'aproject123' - dummy.domain_id = 'adomain123' - dummy.delete().AndRaise(kc_exception.NotFound) - self.mock_admin_client.projects.get(project='aprojectid').AndReturn( - dummy) + self.mock_admin_client.projects.get(project='aprojectid').AndRaise( + kc_exception.NotFound) self.m.ReplayAll() ctx = utils.dummy_context() @@ -1575,11 +1571,6 @@ class KeystoneClientTestDomainName(KeystoneClientTest): p = super(KeystoneClientTestDomainName, self) p.test_delete_stack_domain_project() - def test_delete_stack_domain_project_notfound(self): - self._stub_domain_admin_client_domain_get() - p = super(KeystoneClientTestDomainName, self) - p.test_delete_stack_domain_project_notfound() - def test_delete_stack_domain_project_wrongdomain(self): self._stub_domain_admin_client_domain_get() p = super(KeystoneClientTestDomainName, self) |