def remove_shard_command(parsed_options): shard_id = parsed_options.shardId # determine if the shard is a replicaset cluster or a server shard = repository.lookup_cluster(shard_id) if not shard: shard = repository.lookup_server(shard_id) if not shard: raise MongoctlException("Unknown shard '%s'" % shard_id) shardset_cluster = repository.config_lookup_cluster_by_shard(shard) if not shardset_cluster: raise MongoctlException("'%s' is not a shard" % shard_id) dest = getattr(parsed_options, "unshardedDataDestination") synchronized = getattr(parsed_options, "synchronized") if parsed_options.dryRun: dry_run_remove_shard(shard, shardset_cluster) else: shardset_cluster.remove_shard(shard, unsharded_data_dest_id=dest, synchronized=synchronized)
def add_shard_command(parsed_options): shard_id = parsed_options.shardId # determine if the shard is a replicaset cluster or a server shard = repository.lookup_cluster(shard_id) if not shard: shard = repository.lookup_server(shard_id) if not shard: raise MongoctlException("Unknown shard '%s'" % shard_id) shardset_cluster = repository.config_lookup_cluster_by_shard(shard) if not shardset_cluster: raise MongoctlException("'%s' is not a shard" % shard_id) if parsed_options.dryRun: dry_run_add_shard(shard, shardset_cluster) else: add_shard(shard, shardset_cluster)