# 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
                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"
                     " new shards as needed...")

        for shard_member in self.shards:
            self.add_shard(shard_member.get_member_cluster_or_server())

    ###########################################################################
    def add_shard(self, shard):
        log_info("Adding shard '%s' to ShardedCluster '%s' " % (shard.id, self.id))

        if self.is_shard_configured(shard):
            log_info("Shard '%s' already added! Nothing to do..." % shard.id)
            return

        mongos = self.get_any_online_mongos()
        shard_member = self.get_shard_member(shard)
        cmd = self.get_add_shard_command(shard_member)

        configured_shards = self.list_shards()
        log_info("Current configured shards: \n%s" %

# 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

                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"
                     " new shards as needed...")

        for shard_member in self.shards:
            self.add_shard(shard_member.get_member_cluster_or_server())

    ###########################################################################
    def add_shard(self, shard):
        log_info("Adding shard '%s' to ShardedCluster '%s' " % (shard.id, self.id))

        if self.is_shard_configured(shard):
            log_info("Shard '%s' already added! Nothing to do..." % shard.id)
            return

        mongos = self.get_any_online_mongos()
        shard_member = self.get_shard_member(shard)
        cmd = self.get_add_shard_command(shard_member)

        configured_shards = self.list_shards()
        log_info("Current configured shards: \n%s" %

                 document_pretty_string(configured_shards))