MongoDB

Channel Revision Published Runs on
6/stable 199 04 Oct 2024
Ubuntu 22.04
6/candidate 199 04 Oct 2024
Ubuntu 22.04
6/beta 199 04 Oct 2024
Ubuntu 22.04
6/edge 204 12 Nov 2024
Ubuntu 22.04
5/stable 117 20 Apr 2023
Ubuntu 22.04
5/candidate 117 20 Apr 2023
Ubuntu 22.04
5/edge 139 21 Nov 2023
Ubuntu 22.04 Ubuntu 20.04
5/edge 109 06 Mar 2023
Ubuntu 22.04 Ubuntu 20.04
3.6/stable 100 28 Apr 2023
Ubuntu 20.04 Ubuntu 18.04
3.6/candidate 100 13 Apr 2023
Ubuntu 20.04 Ubuntu 18.04
3.6/edge 100 03 Feb 2023
Ubuntu 20.04 Ubuntu 18.04
juju deploy mongodb --channel 6/stable
Show information

Platform:

Ubuntu
22.04 20.04 18.04

charms.mongodb.v1.mongodb_provider

In this class, we manage client database relations.

This class creates a user and database for each application relation and expose needed information for client connection via fields in external relation.


class FailedToGetHostsError

Description

Raised when charm fails to retrieve hosts. None

class MongoDBProvider

Description

In this class, we manage client database relations. None

Methods

MongoDBProvider. __init__( self , charm: CharmBase , substrate , relation_name: str )

Constructor for MongoDBProvider object.

Arguments

charm

the charm for which this relation is provided

substrate

host type, either "k8s" or "vm"

relation_name

the name of the relation

MongoDBProvider. pass_sanity_hook_checks( self )

Description

Runs reusable and event agnostic checks. None

MongoDBProvider. pass_hook_checks( self , event: RelationEvent )

Description

Runs the pre-hooks checks for MongoDBProvider, returns True if all pass. None

MongoDBProvider. oversee_users( self , departed_relation_id , event )

Oversees the users of the application.

Description

Function manages user relations by removing, updated, and creating users; and dropping databases when necessary.

Args: departed_relation_id: When specified execution of functions makes sure to exclude the users and databases and remove them if necessary. event: relation event.

When the function is executed in relation departed event, the departed relation is still on the list of all relations. Therefore, for proper work of the function, we need to exclude departed relation from the list.

Raises: PyMongoError

MongoDBProvider. remove_users( self , users_being_managed , expected_current_users )

Removes users from Charmed MongoDB.

Description

Note this only removes users that this application of Charmed MongoDB is responsible for managing. It won't remove:

  1. users created from other applications
  2. users created from other mongos routers.

Raises: PyMongoError

MongoDBProvider. add_users( self , users_being_managed , expected_current_users )

Adds users to Charmed MongoDB.

Description

Raises: PyMongoError

MongoDBProvider. update_users( self , event: EventBase , users_being_managed , expected_current_users )

Updates existing users in Charmed MongoDB.

Description

Raises: PyMongoError

MongoDBProvider. auto_delete_dbs( self , departed_relation_id )

Delete's unused dbs if configured to do so.

Description

Raises: PyMongoError

MongoDBProvider. update_app_relation_data( self )

Description

Helper function to update application relation data. None

MongoDBProvider. get_relation_name( self )

Description

Returns the name of the relation to use. None

MongoDBProvider. remove_all_relational_users( self )

Removes all users from DB.

Description

Raises: PyMongoError.