Example #1
0
    def transform(key, value):
        if not include_key(key):
            return

        if key == engine_api.RES_ID:
            identity = identifier.ResourceIdentifier(**value)
            yield ('links', [
                util.make_link(req, identity),
                util.make_link(req, identity.stack(), 'stack')
            ])
        elif (key == engine_api.RES_STACK_NAME
              or key == engine_api.RES_STACK_ID):
            return
        elif (key == engine_api.RES_METADATA):
            return
        else:
            yield (key, value)
Example #2
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)
Example #3
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')
Example #4
0
 def test_resource_id(self):
     ri = identifier.ResourceIdentifier('t', 's', 'i', '', 'r')
     self.assertEqual(ri.resource_name, 'r')
Example #5
0
 def test_resource_stack(self):
     si = identifier.HeatIdentifier('t', 's', 'i')
     ri = identifier.ResourceIdentifier(resource_name='r', **si)
     self.assertEqual(ri.stack(), si)
Example #6
0
 def test_resource_init_from_dict(self):
     hi = identifier.HeatIdentifier('t', 's', 'i', '/resources/r')
     ri = identifier.ResourceIdentifier(**hi)
     self.assertEqual(ri, hi)
Example #7
0
 def test_resource_init_path(self):
     si = identifier.HeatIdentifier('t', 's', 'i')
     pi = identifier.ResourceIdentifier(resource_name='p', **si)
     ri = identifier.ResourceIdentifier(resource_name='r', **pi)
     self.assertEqual(ri.path, '/resources/p/resources/r')
Example #8
0
 def handle_stack_method(controller, stack_identity, resource_name,
                         **kwargs):
     resource_identity = identifier.ResourceIdentifier(
         stack_identity, resource_name)
     return handler(controller, req, dict(resource_identity), **kwargs)