Commit 5979d984 authored by Konstantinos Poulakakis's avatar Konstantinos Poulakakis
Browse files

Merge branch 'develop' into feat/refactorV2-policy

# Conflicts:
#	src/policy/src/main/java/org/etsi/tfs/policy/policy/PolicyServiceImpl.java
#	src/policy/target/kubernetes/kubernetes.yml
parents fd131107 265a2f46
Loading
Loading
Loading
Loading
+9 −5
Original line number Original line Diff line number Diff line
@@ -17,10 +17,9 @@ stages:
  #- dependencies
  #- dependencies
  - build
  - build
  - unit_test
  - unit_test
  #- deploy
  - end2end_test
  #- end2end_test


# include the individual .gitlab-ci.yml of each micro-service
# include the individual .gitlab-ci.yml of each micro-service and tests
include:
include:
  #- local: '/manifests/.gitlab-ci.yml'
  #- local: '/manifests/.gitlab-ci.yml'
  - local: '/src/monitoring/.gitlab-ci.yml'
  - local: '/src/monitoring/.gitlab-ci.yml'
@@ -31,7 +30,8 @@ include:
  - local: '/src/dbscanserving/.gitlab-ci.yml'
  - local: '/src/dbscanserving/.gitlab-ci.yml'
  - local: '/src/opticalattackmitigator/.gitlab-ci.yml'
  - local: '/src/opticalattackmitigator/.gitlab-ci.yml'
  - local: '/src/opticalattackdetector/.gitlab-ci.yml'
  - local: '/src/opticalattackdetector/.gitlab-ci.yml'
  # - local: '/src/opticalattackmanager/.gitlab-ci.yml'
  - local: '/src/opticalattackmanager/.gitlab-ci.yml'
  - local: '/src/opticalcontroller/.gitlab-ci.yml'
  - local: '/src/ztp/.gitlab-ci.yml'
  - local: '/src/ztp/.gitlab-ci.yml'
  - local: '/src/policy/.gitlab-ci.yml'
  - local: '/src/policy/.gitlab-ci.yml'
  - local: '/src/forecaster/.gitlab-ci.yml'
  - local: '/src/forecaster/.gitlab-ci.yml'
@@ -39,8 +39,12 @@ include:
  #- local: '/src/l3_distributedattackdetector/.gitlab-ci.yml'
  #- local: '/src/l3_distributedattackdetector/.gitlab-ci.yml'
  #- local: '/src/l3_centralizedattackdetector/.gitlab-ci.yml'
  #- local: '/src/l3_centralizedattackdetector/.gitlab-ci.yml'
  #- local: '/src/l3_attackmitigator/.gitlab-ci.yml'
  #- local: '/src/l3_attackmitigator/.gitlab-ci.yml'
  #- local: '/src/slice/.gitlab-ci.yml'
  - local: '/src/slice/.gitlab-ci.yml'
  #- local: '/src/interdomain/.gitlab-ci.yml'
  #- local: '/src/interdomain/.gitlab-ci.yml'
  - local: '/src/pathcomp/.gitlab-ci.yml'
  - local: '/src/pathcomp/.gitlab-ci.yml'
  #- local: '/src/dlt/.gitlab-ci.yml'
  #- local: '/src/dlt/.gitlab-ci.yml'
  - local: '/src/load_generator/.gitlab-ci.yml'
  - local: '/src/load_generator/.gitlab-ci.yml'
  - local: '/src/bgpls_speaker/.gitlab-ci.yml'

  # This should be last one: end-to-end integration tests
  - local: '/src/tests/.gitlab-ci.yml'
+18 −7
Original line number Original line Diff line number Diff line
# ETSI TeraFlowSDN Controller
# ETSI TeraFlowSDN Controller


[ETSI OpenSource Group for TeraFlowSDN](https://tfs.etsi.org/)
The [ETSI Software Development Group TeraFlowSDN (SDG TFS)](https://tfs.etsi.org/) is developing an open source cloud native SDN controller enabling smart connectivity services for future networks beyond 5G.


Former, [Teraflow H2020 project](https://teraflow-h2020.eu/) - Secured autonomic traffic management for a Tera of SDN Flows
The project originated from "[Teraflow H2020 project](https://teraflow-h2020.eu/) - Secured autonomic traffic management for a Tera of SDN Flows", a project funded by the European Union’s Horizon 2020 Research and Innovation programme that finished on 30th June 2023.


Branch "master" : [![pipeline status](https://labs.etsi.org/rep/tfs/controller/badges/master/pipeline.svg)](https://labs.etsi.org/rep/tfs/controller/-/commits/master) [![coverage report](https://labs.etsi.org/rep/tfs/controller/badges/master/coverage.svg)](https://labs.etsi.org/rep/tfs/controller/-/commits/master)


Branch "develop" : [![pipeline status](https://labs.etsi.org/rep/tfs/controller/badges/develop/pipeline.svg)](https://labs.etsi.org/rep/tfs/controller/-/commits/develop) [![coverage report](https://labs.etsi.org/rep/tfs/controller/badges/develop/coverage.svg)](https://labs.etsi.org/rep/tfs/controller/-/commits/develop)
## Available branches and releases


# Installation Instructions and Functional Tests
[![Latest Release](https://labs.etsi.org/rep/tfs/controller/-/badges/release.svg)](https://labs.etsi.org/rep/tfs/controller/-/releases)
The [TeraFlowSDN Wiki](https://labs.etsi.org/rep/tfs/controller/-/wikis/home) pages include details on using the ETSI TeraFlowSDN release 2.0.


The documentation, installation instructions, and description of the functional tests defined to enable experimentation with the ETSI TeraFlowSDN Controller can be found in the Wiki pages
- The branch `master` ([![pipeline status](https://labs.etsi.org/rep/tfs/controller/badges/master/pipeline.svg)](https://labs.etsi.org/rep/tfs/controller/-/commits/master) [![coverage report](https://labs.etsi.org/rep/tfs/controller/badges/master/coverage.svg)](https://labs.etsi.org/rep/tfs/controller/-/commits/master)), points always to the latest stable version of the TeraFlowSDN controller.

- The branches `release/X.Y.Z`, point to the code for the different release versions indicated in the branch name.
  - Code in these branches can be considered stable, and no new features are planned.
  - In case of bugs, point releases increasing revision number (Z) might be created.

- The `develop` ([![pipeline status](https://labs.etsi.org/rep/tfs/controller/badges/develop/pipeline.svg)](https://labs.etsi.org/rep/tfs/controller/-/commits/develop) [![coverage report](https://labs.etsi.org/rep/tfs/controller/badges/develop/coverage.svg)](https://labs.etsi.org/rep/tfs/controller/-/commits/develop)) branch is the main development branch and contains the latest contributions.
  - **Use it with care! It might not be stable.**
  - The latest developments and contributions are added to this branch for testing and validation before reaching a release.


## Documentation
The [TeraFlowSDN Wiki](https://labs.etsi.org/rep/tfs/controller/-/wikis/home) pages include the main documentation for the ETSI TeraFlowSDN Controller.
The documentation includes project documentation, installation instructions, functional tests, supported NBIs and SBIs, etc.
+20 −5
Original line number Original line Diff line number Diff line
@@ -40,6 +40,21 @@ export TFS_GRAFANA_PASSWORD=${TFS_GRAFANA_PASSWORD:-"admin123+"}
# Automated steps start here
# Automated steps start here
########################################################################################################################
########################################################################################################################


DOCKER_BUILD="docker build"
DOCKER_MAJOR_VERSION=$(docker --version | grep -o -E "Docker version [0-9]+\." | grep -o -E "[0-9]+" | cut -c 1-3)
if [[ $DOCKER_MAJOR_VERSION -ge 23 ]]; then
    # If Docker version >= 23, build command was migrated to docker-buildx
    # In Ubuntu, in practice, means to install package docker-buildx together with docker.io
    # Check if docker-buildx plugin is installed
    docker buildx version 1>/dev/null 2>/dev/null
    if [[ $? -ne 0 ]]; then
        echo "Docker buildx command is not installed. Check: https://docs.docker.com/build/architecture/#install-buildx"
        echo "If you installed docker through APT package docker.io, consider installing also package docker-buildx"
        exit 1;
    fi
    DOCKER_BUILD="docker buildx build"
fi

# Constants
# Constants
GITLAB_REPO_URL="labs.etsi.org:5050/tfs/controller"
GITLAB_REPO_URL="labs.etsi.org:5050/tfs/controller"
TMP_FOLDER="./tmp"
TMP_FOLDER="./tmp"
@@ -60,17 +75,17 @@ for COMPONENT in $TFS_COMPONENTS; do
    BUILD_LOG="$TMP_LOGS_FOLDER/build_${COMPONENT}.log"
    BUILD_LOG="$TMP_LOGS_FOLDER/build_${COMPONENT}.log"


    if [ "$COMPONENT" == "ztp" ] || [ "$COMPONENT" == "policy" ]; then
    if [ "$COMPONENT" == "ztp" ] || [ "$COMPONENT" == "policy" ]; then
        docker build -t "$IMAGE_NAME" -f ./src/"$COMPONENT"/Dockerfile ./src/"$COMPONENT"/ > "$BUILD_LOG"
        $DOCKER_BUILD -t "$IMAGE_NAME" -f ./src/"$COMPONENT"/Dockerfile ./src/"$COMPONENT"/ > "$BUILD_LOG"
    elif [ "$COMPONENT" == "pathcomp" ]; then
    elif [ "$COMPONENT" == "pathcomp" ]; then
        BUILD_LOG="$TMP_LOGS_FOLDER/build_${COMPONENT}-frontend.log"
        BUILD_LOG="$TMP_LOGS_FOLDER/build_${COMPONENT}-frontend.log"
        docker build -t "$COMPONENT-frontend:$TFS_IMAGE_TAG" -f ./src/"$COMPONENT"/frontend/Dockerfile . >> "$BUILD_LOG"
        $DOCKER_BUILD -t "$COMPONENT-frontend:$TFS_IMAGE_TAG" -f ./src/"$COMPONENT"/frontend/Dockerfile . >> "$BUILD_LOG"


        BUILD_LOG="$TMP_LOGS_FOLDER/build_${COMPONENT}-backend.log"
        BUILD_LOG="$TMP_LOGS_FOLDER/build_${COMPONENT}-backend.log"
        docker build -t "$COMPONENT-backend:$TFS_IMAGE_TAG" -f ./src/"$COMPONENT"/backend/Dockerfile . >> "$BUILD_LOG"
        $DOCKER_BUILD -t "$COMPONENT-backend:$TFS_IMAGE_TAG" -f ./src/"$COMPONENT"/backend/Dockerfile . >> "$BUILD_LOG"
        # next command is redundant, but helpful to keep cache updated between rebuilds
        # next command is redundant, but helpful to keep cache updated between rebuilds
        docker build -t "$COMPONENT-backend:$TFS_IMAGE_TAG-builder" --target builder -f ./src/"$COMPONENT"/backend/Dockerfile . >> "$BUILD_LOG"
        $DOCKER_BUILD -t "$COMPONENT-backend:$TFS_IMAGE_TAG-builder" --target builder -f ./src/"$COMPONENT"/backend/Dockerfile . >> "$BUILD_LOG"
    else
    else
        docker build -t "$IMAGE_NAME" -f ./src/"$COMPONENT"/Dockerfile . > "$BUILD_LOG"
        $DOCKER_BUILD -t "$IMAGE_NAME" -f ./src/"$COMPONENT"/Dockerfile . > "$BUILD_LOG"
    fi
    fi


    if [ -n "$TFS_REGISTRY_IMAGES" ]; then
    if [ -n "$TFS_REGISTRY_IMAGES" ]; then
+14 −4
Original line number Original line Diff line number Diff line
@@ -158,9 +158,19 @@ function crdb_undeploy_single() {


function crdb_drop_database_single() {
function crdb_drop_database_single() {
    echo "Drop database if exists"
    echo "Drop database if exists"
    CRDB_PORT_SQL=$(kubectl --namespace ${CRDB_NAMESPACE} get service cockroachdb-public -o 'jsonpath={.spec.ports[?(@.name=="sql")].port}')

    CRDB_CLIENT_URL="postgresql://${CRDB_USERNAME}:${CRDB_PASSWORD}@cockroachdb-0:${CRDB_PORT_SQL}/defaultdb?sslmode=require"
    if [[ -z "${GITLAB_CI}" ]]; then
    kubectl exec -it --namespace ${CRDB_NAMESPACE} cockroachdb-0 -- \
        #kubectl --namespace ${CRDB_NAMESPACE} get service cockroachdb-public -o yaml
        CRDB_HOST=$(kubectl --namespace ${CRDB_NAMESPACE} get service cockroachdb-public -o 'jsonpath={.spec.clusterIP}')
        CRDB_PORT=$(kubectl --namespace ${CRDB_NAMESPACE} get service cockroachdb-public -o 'jsonpath={.spec.ports[?(@.name=="sql")].port}')
    else
        CRDB_HOST="127.0.0.1"
        CRDB_PORT=${CRDB_EXT_PORT_SQL}
    fi

    CRDB_CLIENT_URL="postgresql://${CRDB_USERNAME}:${CRDB_PASSWORD}@${CRDB_HOST}:${CRDB_PORT}/defaultdb?sslmode=require"
    echo "CRDB_CLIENT_URL=${CRDB_CLIENT_URL}"
    kubectl exec -i --namespace ${CRDB_NAMESPACE} cockroachdb-0 -- \
        ./cockroach sql --certs-dir=/cockroach/cockroach-certs --url=${CRDB_CLIENT_URL} \
        ./cockroach sql --certs-dir=/cockroach/cockroach-certs --url=${CRDB_CLIENT_URL} \
        --execute "DROP DATABASE IF EXISTS ${CRDB_DATABASE};"
        --execute "DROP DATABASE IF EXISTS ${CRDB_DATABASE};"
    echo
    echo
@@ -343,7 +353,7 @@ function crdb_undeploy_cluster() {


function crdb_drop_database_cluster() {
function crdb_drop_database_cluster() {
    echo "Drop database if exists"
    echo "Drop database if exists"
    kubectl exec -it --namespace ${CRDB_NAMESPACE} cockroachdb-client-secure -- \
    kubectl exec -i --namespace ${CRDB_NAMESPACE} cockroachdb-client-secure -- \
        ./cockroach sql --certs-dir=/cockroach/cockroach-certs --host=cockroachdb-public --execute \
        ./cockroach sql --certs-dir=/cockroach/cockroach-certs --host=cockroachdb-public --execute \
        "DROP DATABASE IF EXISTS ${CRDB_DATABASE};"
        "DROP DATABASE IF EXISTS ${CRDB_DATABASE};"
    echo
    echo
+16 −1
Original line number Original line Diff line number Diff line
@@ -58,9 +58,24 @@ echo "Processing '$COMPONENT' component..."
IMAGE_NAME="$COMPONENT:$IMAGE_TAG"
IMAGE_NAME="$COMPONENT:$IMAGE_TAG"
IMAGE_URL=$(echo "$REGISTRY_IMAGE/$IMAGE_NAME" | sed 's,//,/,g' | sed 's,http:/,,g')
IMAGE_URL=$(echo "$REGISTRY_IMAGE/$IMAGE_NAME" | sed 's,//,/,g' | sed 's,http:/,,g')


DOCKER_BUILD="docker build"
DOCKER_MAJOR_VERSION=$(docker --version | grep -o -E "Docker version [0-9]+\." | grep -o -E "[0-9]+" | cut -c 1-3)
if [[ $DOCKER_MAJOR_VERSION -ge 23 ]]; then
    # If Docker version >= 23, build command was migrated to docker-buildx
    # In Ubuntu, in practice, means to install package docker-buildx together with docker.io
    # Check if docker-buildx plugin is installed
    docker buildx version 1>/dev/null 2>/dev/null
    if [[ $? -ne 0 ]]; then
        echo "Docker buildx command is not installed. Check: https://docs.docker.com/build/architecture/#install-buildx"
        echo "If you installed docker through APT package docker.io, consider installing also package docker-buildx"
        exit 1;
    fi
    DOCKER_BUILD="docker buildx build"
fi

echo "  Building Docker image..."
echo "  Building Docker image..."
BUILD_LOG="$TMP_LOGS_FOLDER/build_${COMPONENT}.log"
BUILD_LOG="$TMP_LOGS_FOLDER/build_${COMPONENT}.log"
docker build -t "$IMAGE_NAME" -f ./src/dlt/mock_blockchain/Dockerfile . > "$BUILD_LOG"
$DOCKER_BUILD -t "$IMAGE_NAME" -f ./src/dlt/mock_blockchain/Dockerfile . > "$BUILD_LOG"


if [ -n "$REGISTRY_IMAGE" ]; then
if [ -n "$REGISTRY_IMAGE" ]; then
    echo "  Pushing Docker image to '$REGISTRY_IMAGE'..."
    echo "  Pushing Docker image to '$REGISTRY_IMAGE'..."
Loading