Exemplo n.º 1
0
def get_configured_clusters():

    global __configured_clusters__, __commandline_clusters__

    if __configured_clusters__ is None:
        __configured_clusters__ = {}

        cluster_documents = []
        if has_file_repository():
            file_repo_conf = config.get_file_repository_conf()
            clusters_path_or_url = file_repo_conf.get("clusters",
                                                      DEFAULT_CLUSTERS_FILE)

            cluster_documents = config.read_config_json("clusters",
                                                        clusters_path_or_url)
            if not isinstance(cluster_documents, list):
                raise MongoctlException("Cluster list in '%s' must be an array" %
                                        clusters_path_or_url)
        if __commandline_clusters__:
            cluster_documents.extend(__commandline_clusters__)

        for document in cluster_documents:
            cluster = new_cluster(document)
            __configured_clusters__[cluster.id] = cluster

    return __configured_clusters__
Exemplo n.º 2
0
def get_configured_clusters():

    global __configured_clusters__, __commandline_clusters__

    if __configured_clusters__ is None:
        __configured_clusters__ = {}

        cluster_documents = []
        if has_file_repository():
            file_repo_conf = config.get_file_repository_conf()
            clusters_path_or_url = file_repo_conf.get("clusters",
                                                      DEFAULT_CLUSTERS_FILE)

            cluster_documents = config.read_config_json("clusters",
                                                        clusters_path_or_url)
            if not isinstance(cluster_documents, list):
                raise MongoctlException("Cluster list in '%s' must be an array" %
                                        clusters_path_or_url)
        if __commandline_clusters__:
            cluster_documents.extend(__commandline_clusters__)

        for document in cluster_documents:
            cluster = new_cluster(document)
            __configured_clusters__[cluster.id] = cluster

    return __configured_clusters__
Exemplo n.º 3
0
def get_configured_servers():

    global __configured_servers__, __commandline_servers__

    if __configured_servers__ is None:
        __configured_servers__ = {}

        server_documents = []
        if has_file_repository():
            file_repo_conf = config.get_file_repository_conf()
            servers_path_or_url = file_repo_conf.get("servers",
                                                     DEFAULT_SERVERS_FILE)

            server_documents = config.read_config_json("servers",
                                                       servers_path_or_url)

            if not isinstance(server_documents, list):
                raise MongoctlException("Server list in '%s' must be an array" %
                                        servers_path_or_url)

        if __commandline_servers__:
            server_documents.extend(__commandline_servers__)

        for document in server_documents:
            server = new_server(document)
            __configured_servers__[server.id] = server

    return __configured_servers__
Exemplo n.º 4
0
def get_configured_servers():

    global __configured_servers__, __commandline_servers__

    if __configured_servers__ is None:
        __configured_servers__ = {}

        server_documents = []
        if has_file_repository():
            file_repo_conf = config.get_file_repository_conf()
            servers_path_or_url = file_repo_conf.get("servers",
                                                     DEFAULT_SERVERS_FILE)

            server_documents = config.read_config_json("servers",
                                                       servers_path_or_url)

            if not isinstance(server_documents, list):
                raise MongoctlException("Server list in '%s' must be an array" %
                                        servers_path_or_url)

        if __commandline_servers__:
            server_documents.extend(__commandline_servers__)

        for document in server_documents:
            server = new_server(document)
            __configured_servers__[server.id] = server

    return __configured_servers__