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
This commit is contained in:
Ethan Lynn 2015-02-03 14:15:40 +08:00
parent f271d05f5a
commit 6046182dfa
2 changed files with 4 additions and 11 deletions

View File

@ -475,6 +475,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(_LW('Unable to get details for project %s, '
'not deleting') % project_id)

View File

@ -1307,12 +1307,8 @@ class KeystoneClientTest(common.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()
@ -1593,11 +1589,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)