---
title: Charmhub | Deploy magma-orc8r-libs using Charmhub - The Open Operator Collection
description: Deploy the latest version of magma-orc8r-libs as a Kubernetes Operator
  on any cloud.
url: https://charmhub.io/magma-orc8r-libs/libraries/magma_orc8r_libs
---

# magma-orc8r-libs

[Canonical Telco](https://charmhub.io/publisher/telco-charmers "View all packages from Canonical Telco")

* [Canonical Telco](https://charmhub.io/publisher/telco-charmers "View all packages from Canonical Telco")

Platform:

edge 30

```
juju deploy magma-orc8r-libs --channel edge
```

[Learn to deploy on juju >](https://juju.is/docs/juju/manage-applications)

[Toggle side navigation](https://charmhub.io/magma-orc8r-libs/libraries/magma_orc8r_libs#drawer)

## charms.magma\_orc8r\_libs.v0.magma\_orc8r\_libs

* [*Docstrings*Docstrings](https://charmhub.io/magma-orc8r-libs/libraries/magma_orc8r_libs)
  [*Code*Source code](https://charmhub.io/magma-orc8r-libs/libraries/magma_orc8r_libs/source-code)
* + Download

    Fetch library

    ```
    charmcraft fetch-lib charms.magma_orc8r_libs.v0.magma_orc8r_libs
    ```

    [Download magma\_orc8r\_libs.py](https://charmhub.io/magma-orc8r-libs/libraries/magma_orc8r_libs/download)
  + *Last updated* 16 Dec 2021
  + *Revision* Library version 0.2

#### Orc8rBase Library.

This library is designed to enable developers to easily create new charms for Magma orc8r. 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 service name (str)
* The startup command (str)
* Whether a database relation is needed (bool)
* The pebble Ready event method (ops.CharmEvent)

##### Getting Started

To get started using the library, you just need to fetch the library using `charmcraft`. **Note
that you also need to add `ops-lib-pgsql` to your charm's `requirements.txt`.**

```
cd some-charm
charmcraft fetch-lib charms.magma_orc8r_libs.v0.orc8r_base
echo <<-EOF >> requirements.txt
ops-lib-pgsql
EOF
```

Then, to initialise the library:
For ClusterIP services:

```
from ops.charm import CharmBase
from ops.main import main

from charms.observability_libs.v0.kubernetes_service_patch import KubernetesServicePatch
from charms.orc8r_libs.v0.orc8r_base import Orc8rBase

class MagmaOrc8rDirectorydCharm(CharmBase):

    def __init__(self, *args):
        super().__init__(*args)
        self._service_patcher = KubernetesServicePatch(self, [("grpc", 9180, 9106)])
        startup_command = "/usr/bin/envdir /var/opt/magma/envdir /var/opt/magma/bin/directoryd -logtostderr=true -v=0"
        self._orc8r_base = Orc8rBase(
            self,
            service_name="magma-orc8r-directoryd",
            startup_command=startup_command,
            database_relation_needed=True,
            pebble_ready_event=self.on.magma_orc8r_directoryd_pebble_ready
        )
```

---

Index

* [class Orc8rBase](https://charmhub.io/magma-orc8r-libs/libraries/magma_orc8r_libs#orc8rbase)
* + [def \_\_init\_\_(
    self,
    charm,
    service\_name,
    startup\_command,
    pebble\_ready\_event,
    database\_relation\_needed,
    additional\_environment\_variables)](https://charmhub.io/magma-orc8r-libs/libraries/magma_orc8r_libs#orc8rbase-__init__)

#### class Orc8rBase

Methods

Orc8rBase.
\_\_init\_\_(

*self*

,
charm: CharmBase

,
service\_name: str

,
startup\_command: str

,
pebble\_ready\_event: CharmEvents

,
database\_relation\_needed: bool

,
additional\_environment\_variables: dict
)
