Esempio n. 1
0
def _entity_array_to_alias(entity_type, entity_ids_arr, force_entity_ip_addr):
    """This calls for an object, the class-specific function UniversalAlias, if it exists.
    Otherwise, it generates a default string with the object's parameters.
    The universal alias of an object is the same for all Survol agents no matter what
    the host they are running on, or their URL.
    Therefore, if several agents are running on the same machine but are hosted differently
    (Apache, IIS, cgiserver.py script running with different accounts and different port numbers),
    they will calculate the same universal alias for the same objects, even if
    the URLs are different.
    """

    func_universal_alias = lib_util.HierarchicalFunctionSearch(entity_type, "UniversalAlias")

    if func_universal_alias:
        univ_alias = func_universal_alias(entity_ids_arr, force_entity_ip_addr, entity_type)
    else:
        # The default alias must contain the class name otherwise there could be an ambiguity
        # between objects of different classes, on the same machine with the attributes values.
        ent_ids_joined = ",".join(entity_ids_arr)

        # This adds a hostname to the moniker, with the Survol syntax.
        # But maybe this object will be described by WBEM or WMI.
        univ_alias = "%s@%s:%s" % (force_entity_ip_addr, entity_type, ent_ids_joined)

    return univ_alias
Esempio n. 2
0
def EntityArrToLabel(entity_type, entity_ids_arr):
    funcEntityName = lib_util.HierarchicalFunctionSearch(
        entity_type, "EntityName")

    if funcEntityName:
        entity_name = funcEntityName(entity_ids_arr)
        return entity_name

    # General case of a URI created by us and for us.
    ent_ids_joined = ",".join(entity_ids_arr)
    if lib_patterns.TypeToGraphParams(entity_type) is None:
        # If the type does not have a special color, add its name.
        return "%s (%s)" % (ent_ids_joined, entity_type)
    else:
        return ent_ids_joined
Esempio n. 3
0
def _entity_array_to_label(entity_type, entity_ids_arr):
    """This fetches in the module of the class, a function called "EntityName"."""
    func_entity_name = lib_util.HierarchicalFunctionSearch(entity_type, "EntityName")

    if func_entity_name:
        entity_name = func_entity_name(entity_ids_arr)
        return entity_name

    # General case of a URI created by us and for us.
    ent_ids_joined = ",".join(entity_ids_arr)
    if lib_patterns.TypeToGraphParams(entity_type) is None:
        # If the type does not have a special color, add its name.
        return "%s (%s)" % (ent_ids_joined, entity_type)
    else:
        return ent_ids_joined
Esempio n. 4
0
def EntityArrToAlias(entity_type, entity_ids_arr, entity_host,
                     force_entity_ip_addr):

    funcUniversalAlias = lib_util.HierarchicalFunctionSearch(
        entity_type, "UniversalAlias")

    if funcUniversalAlias:
        univAlias = funcUniversalAlias(entity_ids_arr, force_entity_ip_addr,
                                       entity_type)
    else:
        # The default alias must contain the class name otherwise there could be an ambiguity
        # between objects of different classes, on the same machine with the attributes values.
        ent_ids_joined = ",".join(entity_ids_arr)

        univAlias = "%s@%s:%s" % (force_entity_ip_addr, entity_type,
                                  ent_ids_joined)

    #sys.stderr.write("EntityArrToAlias entity_type=%s entity_ids_arr=%s force_entity_ip_addr=%s univAlias=%s\n"
    #				 %(entity_type,str(entity_ids_arr),force_entity_ip_addr,univAlias) )
    return univAlias