# Path: mongoctl/users.py
# def parse_global_login_user_arg(username, password, server_id):
# def get_global_login_user(server, dbname):
# def setup_server_users(server):
# def setup_cluster_users(cluster, primary_server):
# def should_seed_db_users(server, dbname):
# def setup_db_users(server, db, db_users):
# def _mongo_add_user(server, db, username, password, read_only=False,
#                     num_tries=1):
# def list_database_users(server, db):
# def setup_server_db_users(server, dbname, db_users):
# def prepend_global_admin_user(other_users, server):
# def setup_server_admin_users(server):
# def setup_root_admin_user(server, admin_users):
# def setup_server_local_users(server):
# def read_seed_password(dbname, username):
# def set_server_login_user(server, dbname, username, password):
# def get_server_login_user(server, dbname):
# def _get_server_login_record(server, create_new=True):
# def is_system_user(username):
# LOGIN_USERS = {}
# 
# Path: mongoctl/config.py
# def get_cluster_member_alt_address_mapping():
#     return get_mongoctl_config_val('clusterMemberAltAddressesMapping', {})
# 
# Path: mongoctl/mongoctl_logging.py
# def log_verbose(msg):
#     get_logger().log(VERBOSE, msg)
# 
# def log_error(msg):
#     get_logger().error(msg)
# 
# def log_db_command(cmd):
#     log_info( "Executing db command %s" % utils.document_pretty_string(cmd))


import mongoctl.repository as repository
from cluster import Cluster
from mongoctl import users
from base import DocumentWrapper
from mongoctl.utils import *
from bson import DBRef
from mongoctl.config import get_cluster_member_alt_address_mapping
from mongoctl.mongoctl_logging import log_verbose, log_error, log_db_command
from mongoctl.prompt import prompt_confirm

        return False

    ###########################################################################
    def initialize_replicaset(self, suggested_primary_server=None):
        log_info("Initializing replica set cluster '%s' %s..." %
                 (self.id,
                  "" if suggested_primary_server is None else
                  "to contain only server '%s'" %
                  suggested_primary_server.id))

        ##### Determine primary server
        log_info("Determining which server should be primary...")
        primary_server = suggested_primary_server
        if primary_server is None:
            primary_member = self.suggest_primary_member()
            if primary_member is not None:
                primary_server = primary_member.get_server()

        if primary_server is None:
            raise MongoctlException("Unable to determine primary server."
                                    " At least one member server has"
                                    " to be online.")
        log_info("Selected server '%s' as primary." % primary_server.id)

        init_cmd = self.get_replicaset_init_all_db_command(
            suggested_primary_server)

        try:


# Path: mongoctl/users.py
# def parse_global_login_user_arg(username, password, server_id):
# def get_global_login_user(server, dbname):
# def setup_server_users(server):
# def setup_cluster_users(cluster, primary_server):
# def should_seed_db_users(server, dbname):
# def setup_db_users(server, db, db_users):
# def _mongo_add_user(server, db, username, password, read_only=False,
#                     num_tries=1):
# def list_database_users(server, db):
# def setup_server_db_users(server, dbname, db_users):
# def prepend_global_admin_user(other_users, server):
# def setup_server_admin_users(server):
# def setup_root_admin_user(server, admin_users):
# def setup_server_local_users(server):
# def read_seed_password(dbname, username):
# def set_server_login_user(server, dbname, username, password):
# def get_server_login_user(server, dbname):
# def _get_server_login_record(server, create_new=True):
# def is_system_user(username):
# LOGIN_USERS = {}
# 
# Path: mongoctl/config.py
# def get_cluster_member_alt_address_mapping():
#     return get_mongoctl_config_val('clusterMemberAltAddressesMapping', {})
# 
# Path: mongoctl/mongoctl_logging.py
# def log_verbose(msg):
#     get_logger().log(VERBOSE, msg)
# 
# def log_error(msg):
#     get_logger().error(msg)
# 
# def log_db_command(cmd):
#     log_info( "Executing db command %s" % utils.document_pretty_string(cmd))


# Path: mongoctl/objects/replicaset_cluster.py
import mongoctl.repository as repository
from cluster import Cluster
from mongoctl import users
from base import DocumentWrapper
from mongoctl.utils import *
from bson import DBRef
from mongoctl.config import get_cluster_member_alt_address_mapping
from mongoctl.mongoctl_logging import log_verbose, log_error, log_db_command
from mongoctl.prompt import prompt_confirm


        return False

    ###########################################################################
    def initialize_replicaset(self, suggested_primary_server=None):
        log_info("Initializing replica set cluster '%s' %s..." %
                 (self.id,
                  "" if suggested_primary_server is None else
                  "to contain only server '%s'" %
                  suggested_primary_server.id))

        ##### Determine primary server
        log_info("Determining which server should be primary...")
        primary_server = suggested_primary_server
        if primary_server is None:
            primary_member = self.suggest_primary_member()
            if primary_member is not None:
                primary_server = primary_member.get_server()

        if primary_server is None:
            raise MongoctlException("Unable to determine primary server."
                                    " At least one member server has"
                                    " to be online.")
        log_info("Selected server '%s' as primary." % primary_server.id)

        init_cmd = self.get_replicaset_init_all_db_command(
            suggested_primary_server)

        try:


            log_db_command(init_cmd)