Commit 2ea1cf77 authored by Lluis Gifre Renom's avatar Lluis Gifre Renom
Browse files

Tests - Tools - SIMAP Server

- Arranged file structure
- Corrected dockerization
- Corrected test scripts
- Updated README.md
parent 0705fe97
Loading
Loading
Loading
Loading
+37 −10
Original line number Diff line number Diff line
@@ -14,21 +14,48 @@

FROM python:3.9-slim

# Install dependencies
RUN apt-get --yes --quiet --quiet update && \
    apt-get --yes --quiet --quiet install git build-essential cmake libpcre2-dev python3-dev python3-cffi && \
    rm -rf /var/lib/apt/lists/*

# Download, build and install libyang. Note that APT package is outdated
# - Ref: https://github.com/CESNET/libyang
# - Ref: https://github.com/CESNET/libyang-python/
RUN mkdir -p /var/libyang
RUN git clone https://github.com/CESNET/libyang.git /var/libyang
WORKDIR /var/libyang
RUN git fetch
RUN git checkout v2.1.148
RUN mkdir -p /var/libyang/build
WORKDIR /var/libyang/build
RUN cmake -D CMAKE_BUILD_TYPE:String="Release" ..
RUN make
RUN make install
RUN ldconfig

# Set Python to show logs as they occur
ENV PYTHONUNBUFFERED=0

# Get Python dependencies
# Get generic Python packages
RUN python3 -m pip install --upgrade pip
RUN python3 -m pip install --upgrade setuptools wheel
RUN python3 -m pip install https://github.com/freeconf/lang/releases/download/v0.1.0-alpha/freeconf-0.1.0-py3-none-any.whl
RUN fc-lang-install -v

# Create component sub-folders, and copy content
RUN mkdir -p /var/simap_server/
WORKDIR /var/simap_server
COPY ./simap_server/yang/*.yang ./yang
COPY ./simap_server/*.py ./
RUN python3 -m pip install --upgrade pip-tools

# Create component sub-folders, get specific Python packages
RUN mkdir -p /var/teraflow/simap_server/
WORKDIR /var/teraflow/simap_server/
COPY ./requirements.in ./requirements.in
RUN pip-compile --quiet --output-file=requirements.txt requirements.in
RUN python3 -m pip install -r requirements.txt

# Add component files into working directory
COPY ./yang/*.yang ./yang/
COPY ./simap_server/*.py ./simap_server/
COPY ./startup.json ./startup.json

# Configure Flask for production
ENV FLASK_ENV=production

# Start the service
ENTRYPOINT ["python", "simap_server.py"]
ENTRYPOINT ["gunicorn", "--workers", "1", "--worker-class", "eventlet", "--bind", "0.0.0.0:8080", "simap_server.app:app"]
+14 −23
Original line number Diff line number Diff line
# Mock QKD Node
# RESTCONF/SIMAP Server

This Mock implements very basic support for the software-defined QKD node information models specified in ETSI GS QKD 015 V2.1.1.
This server implements a basic RESTCONF Server that can load, potentially, any YANG data model.
In this case, it is prepared to load a SIMAP Server based on IETF Network Topology + custom SIMAP Telemetry extensions.

The aim of this mock is to enable testing the TFS QKD Framework with an emulated data plane.


## Build the Mock QKD Node Docker image
## Build the RESTCONF/SIMAP Server Docker image
```bash
./build.sh
```

## Run the Mock QKD Node as a container:
## Deploy the RESTCONF/SIMAP Server
```bash
docker network create --driver bridge --subnet=172.254.252.0/24 --gateway=172.254.252.254 tfs-qkd-net-mgmt

docker run --name qkd-node-01 --detach --publish 80:80 \
  --network=tfs-qkd-net-mgmt --ip=172.254.252.101 \
  --env "DATA_FILE_PATH=/var/teraflow/mock-qkd-node/data/database.json" \
  --volume "$PWD/src/tests/mock-qkd-node/data/database-01.json:/var/teraflow/mock-qkd-node/data/database.json" \
  mock-qkd-node:test
./deploy.sh
```

docker run --name qkd-node-02 --detach --publish 80:80 \
  --network=tfs-qkd-net-mgmt --ip=172.254.252.102 \
  --env "DATA_FILE_PATH=/var/teraflow/mock-qkd-node/data/database.json" \
  --volume "$PWD/src/tests/mock-qkd-node/data/database-02.json:/var/teraflow/mock-qkd-node/data/database.json" \
  mock-qkd-node:test
## Run the RESTCONF/SIMAP Client for testing:
```bash
./run_client.sh
```

docker run --name qkd-node-03 --detach --publish 80:80 \
  --network=tfs-qkd-net-mgmt --ip=172.254.252.103 \
  --env "DATA_FILE_PATH=/var/teraflow/mock-qkd-node/data/database.json" \
  --volume "$PWD/src/tests/mock-qkd-node/data/database-03.json:/var/teraflow/mock-qkd-node/data/database.json" \
  mock-qkd-node:test
## Destroy the RESTCONF/SIMAP Server
```bash
./destroy.sh
```
+1 −1
Original line number Diff line number Diff line
@@ -17,7 +17,7 @@
docker rm --force simap-server

# Create SIMAP Server
docker run --detach --name simap-server --network host simap-server:test
docker run --detach --name simap-server --publish 8080:8080 simap-server:test

sleep 2

+25 −0
Original line number Diff line number Diff line
# Copyright 2022-2025 ETSI SDG TeraFlowSDN (TFS) (https://tfs.etsi.org/)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

cryptography==39.0.1
eventlet==0.39.0
Flask-HTTPAuth==4.5.0
Flask-RESTful==0.3.9
Flask==2.1.3
gunicorn==23.0.0
jsonschema==4.4.0
libyang==2.8.4
pyopenssl==23.0.0
requests==2.27.1
werkzeug==2.3.7
+16 −0
Original line number Diff line number Diff line
#!/bin/bash
# Copyright 2022-2025 ETSI SDG TeraFlowSDN (TFS) (https://tfs.etsi.org/)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# Make folder containing the script the root folder for its execution
cd $(dirname $0)

python -m simap_client
Loading