示例#1
0
    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())
示例#2
0
 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
示例#3
0
    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)
示例#4
0
 def test_event_id(self):
     ei = identifier.EventIdentifier('t', 's', 'i', '/resources/p', 'e')
     self.assertEqual(ei.event_id, 'e')
示例#5
0
 def test_resource_name(self):
     ei = identifier.EventIdentifier('t', 's', 'i', '/resources/p', 'e')
     self.assertEqual(ei.resource_name, 'p')
示例#6
0
 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)
示例#7
0
 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)
示例#8
0
 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')
示例#9
0
 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)