Beispiel #1
0
def detect_jboss_fuse(source, facts):
    """Detect if JBoss Fuse is present based on system facts.

    :param source: The source of the facts
    :param facts: facts for a system
    :returns: dictionary defining the product presence
    """
    fuse_on_eap = facts.get(JBOSS_FUSE_FUSE_ON_EAP)
    fuse_on_karaf = facts.get(JBOSS_FUSE_ON_KARAF_KARAF_HOME)
    systemctl_files = facts.get(JBOSS_FUSE_SYSTEMCTL_FILES)
    chkconfig = facts.get(JBOSS_FUSE_CHKCONFIG)
    subman_consumed = facts.get(SUBMAN_CONSUMED, [])
    entitlements = facts.get(ENTITLEMENTS, [])
    # Get activemq versions
    fuse_activemq = facts.get(JBOSS_FUSE_ACTIVEMQ_VER, [])
    eap_activemq = get_version(facts.get(JBOSS_FUSE_ON_EAP_ACTIVEMQ_VER, []))
    ext_fuse_activemq = facts.get(JBOSS_ACTIVEMQ_VER, [])
    activemq_list = fuse_activemq + eap_activemq + ext_fuse_activemq
    # Get camel-core versions
    fuse_camel = facts.get(JBOSS_FUSE_CAMEL_VER, [])
    eap_camel = get_version(facts.get(JBOSS_FUSE_ON_EAP_CAMEL_VER, []))
    ext_fuse_camel = facts.get(JBOSS_CAMEL_VER, [])
    camel_list = fuse_camel + eap_camel + ext_fuse_camel
    # Get cxf-rt versions
    fuse_cxf = facts.get(JBOSS_FUSE_CXF_VER, [])
    eap_cxf = get_version(facts.get(JBOSS_FUSE_ON_EAP_CXF_VER, []))
    ext_fuse_cxf = facts.get(JBOSS_CXF_VER, [])
    cxf_list = fuse_cxf + eap_cxf + ext_fuse_cxf
    fuse_versions = []

    source_object = Source.objects.filter(id=source.get('source_id')).first()
    if source_object:
        source_name = source_object.name
    else:
        source_name = None

    metadata = {
        'source_id': source['source_id'],
        'source_name': source_name,
        'source_type': source['source_type'],
    }
    product_dict = {'name': PRODUCT}
    raw_facts = None
    is_fuse_on_eap = (fuse_on_eap and any(fuse_on_eap.values()))
    is_fuse_on_karaf = (fuse_on_karaf and any(fuse_on_karaf.values()))
    if (activemq_list and camel_list and cxf_list) or is_fuse_on_eap or \
            is_fuse_on_karaf:
        # Set versions from extended-products scan & regular scan
        fuse_versions = list(set(fuse_activemq + eap_activemq +
                                 ext_fuse_activemq + fuse_camel +
                                 eap_camel + ext_fuse_camel +
                                 fuse_cxf + eap_cxf + ext_fuse_cxf))
    if is_fuse_on_eap or is_fuse_on_karaf or fuse_versions:
        raw_facts_dict = {JBOSS_FUSE_FUSE_ON_EAP: is_fuse_on_eap,
                          JBOSS_FUSE_ON_KARAF_KARAF_HOME: is_fuse_on_karaf,
                          JBOSS_ACTIVEMQ_VER: ext_fuse_activemq,
                          JBOSS_CAMEL_VER: ext_fuse_camel,
                          JBOSS_CXF_VER: ext_fuse_cxf,
                          JBOSS_FUSE_ACTIVEMQ_VER: fuse_activemq,
                          JBOSS_FUSE_CAMEL_VER: fuse_camel,
                          JBOSS_FUSE_CXF_VER: fuse_cxf,
                          JBOSS_FUSE_ON_EAP_ACTIVEMQ_VER: eap_activemq,
                          JBOSS_FUSE_ON_EAP_CAMEL_VER: eap_camel,
                          JBOSS_FUSE_ON_EAP_CXF_VER: eap_cxf}
        raw_facts = generate_raw_fact_members(raw_facts_dict)
        product_dict[PRESENCE_KEY] = Product.PRESENT
        versions = []
        if fuse_versions:
            for version_data in fuse_versions:
                unknown_release = 'Unknown-Release: ' + version_data
                versions.append(FUSE_CLASSIFICATIONS.get(version_data,
                                                         unknown_release))
            if versions:
                product_dict[VERSION_KEY] = versions
    elif systemctl_files or chkconfig:
        raw_facts_dict = {JBOSS_FUSE_SYSTEMCTL_FILES: systemctl_files,
                          JBOSS_FUSE_CHKCONFIG: chkconfig}
        raw_facts = generate_raw_fact_members(raw_facts_dict)
        product_dict[PRESENCE_KEY] = Product.POTENTIAL
    elif product_entitlement_found(subman_consumed, PRODUCT):
        raw_facts = SUBMAN_CONSUMED
        product_dict[PRESENCE_KEY] = Product.POTENTIAL
    elif product_entitlement_found(entitlements, PRODUCT):
        raw_facts = ENTITLEMENTS
        product_dict[PRESENCE_KEY] = Product.POTENTIAL
    else:
        product_dict[PRESENCE_KEY] = Product.ABSENT

    metadata[RAW_FACT_KEY] = raw_facts
    product_dict[META_DATA_KEY] = metadata
    return product_dict
Beispiel #2
0
def detect_jboss_brms(source, facts):
    """Detect if JBoss BRMS is present based on system facts.

    :param source: The source of the facts
    :param facts: facts for a system
    :returns: dictionary defining the product presence
    """
    business_central_candidates = facts.get(BUSINESS_CENTRAL_CANDIDATES, [])
    kie_server_candidates = facts.get(KIE_SERVER_CANDIDATES, [])
    manifest_mfs = facts.get(JBOSS_BRMS_MANIFEST_MF, {})
    kie_in_bc = facts.get(JBOSS_BRMS_KIE_IN_BC, [])
    locate_kie_api = facts.get(JBOSS_BRMS_LOCATE_KIE_API, [])
    find_kie_api = facts.get(JBOSS_BRMS_KIE_API_VER, [])
    find_kie_war = facts.get(JBOSS_BRMS_KIE_WAR_VER, [])
    find_drools = facts.get(JBOSS_BRMS_DROOLS_CORE_VER, [])
    subman_consumed = facts.get(SUBMAN_CONSUMED, [])
    entitlements = facts.get(ENTITLEMENTS, [])
    base_directories = set(business_central_candidates + kie_server_candidates)
    kie_files = kie_in_bc + locate_kie_api
    ext_search_versions = list(set(find_kie_api + find_kie_war + find_drools))

    kie_versions_by_directory = {}
    for directory in base_directories:
        versions_in_dir = set()
        for filename in list(kie_files):
            if filename.startswith(directory):
                kie_files.remove(filename)
                category = classify_kie_file(filename)
                if category:
                    versions_in_dir.add(category)
                # Deliberately drop files if their category is falsey,
                # because it means that they are not Red Hat files.
        kie_versions_by_directory[directory] = versions_in_dir

    found_manifest = any(
        ('Red Hat' in manifest for _, manifest in manifest_mfs.items()))
    found_versions = any(
        (version for _, version in kie_versions_by_directory.items()))
    found_redhat_brms = (found_manifest or found_versions
                         or ext_search_versions)

    source_object = Source.objects.filter(id=source.get('source_id')).first()
    if source_object:
        source_name = source_object.name
    else:
        source_name = None

    metadata = {
        'source_id': source['source_id'],
        'source_name': source_name,
        'source_type': source['source_type'],
    }
    product_dict = {'name': PRODUCT}

    if found_redhat_brms:
        raw_facts_dict = {
            JBOSS_BRMS_MANIFEST_MF: found_manifest,
            JBOSS_BRMS_KIE_IN_BC: (found_versions and kie_in_bc),
            JBOSS_BRMS_LOCATE_KIE_API: (found_versions and locate_kie_api),
            JBOSS_BRMS_KIE_API_VER: find_kie_api,
            JBOSS_BRMS_KIE_WAR_VER: find_kie_war,
            JBOSS_BRMS_DROOLS_CORE_VER: find_drools
        }
        raw_facts = generate_raw_fact_members(raw_facts_dict)
        metadata[RAW_FACT_KEY] = raw_facts
        product_dict[PRESENCE_KEY] = Product.PRESENT
        versions = []
        if ext_search_versions:
            for version_data in ext_search_versions:
                unknown_release = 'Unknown-Release: ' + version_data
                versions.append(
                    BRMS_CLASSIFICATIONS.get(version_data, unknown_release))
            if versions:
                product_dict[VERSION_KEY] = versions

    elif product_entitlement_found(subman_consumed, PRODUCT):
        metadata[RAW_FACT_KEY] = SUBMAN_CONSUMED
        product_dict[PRESENCE_KEY] = Product.POTENTIAL
    elif product_entitlement_found(entitlements, PRODUCT):
        metadata[RAW_FACT_KEY] = ENTITLEMENTS
        product_dict[PRESENCE_KEY] = Product.POTENTIAL
    else:
        metadata[RAW_FACT_KEY] = None
        product_dict[PRESENCE_KEY] = Product.ABSENT

    product_dict[META_DATA_KEY] = metadata
    return product_dict
Beispiel #3
0
def detect_jboss_brms(source, facts):
    """Detect if JBoss BRMS is present based on system facts.

    :param source: The source of the facts
    :param facts: facts for a system
    :returns: dictionary defining the product presence
    """
    manifest_mfs = facts.get(JBOSS_BRMS_MANIFEST_MF, set())
    kie_in_bc = facts.get(JBOSS_BRMS_KIE_IN_BC, set())
    locate_kie_api = facts.get(JBOSS_BRMS_LOCATE_KIE_API, set())
    find_kie_api = facts.get(JBOSS_BRMS_KIE_API_VER, set())
    find_kie_war = facts.get(JBOSS_BRMS_KIE_WAR_VER, set())
    find_drools = facts.get(JBOSS_BRMS_DROOLS_CORE_VER, set())
    subman_consumed = facts.get(SUBMAN_CONSUMED, [])
    entitlements = facts.get(ENTITLEMENTS, [])

    source_object = Source.objects.filter(id=source.get('source_id')).first()
    if source_object:
        source_name = source_object.name
    else:
        source_name = None

    metadata = {
        'source_id': source['source_id'],
        'source_name': source_name,
        'source_type': source['source_type'],
    }
    product_dict = {'name': PRODUCT}

    versions = set()
    found_kie_version = False
    for _, version_string in itertools.chain(kie_in_bc, locate_kie_api):
        category = classify_version_string(version_string)
        # categories that are falsey are not Red Hat files.
        if category:
            versions.add(category)
            found_kie_version = True

    found_manifest_version = False
    for _, manifest_version in manifest_mfs:
        category = classify_version_string(manifest_version)
        if category:
            versions.add(category)
            found_manifest_version = True

    for _, filename in itertools.chain(find_kie_api, find_drools):
        category = classify_version_string(filename)
        if category:
            versions.add(category)

    for search_version in find_kie_war:
        category = classify_version_string(search_version)
        if category:
            versions.add(category)

    # Exclude Drools versions for now.
    found_redhat_brms = any(
        (not version.startswith('Drools') for version in versions))

    if found_redhat_brms:
        raw_facts_dict = {
            JBOSS_BRMS_MANIFEST_MF: found_manifest_version,
            JBOSS_BRMS_KIE_IN_BC: (found_kie_version and kie_in_bc),
            JBOSS_BRMS_LOCATE_KIE_API: (found_kie_version and locate_kie_api),
            JBOSS_BRMS_KIE_API_VER: find_kie_api,
            JBOSS_BRMS_KIE_WAR_VER: find_kie_war,
            JBOSS_BRMS_DROOLS_CORE_VER: find_drools
        }
        raw_facts = generate_raw_fact_members(raw_facts_dict)
        metadata[RAW_FACT_KEY] = raw_facts
        product_dict[PRESENCE_KEY] = Product.PRESENT
        product_dict[VERSION_KEY] = list(versions)

    elif product_entitlement_found(subman_consumed, PRODUCT):
        metadata[RAW_FACT_KEY] = SUBMAN_CONSUMED
        product_dict[PRESENCE_KEY] = Product.POTENTIAL
    elif product_entitlement_found(entitlements, PRODUCT):
        metadata[RAW_FACT_KEY] = ENTITLEMENTS
        product_dict[PRESENCE_KEY] = Product.POTENTIAL
    else:
        metadata[RAW_FACT_KEY] = None
        product_dict[PRESENCE_KEY] = Product.ABSENT

    product_dict[META_DATA_KEY] = metadata
    return product_dict
Beispiel #4
0
def detect_jboss_ws(source, facts):
    """Detect if JBoss Web Server is present based on system facts.

    :param source: The raw json source of the facts
    :param facts: facts for a system
    :returns: dictionary defining the product presence
    """
    product_dict = {'name': PRODUCT}
    product_dict[PRESENCE_KEY] = Product.ABSENT

    metadata = {
        'server_id': source['server_id'],
        'source_name': source['source_name'],
        'source_type': source['source_type'],
    }
    subman_consumed = facts.get(SUBMAN_CONSUMED, [])
    installed_with_rpm = facts.get(JWS_INSTALLED_WITH_RPM)
    has_eula_file = facts.get(JWS_HAS_EULA_TXT_FILE)
    jws_has_cert = facts.get(JWS_HAS_CERT)
    tomcat_part_of_redhat = facts.get(TOMCAT_PART_OF_REDHAT_PRODUCT)
    version = get_version(facts.get(JWS_VERSION))
    product_dict[VERSION_KEY] = version
    raw_facts = {}

    # System is subscribed to jws repo, but may or may not have it installed
    if product_entitlement_found(subman_consumed, PRODUCT):
        product_dict[PRESENCE_KEY] = Product.POTENTIAL
        raw_facts[SUBMAN_CONSUMED] = subman_consumed
    # If JWS not installed with rpm, detect potential presence by the presence
    # of a JBossEULA file or tomcat server in JWS_HOME directory
    if tomcat_part_of_redhat:
        product_dict[PRESENCE_KEY] = Product.POTENTIAL
        raw_facts[TOMCAT_PART_OF_REDHAT_PRODUCT] = tomcat_part_of_redhat
    if has_eula_file:
        product_dict[PRESENCE_KEY] = Product.POTENTIAL
        raw_facts[JWS_HAS_EULA_TXT_FILE] = has_eula_file
    # Versions 3.0.0 and over explicitely mention 'JWS' in version string
    if version:
        raw_facts[JWS_VERSION] = facts.get(JWS_VERSION)
        for ver in version:
            if 'EWS' not in ver:
                product_dict[PRESENCE_KEY] = Product.PRESENT
                break
    # Versions prior to 3.0.0 can only be detected by the presence of certain
    # EWS components and don't guarantee the installation of EWS
            else:
                product_dict[PRESENCE_KEY] = Product.POTENTIAL
                break
    if facts.get(JWS_INSTALLED_WITH_RPM):
        product_dict[PRESENCE_KEY] = Product.PRESENT
        raw_facts[JWS_INSTALLED_WITH_RPM] = installed_with_rpm
    # If jws was installed (not as zip) it will have a certifcate
    # https://mojo.redhat.com/docs/DOC-103535
    # The cert may only be installed when a product is installed with RPM,
    # which we already check for. This step may be unnecessary.
    if jws_has_cert:
        product_dict[PRESENCE_KEY] = Product.PRESENT
        raw_facts[JWS_HAS_CERT] = jws_has_cert

    raw_facts = generate_raw_fact_members(raw_facts)
    metadata[RAW_FACT_KEY] = raw_facts
    product_dict[META_DATA_KEY] = metadata

    return product_dict