Merge "Enable ResourceUnknownStatus to report status_reason"

This commit is contained in:
Jenkins 2014-12-12 17:14:50 +00:00 committed by Gerrit Code Review
commit e1540f834c
6 changed files with 20 additions and 18 deletions

View File

@ -69,10 +69,13 @@ class ResourceInError(exception.HeatException):
class ResourceUnknownStatus(exception.HeatException):
msg_fmt = _('%(result)s - Unknown status %(resource_status)s')
msg_fmt = _('%(result)s - Unknown status %(resource_status)s due to '
'"%(status_reason)s"')
def __init__(self, result=_('Resource failed'), **kwargs):
super(ResourceUnknownStatus, self).__init__(result=result, **kwargs)
def __init__(self, result=_('Resource failed'),
status_reason=_('Unknown'), **kwargs):
super(ResourceUnknownStatus, self).__init__(
result=result, status_reason=status_reason, **kwargs)
class Resource(object):

View File

@ -475,9 +475,8 @@ class InstancesTest(common.HeatTestCase):
e = self.assertRaises(resource.ResourceUnknownStatus,
instance.check_create_complete,
(return_server, self.FakeVolumeAttach()))
self.assertEqual(
'Instance is not active - Unknown status BOGUS',
six.text_type(e))
self.assertEqual('Instance is not active - Unknown status BOGUS '
'due to "Unknown"', six.text_type(e))
def test_instance_create_error_status(self):
return_server = self.fc.servers.list()[1]

View File

@ -578,9 +578,9 @@ class NeutronTest(common.HeatTestCase):
e = self.assertRaises(
resource.ResourceUnknownStatus,
nr.NeutronResource.is_built, {'status': 'FROBULATING'})
self.assertEqual(
'Resource is not built - Unknown status FROBULATING',
six.text_type(e))
self.assertEqual('Resource is not built - Unknown status '
'FROBULATING due to "Unknown"',
six.text_type(e))
def test_resolve_attribute(self):
class SomeNeutronResource(nr.NeutronResource):

View File

@ -546,10 +546,9 @@ class PoolTest(common.HeatTestCase):
self.m.ReplayAll()
error = self.assertRaises(exception.ResourceFailure,
scheduler.TaskRunner(rsrc.create))
self.assertEqual(
'ResourceUnknownStatus: Pool creation failed due to vip - '
'Unknown status SOMETHING',
six.text_type(error))
self.assertEqual('ResourceUnknownStatus: Pool creation failed due to '
'vip - Unknown status SOMETHING due to "Unknown"',
six.text_type(error))
self.assertEqual((rsrc.CREATE, rsrc.FAILED), rsrc.state)
self.m.VerifyAll()

View File

@ -585,7 +585,9 @@ class RemoteStackTest(tests_common.HeatTestCase):
remote_stack_id = rsrc.resource_id
error = self.assertRaises(exception.ResourceFailure,
scheduler.TaskRunner(rsrc.delete))
error_msg = _('ResourceUnknownStatus: Resource failed - Unknown '
'status UPDATE_COMPLETE')
reason = ('Resource action mismatch detected: expected=DELETE '
'actual=UPDATE')
error_msg = ('ResourceUnknownStatus: Resource failed - Unknown '
'status UPDATE_COMPLETE due to "%s"') % reason
self.assertEqual(error_msg, six.text_type(error))
self.heat.stacks.delete.assert_called_with(stack_id=remote_stack_id)

View File

@ -494,9 +494,8 @@ class ServersTest(common.HeatTestCase):
e = self.assertRaises(resource.ResourceUnknownStatus,
server.check_create_complete,
return_server)
self.assertEqual(
'Server is not active - Unknown status BOGUS',
six.text_type(e))
self.assertEqual('Server is not active - Unknown status BOGUS due to '
'"Unknown"', six.text_type(e))
def test_server_create_error_status(self):
return_server = self.fc.servers.list()[1]