RPC API: Add a PhysicalResourceNotFound exception
Change-Id: I409f8df9e93809f7267fb09656302082e42753da Signed-off-by: Zane Bitter <zbitter@redhat.com>
This commit is contained in:
parent
d8be4d0c12
commit
805416ebb1
|
@ -250,6 +250,7 @@ def map_remote_error(ex):
|
||||||
'StackNotFound',
|
'StackNotFound',
|
||||||
'ResourceNotFound',
|
'ResourceNotFound',
|
||||||
'ResourceNotAvailable',
|
'ResourceNotAvailable',
|
||||||
|
'PhysicalResourceNotFound',
|
||||||
'StackExists',
|
'StackExists',
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -94,6 +94,7 @@ def remote_error(ex, force_exists=False):
|
||||||
'StackNotFound': exc.HTTPNotFound,
|
'StackNotFound': exc.HTTPNotFound,
|
||||||
'ResourceNotFound': exc.HTTPNotFound,
|
'ResourceNotFound': exc.HTTPNotFound,
|
||||||
'ResourceNotAvailable': exc.HTTPNotFound,
|
'ResourceNotAvailable': exc.HTTPNotFound,
|
||||||
|
'PhysicalResourceNotFound': exc.HTTPNotFound,
|
||||||
'InvalidTenant': exc.HTTPForbidden,
|
'InvalidTenant': exc.HTTPForbidden,
|
||||||
'StackExists': exc.HTTPConflict,
|
'StackExists': exc.HTTPConflict,
|
||||||
}
|
}
|
||||||
|
|
|
@ -224,3 +224,7 @@ class ResourceNotFound(OpenstackException):
|
||||||
|
|
||||||
class ResourceNotAvailable(OpenstackException):
|
class ResourceNotAvailable(OpenstackException):
|
||||||
message = _("The Resource (%(resource_name)s) is not available.")
|
message = _("The Resource (%(resource_name)s) is not available.")
|
||||||
|
|
||||||
|
|
||||||
|
class PhysicalResourceNotFound(OpenstackException):
|
||||||
|
message = _("The Resource (%(resource_id)s) could not be found.")
|
||||||
|
|
|
@ -396,8 +396,8 @@ class EngineService(service.Service):
|
||||||
rs = db_api.resource_get_by_physical_resource_id(context,
|
rs = db_api.resource_get_by_physical_resource_id(context,
|
||||||
physical_resource_id)
|
physical_resource_id)
|
||||||
if not rs:
|
if not rs:
|
||||||
msg = "The specified PhysicalResourceId doesn't exist"
|
raise exception.PhysicalResourceNotFound(
|
||||||
raise AttributeError(msg)
|
resource_id=physical_resource_id)
|
||||||
|
|
||||||
stack = parser.Stack.load(context, stack=rs.stack)
|
stack = parser.Stack.load(context, stack=rs.stack)
|
||||||
resource = stack[rs.name]
|
resource = stack[rs.name]
|
||||||
|
|
|
@ -1208,6 +1208,32 @@ class StackControllerTest(unittest.TestCase):
|
||||||
|
|
||||||
self.assertEqual(response, expected)
|
self.assertEqual(response, expected)
|
||||||
|
|
||||||
|
def test_describe_stack_resources_physical_not_found(self):
|
||||||
|
# Format a dummy request
|
||||||
|
stack_name = "wordpress"
|
||||||
|
identity = dict(identifier.HeatIdentifier('t', stack_name, '6'))
|
||||||
|
params = {'Action': 'DescribeStackResources',
|
||||||
|
'LogicalResourceId': "WikiDatabase",
|
||||||
|
'PhysicalResourceId': 'aaaaaaaa-9f88-404d-cccc-ffffffffffff'}
|
||||||
|
dummy_req = self._dummy_GET_request(params)
|
||||||
|
|
||||||
|
# Stub out the RPC call to the engine with a pre-canned response
|
||||||
|
self.m.StubOutWithMock(rpc, 'call')
|
||||||
|
rpc.call(dummy_req.context, self.topic,
|
||||||
|
{'method': 'find_physical_resource',
|
||||||
|
'args': {'physical_resource_id':
|
||||||
|
'aaaaaaaa-9f88-404d-cccc-ffffffffffff'},
|
||||||
|
'version': self.api_version},
|
||||||
|
None).AndRaise(
|
||||||
|
rpc_common.RemoteError("PhysicalResourceNotFound"))
|
||||||
|
|
||||||
|
self.m.ReplayAll()
|
||||||
|
|
||||||
|
response = self.controller.describe_stack_resources(dummy_req)
|
||||||
|
|
||||||
|
self.assertEqual(type(response),
|
||||||
|
exception.HeatInvalidParameterValueError)
|
||||||
|
|
||||||
def test_describe_stack_resources_err_inval(self):
|
def test_describe_stack_resources_err_inval(self):
|
||||||
# Format a dummy request containing both StackName and
|
# Format a dummy request containing both StackName and
|
||||||
# PhysicalResourceId, which is invalid and should throw a
|
# PhysicalResourceId, which is invalid and should throw a
|
||||||
|
|
|
@ -640,7 +640,7 @@ class stackServiceTest(unittest.TestCase):
|
||||||
self.assertEqual(resource_identity.resource_name, 'WebServer')
|
self.assertEqual(resource_identity.resource_name, 'WebServer')
|
||||||
|
|
||||||
def test_find_physical_resource_nonexist(self):
|
def test_find_physical_resource_nonexist(self):
|
||||||
self.assertRaises(AttributeError,
|
self.assertRaises(exception.PhysicalResourceNotFound,
|
||||||
self.man.find_physical_resource,
|
self.man.find_physical_resource,
|
||||||
self.ctx, 'foo')
|
self.ctx, 'foo')
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue