# 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

        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))


        log_info("Executing command \n%s\non mongos '%s'" %
                 (document_pretty_string(cmd), mongos.id))
        mongos.db_command(cmd, "admin")

        log_info("Shard '%s' added successfully!" % self.id)

    ###########################################################################
    def get_add_shard_command(self, shard_member):
        return {
            "addShard": self.get_shard_member_address(shard_member)
        }

    ###########################################################################
    def remove_shard(self, shard, unsharded_data_dest_id=None,
                     synchronized=False):
        log_info("Removing shard '%s' from ShardedCluster '%s' " %
                 (shard.id, self.id))

        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


        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))


        log_info("Executing command \n%s\non mongos '%s'" %
                 (document_pretty_string(cmd), mongos.id))
        mongos.db_command(cmd, "admin")

        log_info("Shard '%s' added successfully!" % self.id)

    ###########################################################################
    def get_add_shard_command(self, shard_member):
        return {
            "addShard": self.get_shard_member_address(shard_member)
        }

    ###########################################################################
    def remove_shard(self, shard, unsharded_data_dest_id=None,
                     synchronized=False):
        log_info("Removing shard '%s' from ShardedCluster '%s' " %
                 (shard.id, self.id))

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

                 document_pretty_string(configured_shards))