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)
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(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 test_resource_id(self): ri = identifier.ResourceIdentifier('t', 's', 'i', '', 'r') self.assertEqual(ri.resource_name, 'r')
def test_resource_stack(self): si = identifier.HeatIdentifier('t', 's', 'i') ri = identifier.ResourceIdentifier(resource_name='r', **si) self.assertEqual(ri.stack(), si)
def test_resource_init_from_dict(self): hi = identifier.HeatIdentifier('t', 's', 'i', '/resources/r') ri = identifier.ResourceIdentifier(**hi) self.assertEqual(ri, hi)
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')
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)