SD-Core AMF K8s

  • Canonical Telco
Channel Revision Published Runs on
latest/beta 11 03 Jan 2024
Ubuntu 22.04
latest/edge 15 21 Jan 2024
Ubuntu 22.04
1.5/stable 834 26 Nov 2024
Ubuntu 24.04
1.5/candidate 834 26 Nov 2024
Ubuntu 24.04
1.5/beta 834 26 Nov 2024
Ubuntu 24.04 Ubuntu 22.04
1.5/beta 821 26 Nov 2024
Ubuntu 24.04 Ubuntu 22.04
1.5/edge 834 26 Nov 2024
Ubuntu 24.04 Ubuntu 22.04
1.5/edge 821 21 Nov 2024
Ubuntu 24.04 Ubuntu 22.04
1.6/edge 850 02 Dec 2024
Ubuntu 24.04
1.4/beta 160 26 Apr 2024
Ubuntu 22.04
1.4/edge 796 21 Oct 2024
Ubuntu 22.04
1.3/beta 11 22 Jan 2024
Ubuntu 22.04
1.3/edge 103 05 Apr 2024
Ubuntu 22.04
juju deploy sdcore-amf-k8s --channel 1.5/stable
Show information

Platform:

charms.sdcore_amf_k8s.v0.fiveg_n2

Library for the fiveg_n2 relation.

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

The purpose of this library is to relate a charm claiming to be able to provide or consume information on connectivity to the N2 plane.

Getting Started

From a charm directory, fetch the library using charmcraft:

charmcraft fetch-lib charms.sdcore_amf_k8s.v0.fiveg_n2

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

  • pydantic
  • pytest-interface-tester
Requirer charm

The requirer charm is the one requiring the N2 information.

Example:


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

from charms.sdcore_amf_k8s.v0.fiveg_n2 import N2InformationAvailableEvent, N2Requires

logger = logging.getLogger(__name__)


class DummyFivegN2Requires(CharmBase):

    def __init__(self, *args):
        super().__init__(*args)
        self.n2_requirer = N2Requires(self, "fiveg-n2")
        self.framework.observe(
            self.n2_requirer.on.n2_information_available, self._on_n2_information_available
        )

    def _on_n2_information_available(self, event: N2InformationAvailableEvent):
        amf_ip_address = event.amf_ip_address
        amf_hostname = event.amf_hostname
        amf_port = event.amf_port
        <do something with the amf IP, hostname and port>


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

The provider charm is the one providing the information about the N2 interface.

Example:


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

from charms.sdcore_amf_k8s.v0.fiveg_n2 import N2Provides


class DummyFivegN2ProviderCharm(CharmBase):

    HOST = "amf"
    PORT = 38412
    IP_ADDRESS = "192.168.70.132"

    def __init__(self, *args):
        super().__init__(*args)
        self.n2_provider = N2Provides(self, "fiveg-n2")
        self.framework.observe(
            self.on.fiveg_n2_relation_joined, self._on_fiveg_n2_relation_joined
        )

    def _on_fiveg_n2_relation_joined(self, event: RelationJoinedEvent):
        if self.unit.is_leader():
            self.n2_provider.set_n2_information(
                amf_ip_address=self.IP_ADDRESS,
                amf_hostname=self.HOST,
                amf_port=self.PORT,
            )


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

class ProviderAppData

Description

Provider app data for fiveg_n2. None

class ProviderSchema

Description

Provider schema for fiveg_n2. None

def data_is_valid(data)

Return whether data is valid.

Arguments

data (dict)

Data to be validated.

Returns

True if data is valid, False otherwise.

class N2InformationAvailableEvent

Description

Charm event emitted when N2 information is available. It carries the AMF hostname. None

Methods

N2InformationAvailableEvent. __init__( self , handle: Handle , amf_ip_address: str , amf_hostname: str , amf_port: int )

Description

Init. None

N2InformationAvailableEvent. snapshot( self )

Description

Return snapshot. None

N2InformationAvailableEvent. restore( self , snapshot: dict )

Description

Restores snapshot. None

class N2RequirerCharmEvents

Description

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

class N2Requires

Description

Class to be instantiated by the N2 requirer charm. None

Methods

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

Description

Init. None

N2Requires. amf_ip_address( self )

Return AMF IP address.

Returns

str

AMF IP address.

N2Requires. amf_hostname( self )

Return AMF hostname.

Returns

str

AMF hostname.

N2Requires. amf_port( self )

Return the port used to connect to the AMF host.

Returns

int

AMF port.

class N2Provides

Description

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

Methods

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

Description

Init. None

N2Provides. set_n2_information( self , amf_ip_address: str , amf_hostname: str , amf_port: int )

Set the hostname and the ngapp port in the application relation data.

Arguments

amf_ip_address (str)

AMF IP address.

amf_hostname (str)

AMF hostname.

amf_port (int)

AMF NGAPP port.

Returns

None