cloudmesh.mongo.MongoDBController-new
¶
Module Contents¶
Classes¶
-
class
cloudmesh.mongo.MongoDBController-new.
MongoInstaller
(dryrun=False, force=False)¶ Bases:
object
-
__str__
(self)¶ Return str(self).
-
docker
(self)¶
-
install
(self, sudo=True)¶ check where the MongoDB is installed in mongo location. if MongoDB is not installed, python help install it
-
linux
(self, sudo=True)¶
-
debian
(self, sudo=True, version=10)¶ Install MongoDB in Linux Debian (9,10)
-
ubuntu
(self)¶ install MongoDB in Linux system (Ubuntu)
-
darwin
(self, brew=False)¶ install MongoDB in Darwin system (Mac)
-
windows
(self)¶ install MongoDB in windows
-
-
class
cloudmesh.mongo.MongoDBController-new.
MongoDBController
(dryrun=False)¶ Bases:
object
-
script_passwd
= use admin db.changeUserPassword("{MONGO_USERNAME}", "{MONGO_PASSWORD}")¶
-
script_admin
=¶ 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}
pip scriptadmin to
mongo –port 27017
restart mongo
mongod –auth –bind_ip {MONGO_HOST} –port {MONGO_PORT} –dbpath {MONGO_PATH}/{MONGO_DBNAME}
-
login
(self)¶
-
list
(self)¶
-
__str__
(self)¶ Return str(self).
-
expanduser
(self)¶
-
update_auth
(self)¶ create admin account in MongoDB
-
create
(self)¶
-
import_collection
(self, security=True)¶
-
start
(self, security=True)¶ start the MongoDB server
-
stop
(self)¶ shutdown the MongoDB server linux and darwin have different way to shutdown the server, the common way is kill
-
set_auth
(self)¶ add admin account into the MongoDB admin database
-
dump
(self, filename)¶ - Parameters
filename – The filename
dump the entire MongoDB database into output location
-
restore
(self, filename)¶ - Parameters
filename – The filename
restore the backup data generated by dump
-
status
(self)¶ check the MongoDB status returns a json object with status: and pid: command
-
version
(self)¶
-
stats
(self)¶
-
is_installed_as_win_service
(self)¶ returns True if mongodb is installed as a windows service :return:
-
win_service_is_running
(self)¶ returns True if mongodb running :return:
-
linux_process_is_running
(self)¶ returns True if mongod is running :return:
-
mac_process_is_running
(self)¶ returns True if mongod is running :return:
-
service_is_running
(self)¶ checks if mongo service is running :return:
-
start_if_not_running
(self)¶ checks if mongo service is running :return:
-
importAsFile
(self, data, collection, db)¶
-