MongoDB
- Canonical
- Databases
Channel | Revision | Published | Runs on |
---|---|---|---|
6/stable | 199 | 04 Oct 2024 | |
6/candidate | 199 | 04 Oct 2024 | |
6/beta | 199 | 04 Oct 2024 | |
6/edge | 204 | 12 Nov 2024 | |
5/stable | 117 | 20 Apr 2023 | |
5/candidate | 117 | 20 Apr 2023 | |
5/edge | 139 | 21 Nov 2023 | |
5/edge | 109 | 06 Mar 2023 | |
3.6/stable | 100 | 28 Apr 2023 | |
3.6/candidate | 100 | 13 Apr 2023 | |
3.6/edge | 100 | 03 Feb 2023 |
juju deploy mongodb --channel 6/stable
Deploy universal operators easily with Juju, the Universal Operator Lifecycle Manager.
Platform:
charms.mongodb.v0.mongo
-
- Last updated 04 Oct 2024
- Revision Library version 0.2
Code for interactions with MongoDB.
Index
class NotReadyError
Description
Raised when not all replica set members healthy or finished initial sync. None
class AmbiguousConfigError
Description
Raised when the config could correspond to a mongod config or mongos config. None
class MongoConfiguration
Class for Mongo configurations usable my mongos and mongodb.
Description
— replset: name of replica set — database: database name. — username: username. — password: password. — hosts: full list of hosts to connect to, needed for the URI. — tls_external: indicator for use of internal TLS connection. — tls_internal: indicator for use of external TLS connection.
Methods
MongoConfiguration. uri( self )
Description
Return URI concatenated from fields. None
def supported_roles(config: MongoConfiguration)
Description
Return the supported roles for the given configuration. None
class MongoConnection
In this class we create connection object to Mongo[s/db].
Description
This class is meant for agnositc functions in mongos and mongodb.
Real connection is created on the first call to Mongo[s/db]. Delayed connectivity allows to firstly check database readiness and reuse the same connection for an actual query later in the code.
Connection is automatically closed when object destroyed. Automatic close allows to have more clean code.
Note that connection when used may lead to the following pymongo errors: ConfigurationError, ConfigurationError, OperationFailure. It is suggested that the following pattern be adopted when using MongoDBConnection:
with MongoMongos(MongoConfig) as mongo: try: mongo.<some operation from this class> except ConfigurationError, OperationFailure: <error handling as needed>
Methods
MongoConnection. __init__( self , config: MongoConfiguration , uri , direct )
A MongoDB client interface.
Arguments
MongoDB Configuration object.
allow using custom MongoDB URI, needed for replSet init.
force a direct connection to a specific host, avoiding reading replica set configuration and reconnection.
MongoConnection. __enter__( self )
Description
Return a reference to the new connection. None
MongoConnection. __exit__( self , object_type , value , traceback )
Description
Disconnect from MongoDB client. None
MongoConnection. is_ready( self )
Is the MongoDB server ready for services requests.
Returns
True if services is ready False otherwise. Retries over a period of 60 seconds times to allow server time to start up.
MongoConnection. create_user( self , config: MongoConfiguration )
Create user.
Description
Grant read and write privileges for specified database.
MongoConnection. update_user( self , config: MongoConfiguration )
Description
Update grants on database. None
MongoConnection. set_user_password( self , username , password: str )
Description
Update the password. None
MongoConnection. create_role( self , role_name: str , privileges: dict , roles: dict )
Creates a new role.
Arguments
name of the role to be added.
privileges to be associated with the role.
List of roles from which this role inherits privileges.
MongoConnection. drop_user( self , username: str )
Description
Drop user. None
MongoConnection. get_users( self )
Description
Add a new member to replica set config inside MongoDB. None
MongoConnection. get_databases( self )
Description
Return list of all non-default databases. None
MongoConnection. drop_database( self , database: str )
Description
Drop a non-default database. None