Merge "Fix problem creating ResourceFailure"

This commit is contained in:
Jenkins 2013-08-12 02:39:47 +00:00 committed by Gerrit Code Review
commit 0dc3a1e3ab
3 changed files with 35 additions and 3 deletions

View File

@ -339,7 +339,7 @@ class Stack(object):
else: else:
raise exception.ResourceFailure( raise exception.ResourceFailure(
AttributeError(_('Resource action %s not found') % AttributeError(_('Resource action %s not found') %
action_l)) action_l), r)
action_task = scheduler.DependencyTaskGroup(self.dependencies, action_task = scheduler.DependencyTaskGroup(self.dependencies,
resource_action, resource_action,

View File

@ -327,12 +327,12 @@ class Instance(resource.Resource):
delete(wait_time=0.2) delete(wait_time=0.2)
exc = exception.Error("Build of server %s failed." % exc = exception.Error("Build of server %s failed." %
server.name) server.name)
raise exception.ResourceFailure(exc) raise exception.ResourceFailure(exc, self)
else: else:
exc = exception.Error('%s instance[%s] status[%s]' % exc = exception.Error('%s instance[%s] status[%s]' %
('nova reported unexpected', ('nova reported unexpected',
self.name, server.status)) self.name, server.status))
raise exception.ResourceFailure(exc) raise exception.ResourceFailure(exc, self)
else: else:
return volume_attach.step() return volume_attach.step()

View File

@ -16,6 +16,7 @@ import copy
import mox import mox
from heat.engine import clients
from heat.engine import environment from heat.engine import environment
from heat.tests.v1_1 import fakes from heat.tests.v1_1 import fakes
from heat.common import exception from heat.common import exception
@ -205,6 +206,37 @@ class InstancesTest(HeatTestCase):
self.m.VerifyAll() self.m.VerifyAll()
class FakeVolumeAttach:
def started(self):
return False
def test_instance_create_unexpected_status(self):
return_server = self.fc.servers.list()[1]
instance = self._create_test_instance(return_server,
'test_instance_create')
return_server.get = lambda: None
return_server.status = 'BOGUS'
self.assertRaises(exception.ResourceFailure,
instance.check_create_complete,
(return_server, self.FakeVolumeAttach()))
def test_instance_create_error_status(self):
return_server = self.fc.servers.list()[1]
instance = self._create_test_instance(return_server,
'test_instance_create')
return_server.status = 'ERROR'
self.m.StubOutWithMock(return_server, 'get')
return_server.get()
return_server.get().AndRaise(
clients.novaclient.exceptions.NotFound('test'))
self.m.ReplayAll()
self.assertRaises(exception.ResourceFailure,
instance.check_create_complete,
(return_server, self.FakeVolumeAttach()))
self.m.VerifyAll()
def test_instance_validate(self): def test_instance_validate(self):
stack_name = 'test_instance_validate_stack' stack_name = 'test_instance_validate_stack'
(t, stack) = self._setup_test_stack(stack_name) (t, stack) = self._setup_test_stack(stack_name)