Use physical name in event if resource_id is None
An event for CREATE_IN_PROGRESS will have a physical_resource_id value of None because the resource hasn't been created yet. Because of this it is not possible to relate a nested stack event with the CREATE_IN_PROGRESS resource event in the parent stack. This change populates Event.physical_resource_id with Resource.physical_resource_name() if Resource.resource_id isn't populated yet. This change will help fix Related-Bug: #1619415 Change-Id: Ib8feb7752bd5736785d142216312bb35629b3601
This commit is contained in:
parent
313e47f47a
commit
576d092b97
|
@ -1727,8 +1727,9 @@ class Resource(object):
|
|||
|
||||
def _add_event(self, action, status, reason):
|
||||
"""Add a state change event to the database."""
|
||||
physical_res_id = self.resource_id or self.physical_resource_name()
|
||||
ev = event.Event(self.context, self.stack, action, status, reason,
|
||||
self.resource_id, self.properties,
|
||||
physical_res_id, self.properties,
|
||||
self.name, self.type())
|
||||
|
||||
ev.store()
|
||||
|
|
|
@ -3393,6 +3393,7 @@ class ResourceHookTest(common.HeatTestCase):
|
|||
'GenericResourceType')
|
||||
res = resource.Resource('res', snippet, self.stack)
|
||||
res.id = '1234'
|
||||
res.uuid = uuid.uuid4()
|
||||
task = scheduler.TaskRunner(res.create)
|
||||
task.start()
|
||||
task.step()
|
||||
|
@ -3409,6 +3410,7 @@ class ResourceHookTest(common.HeatTestCase):
|
|||
res = resource.Resource('res', snippet, self.stack)
|
||||
res.id = '1234'
|
||||
res.action = 'CREATE'
|
||||
res.uuid = uuid.uuid4()
|
||||
self.stack.action = 'DELETE'
|
||||
task = scheduler.TaskRunner(res.delete)
|
||||
task.start()
|
||||
|
@ -3425,6 +3427,7 @@ class ResourceHookTest(common.HeatTestCase):
|
|||
'GenericResourceType')
|
||||
res = resource.Resource('res', snippet, self.stack)
|
||||
res.id = '1234'
|
||||
res.uuid = uuid.uuid4()
|
||||
task = scheduler.TaskRunner(res.create)
|
||||
task.start()
|
||||
task.step()
|
||||
|
@ -3440,6 +3443,7 @@ class ResourceHookTest(common.HeatTestCase):
|
|||
'GenericResourceType')
|
||||
res = resource.Resource('res', snippet, self.stack)
|
||||
res.id = '1234'
|
||||
res.uuid = uuid.uuid4()
|
||||
res.action = 'CREATE'
|
||||
self.stack.action = 'DELETE'
|
||||
task = scheduler.TaskRunner(res.delete)
|
||||
|
|
|
@ -60,7 +60,7 @@ class StackUserTest(common.HeatTestCase):
|
|||
|
||||
rsrc._store()
|
||||
self.m.StubOutWithMock(short_id, 'get_id')
|
||||
short_id.get_id(rsrc.uuid).AndReturn('aabbcc')
|
||||
short_id.get_id(rsrc.uuid).MultipleTimes().AndReturn('aabbcc')
|
||||
|
||||
self.m.StubOutWithMock(fakes.FakeKeystoneClient,
|
||||
'create_stack_domain_user')
|
||||
|
|
Loading…
Reference in New Issue