# Path: mongoctl/mongoctl_logging.py
# def log_info(msg):
#     get_logger().info(msg)
# 
# Path: mongoctl/utils.py
# def document_pretty_string(document):
#     return json.dumps(document, indent=4, default=json_util.default)


import mongoctl.repository as repository
import time
from cluster import Cluster
from server import Server
from replicaset_cluster import ReplicaSetCluster
from base import DocumentWrapper
from bson import DBRef
from mongoctl.mongoctl_logging import log_info
from mongoctl.utils import document_pretty_string
                         shard_member.get_server().id == shard_id)
                or (shard_member.get_cluster() and
                            shard_member.get_cluster().id == shard_id)):
                return shard_member
    ###########################################################################
    def get_config_db_address(self):
        if isinstance(self.config_servers, list):
            addresses = map(lambda s: s.get_address(), self.config_servers)
            return ",".join(addresses)
        elif isinstance(self.config_servers, ReplicaSetCluster):
            return self.config_servers.get_replica_address()

    ###########################################################################
    def get_shard_member_address(self, shard_member):

        if shard_member.get_server():
            return shard_member.get_server().get_address()
        elif shard_member.get_cluster():
            cluster_member_addresses = []
            for cluster_member in shard_member.get_cluster().get_members():
                cluster_member_addresses.append(
                    cluster_member.get_server().get_address())
            return "%s/%s" % (shard_member.get_cluster().id,
                              ",".join(cluster_member_addresses))


    ###########################################################################
    def configure_sharded_cluster(self):
        sh_list = self.list_shards()
        if sh_list and sh_list.get("shards"):

# Path: mongoctl/mongoctl_logging.py
# def log_info(msg):
#     get_logger().info(msg)
# 
# Path: mongoctl/utils.py
# def document_pretty_string(document):
#     return json.dumps(document, indent=4, default=json_util.default)


# Path: mongoctl/objects/sharded_cluster.py
import mongoctl.repository as repository
import time
from cluster import Cluster
from server import Server
from replicaset_cluster import ReplicaSetCluster
from base import DocumentWrapper
from bson import DBRef
from mongoctl.mongoctl_logging import log_info
from mongoctl.utils import document_pretty_string

                         shard_member.get_server().id == shard_id)
                or (shard_member.get_cluster() and
                            shard_member.get_cluster().id == shard_id)):
                return shard_member
    ###########################################################################
    def get_config_db_address(self):
        if isinstance(self.config_servers, list):
            addresses = map(lambda s: s.get_address(), self.config_servers)
            return ",".join(addresses)
        elif isinstance(self.config_servers, ReplicaSetCluster):
            return self.config_servers.get_replica_address()

    ###########################################################################
    def get_shard_member_address(self, shard_member):

        if shard_member.get_server():
            return shard_member.get_server().get_address()
        elif shard_member.get_cluster():
            cluster_member_addresses = []
            for cluster_member in shard_member.get_cluster().get_members():
                cluster_member_addresses.append(
                    cluster_member.get_server().get_address())
            return "%s/%s" % (shard_member.get_cluster().id,
                              ",".join(cluster_member_addresses))


    ###########################################################################
    def configure_sharded_cluster(self):
        sh_list = self.list_shards()
        if sh_list and sh_list.get("shards"):

            log_info("Shard cluster already configured. Will only be adding"