Skip to content

Commit

Permalink
Merge pull request #131 from atlanticwave-sdx/130.remove-duplicated-env
Browse files Browse the repository at this point in the history
Remove `env`
  • Loading branch information
sajith authored May 30, 2024
2 parents 314954b + 85751af commit df55fcc
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 68 deletions.
3 changes: 0 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,11 @@ jobs:
SDXLC_HOST: 'localhost'
SDXLC_DOMAIN: 'example.net'
SDXLC_PORT: '8080'
SDXLC_VERSION: '1.0.0'
SDXLC_NAME: 'test-lc'
MQ_HOST: 'localhost'
MQ_PORT: '5672'
MQ_USER: 'guest'
MQ_PASS: 'guest'
MQ_NAME: 'hello'
MQ_EXCHANGE: ''
SUB_QUEUE: 'test-queue'
SUB_TOPIC: 'test-topic'
SUB_EXCHANGE: 'test-exchange'
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ test-db

# Ignore copies of env
env.*
.env

# Ignore files written by code coverage tools
.coverage
Expand Down
31 changes: 14 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ 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/1.0.0/ui/ for testing the API. The
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/1.0.0/openapi.json.
http://localhost:8080/SDX-LC/2.0.0/openapi.json.


## Requirement: RabbitMQ
Expand All @@ -36,19 +36,10 @@ $ docker run -it --rm --name rabbitmq \
rabbitmq:latest
```

Then in `env` and `docker-compose.yml` files, change the following vars:

- `MQ_HOST` host to the corresponding IP address or hostname of the RabbitMQ server
- `MQ_PORT` to the corresponding port where the server will listen (default 5672)
- `MQ_USER` to the corresponding username to authenticate (default guest)
- `MQ_PASS` to the corresponding password to authenticate (default guest)


## Running SDX Local Controller with Docker Compose

Adjust the rest of the environment in `docker-compose.yml` according
to your needs (these will be eventually parameterized), and run Docker
Compose from the top-level directory:
Copy `env.template` to `.env`, and adjust it according to your needs
and then run Docker Compose from the top-level directory:

```console
$ docker compose up --build
Expand All @@ -72,16 +63,22 @@ $ docker run -it --rm --name mongo \
-p 27017:27017 \
-e MONGO_INITDB_ROOT_USERNAME=guest \
-e MONGO_INITDB_ROOT_PASSWORD=guest \
mongo:3.7
mongo:7.0.5
```

Now create a virtual environment, install the dependencies, and run
the server:
Now create a virtual environment, and install the server:

```console
$ python3 -m venv venv --upgrade-deps
$ source venv/bin/activate
$ pip3 install -r requirements.txt
$ pip3 install .
```

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

```console
$ source .env
$ python3 -m sdx_lc
```

Expand Down
25 changes: 11 additions & 14 deletions compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,27 +30,24 @@ services:
# the `healthcheck` above.
condition: service_started
environment:
# connect to the mongodb service started by compose.
- MONGODB_CONNSTRING=mongodb://${MONGO_INITDB_ROOT_USERNAME}:${MONGO_INITDB_ROOT_PASSWORD}@mongodb:27017/
- SDX_MQ_IP=${SDX_MQ_IP}
# Local controller settings.
- SDXLC_DOMAIN=${SDXLC_DOMAIN}
# change to local controller host name
- SDXLC_HOST=${SDXLC_HOST}
- SDXLC_PORT=${SDXLC_PORT}
- SDXLC_VERSION=${SDXLC_VERSION}
- PUB_TOPIC=${PUB_TOPIC}
- PUB_QUEUE=${PUB_QUEUE}
- SUB_QUEUE=${SUB_QUEUE}
- SUB_EXCHANGE=${SUB_EXCHANGE}
# change to local controller config (lcX_q1)
- SUB_TOPIC=${SUB_TOPIC}
- MQ_NAME=${MQ_NAME}
# MongoDB settings. When using compose, we connect to the
# mongodb service started by compose.
- MONGODB_CONNSTRING=mongodb://${MONGO_INITDB_ROOT_USERNAME}:${MONGO_INITDB_ROOT_PASSWORD}@mongodb:27017/
- DB_NAME=${DB_NAME}
- DB_CONFIG_TABLE_NAME=${DB_CONFIG_TABLE_NAME}
# Message queue settings.
- MQ_HOST=${MQ_HOST}
- MQ_PORT=${MQ_PORT}
- MQ_USER=${MQ_USER}
- MQ_PASS=${MQ_PASS}
- DB_NAME=${DB_NAME}
- DB_CONFIG_TABLE_NAME=${DB_CONFIG_TABLE_NAME}
- SUB_QUEUE=${SUB_QUEUE}
- SUB_EXCHANGE=${SUB_EXCHANGE}
- SUB_TOPIC=${SUB_TOPIC}
# OXP settings.
- OXP_CONNECTION_URL=${OXP_CONNECTION_URL}
- OXP_PULL_URL=${OXP_PULL_URL}
- OXP_PULL_INTERVAL=${OXP_PULL_INTERVAL}
Expand Down
13 changes: 0 additions & 13 deletions env

This file was deleted.

36 changes: 18 additions & 18 deletions env.template
Original file line number Diff line number Diff line change
@@ -1,37 +1,37 @@
export SDX_MQ_IP='152.54.3.143'
export SDXLC_VERSION='1.0.0'
# -*- conf -*-

# SDX-LC settings
export SDXLC_NAME='lc1'
export SDXLC_DOMAIN='amlight.net'

export DB_NAME='test-db'
export DB_CONFIG_TABLE_NAME='test-1'
# change to local controller host name
export SDXLC_HOST="aw-sdx-lc-1.renci.org"
export SDXLC_PORT="8080"

# To run tests locally (with tox), localhost is convenient as
# MONGO_HOST; for Docker Compose, we hard-code the container name in
# the compose file.
export MONGO_HOST="my-mongodb"
# To run tests locally (with tox or pytest) or to run the server
# without Docker Compose, localhost is convenient as MONGO_HOST; for
# Docker Compose, we hard-code the container name in the compose file.
export MONGO_HOST="localhost"
export MONGO_PORT="27017"
export MONGO_INITDB_ROOT_USERNAME="guest"
export MONGO_INITDB_ROOT_PASSWORD="guest"
export MONGODB_CONNSTRING="mongodb://${MONGO_INITDB_ROOT_USERNAME}:${MONGO_INITDB_ROOT_PASSWORD}@${MONGO_HOST}:${MONGO_PORT}/"
export MONGODB_DATA_DIR="/data/db"
export SDXLC_MONGO_DB="sdx-controllder-test-db"
export SDXLC_MONGO_COLLECTION="sdx-controller-test-table"
# change to local controller host name
export SDXLC_HOST="aw-sdx-lc-1.renci.org"
export SDXLC_PORT="8080"

export DB_NAME='test-db'
export DB_CONFIG_TABLE_NAME='test-1'

# Message queue settings for SDX Controller.
export PUB_TOPIC="topo"
export PUB_QUEUE="sdx_q1"
export SUB_QUEUE="connection"
export SUB_EXCHANGE="connection"
export SUB_TOPIC="lc1_q1"
export MQ_NAME="hello"
export MQ_HOST="aw-sdx-monitor.renci.org"
export MQ_PORT=5672
export MQ_USER="guest"
export MQ_PASS="guest"

export SUB_QUEUE="connection"
export SUB_EXCHANGE="connection"
export SUB_TOPIC="lc1_q1"

# Kytos/OESS API address
export OXP_PROVISION_URL='http://192.168.201.205:8088/SDX-LC/1.0.0/provision'
export OXP_PULL_URL='http://192.168.201.205:8088/SDX-LC/1.0.0/topology'
Expand Down
3 changes: 0 additions & 3 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,11 @@ setenv =
SDXLC_DOMAIN = example.net
SDXLC_HOST = localhost
SDXLC_PORT = 8082
SDXLC_VERSION = 2.0.0
SDXLC_NAME = test-sdx-lc
MQ_NAME = test-mq
MQ_HOST = localhost
MQ_PORT = 5672
MQ_USER = guest
MQ_PASS = guest
MQ_EXCHANGE = ''
SUB_QUEUE = connection
SUB_EXCHANGE = connection
MONGODB_CONNSTRING = mongodb://guest:guest@localhost:27017/
Expand Down

0 comments on commit df55fcc

Please sign in to comment.