def identifier(self): '''Return a unique identifier for the event''' if self.id is None: return None return identifier.EventIdentifier(event_id=str(self.id), **self.resource.identifier())
def _id_format(resp): """ Format the StackId field in the response as an ARN, and process other IDs into the correct format. """ if 'StackId' in resp: identity = identifier.HeatIdentifier(**resp['StackId']) resp['StackId'] = identity.arn() if 'EventId' in resp: identity = identifier.EventIdentifier(**resp['EventId']) resp['EventId'] = identity.event_id return resp
def transform(key, value): if not include_key(key): return if key == engine_api.EVENT_ID: identity = identifier.EventIdentifier(**value) yield ('id', identity.event_id) yield ('links', [ util.make_link(req, identity), util.make_link(req, identity.resource(), 'resource'), util.make_link(req, identity.stack(), 'stack') ]) elif (key == engine_api.EVENT_STACK_ID or key == engine_api.EVENT_STACK_NAME): return else: yield (key, value)
def test_event_id(self): ei = identifier.EventIdentifier('t', 's', 'i', '/resources/p', 'e') self.assertEqual(ei.event_id, 'e')
def test_resource_name(self): ei = identifier.EventIdentifier('t', 's', 'i', '/resources/p', 'e') self.assertEqual(ei.resource_name, 'p')
def test_event_resource(self): si = identifier.HeatIdentifier('t', 's', 'i') pi = identifier.ResourceIdentifier(resource_name='r', **si) ei = identifier.EventIdentifier(event_id='e', **pi) self.assertEqual(ei.resource(), pi)
def test_event_init_from_dict(self): hi = identifier.HeatIdentifier('t', 's', 'i', '/resources/p/events/42') ei = identifier.EventIdentifier(**hi) self.assertEqual(ei, hi)
def test_event_init(self): si = identifier.HeatIdentifier('t', 's', 'i') pi = identifier.ResourceIdentifier(resource_name='p', **si) ei = identifier.EventIdentifier(event_id='e', **pi) self.assertEqual(ei.path, '/resources/p/events/e')
def event_match(ev): identity = identifier.EventIdentifier(**ev[engine_api.EVENT_ID]) return (ev[engine_api.EVENT_RES_NAME] == resource_name and identity.event_id == event_id)