FINOS Legend Database Manager

  • FINOS
Channel Revision Published Runs on
latest/stable 22 14 Aug 2023
Ubuntu 20.04
latest/edge 23 21 Aug 2023
Ubuntu 20.04
juju deploy finos-legend-db-k8s
Show information

Platform:

charms.finos_legend_db_k8s.v0.legend_database

Module defining Legend DB consumer class and helpers.


def get_database_connection_from_mongo_data(
    mongodb_consumer_data,
    mongodb_databases
)

Returns a dict with Mongo connection info for Legend components.

Arguments

mongodb_consumer_connection

connection data as returned by charms.mongodb_k8s.v0.mongodb.MongoConsumer.connection() Should be a dict of the following structure: { "username": "user", "password": "pass", "replica_set_uri": "Replica set URI with user/pass/login DB" }

mongodb_databases

List of database names as returned by charms.mongodb_k8s.v0.mongodb.MongoConsumer.databases()

Returns

Dictionary with the following structure: { "uri": "<replica set URI (with user/pass, no DB name)>", "username": "<username>", "password": "<password>", "database": "<database name>" }

Description

Output is compatible with LegendDatabaseConsumer.get_legend_database_creds().

def set_legend_database_creds_in_relation_data(
    relation_data,
    creds
)

Set connection data for MongoDB from the provided relation data.

Arguments

relation_data

Data of the relation to set the info into.

Returns

True if the provided creds are of a valid structure, else False.

class LegendDatabaseConsumer

Description

Class which facilitates reading Legend DB creds from relation data. None

Methods

LegendDatabaseConsumer. __init__( self , charm , relation_name )

LegendDatabaseConsumer. get_legend_database_creds( self , relation_id )

Get connection data for MongoDB from the provided relation.

Description

Args: relation_id: ID of the relation to fetch data from.

Returns: Dictionary with the following structure: { "uri": "<replica set URI (with user/pass, no DB name)>", "username": "<username>", "password": "<password>", "database": "<database name>" }

Raises: TooManyRelatedAppsError if relation id is not provided and multiple relation of the same name are present.