Beispiel #1
0
def _create_credentials_map():
    """This lists the content of credentials and associates a variable name to each element.
    This variable name which must be unique, is later used to build a HTML form."""
    cred_type_list = lib_credentials.get_credentials_types()

    cred_types_dict = dict()

    for cred_type in sorted(cred_type_list):

        cred_types_dict[cred_type] = dict()

        # This is a homogeneous list, for example of machines names, or databases.
        cred_nams = lib_credentials.get_credentials_names(cred_type)

        for cred_name in sorted(cred_nams):
            cred = lib_credentials.GetCredentials(cred_type, cred_name)

            cred_input_prefix = cred_type + "_" + cred_name + "_" + cred[0]
            cred_input_password = cred_input_prefix + "_UPDATE_PASSWORD"
            cred_input_name_del = cred_input_prefix + "_DELETE_CREDENTIAL"

            cred_name_url = _cred_type_name_to_url(cred_type, cred_name)

            cred_types_dict[cred_type][cred_name] = [
                cred[0],
                cred[1],
                cred_input_password,
                cred_input_name_del,
                cred_name_url]

    return cred_types_dict
Beispiel #2
0
def Main():
    cgiEnv = lib_common.ScriptEnvironment()

    grph = cgiEnv.GetGraph()

    cred_names = lib_credentials.get_credentials_names("MySql")
    logging.debug("Mysql servers")

    for instance_my_sql in cred_names:
        logging.debug("MySql servers instance_my_sql=%s", instance_my_sql)

        # Do not use sources_types.mysql
        host_my_sql = instance_my_sql.split(":")[0]

        # TODO: Display the connection socket ?
        node_host_my_sql = lib_uris.gUriGen.HostnameUri(host_my_sql)

        node_instance = survol_mysql_instance.MakeUri(instance_my_sql)

        a_cred = lib_credentials.GetCredentials("MySql", instance_my_sql)

        grph.add((node_instance, lib_common.MakeProp("Mysql user"),
                  lib_util.NodeLiteral(a_cred[0])))
        grph.add((node_instance, lib_common.MakeProp("Mysql instance"),
                  node_host_my_sql))

    cgiEnv.OutCgiRdf()
def _wbem_servers_display(grph):
    cred_names = lib_credentials.get_credentials_names("WBEM")
    logging.debug("WbemServersDisplay")
    for cimom_wbem in cred_names:
        logging.debug("WbemServersDisplay cimomWbem=%s", cimom_wbem)

        # The credentials are not needed until a Survol agent uses HTTPS.
        wbem_node = _add_from_wbem_cimom(grph, cimom_wbem)
        if not wbem_node:
            continue
        grph.add((wbem_node, pc.property_information, lib_util.NodeLiteral("Static definition")))
Beispiel #4
0
def Main():
    cgiEnv = lib_common.ScriptEnvironment()

    grph = cgiEnv.GetGraph()

    subscriptions = lib_credentials.get_credentials_names("Azure")

    for subscription_name in subscriptions:
        _enumerate_services(grph, subscription_name)

    cgiEnv.OutCgiRdf()
Beispiel #5
0
def DatabaseEnvParams(processId):
    # This is a list of db names, such as ["XE"]
    lst_cred_nams = lib_credentials.get_credentials_names('Oracle')

    # TODO: We could use the process id to check if the process executable is linked
    # with the Oracle shareable library. If not, return None.

    # Each of these elements allows to connect to an Oracle database.
    list_args = ({"Db": db} for db in lst_cred_nams)

    return ("oracle/query", list_args)
Beispiel #6
0
def WbemServersList():
    lst_wbem_servers = []
    cred_names = lib_credentials.get_credentials_names("WBEM")
    logging.debug("WbemServersList")
    for url_wbem in cred_names:
        # crdNam = "http://192.168.1.83:5988"
        parsed_url = lib_util.survol_urlparse(url_wbem)
        the_host = parsed_url.hostname
        if the_host:
            lst_wbem_servers.append((the_host, url_wbem))

    return lst_wbem_servers
Beispiel #7
0
def Main():
    cgiEnv = lib_common.ScriptEnvironment()

    grph = cgiEnv.GetGraph()

    cred_names = lib_credentials.get_credentials_names("MySql")

    for instance_my_sql in cred_names:
        logging.debug("MySql servers instance_my_sql=%s", instance_my_sql)

        phpmyadmin_node = _add_my_sql_port(grph, instance_my_sql)
        grph.add((lib_common.nodeMachine, pc.property_rdf_data_nolist1, phpmyadmin_node))

    cgiEnv.OutCgiRdf()
Beispiel #8
0
def Main():
    cgiEnv = lib_common.ScriptEnvironment()

    grph = cgiEnv.GetGraph()

    root_node = lib_common.nodeMachine
    subscriptions = lib_credentials.get_credentials_names("Azure")

    # This creates a node for each available Azure subscription,
    # as they are given, with password, in the credentials file.
    # From this node, it is possible to access to anything related to it.
    for subscription_name in subscriptions:
        subscription_node = azure_subscription.MakeUri(subscription_name)

        grph.add((root_node, lib_common.MakeProp("Azure"), subscription_node))

    cgiEnv.OutCgiRdf()
Beispiel #9
0
def HostnameToWbemServer(hostname):
    """This returns the WBEM server of a machine.
    It checks the credentials to find the best possible Cimom."""

    # TODO: This should prefer port 5988 over 5989 which does not work with pywbem anyway.
    entity_ip_addr = lib_util.EntHostToIpReally(hostname)

    cred_names = lib_credentials.get_credentials_names("WBEM")
    for url_wbem in cred_names:
        # url_wbem = "http://192.168.1.83:5988"
        parsed_url = lib_util.survol_urlparse(url_wbem)
        the_host = parsed_url.hostname
        if the_host == hostname:
            return url_wbem
        if the_host == entity_ip_addr:
            return url_wbem

    # If no credential can be found, just return a default one.
    return "http://" + entity_ip_addr + ":5988"
Beispiel #10
0
def Main():
    cgiEnv = lib_common.ScriptEnvironment()

    #"RabbitMQ" : {
    #    "localhost:12345" : [ "guest", "*********" ]
    #    }
    cred_list = lib_credentials.get_credentials_names("RabbitMQ")

    grph = cgiEnv.GetGraph()

    if cred_list:
        for config_nam in cred_list:

            # Nothing else but a host and a port. The host is case insensitive: RFC4343.
            config_nam = config_nam.lower()

            logging.debug("config_nam=%s", config_nam)
            node_manager = survol_rabbitmq_manager.MakeUri(config_nam)

            host_split = config_nam.split(":")

            if len(host_split) < 2:
                lib_common.ErrorMessageHtml(
                    "RabbitMQ configuration. Port number not defined:%s" %
                    config_nam)

            node_addr = lib_uris.gUriGen.AddrUri(host_split[0], host_split[1])

            grph.add((node_addr, lib_common.MakeProp("RabbitMQ manager"),
                      node_manager))

            # http://127.0.0.1:12345/#/
            management_url = rabbitmq.ManagementUrlPrefix(config_nam)
            grph.add((node_addr, lib_common.MakeProp("Management"),
                      lib_common.NodeUrl(management_url)))

            # TODO: Get and display the log files.
            # Config file     c:/Users/jsmith/AppData/Roaming/RabbitMQ/rabbitmq.config
            # Database directory     c:/Users/jsmith/AppData/Roaming/RabbitMQ/db/RABBIT~1
            # Log file     C:/Users/jsmith/AppData/Roaming/RabbitMQ/log/RABBIT~1.LOG
            # SASL log file     C:/Users/jsmith/AppData/Roaming/RabbitMQ/log/RABBIT~2.LOG

    cgiEnv.OutCgiRdf()
Beispiel #11
0
def has_credentials(credential_type):
    return lib_credentials.get_credentials_names(credential_type)
def _survol_servers_display(grph):
    cred_names = lib_credentials.get_credentials_names("Survol")
    logging.debug("SurvolServersDisplay")
    for url_survol in cred_names:
        # The credentials are not needed until a Survol agent uses HTTPS.
        _callback_node_adder(grph, url_survol)