Ejemplo n.º 1
0
def data_connection_actions(rtsprofile):
    # The ports on those components in any required connections must also be
    # present.
    checks = []
    make_connections = []
    for conn in rtsprofile.required_data_connections():
        source_comp = rtsprofile.find_comp_by_target(conn.source_data_port)
        source_path = '/' + source_comp.path_uri
        source_port = conn.source_data_port.port_name
        prefix = source_comp.instance_name + '.'
        if source_port.startswith(prefix):
            source_port = source_port[len(prefix):]
        dest_comp = rtsprofile.find_comp_by_target(conn.target_data_port)
        dest_path = '/' + dest_comp.path_uri
        dest_port = conn.target_data_port.port_name
        prefix = dest_comp.instance_name + '.'
        if dest_port.startswith(prefix):
            dest_port = dest_port[len(prefix):]
        checks.append(actions.CheckForPortAct(source_path, source_port,
            callbacks=[actions.RequiredActionCB()]))
        checks.append(actions.CheckForPortAct(dest_path, dest_port,
            callbacks=[actions.RequiredActionCB()]))
        props = get_data_conn_props(conn)
        props.update(conn.properties)
        props = clean_props(props)
        make_connections.append(actions.ConnectPortsAct(source_path,
            source_port, dest_path, dest_port, str(conn.name),
            str(conn.connector_id), props,
            callbacks=[actions.RequiredActionCB()]))

    # Add the other connections to the list
    for conn in rtsprofile.optional_data_connections():
        source_comp = rtsprofile.find_comp_by_target(conn.source_data_port)
        source_path = '/' + source_comp.path_uri
        source_port = conn.source_data_port.port_name
        prefix = source_comp.instance_name + '.'
        if source_port.startswith(prefix):
            source_port = source_port[len(prefix):]
        dest_comp = rtsprofile.find_comp_by_target(conn.target_data_port)
        dest_path = '/' + dest_comp.path_uri
        dest_port = conn.target_data_port.port_name
        prefix = dest_comp.instance_name + '.'
        if dest_port.startswith(prefix):
            dest_port = dest_port[len(prefix):]
        props = get_data_conn_props(conn)
        props.update(conn.properties)
        props = clean_props(props)
        make_connections.append(actions.ConnectPortsAct(source_path,
            source_port, dest_path, dest_port, str(conn.name),
            str(conn.connector_id), props))

    return checks, make_connections
Ejemplo n.º 2
0
def check_required_component_actions(rtsprofile):
    checks = []
    # First perform a sanity check of the system.
    # All required components must be present
    for comp in [c for c in rtsprofile.components if c.is_required]:
        checks.append(actions.CheckForRequiredCompAct('/' + comp.path_uri,
            comp.id, comp.instance_name,
            callbacks=[actions.RequiredActionCB()]))
    return checks
Ejemplo n.º 3
0
def activate_actions(rtsprofile):
    checks = check_required_component_actions(rtsprofile)

    activates = []
    for comp in [c for c in rtsprofile.components if c.is_required]:
        for ec in comp.execution_contexts:
            activates.append(
                actions.ActivateCompAct('/' + comp.path_uri,
                                        comp.id,
                                        comp.instance_name,
                                        ec.id,
                                        callbacks=[actions.RequiredActionCB()
                                                   ]))

    for comp in [c for c in rtsprofile.components if not c.is_required]:
        for ec in comp.execution_contexts:
            activates.append(
                actions.ActivateCompAct('/' + comp.path_uri, comp.id,
                                        comp.instance_name, ec.id))

    return checks, activates