fix an CFN API and AWS error mapping
StackExists should return AlreadyExists, not InvalidParameterValue Fixes bug #1188473 Change-Id: Ia969cddc1b61caa13f4f70bcc29f3160595a779b
This commit is contained in:
parent
4d58e84ab3
commit
7b9c2312cd
@ -204,6 +204,15 @@ class HeatThrottlingError(HeatAPIException):
|
|||||||
explanation = "Request was denied due to request throttling"
|
explanation = "Request was denied due to request throttling"
|
||||||
|
|
||||||
|
|
||||||
|
class AlreadyExistsError(HeatAPIException):
|
||||||
|
'''
|
||||||
|
Resource with the name requested already exists
|
||||||
|
'''
|
||||||
|
code = 400
|
||||||
|
title = 'AlreadyExists'
|
||||||
|
explanation = "Resource with the name requested already exists"
|
||||||
|
|
||||||
|
|
||||||
# Not documented in the AWS docs, authentication failure errors
|
# Not documented in the AWS docs, authentication failure errors
|
||||||
class HeatAccessDeniedError(HeatAPIException):
|
class HeatAccessDeniedError(HeatAPIException):
|
||||||
'''
|
'''
|
||||||
@ -252,17 +261,19 @@ def map_remote_error(ex):
|
|||||||
'ResourceNotAvailable',
|
'ResourceNotAvailable',
|
||||||
'PhysicalResourceNotFound',
|
'PhysicalResourceNotFound',
|
||||||
'WatchRuleNotFound',
|
'WatchRuleNotFound',
|
||||||
'StackExists',
|
|
||||||
'StackValidationFailed',
|
'StackValidationFailed',
|
||||||
'InvalidTemplateReference',
|
'InvalidTemplateReference',
|
||||||
'UnknownUserParameter',
|
'UnknownUserParameter',
|
||||||
)
|
)
|
||||||
denied_errors = ('Forbidden', 'NotAuthorized')
|
denied_errors = ('Forbidden', 'NotAuthorized')
|
||||||
|
already_exists_errors = ('StackExists')
|
||||||
|
|
||||||
if ex.exc_type in inval_param_errors:
|
if ex.exc_type in inval_param_errors:
|
||||||
return HeatInvalidParameterValueError(detail=ex.value)
|
return HeatInvalidParameterValueError(detail=ex.value)
|
||||||
elif ex.exc_type in denied_errors:
|
elif ex.exc_type in denied_errors:
|
||||||
return HeatAccessDeniedError(detail=ex.value)
|
return HeatAccessDeniedError(detail=ex.value)
|
||||||
|
elif ex.exc_type in already_exists_errors:
|
||||||
|
return AlreadyExistsError(detail=ex.value)
|
||||||
else:
|
else:
|
||||||
# Map everything else to internal server error for now
|
# Map everything else to internal server error for now
|
||||||
return HeatInternalFailureError(detail=ex.value)
|
return HeatInternalFailureError(detail=ex.value)
|
||||||
|
@ -597,7 +597,7 @@ class CfnStackControllerTest(HeatTestCase):
|
|||||||
result = self.controller.create(dummy_req)
|
result = self.controller.create(dummy_req)
|
||||||
|
|
||||||
self.assertEqual(type(result),
|
self.assertEqual(type(result),
|
||||||
exception.HeatInvalidParameterValueError)
|
exception.AlreadyExistsError)
|
||||||
self.m.VerifyAll()
|
self.m.VerifyAll()
|
||||||
|
|
||||||
def test_create_err_engine(self):
|
def test_create_err_engine(self):
|
||||||
|
Loading…
Reference in New Issue
Block a user