---
title: Charmhub | Deploy SD-CORE 5G UPF using Charmhub - The Open Operator Collection
description: Deploy the latest version of SD-CORE 5G UPF as a Kubernetes Operator
  on any cloud.
url: https://charmhub.io/sdcore-upf/libraries/fiveg_n3
---

# SD-CORE 5G UPF

[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 68

```
juju deploy sdcore-upf --channel edge
```

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

[Toggle side navigation](https://charmhub.io/sdcore-upf/libraries/fiveg_n3#drawer)

## charms.sdcore\_upf.v0.fiveg\_n3

* [*Docstrings*Docstrings](https://charmhub.io/sdcore-upf/libraries/fiveg_n3)
  [*Code*Source code](https://charmhub.io/sdcore-upf/libraries/fiveg_n3/source-code)
* + Download

    Fetch library

    ```
    charmcraft fetch-lib charms.sdcore_upf.v0.fiveg_n3
    ```

    [Download fiveg\_n3.py](https://charmhub.io/sdcore-upf/libraries/fiveg_n3/download)
  + *Last updated* 20 Sep 2023
  + *Revision* Library version 0.2

Library for the `fiveg_n3` relation.

This library offers a way of providing and consuming an IP address of the SDCORE's UPF.
In a typical 5G network, UPF's IP address is consumed by the gNodeBs, in order to establish
communication over the N3 interface.

To get started using the library, you need to fetch the library using `charmcraft`.

```
cd some-charm
charmcraft fetch-lib charms.sdcore_upf.v0.fiveg_n3
```

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

* pydantic
* pytest-interface-tester

Charms providing the `fiveg_n3` relation should use `N3Provides`.
Typical usage of this class would look something like:

```
```python
...
from charms.sdcore_upf.v0.fiveg_n3 import N3Provides
...

class SomeProviderCharm(CharmBase):

    def __init__(self, *args):
        ...
        self.fiveg_n3 = N3Provides(charm=self, relation_name="fiveg_n3")
        ...
        self.framework.observe(self.fiveg_n3.on.fiveg_n3_request, self._on_fiveg_n3_request)

    def _on_fiveg_n3_request(self, event):
        ...
        self.fiveg_n3.publish_upf_information(
            relation_id=event.relation_id,
            upf_ip_address=ip_address,
        )
```

And a corresponding section in charm's `metadata.yaml`:
```
provides:
    fiveg_n3:  # Relation name
        interface: fiveg_n3  # Relation interface
```
```

Charms that require the `fiveg_n3` relation should use `N3Requires`.
Typical usage of this class would look something like:

```
```python
...
from charms.sdcore_upf.v0.fiveg_n3 import N3Requires
...

class SomeRequirerCharm(CharmBase):

    def __init__(self, *args):
        ...
        self.fiveg_n3 = N3Requires(charm=self, relation_name="fiveg_n3")
        ...
        self.framework.observe(self.upf.on.fiveg_n3_available, self._on_fiveg_n3_available)

    def _on_fiveg_n3_available(self, event):
        upf_ip_address = event.upf_ip_address
        # Do something with the UPF's IP address
```

And a corresponding section in charm's `metadata.yaml`:
```
requires:
    fiveg_n3:  # Relation name
        interface: fiveg_n3  # Relation interface
```
```

---

Index

* [class ProviderAppData](https://charmhub.io/sdcore-upf/libraries/fiveg_n3#providerappdata)
* [class ProviderSchema](https://charmhub.io/sdcore-upf/libraries/fiveg_n3#providerschema)
* [def data\_matches\_provider\_schema(
  data
  )](https://charmhub.io/sdcore-upf/libraries/fiveg_n3#data_matches_provider_schema)
* [class FiveGN3RequestEvent](https://charmhub.io/sdcore-upf/libraries/fiveg_n3#fivegn3requestevent)
* + [def \_\_init\_\_(
    self,
    handle,
    relation\_id)](https://charmhub.io/sdcore-upf/libraries/fiveg_n3#fivegn3requestevent-__init__)
* + [def snapshot(
    self)](https://charmhub.io/sdcore-upf/libraries/fiveg_n3#fivegn3requestevent-snapshot)
* + [def restore(
    self,
    snapshot)](https://charmhub.io/sdcore-upf/libraries/fiveg_n3#fivegn3requestevent-restore)
* [class N3ProviderCharmEvents](https://charmhub.io/sdcore-upf/libraries/fiveg_n3#n3providercharmevents)
* [class N3Provides](https://charmhub.io/sdcore-upf/libraries/fiveg_n3#n3provides)
* + [def \_\_init\_\_(
    self,
    charm,
    relation\_name)](https://charmhub.io/sdcore-upf/libraries/fiveg_n3#n3provides-__init__)
* + [def publish\_upf\_information(
    self,
    relation\_id,
    upf\_ip\_address)](https://charmhub.io/sdcore-upf/libraries/fiveg_n3#n3provides-publish_upf_information)
* [class N3AvailableEvent](https://charmhub.io/sdcore-upf/libraries/fiveg_n3#n3availableevent)
* + [def \_\_init\_\_(
    self,
    handle,
    upf\_ip\_address)](https://charmhub.io/sdcore-upf/libraries/fiveg_n3#n3availableevent-__init__)
* + [def snapshot(
    self)](https://charmhub.io/sdcore-upf/libraries/fiveg_n3#n3availableevent-snapshot)
* + [def restore(
    self,
    snapshot)](https://charmhub.io/sdcore-upf/libraries/fiveg_n3#n3availableevent-restore)
* [class N3RequirerCharmEvents](https://charmhub.io/sdcore-upf/libraries/fiveg_n3#n3requirercharmevents)
* [class N3Requires](https://charmhub.io/sdcore-upf/libraries/fiveg_n3#n3requires)
* + [def \_\_init\_\_(
    self,
    charm,
    relation\_name)](https://charmhub.io/sdcore-upf/libraries/fiveg_n3#n3requires-__init__)

#### class ProviderAppData

Description

Provider app data for fiveg\_n3. None

#### class ProviderSchema

Description

Provider schema for fiveg\_n3. None

#### def data\_matches\_provider\_schema(data: dict)

Returns whether data matches provider schema.

Arguments

data
(dict)

Data to be validated.

Returns

True if data matches provider schema, False otherwise.

#### class FiveGN3RequestEvent

Description

Dataclass for the `fiveg_n3` request event. None

Methods

FiveGN3RequestEvent.
\_\_init\_\_(

*self*

,
handle

,
relation\_id: int
)

Description

Sets relation id. None

FiveGN3RequestEvent.
snapshot(

*self*
)

Description

Returns event data. None

FiveGN3RequestEvent.
restore(

*self*

,
snapshot
)

Description

Restores event data. None

#### class N3ProviderCharmEvents

Description

Custom events for the N3Provider. None

#### class N3Provides

Description

Class to be instantiated by provider of the `fiveg_n3`. None

Methods

N3Provides.
\_\_init\_\_(

*self*

,
charm: CharmBase

,
relation\_name: str
)

Observes relation joined event.

Arguments

charm

Juju charm

relation\_name
(str)

Relation name

N3Provides.
publish\_upf\_information(

*self*

,
relation\_id: int

,
upf\_ip\_address: str
)

Sets UPF's IP address in the relation data.

Arguments

relation\_id
(str)

Relation ID

upf\_ip\_address
(str)

UPF's IP address

#### class N3AvailableEvent

Description

Dataclass for the `fiveg_n3` available event. None

Methods

N3AvailableEvent.
\_\_init\_\_(

*self*

,
handle

,
upf\_ip\_address: str
)

Description

Sets certificate. None

N3AvailableEvent.
snapshot(

*self*
)

Description

Returns event data. None

N3AvailableEvent.
restore(

*self*

,
snapshot
)

Description

Restores event data. None

#### class N3RequirerCharmEvents

Description

Custom events for the N3Requirer. None

#### class N3Requires

Description

Class to be instantiated by requirer of the `fiveg_n3`. None

Methods

N3Requires.
\_\_init\_\_(

*self*

,
charm: CharmBase

,
relation\_name: str
)

Observes relation joined and relation changed events.

Arguments

charm

Juju charm

relation\_name
(str)

Relation name
