magma-orc8r-libs

magma-orc8r-libs

  • Canonical Telco
Channel Revision Published Runs on
latest/edge 30 27 Apr 2023
Ubuntu 22.04 Ubuntu 20.04
latest/edge 23 01 Feb 2023
Ubuntu 22.04 Ubuntu 20.04
juju deploy magma-orc8r-libs --channel edge
Show information

Platform:

charms.magma_orc8r_libs.v1.orc8r_base_db

Orc8rBaseDB Library.

This library is designed to enable developers to easily create new charms for Magma orc8r that require a relationship to a database. This library contains all the logic necessary to wait for necessary relations and be deployed. When initialised, this library binds a handler to the parent charm's pebble_ready event. This will ensure that the service is configured when this event is triggered. The constructor simply takes the following:

  • Reference to the parent charm (CharmBase)
  • The startup command (str)
Getting Started

To get started using the library, you just need to fetch the library using charmcraft. Note that you also need to add pgconnstr to your charm's requirements.txt.

cd some-charm
charmcraft fetch-lib charms.magma_orc8r_libs.v1.orc8r_base_db
echo <<-EOF >> requirements.txt
pgconnstr
EOF

Then, to initialise the library:

from charms.magma_orc8r_libs.v1.orc8r_base_db import Orc8rBase
from charms.observability_libs.v0.kubernetes_service_patch import KubernetesServicePatch
from ops.charm import CharmBase
from ops.main import main


class MagmaOrc8rDirectorydCharm(CharmBase):
    def __init__(self, *args):
        super().__init__(*args)
        self._service_patcher = KubernetesServicePatch(self, [("grpc", 9180)])
        startup_command = (
            "/usr/bin/envdir "
            "/var/opt/magma/envdir "
            "/var/opt/magma/bin/directoryd "
            "-logtostderr=true "
            "-v=0"
        )
        self._orc8r_base = Orc8rBase(self, startup_command=startup_command)

Charms that leverage this library also need to specify a provides relation in their metadata.yaml file. For example:

provides:
  magma-orc8r-directoryd:
    interface: magma-orc8r-directoryd

Charms that leverage this library also need to specify a requires relation in their metadata.yaml file. For example:

requires:
  database:
    interface: postgresql_client

class Orc8rBase

Description

Instantiated by Orchestrator charms that require connection with a DB. None

Methods

Orc8rBase. __init__( self , charm: CharmBase , startup_command: str , additional_environment_variables: dict )

Description

Observes common events for all Orchestrator charms. None

Orc8rBase. namespace( self )

Returns Kubernetes namespace.

Returns

str

Kubernetes namespace