:mod:`cloudmesh.mongo.MongoDBController` ======================================== .. py:module:: cloudmesh.mongo.MongoDBController Module Contents --------------- Classes ~~~~~~~ .. autoapisummary:: cloudmesh.mongo.MongoDBController.MongoInstaller cloudmesh.mongo.MongoDBController.MongoDBController .. class:: MongoInstaller(dryrun=False, force=False) Bases: :class:`object` .. method:: __str__(self) Return str(self). .. method:: install(self, sudo=True) check where the MongoDB is installed in mongo location. if MongoDB is not installed, python help install it .. method:: linux(self, sudo=True) .. method:: debian(self, sudo=True, version=10) Install MongoDB in Linux Debian (9,10) .. method:: ubuntu(self) install MongoDB in Linux system (Ubuntu) .. method:: darwin(self, brew=False) install MongoDB in Darwin system (Mac) .. method:: windows(self) install MongoDB in windows .. class:: MongoDBController(dryrun=False) Bases: :class:`object` .. attribute:: __shared_state .. attribute:: script_passwd :annotation: = use admin db.changeUserPassword("{MONGO_USERNAME}", "{MONGO_PASSWORD}") .. attribute:: script_admin :annotation: = use admin db.createUser( { user: "{MONGO_USERNAME}", pwd: "{MONGO_PASSWORD}", roles: [ { role: "userAdminAnyDatabase", db: "admin" }, "readWriteAnyDatabase" ] } ) Steps to add admin 1. start mongo mongod --port {MONGO_PORT} --bind_ip {MONGO_HOST} --dbpath {MONGO_PATH}/{MONGO_DBNAME} 2. pip scriptadmin to mongo --port 27017 3. restart mongo mongod --auth --bind_ip {MONGO_HOST} --port {MONGO_PORT} --dbpath {MONGO_PATH}/{MONGO_DBNAME} .. method:: login(self) .. method:: list(self) .. method:: __str__(self) Return str(self). .. method:: expanduser(self) .. method:: update_auth(self) create admin account in MongoDB .. method:: ssh(self) .. method:: create(self) .. method:: import_collection(self, security=True) .. method:: start(self, security=True) start the MongoDB server .. method:: stop(self) shutdown the MongoDB server linux and darwin have different way to shutdown the server, the common way is kill .. method:: set_auth(self) add admin account into the MongoDB admin database .. method:: dump(self, filename) :param filename: The filename dump the entire MongoDB database into output location .. method:: restore(self, filename) :param filename: The filename restore the backup data generated by dump .. method:: status(self) check the MongoDB status returns a json object with status: and pid: command .. method:: version(self) .. method:: stats(self) .. method:: is_installed_as_win_service(self) returns True if mongodb is installed as a windows service :return: .. method:: win_service_is_running(self) returns True if mongodb running :return: .. method:: linux_process_is_running(self) returns True if mongod is running :return: .. method:: mac_process_is_running(self) returns True if mongod is running :return: .. method:: service_is_running(self) checks if mongo service is running :return: .. method:: exit_if_not_running(self) .. method:: start_if_not_running(self) checks if mongo service is running :return: .. method:: importAsFile(self, data, collection, db)