README.md 2.79 KB
Newer Older
torrespel's avatar
torrespel committed
# CAPIF_Provider_ONE
Silvia Almagia's avatar
Silvia Almagia committed

torrespel's avatar
torrespel committed
This is the implementation of a Provider (AEF) for the Opennebula service
Silvia Almagia's avatar
Silvia Almagia committed

torrespel's avatar
torrespel committed
## Prerequisites
In order to use the Provider you must use the public CAPIF or create a [CAPIF](https://github.com/EVOLVED-5G/CAPIF_API_Services) instance.
Silvia Almagia's avatar
Silvia Almagia committed


torrespel's avatar
torrespel committed
## Important
This code is intended for testing in a local docker environment. If it is going to be deployed in an environment such as kubernetes, it is necessary to make modifications to the following file:
Silvia Almagia's avatar
Silvia Almagia committed

torrespel's avatar
torrespel committed
```
./capif_ops/config_files/service_api_description_one.json
Silvia Almagia's avatar
Silvia Almagia committed

torrespel's avatar
torrespel committed
```
```
"ipv4Addr": <url of the service>
```
Silvia Almagia's avatar
Silvia Almagia committed

torrespel's avatar
torrespel committed
## Set Up
This repo is designed to be executed from docker, to create the images and raise the instance it is only necessary to execute the following command:
Silvia Almagia's avatar
Silvia Almagia committed
```
torrespel's avatar
torrespel committed
./run.sh

Silvia Almagia's avatar
Silvia Almagia committed
```

torrespel's avatar
torrespel committed
- Before executing the run.sh command, note that it supports one parameter, this parameter is the CAPIF hostname, by default this field is 'capifcore'. Modify it if necessary or add the hostname when executing the run.sh command
Silvia Almagia's avatar
Silvia Almagia committed

torrespel's avatar
torrespel committed
    ```
    ./run.sh <other_hostname>
Silvia Almagia's avatar
Silvia Almagia committed

torrespel's avatar
torrespel committed
    ```
Silvia Almagia's avatar
Silvia Almagia committed

torrespel's avatar
torrespel committed
- It is important to have the following environment variables in the docker-compose file:
    ```
   - REGISTER_HOSTNAME = register
   - CAPIF_PORT=8080
   - REGISTER_PORT=8084
Silvia Almagia's avatar
Silvia Almagia committed

torrespel's avatar
torrespel committed
   extra_hosts:
      - host.docker.internal:host-gateway
      - capifcore:host-gateway
      - register:host-gateway
Silvia Almagia's avatar
Silvia Almagia committed

torrespel's avatar
torrespel committed
    ```
    By default, these are the ports and names that the CAPIF script uses when launching the different services. If during the deployment of CAPIF you modify these parameters, you must modify them so that they correspond to the new ones.
Silvia Almagia's avatar
Silvia Almagia committed

torrespel's avatar
torrespel committed
    If the hostname environment variables are modified, the extra host must also be modified so that the hostnames correspond and be able to reach the services deployed in docker.
Silvia Almagia's avatar
Silvia Almagia committed

torrespel's avatar
torrespel committed
Now it is only necessary to enter inside the container by executing this command
torrespel's avatar
torrespel committed
```
./terminal_to_py_aef.sh
Silvia Almagia's avatar
Silvia Almagia committed

torrespel's avatar
torrespel committed
```
Silvia Almagia's avatar
Silvia Almagia committed

torrespel's avatar
torrespel committed
Once inside the container you can run the provider command GUI by running
Silvia Almagia's avatar
Silvia Almagia committed

torrespel's avatar
torrespel committed
```
./python main.py
Silvia Almagia's avatar
Silvia Almagia committed

torrespel's avatar
torrespel committed
```
Silvia Almagia's avatar
Silvia Almagia committed

torrespel's avatar
torrespel committed
## Interacting with the GUI
The provider is prepared to make the necessary previous provisions automatically.
The different .json files that must be saved in CAPIF are also added. To make the necessary provisions you just have to execute the following commands within the GUI
Silvia Almagia's avatar
Silvia Almagia committed

torrespel's avatar
torrespel committed
```
register_provider
Silvia Almagia's avatar
Silvia Almagia committed

torrespel's avatar
torrespel committed
```
Silvia Almagia's avatar
Silvia Almagia committed

torrespel's avatar
torrespel committed
```
publish_service
Silvia Almagia's avatar
Silvia Almagia committed

torrespel's avatar
torrespel committed
```
*If the first command returns a 401, it means that the token to interact the first time with CAPIF has expired, run the following command

```
provider_get_auth

```

## Run ONE Service
Silvia Almagia's avatar
Silvia Almagia committed

torrespel's avatar
torrespel committed
This service has Apified some of the functions of ONE. To start the service run the following command:
Silvia Almagia's avatar
Silvia Almagia committed

torrespel's avatar
torrespel committed
```
python service/service_oauth.py

```
- It is necessary to modify the URL and the ONE credentials to be used in the python service itself
Silvia Almagia's avatar
Silvia Almagia committed

torrespel's avatar
torrespel committed
The endpoints that are implemented are the following
Silvia Almagia's avatar
Silvia Almagia committed

torrespel's avatar
torrespel committed
```
/hello [POST]

Request Body:
{
  "name": "ocf_user"
}
Silvia Almagia's avatar
Silvia Almagia committed

torrespel's avatar
torrespel committed
```