Oai Ran Cu K8S

  • Canonical Telco
Channel Revision Published Runs on
latest/edge 1 05 Aug 2024
Ubuntu 22.04
2.1/edge 46 15 Dec 2024
Ubuntu 22.04
juju deploy oai-ran-cu-k8s --channel edge
Show information

Platform:

charms.oai_ran_cu_k8s.v0.oai_ran_cu_k8s

Library for the fiveg_f1 relation.

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

The purpose of this library is to relate two charms claiming to be able to communicate over the F1 interface. In the Telco world this will typically be charms implementing the CU (Central Unit) and the DU (Distributed Unit).

Getting Started

From a charm directory, fetch the library using charmcraft:

charmcraft fetch-lib charms.oai_ran_cu_k8s.v0.fiveg_f1

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

  • pydantic
  • pytest-interface-tester
Provider charm

The provider charm is the one providing the information about the F1 interface. Typically, this will be the CU charm.

Example:


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

from charms.oai_ran_cu_k8s.v0.fiveg_f1 import F1Provides, PLMNConfig


class DummyFivegF1ProviderCharm(CharmBase):

    IP_ADDRESS = "192.168.70.132"
    PORT = 2153
    TAC = 1
    PLMNS = [PLMNConfig(mcc="123", mnc="12", sst=1, sd=1)]

    def __init__(self, *args):
        super().__init__(*args)
        self.f1_provider = F1Provides(self, "fiveg_f1")
        self.framework.observe(
            self.on.fiveg_f1_relation_joined, self._on_fiveg_f1_relation_joined
        )
        self.framework.observe(
            self.on.fiveg_f1_relation_changed, self._on_fiveg_f1_relation_changed
        )

    def _on_fiveg_f1_relation_joined(self, event: RelationJoinedEvent):
        if self.unit.is_leader():
            self.f1_provider.set_f1_information(
                ip_address=self.IP_ADDRESS,
                port=self.PORT,
                tac=self.TAC,
                plmns=self.PLMNS,
            )

    def _on_fiveg_f1_relation_changed(self, event: RelationChangedEvent):
        requirer_f1_port = self.f1_provider.requirer_f1_port
        if requirer_f1_port:
            <do something with port>


if __name__ == "__main__":
    main(DummyFivegF1ProviderCharm)
Requirer charm

The requirer charm is the one requiring the F1 information. Typically, this will be the DU charm.

Example:


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

from charms.oai_ran_cu_k8s.v0.fiveg_f1 import F1Requires


class DummyFivegF1Requires(CharmBase):

    PORT = 2153

    def __init__(self, *args):
        super().__init__(*args)
        self.f1_requirer = F1Requires(self, "fiveg_f1")
        self.framework.observe(
            self.on.fiveg_f1_relation_joined, self._on_fiveg_f1_relation_joined
        )
        self.framework.observe(
            self.on.fiveg_f1_relation_changed, self._on_fiveg_f1_relation_changed
        )

    def _on_fiveg_f1_relation_joined(self, event: RelationJoinedEvent):
        if self.unit.is_leader():
            self.f1_requirer.set_f1_information(port=self.PORT)

    def _on_fiveg_f1_relation_changed(self, event: RelationChangedEvent):
        provider_f1_ip_address = self.f1_requirer.f1_ip_address
        provider_f1_port = self.f1_requirer.f1_port
        provider_f1_tac = self.f1_requirer.tac
        provider_f1_plmn = self.f1_requirer.plmn
        <do something with the IP address, port, TAC and PLMNs>


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

class PLMNConfig

Description

Dataclass representing the configuration for a PLMN. None

Methods

PLMNConfig. __init__( self , mcc: str , mnc: str , sst: int , sd )

PLMNConfig. asdict( self )

Description

Convert the dataclass into a dictionary. None

class ProviderAppData

Description

Provider app data for fiveg_f1. None

class ProviderSchema

Description

Provider schema for fiveg_f1. None

class RequirerAppData

Description

Requirer app data for fiveg_f1. None

class RequirerSchema

Description

Requirer schema for fiveg_f1. None

def provider_data_is_valid(data: dict)

Return whether the provider data is valid.

Arguments

data (dict)

Data to be validated.

Returns

True if data is valid, False otherwise.

def requirer_data_is_valid(data: dict)

Return whether the requirer data is valid.

Arguments

data (dict)

Data to be validated.

Returns

True if data is valid, False otherwise.

class FivegF1Error

Description

Custom error class for the fiveg_f1 library. None

Methods

FivegF1Error. __init__( self , message: str )

class F1Provides

Description

Class to be instantiated by the charm providing relation using the fiveg_f1 interface. None

Methods

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

Description

Init. None

F1Provides. set_f1_information( self , ip_address: str , port: int , tac: int , plmns )

Push the information about the F1 interface in the application relation data.

Arguments

ip_address (str)

IPv4 address of the network interface used for F1 traffic.

port (int)

Number of the port used for F1 traffic.

tac (int)

Tracking Area Code.

plmns (list[PLMNConfig])

Configured PLMNs.

F1Provides. requirer_f1_port( self )

Return the number of the port used for F1 traffic.

Returns

Optional[int]

Port number.

class F1Requires

Description

Class to be instantiated by the charm requiring relation using the fiveg_f1 interface. None

Methods

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

Description

Init. None

F1Requires. set_f1_information( self , port: int )

Push the information about the F1 interface in the application relation data.

Arguments

port (int)

Number of the port used for F1 traffic.

F1Requires. get_provider_f1_information( self , relation )

Get relation data for the remote application.

Arguments

relation

Juju relation object (optional).

Returns

ProviderAppData

Relation data for the remote application if valid, None otherwise.