# VNF

All our thesis is focus on this, so we hope to do a good job, at least here. What you're gonna find here is a brief explanation of how we built our system to process packets through VNF and get that packets back.

## Harbor: create and destroy VNF in Kubernetes

We're aware that in this kind of environment automation is fundamental, and generally you'd expect that VNF get deployed, scaled and destroyed automatically on-demand, rather than manually accessing your cluster and loading them manually. To accomplish this, we've create a little backend, Harbor, that is capable of creating, destroying, and storing VNF definition.

Harbor, written in Java using the Spark framework, at the time of writing has the following API configuration.

At the end of the day, Harbor ended substituting the Openbaton role: indeed it already covers what Openbaton does, so we see an opportunity to drop the latter and to stick with a component created from us that perfectly fits our needs.

### API definition

## Launch a VNF

<mark style="color:blue;">`GET`</mark> `/vnf/launch/:id`

It gives the possibility to launch an already uploaded VNF.

#### Path Parameters

| Name | Type   | Description |
| ---- | ------ | ----------- |
| id   | string | The VNF id  |

{% tabs %}
{% tab title="200 " %}

```javascript
{ "result": "ok" }
```

{% endtab %}
{% endtabs %}

## Stop a VNF

<mark style="color:blue;">`GET`</mark> `/vnf/stop/:id`

Stop an already running VNF. Note that this destroys all the resources created

#### Path Parameters

| Name | Type   | Description |
| ---- | ------ | ----------- |
| id   | string | The VNF id  |

{% tabs %}
{% tab title="200 " %}

```javascript
{ "result": "ok" }
```

{% endtab %}
{% endtabs %}

## Get YAML definition of a VNF

<mark style="color:blue;">`GET`</mark> `/vnf/get/:id`

This API calls return the YAML of a given VNF id.

#### Path Parameters

| Name | Type   | Description |
| ---- | ------ | ----------- |
| id   | string | The VNF id  |

{% tabs %}
{% tab title="200 " %}

```javascript
{ "result" : "ok" }
```

{% endtab %}
{% endtabs %}

## Add a VNF to the catalog

<mark style="color:green;">`POST`</mark> `/vnf/create/:id`

Uploads a new VNF to the catalog. Note that the VNF must have an unique id, otherwise the upload will fail. You need to send as the body request a valid Kubernetes YAML.

#### Path Parameters

| Name | Type   | Description       |
| ---- | ------ | ----------------- |
| id   | string | The VNF unique id |

{% tabs %}
{% tab title="200 " %}

```javascript
{ "result" : "ok" }
```

{% endtab %}
{% endtabs %}

## Update a VNF

<mark style="color:green;">`POST`</mark> `/vnf/update/:id`

Update an existing VNF with a new one. Note that this doesn't modify the resources running in the cluster.

#### Path Parameters

| Name | Type   | Description |
| ---- | ------ | ----------- |
| id   | string | The VNF id  |

{% tabs %}
{% tab title="200 " %}

```javascript
{ "result" : "ok" }
```

{% endtab %}
{% endtabs %}

## Delete a VNF from the catalog

<mark style="color:red;">`DELETE`</mark> `/vnf/delete/:id`

This method deletes an existing VNF from the catalog. Note that the resources in this case are **not** stopped!

#### Path Parameters

| Name | Type   | Description |
| ---- | ------ | ----------- |
| id   | string | The VNF id  |

{% tabs %}
{% tab title="200 " %}

```javascript
{ "result" : "ok" }
```

{% endtab %}
{% endtabs %}

The API json definition can be found here:

```javascript
[
  {
    "name": "/vnf",
    "path": [
      {
        "name": "/launch/:id",
        "type": "get",
        "function": "routes.vnf.VnfLauncherRoute"
      },
      {
        "name": "/stop/:id",
        "type": "get",
        "function": "routes.vnf.VnfStopperRoute"
      },
      {
        "name": "/create/:id",
        "type": "post",
        "function": "routes.vnf.CreateVnfRoute"
      },
      {
        "name": "/delete/:id",
        "type": "delete",
        "function": "routes.vnf.DeleteVnfRoute"
      },
      {
        "name": "/update/:id",
        "type": "post",
        "function": "routes.vnf.UpdateVnfRoute"
      },
      {
        "name": "/get/:id",
        "type": "get",
        "function": "routes.vnf.GetVnfRoute"
      }
    ]
  }
]
```

### Additional notes about implementation

We tried initially to use Kubernetes Java client API, without success, since they're not documented and cryptic. Thus we fell back to a simple, yet horrible, solution, using `kubectl` to deploy YAML on the cluster and paring CLI output.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://augugrumi.gitbook.io/thesisnotes/vnf.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
