def __init__(self): BaseCmdLineTool.__init__(self) self.argparser.description = 'script to launch MongoDB stand-alone servers, replica sets and shards. You must specify either --single or --replicaset. \ In addition to the optional arguments below, you can specify any mongos and mongod argument, which will be passed on, if the process accepts it.' # either single or replica set me_group = self.argparser.add_mutually_exclusive_group(required=True) me_group.add_argument('--single', action='store_true', help='creates a single stand-alone mongod instance') me_group.add_argument('--replicaset', action='store_true', help='creates replica set with several mongod instances') me_group.add_argument('--restart', '--restore', action='store_true', help='restarts a previously launched existing configuration from the data directory.') # replica set arguments self.argparser.add_argument('--nodes', action='store', metavar='NUM', type=int, default=3, help='adds NUM data nodes to replica set (requires --replicaset, default=3)') self.argparser.add_argument('--arbiter', action='store_true', default=False, help='adds arbiter to replica set (requires --replicaset)') self.argparser.add_argument('--name', action='store', metavar='NAME', default='replset', help='name for replica set (default=replset)') # sharded clusters self.argparser.add_argument('--sharded', action='store', nargs='*', metavar='N', help='creates a sharded setup consisting of several singles or replica sets. Provide either list of shard names or number of shards (default=1)') self.argparser.add_argument('--config', action='store', default=1, type=int, metavar='NUM', choices=[1, 3], help='adds NUM config servers to sharded setup (requires --sharded, NUM must be 1 or 3, default=1)') self.argparser.add_argument('--mongos', action='store', default=1, type=int, metavar='NUM', help='starts NUM mongos processes (requires --sharded, default=1)') # dir, verbose, port, auth self.argparser.add_argument('--dir', action='store', default='./data', help='base directory to create db and log paths (default=./data/)') self.argparser.add_argument('--verbose', action='store_true', default=False, help='outputs information about the launch') self.argparser.add_argument('--port', action='store', type=int, default=27017, help='port for mongod, start of port range in case of replica set or shards (default=27017)') self.argparser.add_argument('--authentication', action='store_true', default=False, help='enable authentication and create a key file and admin user (admin/mypassword)') self.argparser.add_argument('--binarypath', action='store', default=None, metavar='PATH', help='search for mongod/s binaries in the specified PATH.') self.hostname = socket.gethostname()
def __init__(self): BaseCmdLineTool.__init__(self) self.argparser.description = 'Script to generate pseudo-random data based on template documents.' self.argparser.add_argument( 'template', action='store', help='template for data generation, JSON or file') self.argparser.add_argument('--number', '-n', action='store', type=int, metavar='NUM', default=1, help='number of documents to insert.') self.argparser.add_argument( '--host', action='store', default='localhost', help='mongod/s host to import data, default=localhost') self.argparser.add_argument( '--port', action='store', default=27017, type=int, help='mongod/s port to import data, default=27017') self.argparser.add_argument( '--database', '-d', action='store', metavar='D', default='test', help='database D to insert data, default=test') self.argparser.add_argument( '--collection', '-c', action='store', metavar='C', default='mgendata', help='collection C to import data, default=mgendata') self.argparser.add_argument( '--drop', action='store_true', default=False, help='drop collection before inserting data') self.argparser.add_argument( '--stdout', action='store_true', default=False, help= 'prints data to stdout instead of inserting to mongod/s instance.') self.argparser.add_argument( '--write-concern', '-w', action='store', metavar="W", default=1, help='write concern for inserts, default=1')
def __init__(self): BaseCmdLineTool.__init__(self) self.argparser.description = 'Script to generate pseudo-random data based on template documents.' self.argparser.add_argument('template', action='store', help='template for data generation, JSON or file') self.argparser.add_argument('--number', '-n', action='store', type=int, metavar='NUM', default=1, help='number of documents to insert.') self.argparser.add_argument('--host', action='store', default='localhost', help='mongod/s host to import data, default=localhost') self.argparser.add_argument('--port', action='store', default=27017, type=int, help='mongod/s port to import data, default=27017') self.argparser.add_argument('--database', '-d', action='store', metavar='D', default='test', help='database D to insert data, default=test') self.argparser.add_argument('--collection', '-c', action='store', metavar='C', default='mgendata', help='collection C to import data, default=mgendata') self.argparser.add_argument('--drop', action='store_true', default=False, help='drop collection before inserting data') self.argparser.add_argument('--stdout', action='store_true', default=False, help='prints data to stdout instead of inserting to mongod/s instance.') self.argparser.add_argument('--write-concern', '-w', action='store', metavar="W", default=1, help='write concern for inserts, default=1')
def __init__(self): BaseCmdLineTool.__init__(self) self.argparser.description = ('Import and export databases between MongoDB deployments ' 'for WiredTiger storage with directoryPerDB configuration.') self.argparser.add_argument('--dbpath', dest='dbpath', default='.', nargs=1, help='MongoDB database path') self.argparser.add_argument('--force', action='store_true', help='ignore safety checks') self.argparser.add_argument('--verbose', action='store_true', help='enable verbose output') self.argparser.add_argument('command', choices=['export', 'import']) self.argparser.add_argument('database', nargs=1, type=str, help='name of the database to export / import')
def __init__(self): BaseCmdLineTool.__init__(self) self.hostname = socket.gethostname() # arguments self.args = None # startup parameters for each port self.startup_info = {} # data structures for the discovery feature self.cluster_tree = {} self.cluster_tags = defaultdict(list) self.cluster_running = {} # config docs for replica sets (key is replica set name) self.config_docs = {} # shard connection strings self.shard_connection_str = []
def __init__(self): BaseCmdLineTool.__init__(self) self.argparser.description = 'script to launch MongoDB stand-alone servers, replica sets and shards. You must specify either --single or --replicaset. \ In addition to the optional arguments below, you can specify any mongos and mongod argument, which will be passed on, if the process accepts it.' # either single or replica set me_group = self.argparser.add_mutually_exclusive_group(required=True) me_group.add_argument( '--single', action='store_true', help='creates a single stand-alone mongod instance') me_group.add_argument( '--replicaset', action='store_true', help='creates replica set with several mongod instances') me_group.add_argument( '--restart', action='store_true', help= 'restarts a previously launched existing configuration from the data directory.' ) # replica set arguments self.argparser.add_argument( '--nodes', action='store', metavar='NUM', type=int, default=3, help= 'adds NUM data nodes to replica set (requires --replicaset, default=3)' ) self.argparser.add_argument( '--arbiter', action='store_true', default=False, help='adds arbiter to replica set (requires --replicaset)') self.argparser.add_argument( '--name', action='store', metavar='NAME', default='replset', help='name for replica set (default=replset)') # sharded clusters self.argparser.add_argument( '--sharded', action='store', nargs='*', metavar='N', help= 'creates a sharded setup consisting of several singles or replica sets. Provide either list of shard names or number of shards (default=1)' ) self.argparser.add_argument( '--config', action='store', default=1, type=int, metavar='NUM', choices=[1, 3], help= 'adds NUM config servers to sharded setup (requires --sharded, NUM must be 1 or 3, default=1)' ) self.argparser.add_argument( '--mongos', action='store', default=1, type=int, metavar='NUM', help='starts NUM mongos processes (requires --sharded, default=1)') # dir, verbose, port, auth self.argparser.add_argument( '--dir', action='store', default='./data', help='base directory to create db and log paths (default=./data/)') self.argparser.add_argument( '--verbose', action='store_true', default=False, help='outputs information about the launch') self.argparser.add_argument( '--port', action='store', type=int, default=27017, help= 'port for mongod, start of port range in case of replica set or shards (default=27017)' ) self.argparser.add_argument( '--authentication', action='store_true', default=False, help= 'enable authentication and create a key file and admin user (admin/mypassword)' ) self.argparser.add_argument( '--binarypath', action='store', default=None, metavar='PATH', help='search for mongod/s binaries in the specified PATH.') self.hostname = socket.gethostname()
def __init__(self): BaseCmdLineTool.__init__(self) self.argparser.description = "script to launch MongoDB stand-alone servers, replica sets and shards. You must specify either --single or --replicaset. \ In addition to the optional arguments below, you can specify any mongos and mongod argument, which will be passed on, if the process accepts it." # either single or replica set me_group = self.argparser.add_mutually_exclusive_group(required=True) me_group.add_argument("--single", action="store_true", help="creates a single stand-alone mongod instance") me_group.add_argument( "--replicaset", action="store_true", help="creates replica set with several mongod instances" ) me_group.add_argument( "--restart", action="store_true", help="restarts a previously launched existing configuration from the data directory.", ) # replica set arguments self.argparser.add_argument( "--nodes", action="store", metavar="NUM", type=int, default=3, help="adds NUM data nodes to replica set (requires --replicaset, default=3)", ) self.argparser.add_argument( "--arbiter", action="store_true", default=False, help="adds arbiter to replica set (requires --replicaset)" ) self.argparser.add_argument( "--name", action="store", metavar="NAME", default="replset", help="name for replica set (default=replset)" ) # sharded clusters self.argparser.add_argument( "--sharded", action="store", nargs="*", metavar="N", help="creates a sharded setup consisting of several singles or replica sets. Provide either list of shard names or number of shards (default=1)", ) self.argparser.add_argument( "--config", action="store", default=1, type=int, metavar="NUM", choices=[1, 3], help="adds NUM config servers to sharded setup (requires --sharded, NUM must be 1 or 3, default=1)", ) self.argparser.add_argument( "--mongos", action="store", default=1, type=int, metavar="NUM", help="starts NUM mongos processes (requires --sharded, default=1)", ) # dir, verbose, port, auth self.argparser.add_argument( "--dir", action="store", default="./data", help="base directory to create db and log paths (default=./data/)", ) self.argparser.add_argument( "--verbose", action="store_true", default=False, help="outputs information about the launch" ) self.argparser.add_argument( "--port", action="store", type=int, default=27017, help="port for mongod, start of port range in case of replica set or shards (default=27017)", ) self.argparser.add_argument( "--authentication", action="store_true", default=False, help="enable authentication and create a key file and admin user (admin/mypassword)", ) self.argparser.add_argument( "--binarypath", action="store", default=None, metavar="PATH", help="search for mongod/s binaries in the specified PATH.", ) self.hostname = socket.gethostname()
def __init__(self): """ Constructor: add description to argparser. """ BaseCmdLineTool.__init__(self) self.argparser.description = 'Performs a health check on config servers and compares them for inconsistencies.' self.argparser.add_argument('config', action='store', nargs='*', metavar='URI', default=['mongodb://localhost:27017/config'], help='provide uri(s) to config server(s), default is mongodb://localhost:27017/config')
def __init__(self): BaseCmdLineTool.__init__(self) self.argparser.description = 'Script to generate pseudo-random data based on template documents.' self.argparser.add_argument( 'template', action='store', help='template for data generation, JSON or file') self.argparser.add_argument('--number', '-n', action='store', type=int, metavar='NUM', default=1, help='number of documents to insert.') self.argparser.add_argument( '--host', action='store', default='localhost', help='mongod/s host to import data, default=localhost') self.argparser.add_argument( '--port', action='store', default=27017, help='mongod/s port to import data, default=27017') self.argparser.add_argument( '--database', '-d', action='store', metavar='D', default='test', help='database D to insert data, default=test') self.argparser.add_argument( '--collection', '-c', action='store', metavar='C', default='mgendata', help='collection C to import data, default=mgendata') self.argparser.add_argument( '--drop', action='store_true', default=False, help='drop collection before inserting data') self.argparser.add_argument( '--stdout', action='store_true', default=False, help= 'prints data to stdout instead of inserting to mongod/s instance.') self.argparser.add_argument( '--write-concern', '-w', action='store', metavar="W", default=1, help='write concern for inserts, default=1') # add all operators classes from the operators module, pass in _decode method self.operators = [ c[1](self._decode) for c in inspect.getmembers(operators, inspect.isclass) ] self.string_operators = {} self.dict_operators = {} # separate into key and value operators for o in self.operators: if o.string_format: for name in o.names: self.string_operators[name] = o if o.dict_format: for name in o.names: self.dict_operators[name] = o