SD-Core NRF K8s

  • Canonical Telco
Channel Revision Published Runs on
latest/beta 10 03 Jan 2024
Ubuntu 22.04
latest/edge 16 21 Jan 2024
Ubuntu 22.04
1.5/stable 757 20 Dec 2024
Ubuntu 24.04
1.5/candidate 757 20 Dec 2024
Ubuntu 24.04
1.5/beta 757 20 Dec 2024
Ubuntu 24.04
1.5/edge 757 18 Dec 2024
Ubuntu 24.04 Ubuntu 22.04
1.5/edge 714 25 Nov 2024
Ubuntu 24.04 Ubuntu 22.04
1.6/edge 759 22 Dec 2024
Ubuntu 24.04
1.4/beta 142 26 Apr 2024
Ubuntu 22.04
1.4/edge 688 29 Oct 2024
Ubuntu 22.04
1.3/beta 10 22 Jan 2024
Ubuntu 22.04
1.3/edge 94 05 Apr 2024
Ubuntu 22.04
juju deploy sdcore-nrf-k8s --channel 1.5/stable
Show information

Platform:

charms.sdcore_nrf_k8s.v0.fiveg_nrf

Library for the fiveg_nrf relation.

This library contains the Requires and Provides classes for handling the fiveg_nrf interface.

The purpose of this library is to relate a charm claiming to provide NRF information and another charm requiring this information.

Getting Started

From a charm directory, fetch the library using charmcraft:

charmcraft fetch-lib charms.sdcore_nrf_k8s.v0.fiveg_nrf

Add the following libraries to the charm's requirements.txt file:

  • pydantic
Requirer charm

The requirer charm is the one requiring the NRF information.

Example:


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

from charms.sdcore_nrf_k8s.v0.fiveg_nrf import NRFAvailableEvent, NRFRequires

logger = logging.getLogger(__name__)


class DummyFiveGNRFRequirerCharm(CharmBase):

    def __init__(self, *args):
        super().__init__(*args)
        self.nrf_requirer = NRFRequires(self, "fiveg_nrf")
        self.framework.observe(self.nrf_requirer.on.nrf_available, self._on_nrf_available)

    def _on_nrf_available(self, event: NRFAvailableEvent):
        nrf_url = self.nrf_requirer.nrf_url
        <do something with the nrf_url>


if __name__ == "__main__":
    main(DummyFiveGNRFRequirerCharm)
Provider charm

The provider charm is the one providing the information about the NRF.

Example:


from ops.charm import CharmBase, RelationJoinedEvent
from ops.main import main

from charms.sdcore_nrf_k8s.v0.fiveg_nrf import NRFProvides


class DummyFiveGNRFProviderCharm(CharmBase):

    NRF_URL = "https://nrf.example.com"

    def __init__(self, *args):
        super().__init__(*args)
        self.nrf_provider = NRFProvides(self, "fiveg_nrf")
        self.framework.observe(
            self.on.fiveg_nrf_relation_joined, self._on_fiveg_nrf_relation_joined
        )

    def _on_fiveg_nrf_relation_joined(self, event: RelationJoinedEvent):
        relation_id = event.relation.id
        self.nrf_provider.set_nrf_information(
            url=self.NRF_URL,
            relation_id=relation_id,
        )

    def _on_nrf_url_changed(
        self,
    ):
        self.nrf_provider.set_nrf_information_in_all_relations(
            url="https://different.nrf.com",
        )


if __name__ == "__main__":
    main(DummyFiveGNRFProviderCharm)

class ProviderAppData

Description

Provider app data for fiveg_nrf. None

class ProviderSchema

Description

Provider schema for fiveg_nrf. None

def data_matches_provider_schema(data)

Return whether data matches provider schema.

Arguments

data (dict)

Data to be validated.

Returns

True if data matches provider schema, False otherwise.

class NRFAvailableEvent

Description

Charm event emitted when a NRF is available. It carries the NRF url. None

Methods

NRFAvailableEvent. __init__( self , handle: Handle , url: str )

Description

Init. None

NRFAvailableEvent. snapshot( self )

Description

Return snapshot. None

NRFAvailableEvent. restore( self , snapshot: dict )

Description

Restore snapshot. None

class NRFBrokenEvent

Description

Charm event emitted when a NRF goes down. None

Methods

NRFBrokenEvent. __init__( self , handle: Handle )

Description

Init. None

class NRFRequirerCharmEvents

Description

List of events that the NRF requirer charm can leverage. None

class NRFRequires

Description

Class to be instantiated by the NRF requirer charm. None

Methods

NRFRequires. __init__( self , charm: CharmBase , relation_name: str )

Description

Init. None

NRFRequires. nrf_url( self )

Return NRF url.

Returns

str

NRF url.

class NRFProvides

Description

Class to be instantiated by the charm providing the NRF data. None

Methods

NRFProvides. __init__( self , charm: CharmBase , relation_name: str )

Description

Init. None

NRFProvides. set_nrf_information( self , url: str , relation_id: int )

Set NRF url in the application(s) relation data.

Arguments

url (str)

NRF url.

relation_id (int)

Relation ID.

Returns

None

NRFProvides. set_nrf_information_in_all_relations( self , url: str )

Set NRF url in applications for all applications.

Arguments

url (str)

NRF url.

Returns

None