Ejemplo n.º 1
0
def get_database_tcid(framework, cred_manager):
    r'@types: db2_flow.RichFramework, db2_flow.CredsManager -> generator(tuple(str, str, str, str, str))'
    proto_name = ClientsConsts.SQL_PROTOCOL_NAME
    if framework.tcidHasValues('db_id'):
        db_ids = framework.getTriggerCIDataAsList('db_id')
        db_names = framework.getTriggerCIDataAsList('db_name')
        ports = framework.getTriggerCIDataAsList('db_application_port')
        ips = framework.getTriggerCIDataAsList('ip_address')
        result = []
        for ip in ips:
            ips_ = [ip] * len(db_ids)
            creds = cred_manager.get_creds_for_destination(proto_name)

            tcid_creds = filter(
                None, framework.getTriggerCIDataAsList('credentials_id'))
            creds = list(tcid_creds) + list(set(creds) - set(tcid_creds))

            creds = iteratortools.product(creds,
                                          zip(ips_, ports, db_names, db_ids))
            creds = imap(iteratortools.flatten, creds)
            result.extend([
                cred for cred in creds
                if db2_flow.is_applicable_db2_cred(cred_manager, *cred[:4])
            ])
        return result
Ejemplo n.º 2
0
def get_alias_tcid_2d_for_ip(ip, framework, cred_manager):
    proto_name = ClientsConsts.SQL_PROTOCOL_NAME
    alias_ids = framework.getTriggerCIDataAsList('alias_id')
    ips = [ip] * len(alias_ids)

    alias_containers = framework.getTriggerCIDataAsList('alias_container')
    alias_names = framework.getTriggerCIDataAsList('alias_name')

    inst_ports = framework.getTriggerCIDataAsList('inst_application_port')
    inst_ids = framework.getTriggerCIDataAsList('inst_id')
    inst_port_by_id = dict(zip(inst_ids, inst_ports))

    ports = []
    for alias_container_id in alias_containers:
        ports.append(inst_port_by_id.get(alias_container_id))

    creds = cred_manager.get_creds_for_destination(proto_name)

    creds = iteratortools.product(creds, zip(ips, ports, alias_names,
                                             alias_ids))
    creds = imap(iteratortools.flatten, creds)

    return [
        cred for cred in creds
        if db2_flow.is_applicable_db2_cred(cred_manager, *cred[:4])
    ]
Ejemplo n.º 3
0
def get_ipse_only_tcid(framework, cred_manager):
    r'@types: db2_flow.RichFramework, db2_flow.CredsManager -> generator(tuple(str, str, str, str, str))'
    proto_name = ClientsConsts.SQL_PROTOCOL_NAME

    if framework.tcidHasValues('ipse_only_id'):
        result = []
        ips = framework.getTriggerCIDataAsList('ip_address')
        for ip in ips:
            ipse_ids = framework.getTriggerCIDataAsList('ipse_only_id')
            ipse_ports = framework.getTriggerCIDataAsList('ipse_only_port')
            ips_ = [ip] * len(ipse_ids)
            creds = cred_manager.get_creds_for_destination(proto_name)

            dbnames = [None] * len(ipse_ports)
            creds = iteratortools.product(creds, zip(ips_, ipse_ports, dbnames, ipse_ids))
            creds = imap(iteratortools.flatten, creds)
            result.extend([cred for cred in creds
                    if db2_flow.is_applicable_db2_cred(cred_manager, *cred[:4])])
        return result
Ejemplo n.º 4
0
def get_database_tcid(framework, cred_manager):
    r'@types: db2_flow.RichFramework, db2_flow.CredsManager -> generator(tuple(str, str, str, str, str))'
    proto_name = ClientsConsts.SQL_PROTOCOL_NAME
    if framework.tcidHasValues('db_id'):
        db_ids = framework.getTriggerCIDataAsList('db_id')
        db_names = framework.getTriggerCIDataAsList('db_name')
        ports = framework.getTriggerCIDataAsList('db_application_port')
        ips = framework.getTriggerCIDataAsList('ip_address')
        result = []
        for ip in ips:
            ips_ = [ip] * len(db_ids)
            creds = cred_manager.get_creds_for_destination(proto_name)

            tcid_creds = filter(None, framework.getTriggerCIDataAsList('credentials_id'))
            creds = list(tcid_creds) + list(set(creds) - set(tcid_creds))

            creds = iteratortools.product(creds, zip(ips_, ports, db_names, db_ids))
            creds = imap(iteratortools.flatten, creds)
            result.extend([cred for cred in creds
                    if db2_flow.is_applicable_db2_cred(cred_manager, *cred[:4])])
        return result
Ejemplo n.º 5
0
def get_ipse_only_tcid(framework, cred_manager):
    r'@types: db2_flow.RichFramework, db2_flow.CredsManager -> generator(tuple(str, str, str, str, str))'
    proto_name = ClientsConsts.SQL_PROTOCOL_NAME

    if framework.tcidHasValues('ipse_only_id'):
        result = []
        ips = framework.getTriggerCIDataAsList('ip_address')
        for ip in ips:
            ipse_ids = framework.getTriggerCIDataAsList('ipse_only_id')
            ipse_ports = framework.getTriggerCIDataAsList('ipse_only_port')
            ips_ = [ip] * len(ipse_ids)
            creds = cred_manager.get_creds_for_destination(proto_name)

            dbnames = [None] * len(ipse_ports)
            creds = iteratortools.product(
                creds, zip(ips_, ipse_ports, dbnames, ipse_ids))
            creds = imap(iteratortools.flatten, creds)
            result.extend([
                cred for cred in creds
                if db2_flow.is_applicable_db2_cred(cred_manager, *cred[:4])
            ])
        return result
Ejemplo n.º 6
0
def get_alias_tcid_2d_for_ip(ip, framework, cred_manager):
    proto_name = ClientsConsts.SQL_PROTOCOL_NAME
    alias_ids = framework.getTriggerCIDataAsList('alias_id')
    ips = [ip] * len(alias_ids)

    alias_containers = framework.getTriggerCIDataAsList('alias_container')
    alias_names = framework.getTriggerCIDataAsList('alias_name')

    inst_ports = framework.getTriggerCIDataAsList('inst_application_port')
    inst_ids = framework.getTriggerCIDataAsList('inst_id')
    inst_port_by_id = dict(zip(inst_ids, inst_ports))

    ports = []
    for alias_container_id in alias_containers:
        ports.append(inst_port_by_id.get(alias_container_id))

    creds = cred_manager.get_creds_for_destination(proto_name)

    creds = iteratortools.product(creds, zip(ips, ports, alias_names, alias_ids))
    creds = imap(iteratortools.flatten, creds)

    return [cred for cred in creds
            if db2_flow.is_applicable_db2_cred(cred_manager, *cred[:4])]