atlanticwave-sdx / sdx-lc

Local Controller of AtlanticWave SDX.
https://www.atlanticwave-sdx.net
MIT License
0 stars 2 forks source link
networking research

AtlanticWave-SDX Local Controller Service

lc-ci-badge lc-cov-badge

Overview

SDX Local Controller (SDX-LC) is a component of AtlanticWave-SDX.

SDX-LC is a per-OXP (Open eXchange Point) component responsible for interfacing the OXP network Orchestrator, or OXPO. The SDX-LC uses the OXPO's API to submit service requests and retrieve topology data and converts the output to the SDX data model before pushing the data to the SDX Controller.

SDX-LC is a swagger-enabled Flask server based on the swagger-codegen project, and uses connexion library on top of Flask.

SDX-LC provides a REST API that other services can use. Once SDX-LC is up and running (see below), navigate to http://localhost:8080/SDX-LC/2.0.0/ui/ for testing the API. The OpenAPI/Swagger definition should be available at http://localhost:8080/SDX-LC/2.0.0/openapi.json.

Requirement: RabbitMQ

The communication between SDX controller and Local controller rely on RabbitMQ. RabbitMQ can either run on the same node as SDX controller, or on a separate node. The easiest way to run RabbitMQ is using Docker:

$ docker run -it --rm --name rabbitmq \
    -p 5672:5672 -p 15672:15672 \
    rabbitmq:latest

Running SDX Local Controller with Docker Compose

Copy env.template to .env, and adjust it according to your needs and then run Docker Compose from the top-level directory:

$ docker compose up --build

Or, to build the image and run:

$ docker build -t sdx_lc .
$ docker run --env-file=.env -p 8080:8080 sdx_lc

Running SDX Local Controller with Python

We will need Python 3.9.6+. Also, in addition to RabbitMQ, we also need a MongoDB server:

$ docker run -it --rm --name mongo \
    -p 27017:27017 \
    -e MONGO_INITDB_ROOT_USERNAME=guest \
    -e MONGO_INITDB_ROOT_PASSWORD=guest \
    mongo:7.0.11

Now create a virtual environment, and install the server:

$ python3 -m venv venv --upgrade-deps
$ source venv/bin/activate
$ pip3 install .

Now export required environment variables with source .env (for example -- see above), and then run the server:

$ source .env
$ flask --app sdx_lc.app:app run --debug

Running tests

With tox

An easy way to run tests is using tox and tox-docker. You will need Docker installed and running.

$ python3 -m venv venv --upgrade-deps
$ source venv/bin/activate
$ pip install 'tox>=4' 'tox-docker>=5'
$ tox

With pytest

If you want to avoid tox and run pytest directly, that is possible too. You will need to run RabbitMQ and MongoDB, with Docker perhaps. See above for the steps.

Some environment variables are expected to be set for the tests to work as expected, so you may want to copy env.template to .env and edit it according to your environment, and make sure the env vars are present in your shell:

$ cp env.template .env 
$ # and then edit .env to suit your environment
$ source .env

And now, activate a virtual environment, install the requirements, and then run pytest:

$ python3 -m venv venv --upgrade-deps
$ source ./venv/bin/activate
$ pip3 install --editable .[test]
$ pytest

Communication between SDX Controller and Local Controller

The SDX controller and local controller communicate using RabbitMQ. All the topology and connectivity related messages are sent with RPC, with receiver confirmation. The monitoring related messages are sent without receiver confirmation.

Below are two sample scenarios for RabbitMQ implementation:

SDX controller breaks down the topology and sends connectivity information to local controllers:

SDX controller to local controller

Local controller sends domain information to SDX controller:

Local controller to SDX controller