# 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
                                          not self.is_shard_configured(shard))
            if not completed:
                time.sleep(2)

    ###########################################################################

    def _do_remove_shard(self, shard, unsharded_data_dest_id=None):
        cmd = self.get_validate_remove_shard_command(shard)
        mongos = self.get_any_online_mongos()

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

        result = mongos.db_command(cmd, "admin")

        log_info("Command result: \n%s" % result)

        if "dbsToMove" in result and unsharded_data_dest_id:
            dest_shard_member = self.get_shard_member_by_shard_id(
                unsharded_data_dest_id)

            if not dest_shard_member:
                raise Exception("No such shard '%s' in ShardedCluster '%s' " %
                                (unsharded_data_dest_id, self.id))

            dest_shard = dest_shard_member.get_member_cluster_or_server()
            self.move_dbs_primary(result["dbsToMove"], dest_shard)


        if result.get('state') == "completed":

# 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

                                          not self.is_shard_configured(shard))
            if not completed:
                time.sleep(2)

    ###########################################################################

    def _do_remove_shard(self, shard, unsharded_data_dest_id=None):
        cmd = self.get_validate_remove_shard_command(shard)
        mongos = self.get_any_online_mongos()

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

        result = mongos.db_command(cmd, "admin")

        log_info("Command result: \n%s" % result)

        if "dbsToMove" in result and unsharded_data_dest_id:
            dest_shard_member = self.get_shard_member_by_shard_id(
                unsharded_data_dest_id)

            if not dest_shard_member:
                raise Exception("No such shard '%s' in ShardedCluster '%s' " %
                                (unsharded_data_dest_id, self.id))

            dest_shard = dest_shard_member.get_member_cluster_or_server()
            self.move_dbs_primary(result["dbsToMove"], dest_shard)


        if result.get('state') == "completed":

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