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 or key == engine_api.RES_ACTION): return elif (key == engine_api.RES_METADATA): return elif (key == engine_api.RES_STATUS and engine_api.RES_ACTION in res): # To avoid breaking API compatibility, we join RES_ACTION # and RES_STATUS, so the API format doesn't expose the # internal split of state into action/status yield (key, '_'.join((res[engine_api.RES_ACTION], value))) elif (key == engine_api.RES_NAME): yield ('logical_resource_id', value) yield (key, value) else: yield (key, value)
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 or key == engine_api.RES_ACTION): return elif (key == engine_api.RES_METADATA): return elif (key == engine_api.RES_STATUS and engine_api.RES_ACTION in res): # To avoid breaking API compatibility, we join RES_ACTION # and RES_STATUS, so the API format doesn't expose the # internal split of state into action/status yield (key, '_'.join((res[engine_api.RES_ACTION], value))) elif (key == engine_api.RES_NAME): yield ('logical_resource_id', value) yield (key, value) else: yield (key, value)
def transform(key, value): if not include_key(key): return if key == rpc_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 in (rpc_api.EVENT_STACK_ID, rpc_api.EVENT_STACK_NAME, rpc_api.EVENT_RES_ACTION): return elif (key == rpc_api.EVENT_RES_STATUS and rpc_api.EVENT_RES_ACTION in event): # To avoid breaking API compatibility, we join RES_ACTION # and RES_STATUS, so the API format doesn't expose the # internal split of state into action/status yield (key, '_'.join((event[rpc_api.EVENT_RES_ACTION], value))) elif (key == rpc_api.RES_NAME): yield ('logical_resource_id', value) yield (key, value) else: yield (key, value)
def transform(key, value): if not include_key(key): return if key == rpc_api.RES_ID: identity = identifier.ResourceIdentifier(**value) links = [util.make_link(req, identity), util.make_link(req, identity.stack(), 'stack')] nested_id = res.get(rpc_api.RES_NESTED_STACK_ID) if nested_id: nested_identity = identifier.HeatIdentifier(**nested_id) links.append(util.make_link(req, nested_identity, 'nested')) yield ('links', links) elif (key == rpc_api.RES_STACK_NAME or key == rpc_api.RES_STACK_ID or key == rpc_api.RES_ACTION or key == rpc_api.RES_NESTED_STACK_ID): return elif (key == rpc_api.RES_METADATA): return elif (key == rpc_api.RES_STATUS and rpc_api.RES_ACTION in res): # To avoid breaking API compatibility, we join RES_ACTION # and RES_STATUS, so the API format doesn't expose the # internal split of state into action/status yield (key, '_'.join((res[rpc_api.RES_ACTION], value))) elif (key == rpc_api.RES_NAME): yield ('logical_resource_id', value) yield (key, value) else: yield (key, value)
def transform(key, value): if not include_key(key): return if key == rpc_api.RES_ID: identity = identifier.ResourceIdentifier(**value) links = [ util.make_link(req, identity), util.make_link(req, identity.stack(), 'stack') ] nested_id = res.get(rpc_api.RES_NESTED_STACK_ID) if nested_id: nested_identity = identifier.HeatIdentifier(**nested_id) links.append(util.make_link(req, nested_identity, 'nested')) yield ('links', links) elif (key == rpc_api.RES_STACK_NAME or key == rpc_api.RES_STACK_ID or key == rpc_api.RES_ACTION or key == rpc_api.RES_NESTED_STACK_ID): return elif (key == rpc_api.RES_METADATA): return elif (key == rpc_api.RES_STATUS and rpc_api.RES_ACTION in res): # To avoid breaking API compatibility, we join RES_ACTION # and RES_STATUS, so the API format doesn't expose the # internal split of state into action/status yield (key, '_'.join((res[rpc_api.RES_ACTION], value))) elif (key == rpc_api.RES_NAME): yield ('logical_resource_id', value) yield (key, value) else: yield (key, value)
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 in (engine_api.EVENT_STACK_ID, engine_api.EVENT_STACK_NAME, engine_api.EVENT_RES_ACTION): return elif key == engine_api.EVENT_RES_STATUS and engine_api.EVENT_RES_ACTION in event: # To avoid breaking API compatibility, we join RES_ACTION # and RES_STATUS, so the API format doesn't expose the # internal split of state into action/status yield (key, "_".join((event[engine_api.EVENT_RES_ACTION], value))) elif key == engine_api.RES_NAME: yield ("logical_resource_id", value) yield (key, value) else: yield (key, value)
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 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 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 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 transform(key, value): if not include_key(key): return if key == engine_api.STACK_ID: yield ('id', value['stack_id']) yield ('links', [util.make_link(req, value)]) else: # TODO(zaneb): ensure parameters can be formatted for XML #elif key == engine_api.STACK_PARAMETERS: # return key, json.dumps(value) yield (key, value)
def transform(key, value): if not include_key(key): return if key == engine_api.STACK_ID: yield ("id", value["stack_id"]) yield ("links", [util.make_link(req, value)]) elif key == engine_api.STACK_ACTION: return elif key == engine_api.STACK_STATUS and engine_api.STACK_ACTION in stack: # To avoid breaking API compatibility, we join RES_ACTION # and RES_STATUS, so the API format doesn't expose the # internal split of state into action/status yield (key, "_".join((stack[engine_api.STACK_ACTION], value))) else: # TODO(zaneb): ensure parameters can be formatted for XML # elif key == engine_api.STACK_PARAMETERS: # return key, json.dumps(value) yield (key, value)
def transform(key, value): if not include_key(key): return if key == engine_api.STACK_ID: yield ('id', value['stack_id']) yield ('links', [util.make_link(req, value)]) elif key == engine_api.STACK_ACTION: return elif (key == engine_api.STACK_STATUS and engine_api.STACK_ACTION in stack): # To avoid breaking API compatibility, we join RES_ACTION # and RES_STATUS, so the API format doesn't expose the # internal split of state into action/status yield (key, '_'.join((stack[engine_api.STACK_ACTION], value))) else: # TODO(zaneb): ensure parameters can be formatted for XML #elif key == engine_api.STACK_PARAMETERS: # return key, json.dumps(value) yield (key, value)
def format_event(req, event, keys=None): def include_key(k): return k in keys if keys else True def transform(key, value): if not include_key(key): return if key == rpc_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 in (rpc_api.EVENT_STACK_ID, rpc_api.EVENT_STACK_NAME, rpc_api.EVENT_RES_ACTION): return elif (key == rpc_api.EVENT_RES_STATUS and rpc_api.EVENT_RES_ACTION in event): # To avoid breaking API compatibility, we join RES_ACTION # and RES_STATUS, so the API format doesn't expose the # internal split of state into action/status yield (key, '_'.join((event[rpc_api.EVENT_RES_ACTION], value))) elif (key == rpc_api.RES_NAME): yield ('logical_resource_id', value) yield (key, value) else: yield (key, value) ev = dict(itertools.chain.from_iterable( transform(k, v) for k, v in event.items())) root_stack_id = event.get(rpc_api.EVENT_ROOT_STACK_ID) if root_stack_id: root_identifier = identifier.HeatIdentifier(**root_stack_id) ev['links'].append(util.make_link(req, root_identifier, 'root_stack')) return ev
def format_event(req, event, keys=None): def include_key(k): return k in keys if keys else True def transform(key, value): if not include_key(key): return if key == rpc_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 in (rpc_api.EVENT_STACK_ID, rpc_api.EVENT_STACK_NAME, rpc_api.EVENT_RES_ACTION): return elif (key == rpc_api.EVENT_RES_STATUS and rpc_api.EVENT_RES_ACTION in event): # To avoid breaking API compatibility, we join RES_ACTION # and RES_STATUS, so the API format doesn't expose the # internal split of state into action/status yield (key, '_'.join((event[rpc_api.EVENT_RES_ACTION], value))) elif (key == rpc_api.RES_NAME): yield ('logical_resource_id', value) yield (key, value) else: yield (key, value) ev = dict( itertools.chain.from_iterable( transform(k, v) for k, v in event.items())) root_stack_id = event.get(rpc_api.EVENT_ROOT_STACK_ID) if root_stack_id: root_identifier = identifier.HeatIdentifier(**root_stack_id) ev['links'].append(util.make_link(req, root_identifier, 'root_stack')) return ev
def transform(key, value): if keys and key not in keys: return if key == rpc_api.STACK_ID: yield ('id', value['stack_id']) yield ('links', [util.make_link(req, value)]) if not tenant_safe: yield ('project', value['tenant']) elif key == rpc_api.STACK_ACTION: return elif (key == rpc_api.STACK_STATUS and rpc_api.STACK_ACTION in stack): # To avoid breaking API compatibility, we join RES_ACTION # and RES_STATUS, so the API format doesn't expose the # internal split of state into action/status yield (key, '_'.join((stack[rpc_api.STACK_ACTION], value))) else: # TODO(zaneb): ensure parameters can be formatted for XML #elif key == rpc_api.STACK_PARAMETERS: # return key, json.dumps(value) yield (key, value)