diff --git a/.gitignore b/.gitignore index cedb125e2123af3ea932cd34f514152c03a9e55f..ba1c1ed94b1a2a741482af5f1ec7528c9d34296c 100644 --- a/.gitignore +++ b/.gitignore @@ -25,3 +25,5 @@ gostructs.go *.lof *.log *.out + +.gosdnc.toml diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 3f99c85a5319662b19cb02863d071f6a536b6bc2..99e2ea439a09001c9e5b297b1a2415bf31bdbe1a 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,12 +1,16 @@ stages: - build + - build-integration-test - test - analyze - build-latest variables: IMAGE_PATH: "${CI_REGISTRY_IMAGE}" + DQ_REGISTRY_PATH: "registry.code.fbi.h-da.de/demoquandt/qkdn-controller" + DQ_QUANT_INTEGRATION_REGISTRY_PATH: $DQ_REGISTRY_PATH/quant-integration GOLANG_VERSION: "1.22" + GOLANG_MINOR_VERSION: "${GOLANG_VERSION}.6" DOCKER_TLS_CERTDIR: "/certs" @@ -67,6 +71,31 @@ build-binaries: script: - make build +# Integration test stage preparations + +.build-integration-test: &build-integration-test + stage: build-integration-test + image: ${CI_DEPENDENCY_PROXY_GROUP_IMAGE_PREFIX}/docker:latest + services: + - name: ${CI_DEPENDENCY_PROXY_GROUP_IMAGE_PREFIX}/docker:latest + alias: docker + needs: [] + before_script: + - apk add git + - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY + - docker login -u $CI_DEPENDENCY_PROXY_USER -p $CI_DEPENDENCY_PROXY_PASSWORD $CI_DEPENDENCY_PROXY_SERVER + - docker login -u $QKDN_REPO_USERNAME -p $QKDN_REPO_TOKEN $CI_REGISTRY + +patch-qkdn-controller: + script: + - docker buildx build --push -t ${DQ_QUANT_INTEGRATION_REGISTRY_PATH}/qkdn-controller:${CI_COMMIT_REF_SLUG} -f integration-tests/Dockerfiles/integration.Dockerfile --build-arg "BASEIMAGE=$DQ_REGISTRY_PATH" integration-tests + <<: *build-integration-test + +patch-routing-app: + script: + - docker buildx build --push -t ${DQ_QUANT_INTEGRATION_REGISTRY_PATH}/routing-app:${CI_COMMIT_REF_SLUG} -f integration-tests/Dockerfiles/integration.Dockerfile --build-arg "BASEIMAGE=$DQ_REGISTRY_PATH/routing-app:qkdn-main" integration-tests + <<: *build-integration-test + # Build latest stage .build-latest: &build-latest @@ -108,8 +137,8 @@ build-etsi14module-latest: - docker buildx build --push -t "$IMAGE_NAME:$TAG" -f etsi14module/Dockerfile --build-arg "GITLAB_PROXY=${CI_DEPENDENCY_PROXY_GROUP_IMAGE_PREFIX}/" --build-arg GITLAB_LOGIN=${GITLAB_LOGIN} --build-arg GITLAB_TOKEN=${GITLAB_TOKEN} --build-arg GOLANG_VERSION=${GOLANG_VERSION} . <<: *build-latest -# Analyze stage +# Analyze stage lint: stage: analyze image: ${CI_DEPENDENCY_PROXY_GROUP_IMAGE_PREFIX}/golangci/golangci-lint:v1.60.1-alpine @@ -146,61 +175,20 @@ unit-tests: path: coverage.xml needs: [] -integration-test-kms: - image: ${CI_DEPENDENCY_PROXY_GROUP_IMAGE_PREFIX}/golang:$GOLANG_VERSION-bookworm - needs: - - ["build-quantumlayer", "build-akms-simulator", "build-kms"] + +integration-test: + tags: + - shell + needs: [] variables: - FF_NETWORK_PER_BUILD: 1 - INTEGRATION_TEST_KMS1_URL: kms_1:7030 - INTEGRATION_TEST_KMS2_URL: kms_2:7030 - INTEGRATION_TEST_KMS1_AKMS_URL: kms_1:9696 - INTEGRATION_TEST_LOG_FILE1_URL: akms-simulator_1:4444 - INTEGRATION_TEST_LOG_FILE2_URL: akms-simulator_2:4444 - INTEGRATION_TEST_KMS1_ETSI14_URL: kms_1:1414 - INTEGRATION_TEST_KMS2_ETSI14_URL: kms_2:1414 - services: - - name: $IMAGE_PATH/akms-simulator:$CI_COMMIT_REF_SLUG - alias: akms-simulator_1 - - name: $IMAGE_PATH/akms-simulator:$CI_COMMIT_REF_SLUG - alias: akms-simulator_2 - - name: $IMAGE_PATH/gokms:${CI_COMMIT_REF_SLUG}_integration-test - alias: kms_1 - command: - [ - "--log", - "debug", - "--kms_config", - "/config/kms/kms_1.yaml", - ] - - name: $IMAGE_PATH/gokms:${CI_COMMIT_REF_SLUG}_integration-test - alias: kms_2 - command: - [ - "--log", - "debug", - "--kms_config", - "/config/kms/kms_2.yaml", - ] - - name: $IMAGE_PATH/quantumlayer:${CI_COMMIT_REF_SLUG}_integration-test - alias: quantumlayer_1 - command: - [ - "--log", - "debug", - "--config", - "/config/quantumlayer/quantumlayer_1.yaml", - ] - - name: $IMAGE_PATH/quantumlayer:${CI_COMMIT_REF_SLUG}_integration-test - alias: quantumlayer_2 - command: - [ - "--log", - "debug", - "--config", - "/config/quantumlayer/quantumlayer_2.yaml", - ] + DEPENDENCY_PROXY: ${CI_DEPENDENCY_PROXY_GROUP_IMAGE_PREFIX}/ before_script: - - bash -c "$(curl -sL https://get-gnmic.openconfig.net)" + - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY + - docker login -u $CI_DEPENDENCY_PROXY_USER -p $CI_DEPENDENCY_PROXY_PASSWORD $CI_DEPENDENCY_PROXY_SERVER + - ./scripts/install_go_as_user.sh $GOLANG_MINOR_VERSION + - export PATH="$HOME/go/go/bin:$PATH" + - export GOROOT="$HOME/go/go" + - export GOPATH=$HOME/go_projects + - go version script: - - go test -p 1 ./integration-tests/code/getKSAKeyTest + - make integration-test diff --git a/.vscode/launch.json b/.vscode/launch.json index 451f53a862bd28c13b15cf99e7a39eb126ac22de..fc785bb504ec59954458135389216ed776ef84a6 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -5,33 +5,110 @@ "version": "0.2.0", "configurations": [ { - "name": "Launch file", + "name": "kms01-debug", "type": "go", - "request": "launch", - "mode": "auto", - "program": "${file}" + "request": "attach", + "mode": "remote", + "remotePath": "", + "port": 4401, + "host": "127.0.0.1", + "showLog": true, + "trace": "log", + "logOutput": "rpc", + "preLaunchTask": "compose-debug-up", }, { - "name": "kms", + "name": "kms02-debug", "type": "go", - "request": "launch", - "mode": "auto", - "program": "${workspaceFolder}/goKMS/main.go", - "env": {}, - "args": [ - "--log", "debug", "--kms_config", "${workspaceFolder}/debug_configs/config/kms/kms_1.yaml" - ] + "request": "attach", + "mode": "remote", + "remotePath": "", + "port": 4402, + "host": "127.0.0.1", + "showLog": true, + "trace": "log", + "logOutput": "rpc", + "preLaunchTask": "compose-debug-up", + }, + { + "name": "kms03-debug", + "type": "go", + "request": "attach", + "mode": "remote", + "remotePath": "", + "port": 4403, + "host": "127.0.0.1", + "showLog": true, + "trace": "log", + "logOutput": "rpc", + "preLaunchTask": "compose-debug-up", + }, + { + "name": "kms04-debug", + "type": "go", + "request": "attach", + "mode": "remote", + "remotePath": "", + "port": 4404, + "host": "127.0.0.1", + "showLog": true, + "trace": "log", + "logOutput": "rpc", + "preLaunchTask": "compose-debug-up", }, { - "name": "kms-debug", + "name": "integration-test-kms01-debug", + "type": "go", + "request": "attach", + "mode": "remote", + "remotePath": "", + "port": 4401, + "host": "127.0.0.1", + "showLog": true, + "trace": "log", + "logOutput": "rpc", + "preLaunchTask": "integration-test-debug-kms-up", + }, + { + "name": "integration-test-kms02-debug", + "type": "go", + "request": "attach", + "mode": "remote", + "remotePath": "", + "port": 4402, + "host": "127.0.0.1", + "showLog": true, + "trace": "log", + "logOutput": "rpc", + "preLaunchTask": "integration-test-debug-kms-up", + }, + { + "name": "Launch currently open test", "type": "go", "request": "launch", "mode": "auto", - "program": "${workspaceFolder}/goKMS/main.go", - "env": {}, - "args": [ - "--log", "debug", "--kms_config", "${workspaceFolder}/dev_env_data/debug_configs/config/kms/kms_1.yaml" - ] + "program": "${file}" }, + ], + "compounds": [ + { + "name": "Debug all kms parallel", + "configurations": [ + "kms01-debug", + "kms02-debug", + "kms03-debug", + "kms04-debug" + ], + "stopAll": true + }, + { + "name": "Debug open integration test and kms", + "configurations": [ + "integration-test-kms01-debug", + "integration-test-kms02-debug", + "Launch currently open test" + ], + "stopAll": true + } ] } diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 0000000000000000000000000000000000000000..17d823499757d7dd2546f0848c8301790161df11 --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,15 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "label": "integration-test-debug-kms-up", + "command": "make integration-test-debug-compose-up", + "type": "shell", + }, + { + "label": "compose-debug-up", + "command": "make compose-debug-up", + "type": "shell", + } + ] +} diff --git a/Makefile b/Makefile index 2a0436890cc58a517f3daec505c34538cec41dc3..3df2e31e6198171a555ce5b1f5189b960aeb0e39 100644 --- a/Makefile +++ b/Makefile @@ -23,7 +23,7 @@ all: build pre: mkdir -p $(BUILD_ARTIFACTS_PATH) -install-tools: +install-tools: pre @echo Install development tooling mkdir -p $(GOSDN_PRG) export GOBIN=$(GOSDN_PRG) &&\ @@ -32,6 +32,9 @@ install-tools: go install github.com/golangci/golangci-lint/cmd/golangci-lint@$(GOLANGCI_LINT_VERSION) @echo Finished installing development tooling +install-gosdnc: + ./scripts/install_gosdnc.sh + ci-lint: install-tools ./$(TOOLS_DIR)/golangci-lint run --config .golangci.yml @@ -59,10 +62,10 @@ build-akms-simulator: pre $(GOBUILD) -o $(BUILD_ARTIFACTS_PATH)/akms-simulator ./akms-simulator/akms-simulator.go quantumlayer-container: - docker buildx build --rm -t quantumlayer --load -f ./quantumlayer/Dockerfile --build-arg GITLAB_LOGIN=${GITLAB_LOGIN} --build-arg GITLAB_TOKEN=${GITLAB_TOKEN} --build-arg GOLANG_VERSION=${GOLANG_VERSION} . + docker buildx build --rm -t quantumlayer --load -f ./quantumlayer/Dockerfile --build-arg GITLAB_LOGIN=${GITLAB_LOGIN} --build-arg GITLAB_TOKEN=${GITLAB_TOKEN} --build-arg GOLANG_VERSION=${GOLANG_VERSION} --build-arg GITLAB_PROXY=${DEPENDENCY_PROXY} . etsi14module-container: - docker buildx build --rm -t etsi14module --load -f ./etsi14module/Dockerfile --build-arg GOLANG_VERSION=${GOLANG_VERSION} . + docker buildx build --rm -t etsi14module --load -f ./etsi14module/Dockerfile --build-arg GOLANG_VERSION=${GOLANG_VERSION} --build-arg GITLAB_PROXY=${DEPENDENCY_PROXY} . gokms-build-debug: pre $(GOBUILD) -gcflags="all=-N -l" -o $(BUILD_ARTIFACTS_PATH)/goKMS ./goKMS/main.go @@ -73,56 +76,47 @@ generate-yang-models: install-tools go generate gokms-container: - docker buildx build --rm -t gokms --load -f ./goKMS/Dockerfile --build-arg GITLAB_LOGIN=${GITLAB_LOGIN} --build-arg GITLAB_TOKEN=${GITLAB_TOKEN} --build-arg GOLANG_VERSION=${GOLANG_VERSION} . - -gokms-container-debug: - docker buildx build --rm -t gokms-debug --load -f ./goKMS/Dockerfile.debug --build-arg GITLAB_LOGIN=${GITLAB_LOGIN} --build-arg GITLAB_TOKEN=${GITLAB_TOKEN} --build-arg GOLANG_VERSION=${GOLANG_VERSION} . + docker buildx build --rm -t gokms_debug --load -f ./goKMS/Dockerfile --target debug --build-arg GITLAB_LOGIN=${GITLAB_LOGIN} --build-arg GITLAB_TOKEN=${GITLAB_TOKEN} --build-arg GOLANG_VERSION=${GOLANG_VERSION} --build-arg GITLAB_PROXY=${DEPENDENCY_PROXY} . + docker buildx build --rm -t gokms --load -f ./goKMS/Dockerfile --build-arg GITLAB_LOGIN=${GITLAB_LOGIN} --build-arg GITLAB_TOKEN=${GITLAB_TOKEN} --build-arg GOLANG_VERSION=${GOLANG_VERSION} --build-arg GITLAB_PROXY=${DEPENDENCY_PROXY} . akms-simulator-container: - docker buildx build --rm -t akms-simulator --load -f ./akms-simulator/Dockerfile --build-arg GOLANG_VERSION=${GOLANG_VERSION} . + docker buildx build --rm -t akms-simulator --load -f ./akms-simulator/Dockerfile --build-arg GOLANG_VERSION=${GOLANG_VERSION} --build-arg GITLAB_PROXY=${DEPENDENCY_PROXY} . build-images: gokms-container quantumlayer-container akms-simulator-container -compose-up: generate-gokms-certs build-images - docker-compose up -d +compose-up: generate-gokms-certs build-images install-gosdnc + docker compose down + docker compose up -d + echo "Will add devices, can take a while" + ./config/controller/add_devices.sh compose-down: - docker-compose down - -debug-kms-up: generate-debug-certs build-images - echo "After running this please start the debugger setup for KMS_1" - docker-compose -f dev_env_data/docker-compose/docker-compose_debug_kms.yml down - docker-compose -f dev_env_data/docker-compose/docker-compose_debug_kms.yml up - echo "Setup available, please start the debug configuration for KMS_1" + docker compose down -debug-kms-down: - docker-compose -f dev_env_data/docker-compose/docker-compose_debug_kms.yml down +compose-debug-up: generate-gokms-certs build-images install-gosdnc + docker compose -f docker-compose.yml -f docker-compose.override.debug.yml down + docker compose -f docker-compose.yml -f docker-compose.override.debug.yml up -d + echo "compose debug setup done. You have to manually add the devices to the controller by using './config/controller/add_devices_no_sleep.sh'" -integration-test-debug-up: generate-integration-test-certs build-images - docker-compose -f integration-tests/docker-compose_integration_test.yml down - docker-compose -f integration-tests/docker-compose_integration_test.yml up +compose-debug-down: + docker compose -f docker-compose.yml -f docker-compose.override.debug.yml down -integration-test-debug-down: - docker-compose -f integration-tests/docker-compose_integration_test.yml down - -integration-test: generate-integration-test-certs build-images - docker-compose -f integration-tests/docker-compose_integration_test.yml down - docker-compose -f integration-tests/docker-compose_integration_test.yml up -d +integration-test: install-gosdnc generate-integration-test-certs build-images + docker compose -f integration-tests/docker-compose.yml down + docker compose -f integration-tests/docker-compose.yml up -d echo "Will sleep for the quantumlayers to get ready" - sleep 25 + sleep 45 go test -p 1 -count=1 -v ./integration-tests/code/* - docker-compose -f integration-tests/docker-compose_integration_test.yml down - -playground-start: generate-certs build-images - sudo containerlab deploy --reconfigure --topo dev_env_data/containerlab/playground.clab.yaml + docker compose -f integration-tests/docker-compose.yml down -playground-stop: - sudo containerlab destroy --topo dev_env_data/containerlab/playground.clab.yaml +integration-test-debug-compose-up: generate-integration-test-certs build-images install-gosdnc + docker compose -f integration-tests/docker-compose.yml -f integration-tests/docker-compose.override.debug.yml down + docker compose -f integration-tests/docker-compose.yml -f integration-tests/docker-compose.override.debug.yml up -d -playground-graph: - sudo containerlab graph --topo dev_env_data/containerlab/playground.clab.yaml +integration-test-debug-compose-down: + docker compose -f integration-tests/docker-compose.yml -f integration-tests/docker-compose.override.debug.yml down -generate-certs: generate-root-ca generate-gokms-certs generate-debug-certs generate-integration-test-certs +generate-certs: generate-root-ca generate-gokms-certs generate-integration-test-certs generate-root-ca: pre if [ ! -d "$(BUILD_ARTIFACTS_PATH)/ssl" ]; then \ @@ -135,9 +129,6 @@ generate-root-ca: pre generate-gokms-certs: generate-root-ca ./config/goKMS/generate-kms-certs.sh -generate-debug-certs: generate-root-ca - ./dev_env_data/debug_configs/config/kms/generate-debug-certs.sh - generate-integration-test-certs: generate-root-ca ./integration-tests/config/kms/generate-certs.sh diff --git a/README.md b/README.md index f20c8119d3a40cbe3a231e02850f517862ca9f89..b882bb772934604a4bcd4d6616fd6624d90d5c53 100644 --- a/README.md +++ b/README.md @@ -29,6 +29,7 @@ InterComAddr: 0.0.0.0:50910 # IP and port to bind the local gRPC server for inte QuantumAddr: 0.0.0.0:50911 # IP and port to bind the local gRPC server for QKD modules to reach the KMS to (optional, only used for specific emulated or experimental QKD modules) AkmsURL: "http://172.100.20.22:4444/api/v1/keys/push_ksa_key" # address of the rest endpoint of a connected AKMS (used for sending KSA key to the AKMS). AkmsCkmsServerPort: "9696" # Port of connected AKMS +GRPCTimeoutInSeconds: 10 # Time in seconds for timeout of gRPC connections as a client. Defaults to 10 seconds. Should not be set to 0 or negative values. GnmiTLS: # Settings for TLS for gNMI endpoint. Can be overwritten with cli parameters. TLS: true # Whether TLS is enabled CAFile: "ssl/ca.crt" # Path to ca @@ -194,12 +195,12 @@ The key exchange can also be triggered by sending a `GetKey` request as defined ### Debug setup -For goKMS there is a debug setup available for VS Code. -1. Set your breakpoints -2. To use it run `make debug-kms-up` and wait for the build to complete. -3. If you see the first log outputs from the running docker setup start the debugger in VS Code named `kms-debug`. +For goKMS there is a debug setup available for VS Code. It uses the standard `docker-compose.yml` setup and simply adds the debugger to it in the `docker-compose.override.yaml` +1. Set your breakpoints for the goKMS (akms-simulator and quantumlayer currently not supported) +2. Go to the debugger tab in vscode and select `Debug all kms parallel`. The single KMS options may work for certain things, but are not guaranteed to work because of how the debugging setup works. +3. Wait for it to start. At the end you can follow the instruction printed in your terminal to add the devices to the qkdn-controller. -If you are finished stop the debugger and run `make debug-kms-down` to stop the environment. +If you are finished stop the debugger and run `make compose-debug-down` to stop the environment. ## Quantumlayer @@ -272,7 +273,7 @@ used as quantum modules. #### Start and Stop By running `make compose-up` and `make compose-down` the setup can be started -or stopped with its default config. +or stopped with its default config. Please note that you need access to private QKDN repos to do this. If you don"t have this access, you can use the small examples in `/dev_env_data`. The default config is based on the configuration files provided in the [config/goKMS](config/goKMS) and [config/quantumlayer](config/quantumlayer) folder. @@ -338,6 +339,16 @@ Below is a short demo video of this setup in combination with the  +## Integration Tests + +Everything needed for the integration tests is found in the `integration-tests` folder. +You can run them by simply using `make integration-tests` in the project root. + +If you need to debug the integration tests you can use vscode and provided configurations. +Open the integration test file you want to debug and set your breakpoints in the test and the kms code (a breakpoint before the tests add the devices to the controller is nearly always required), then go to VSCodes debug tab and start `Debug open integration test and kms`. +After all images are build and started wait around 25 seconds before starting to progress through the test. +You can switch between stepping through the test and each kms. Stepping through the quantum layer, controller, routing app and akms-simulator is currently not supported. + ## Contributing Contributions are welcome! Please follow these guidelines: diff --git a/akms-simulator/Dockerfile b/akms-simulator/Dockerfile index ac63780cea52e95b98c29f21bc878f075278aed0..5e906fda6c66a3c925608257e33a4baac44fbc67 100644 --- a/akms-simulator/Dockerfile +++ b/akms-simulator/Dockerfile @@ -2,7 +2,7 @@ ARG GOLANG_VERSION=1.22 ARG BUILDARGS ARG GITLAB_PROXY -FROM ${GITLAB_PROXY}golang:$GOLANG_VERSION-bookworm as builder +FROM ${GITLAB_PROXY}golang:$GOLANG_VERSION-bookworm AS builder RUN apt-get update && apt-get upgrade -y WORKDIR /app/ @@ -11,7 +11,7 @@ RUN --mount=type=cache,target=/root/go/pkg/mod \ --mount=type=cache,target=/root/.cache/go-build \ make build-akms-simulator -FROM ${GITLAB_PROXY}debian:12-slim as debian +FROM ${GITLAB_PROXY}debian:12-slim AS debian RUN apt-get update && apt-get upgrade -y COPY --from=builder app/artifacts/akms-simulator /usr/bin/akms-simulator diff --git a/config/controller/add_devices.sh b/config/controller/add_devices.sh new file mode 100755 index 0000000000000000000000000000000000000000..e91aae019f56cdf793dcb1db79a00ccfa062c549 --- /dev/null +++ b/config/controller/add_devices.sh @@ -0,0 +1,30 @@ +#!/bin/sh + +## Note: This script does not clean up network elements already existing in the storage. Running it repeatedly will +## create a garbage storage. + +GOSDNC_PATH="./artifacts/gosdnc" +GOSDN_ADDRESS="127.0.0.1:55055" +ADMINPW="TestPassword" +KMS_PLUGIN="823aad29-69be-42f0-b279-90f2c1b6a94d" +PND_UUID="5f20f34b-cbd0-4511-9ddc-c50cf6a3b49d" +## Adjust this if timer is to short. +SLEEP_TIMER=20 + +echo 'Logging in via gosdnc and setting up KMS in controller...' + +## Sleep is needed to give gosdn some time to start correctly. +echo "Sleeping for $SLEEP_TIMER before starting" +sleep $SLEEP_TIMER + +# TODO: Add --tls when adding certs to this! + +## Call login and create entries for all the network elements. +## Could be a bit more automated in the future, but fine for now. +$GOSDNC_PATH login --controller $GOSDN_ADDRESS --u admin --p $ADMINPW +$GOSDNC_PATH pnd use $PND_UUID + +$GOSDNC_PATH mne create --address "kms01:7030" --name kms01 --password admin --plugin-id $KMS_PLUGIN --username admin --uuid 0ff33c82-7fe1-482b-a0ca-67565806ee4b +$GOSDNC_PATH mne create --address "kms02:7030" --name kms02 --password admin --plugin-id $KMS_PLUGIN --username admin --uuid 5e41c291-6121-4335-84f6-41e04b8bdaa2 +$GOSDNC_PATH mne create --address "kms03:7030" --name kms03 --password admin --plugin-id $KMS_PLUGIN --username admin --uuid f80db2c0-2480-46b9-b7d1-b63f954e8227 +$GOSDNC_PATH mne create --address "kms04:7030" --name kms03 --password admin --plugin-id $KMS_PLUGIN --username admin --uuid 968fd594-b0e7-41f0-ba4b-de259047a933 diff --git a/config/controller/add_devices_no_sleep.sh b/config/controller/add_devices_no_sleep.sh new file mode 100755 index 0000000000000000000000000000000000000000..2b9418e2008a05d54f8a8fa373cdb012e4eb5185 --- /dev/null +++ b/config/controller/add_devices_no_sleep.sh @@ -0,0 +1,24 @@ +#!/bin/sh + +## Note: This script does not clean up network elements already existing in the storage. Running it repeatedly will +## create a garbage storage. + +GOSDNC_PATH="./artifacts/gosdnc" +GOSDN_ADDRESS="127.0.0.1:55055" +ADMINPW="TestPassword" +KMS_PLUGIN="823aad29-69be-42f0-b279-90f2c1b6a94d" +PND_UUID="5f20f34b-cbd0-4511-9ddc-c50cf6a3b49d" + +echo 'Logging in via gosdnc and setting up KMS in controller...' + +# TODO: Add --tls when adding certs to this! + +## Call login and create entries for all the network elements. +## Could be a bit more automated in the future, but fine for now. +$GOSDNC_PATH login --controller $GOSDN_ADDRESS --u admin --p $ADMINPW +$GOSDNC_PATH pnd use $PND_UUID + +$GOSDNC_PATH mne create --address "kms01:7030" --name kms01 --password admin --plugin-id $KMS_PLUGIN --username admin --uuid 0ff33c82-7fe1-482b-a0ca-67565806ee4b +$GOSDNC_PATH mne create --address "kms02:7030" --name kms02 --password admin --plugin-id $KMS_PLUGIN --username admin --uuid 5e41c291-6121-4335-84f6-41e04b8bdaa2 +$GOSDNC_PATH mne create --address "kms03:7030" --name kms03 --password admin --plugin-id $KMS_PLUGIN --username admin --uuid f80db2c0-2480-46b9-b7d1-b63f954e8227 +$GOSDNC_PATH mne create --address "kms04:7030" --name kms03 --password admin --plugin-id $KMS_PLUGIN --username admin --uuid 968fd594-b0e7-41f0-ba4b-de259047a933 diff --git a/config/controller/gNMISubscriptions.txt b/config/controller/gNMISubscriptions.txt new file mode 100644 index 0000000000000000000000000000000000000000..2f8ab7957d2c410cc8bf3324dd66c8cde753941d --- /dev/null +++ b/config/controller/gNMISubscriptions.txt @@ -0,0 +1 @@ +create-route-requests \ No newline at end of file diff --git a/config/controller/qkdn-gosdn.toml b/config/controller/qkdn-gosdn.toml new file mode 100644 index 0000000000000000000000000000000000000000..e3c275e1c2101b7707366774681d4ba6a8370934 --- /dev/null +++ b/config/controller/qkdn-gosdn.toml @@ -0,0 +1,19 @@ +amqphost = 'rabbitmq' +amqppassword = 'guest' +amqpport = '5672' +amqpprefix = 'amqp://' +amqpuser = 'guest' +basepnduuid = '5f20f34b-cbd0-4511-9ddc-c50cf6a3b49d' +config = './configs/qkdn-gosdn.toml' +csbi-orchestrator = 'localhost:55056' +databaseconnection = 'mongodb://root:example@mongodb:27017' +defaultjwtduration = 24 +filesystempathtostores = 'stores' +gnmisubscriptionspath = 'configs/gNMISubscriptions.txt' +help = false +log-level = 'debug' +nogrpcpassthrough = false +plugin-folder = 'plugins' +plugin-registry = 'plugin-registry:55057' +security = 'secure' +socket = ':55055' diff --git a/config/controller/routing-config.yaml b/config/controller/routing-config.yaml new file mode 100644 index 0000000000000000000000000000000000000000..4611c0842c061d85da88297ca962889d04a66f37 --- /dev/null +++ b/config/controller/routing-config.yaml @@ -0,0 +1,7 @@ +ControllerAddress: "qkdn-controller:55055" +PndID: "5f20f34b-cbd0-4511-9ddc-c50cf6a3b49d" +UserName: "admin" +UserPW: "TestPassword" +AppName: "dq-routing" +RegistrationToken: "SecurePresharedToken" +GrpcAddress: ":54321" diff --git a/config/controller/start_ra_sleep.sh b/config/controller/start_ra_sleep.sh new file mode 100755 index 0000000000000000000000000000000000000000..00d2d57d37cd4e1649c16ec00f3943c47c45497d --- /dev/null +++ b/config/controller/start_ra_sleep.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +echo "Sleeping for 10 before starting" +sleep 10 +echo "Done sleeping" +./routing --config /new/routing-config.yaml diff --git a/config/goKMS/example01.yaml b/config/goKMS/example01.yaml index e3b918260c63e4d2ca1e26cd832acd65f577cf5e..30950bfbfcfc330fed3d93917971ffdf06c7c2f2 100644 --- a/config/goKMS/example01.yaml +++ b/config/goKMS/example01.yaml @@ -1,9 +1,11 @@ Id: "0ff33c82-7fe1-482b-a0ca-67565806ee4b" Name: kms01 -InterComAddr: 172.100.20.10:50910 -QuantumAddr: 172.100.20.10:50911 -AkmsURL: "http://172.100.20.22:4444/api/v1/keys/push_ksa_key" +InterComAddr: 0.0.0.0:50910 +QuantumAddr: 0.0.0.0:50911 +GRPCAddr: 0.0.0.0:50900 +AkmsURL: "http://akms-receiver01:4444/api/v1/keys/push_ksa_key" AkmsCkmsServerPort: "9696" +GRPCTimeoutInSeconds: 600 KmsTLS: TLS: false CAFile: "ssl/ca.crt" @@ -17,20 +19,22 @@ QuantumModuleTLS: Peers: # peer to kms02 - PeerId: "5e41c291-6121-4335-84f6-41e04b8bdaa2" - PeerInterComAddr: 172.100.20.11:50910 + PeerInterComAddr: kms02:50910 + Sync: true Type: danet # quantum module of type emulated at the given address QuantumModule: Type: emulated - Address: 172.100.20.14 + Hostname: qlayer01 # peer to kms03 - PeerId: "f80db2c0-2480-46b9-b7d1-b63f954e8227" - PeerInterComAddr: 172.100.20.12:50910 + PeerInterComAddr: kms03:50910 + Sync: false Type: danet # quantum module of type emulated at the given address QuantumModule: Type: emulated - Address: 172.100.20.18 + Hostname: qlayer05 QkdnManagerServer: Address: ":8090" ETSI14Server: diff --git a/config/goKMS/example02.yaml b/config/goKMS/example02.yaml index d1d37160ad488a1a1239c179a223c62261de1f8a..f99a774eb1f385c570589923349b2773bfbeff14 100644 --- a/config/goKMS/example02.yaml +++ b/config/goKMS/example02.yaml @@ -1,7 +1,9 @@ Id: "5e41c291-6121-4335-84f6-41e04b8bdaa2" Name: kms02 -InterComAddr: 172.100.20.11:50910 -QuantumAddr: 172.100.20.11:50911 +InterComAddr: 0.0.0.0:50910 +QuantumAddr: 0.0.0.0:50911 +GRPCAddr: 0.0.0.0:50900 +GRPCTimeoutInSeconds: 600 KmsTLS: TLS: false CAFile: "ssl/ca.crt" @@ -15,19 +17,21 @@ QuantumModuleTLS: Peers: # peer to kms01 - PeerId: "0ff33c82-7fe1-482b-a0ca-67565806ee4b" - PeerInterComAddr: 172.100.20.10:50910 + PeerInterComAddr: kms01:50910 + Sync: false Type: danet # quantum module of type emulated at the given address QuantumModule: Type: emulated - Address: 172.100.20.15 + Hostname: qlayer02 # peer to kms04 - PeerId: "968fd594-b0e7-41f0-ba4b-de259047a933" - PeerInterComAddr: 172.100.20.13:50910 + PeerInterComAddr: kms04:50910 + Sync: true Type: danet # quantum module of type emulated at the given address QuantumModule: Type: emulated - Address: 172.100.20.16 + Hostname: qlayer03 QkdnManagerServer: Address: ":8090" diff --git a/config/goKMS/example03.yaml b/config/goKMS/example03.yaml index f1a31603c0f3f4fd5091adc19c36d84679de0113..fdf66fe2e2cf7b2418d7a757e466fc237b054640 100644 --- a/config/goKMS/example03.yaml +++ b/config/goKMS/example03.yaml @@ -1,7 +1,9 @@ Id: "f80db2c0-2480-46b9-b7d1-b63f954e8227" Name: kms03 -InterComAddr: 172.100.20.12:50910 -QuantumAddr: 172.100.20.12:50911 +InterComAddr: 0.0.0.0:50910 +QuantumAddr: 0.0.0.0:50911 +GRPCAddr: 0.0.0.0:50900 +GRPCTimeoutInSeconds: 600 KmsTLS: TLS: false CAFile: "ssl/ca.crt" @@ -15,19 +17,21 @@ QuantumModuleTLS: Peers: # peer to kms01 - PeerId: "0ff33c82-7fe1-482b-a0ca-67565806ee4b" - PeerInterComAddr: 172.100.20.10:50910 + PeerInterComAddr: kms01:50910 + Sync: true Type: danet # quantum module of type emulated at the given address QuantumModule: Type: emulated - Address: 172.100.20.19 + Hostname: qlayer06 # peer to kms04 - PeerId: "968fd594-b0e7-41f0-ba4b-de259047a933" - PeerInterComAddr: 172.100.20.13:50910 + PeerInterComAddr: kms04:50910 + Sync: true Type: danet # quantum module of type emulated at the given address QuantumModule: Type: emulated - Address: 172.100.20.20 + Hostname: qlayer07 QkdnManagerServer: Address: ":8090" diff --git a/config/goKMS/example04.yaml b/config/goKMS/example04.yaml index 7e6b79b57ddf7db0f6ce1f24c8d7f0c78a8749a0..a52d54843e90bed22866ec0a8fcf88b34e85de62 100644 --- a/config/goKMS/example04.yaml +++ b/config/goKMS/example04.yaml @@ -1,9 +1,11 @@ Id: "968fd594-b0e7-41f0-ba4b-de259047a933" Name: kms04 -InterComAddr: 172.100.20.13:50910 -QuantumAddr: 172.100.20.13:50911 -AkmsURL: "http://172.100.20.23:4444/api/v1/keys/push_ksa_key" +InterComAddr: 0.0.0.0:50910 +QuantumAddr: 0.0.0.0:50911 +GRPCAddr: 0.0.0.0:50900 +AkmsURL: "http://akms-receiver02:4444/api/v1/keys/push_ksa_key" AkmsCkmsServerPort: "9696" +GRPCTimeoutInSeconds: 600 KmsTLS: TLS: false CAFile: "ssl/ca.crt" @@ -17,20 +19,22 @@ QuantumModuleTLS: Peers: # peer to kms02 - PeerId: "5e41c291-6121-4335-84f6-41e04b8bdaa2" - PeerInterComAddr: 172.100.20.11:50910 + PeerInterComAddr: kms02:50910 + Sync: false Type: danet # quantum module of type emulated at the given address QuantumModule: Type: emulated - Address: 172.100.20.17 + Hostname: qlayer04 # peer to kms03 - PeerId: "f80db2c0-2480-46b9-b7d1-b63f954e8227" - PeerInterComAddr: 172.100.20.12:50910 + PeerInterComAddr: kms03:50910 + Sync: false Type: danet # quantum module of type emulated at the given address QuantumModule: Type: emulated - Address: 172.100.20.21 + Hostname: qlayer08 QkdnManagerServer: Address: ":8090" ETSI14Server: diff --git a/config/quantumlayer/example01.yaml b/config/quantumlayer/example01.yaml index 8aeea7af2f4ac1500733fc4311b45943c96445a2..2d2c55049973b01dc0e65a783c5c9fb3f0709d57 100644 --- a/config/quantumlayer/example01.yaml +++ b/config/quantumlayer/example01.yaml @@ -1 +1 @@ -KMSAddr: '172.100.20.10:50911' +KMSAddr: 'kms01:50911' diff --git a/config/quantumlayer/example02.yaml b/config/quantumlayer/example02.yaml index f217b96b3287c12f85b96f8dddc28571ca9f7b0f..b569dcec9c797fae80d25e12f3d900cc4ee911d3 100644 --- a/config/quantumlayer/example02.yaml +++ b/config/quantumlayer/example02.yaml @@ -1 +1 @@ -KMSAddr: '172.100.20.11:50911' +KMSAddr: 'kms02:50911' diff --git a/config/quantumlayer/example03.yaml b/config/quantumlayer/example03.yaml index f217b96b3287c12f85b96f8dddc28571ca9f7b0f..b569dcec9c797fae80d25e12f3d900cc4ee911d3 100644 --- a/config/quantumlayer/example03.yaml +++ b/config/quantumlayer/example03.yaml @@ -1 +1 @@ -KMSAddr: '172.100.20.11:50911' +KMSAddr: 'kms02:50911' diff --git a/config/quantumlayer/example04.yaml b/config/quantumlayer/example04.yaml index e816a74cb07efd0365fb9f37dcf03df51d892927..c5d0dc9f28c970e3eb97cc6089e351ad4083acda 100644 --- a/config/quantumlayer/example04.yaml +++ b/config/quantumlayer/example04.yaml @@ -1 +1 @@ -KMSAddr: '172.100.20.13:50911' +KMSAddr: 'kms04:50911' diff --git a/config/quantumlayer/example05.yaml b/config/quantumlayer/example05.yaml index 8aeea7af2f4ac1500733fc4311b45943c96445a2..2d2c55049973b01dc0e65a783c5c9fb3f0709d57 100644 --- a/config/quantumlayer/example05.yaml +++ b/config/quantumlayer/example05.yaml @@ -1 +1 @@ -KMSAddr: '172.100.20.10:50911' +KMSAddr: 'kms01:50911' diff --git a/config/quantumlayer/example06.yaml b/config/quantumlayer/example06.yaml index 8dbb2b6bea674f78dfe55f272ca560e3b5957358..f499e9fc11eb867648c7bd5b7163e2452199d1b0 100644 --- a/config/quantumlayer/example06.yaml +++ b/config/quantumlayer/example06.yaml @@ -1 +1 @@ -KMSAddr: '172.100.20.12:50911' +KMSAddr: 'kms03:50911' diff --git a/config/quantumlayer/example07.yaml b/config/quantumlayer/example07.yaml index 8dbb2b6bea674f78dfe55f272ca560e3b5957358..f499e9fc11eb867648c7bd5b7163e2452199d1b0 100644 --- a/config/quantumlayer/example07.yaml +++ b/config/quantumlayer/example07.yaml @@ -1 +1 @@ -KMSAddr: '172.100.20.12:50911' +KMSAddr: 'kms03:50911' diff --git a/config/quantumlayer/example08.yaml b/config/quantumlayer/example08.yaml index e816a74cb07efd0365fb9f37dcf03df51d892927..c5d0dc9f28c970e3eb97cc6089e351ad4083acda 100644 --- a/config/quantumlayer/example08.yaml +++ b/config/quantumlayer/example08.yaml @@ -1 +1 @@ -KMSAddr: '172.100.20.13:50911' +KMSAddr: 'kms04:50911' diff --git a/dev_env_data/containerlab/playground.clab.yaml b/dev_env_data/containerlab/playground.clab.yaml deleted file mode 100644 index 03fbfd580f8f27c5dd5ba4c491149426de02e9fb..0000000000000000000000000000000000000000 --- a/dev_env_data/containerlab/playground.clab.yaml +++ /dev/null @@ -1,175 +0,0 @@ -name: quant_playground - -mgmt: - network: quant_playground_net - ipv4-subnet: 172.100.20.0/24 - -topology: - nodes: - gosdn: - kind: linux - image: registry.code.fbi.h-da.de/danet/gosdn:latest - ports: - - 55055:55055 - - 8080:8080 - - 40000:40000 - binds: - - ../../config/quant-gosdn.toml:/app/configs/quant-gosdn.toml - cmd: --config ./configs/quant-gosdn.toml - mgmt-ipv4: 172.100.20.2 - env: - GOSDN_ADMIN_PASSWORD: TestPassword - - plugin-registry: - kind: linux - image: registry.code.fbi.h-da.de/danet/quant/plugin-registry:latest - mgmt-ipv4: 172.100.20.3 - - gosdnc: - kind: linux - image: registry.code.fbi.h-da.de/danet/gosdn/gosdnc:latest - mgmt-ipv4: 172.100.20.4 - binds: - - ../../config/kms01-a.json:/kms01-a.json - - ../../config/kms02-a.json:/kms02-a.json - - ../../config/kms03-a.json:/kms03-a.json - - ../../config/kms01-b.json:/kms01-b.json - - ../../config/kms02-b.json:/kms02-b.json - - ../../config/kms03-b.json:/kms03-b.json - - ../../config/scripts/add_kms_and_user_to_controller.sh:/scripts/add_kms_and_user_to_controller.sh - exec: - - bash /scripts/add_kms_and_user_to_controller.sh - - kms1: - kind: linux - image: registry.code.fbi.h-da.de/danet/quant/gokms:latest - mgmt-ipv4: 172.100.20.10 - binds: - - ../../config/goKMS/example01.yaml:/tmp/kms/config/kms01.yaml - cmd: --log debug --kms_config /tmp/kms/config/kms01.yaml - - kms2: - kind: linux - image: registry.code.fbi.h-da.de/danet/quant/gokms:latest - mgmt-ipv4: 172.100.20.11 - binds: - - ../../config/goKMS/example02.yaml:/tmp/kms/config/kms02.yaml - cmd: --log debug --kms_config /tmp/kms/config/kms02.yaml - - kms3: - kind: linux - image: registry.code.fbi.h-da.de/danet/quant/gokms:latest - mgmt-ipv4: 172.100.20.12 - binds: - - ../../config/goKMS/example03.yaml:/tmp/kms/config/kms03.yaml - cmd: --log debug --kms_config /tmp/kms/config/kms03.yaml - - kms4: - kind: linux - image: registry.code.fbi.h-da.de/danet/quant/gokms:latest - mgmt-ipv4: 172.100.20.13 - binds: - - ../../config/goKMS/example04.yaml:/tmp/kms/config/kms04.yaml - cmd: --log debug --kms_config /tmp/kms/config/kms04.yaml - - qlayer01: - kind: linux - image: registry.code.fbi.h-da.de/danet/quant/quantumlayer:master - mgmt-ipv4: 172.100.20.14 - binds: - - ../../config/quantumlayer/example01.yaml:/tmp/quantumlayer/config/quantumlayer01.yaml - cmd: --config /tmp/quantumlayer/config/quantumlayer01.yaml - - qlayer02: - kind: linux - image: registry.code.fbi.h-da.de/danet/quant/quantumlayer:master - mgmt-ipv4: 172.100.20.15 - binds: - - ../../config/quantumlayer/example02.yaml:/tmp/quantumlayer/config/quantumlayer02.yaml - cmd: --config /tmp/quantumlayer/config/quantumlayer02.yaml - - qlayer03: - kind: linux - image: registry.code.fbi.h-da.de/danet/quant/quantumlayer:master - mgmt-ipv4: 172.100.20.16 - binds: - - ../../config/quantumlayer/example03.yaml:/tmp/quantumlayer/config/quantumlayer03.yaml - cmd: --config /tmp/quantumlayer/config/quantumlayer03.yaml - - qlayer04: - kind: linux - image: registry.code.fbi.h-da.de/danet/quant/quantumlayer:master - mgmt-ipv4: 172.100.20.17 - binds: - - ../../config/quantumlayer/example04.yaml:/tmp/quantumlayer/config/quantumlayer04.yaml - cmd: --config /tmp/quantumlayer/config/quantumlayer04.yaml - - qlayer05: - kind: linux - image: registry.code.fbi.h-da.de/danet/quant/quantumlayer:master - mgmt-ipv4: 172.100.20.18 - binds: - - ../../config/quantumlayer/example05.yaml:/tmp/quantumlayer/config/quantumlayer05.yaml - cmd: --config /tmp/quantumlayer/config/quantumlayer05.yaml - - qlayer06: - kind: linux - image: registry.code.fbi.h-da.de/danet/quant/quantumlayer:master - mgmt-ipv4: 172.100.20.19 - binds: - - ../../config/quantumlayer/example06.yaml:/tmp/quantumlayer/config/quantumlayer06.yaml - cmd: --config /tmp/quantumlayer/config/quantumlayer06.yaml - - qlayer07: - kind: linux - image: registry.code.fbi.h-da.de/danet/quant/quantumlayer:master - mgmt-ipv4: 172.100.20.20 - binds: - - ../../config/quantumlayer/example07.yaml:/tmp/quantumlayer/config/quantumlayer07.yaml - cmd: --config /tmp/quantumlayer/config/quantumlayer07.yaml - - qlayer08: - kind: linux - image: registry.code.fbi.h-da.de/danet/quant/quantumlayer:master - mgmt-ipv4: 172.100.20.21 - binds: - - ../../config/quantumlayer/example08.yaml:/tmp/quantumlayer/config/quantumlayer08.yaml - cmd: --config /tmp/quantumlayer/config/quantumlayer08.yaml - - akms-receiver-01: - kind: linux - image: registry.code.fbi.h-da.de/danet/quant/akms-simulator:master - mgmt-ipv4: 172.100.20.22 - - akms-receiver-02: - kind: linux - image: registry.code.fbi.h-da.de/danet/quant/akms-simulator:master - mgmt-ipv4: 172.100.20.23 - - mongodb: - kind: linux - image: mongo:7 - ports: - - 27017:27017 - env: - MONGO_INITDB_ROOT_USERNAME: root - MONGO_INITDB_ROOT_PASSWORD: example - mgmt-ipv4: 172.100.20.24 - - rabbitmq: - kind: linux - image: rabbitmq:3-management - ports: - - 127.0.0.1:5672:5672 - - 127.0.0.1:15672:15672 - mgmt-ipv4: 172.100.20.25 - - links: - - endpoints: ["kms1:eth1", "kms2:eth1"] - - endpoints: ["kms2:eth2", "kms3:eth1"] - - endpoints: ["qlayer01:eth1", "qlayer02:eth1"] - - endpoints: ["qlayer03:eth1", "qlayer04:eth1"] - - endpoints: ["qlayer01:eth2", "kms1:eth2"] - - endpoints: ["qlayer02:eth2", "kms2:eth3"] - - endpoints: ["qlayer03:eth2", "kms2:eth4"] - - endpoints: ["qlayer04:eth2", "kms3:eth2"] diff --git a/dev_env_data/debug_configs/config/kms/generate-debug-certs.sh b/dev_env_data/debug_configs/config/kms/generate-debug-certs.sh deleted file mode 100755 index 5270a6f1b1eef25ace4d9bd39b1636a9dabc0b36..0000000000000000000000000000000000000000 --- a/dev_env_data/debug_configs/config/kms/generate-debug-certs.sh +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/sh -dirPath="artifacts/ssl" - -if [ ! -d "${dirPath}/debug-kms" ]; then - mkdir $dirPath/debug-kms - counter=1 - for FILE in dev_env_data/debug_configs/config/kms/tlsConfigs/*.txt; - do openssl req -x509 -nodes -days 365 -newkey rsa:4096 -config $FILE \ - -CA $dirPath/ca.crt -CAkey $dirPath/ca.key \ - -keyout "$dirPath/debug-kms/kms$counter-selfsigned.key" -out "$dirPath/debug-kms/kms$counter-selfsigned.crt"; \ - openssl x509 -in "$dirPath/debug-kms/kms$counter-selfsigned.crt" -noout -text - counter=$((counter+1)); - done - fi - diff --git a/dev_env_data/debug_configs/config/kms/kms_1.json b/dev_env_data/debug_configs/config/kms/kms_1.json deleted file mode 100644 index 65c46e12e6f7734817a494001ca9c5fcc45dd46a..0000000000000000000000000000000000000000 --- a/dev_env_data/debug_configs/config/kms/kms_1.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "path-id": "38e0588b-6a2d-42c9-85a0-887cc877c299", - "next-hop": { - "node-id": "5e41c291-6121-4335-84f6-41e04b8bdaa2", - "ip-address": "kms_2", - "port": 50910 - }, - "initiating-kms-address": { - "initiating-kms-ip": "kms_2", - "initiating-kms-port": 50910 - } -} diff --git a/dev_env_data/debug_configs/config/kms/kms_1.yaml b/dev_env_data/debug_configs/config/kms/kms_1.yaml deleted file mode 100644 index 3be024c2d425380fd6aab156243f7712b6d10adf..0000000000000000000000000000000000000000 --- a/dev_env_data/debug_configs/config/kms/kms_1.yaml +++ /dev/null @@ -1,23 +0,0 @@ -Id: '0ff33c82-7fe1-482b-a0ca-67565806ee4b' -Name: kms_1 -InterComAddr: 0.0.0.0:50910 -GRPCAddr: 127.0.0.1:50900 -QuantumAddr: 0.0.0.0:50911 -AkmsURL: "http://127.0.0.1:4444/api/v1/keys/push_ksa_key" -AkmsCkmsServerPort: "9696" -KmsTLS: - TLS: true - CAFile: "../artifacts/ssl/ca.crt" - CertFile: "../artifacts/ssl/debug-kms/kms1-selfsigned.crt" - KeyFile: "../artifacts/ssl/debug-kms/kms1-selfsigned.key" -Peers: - # peer to kms_2 - - PeerId: '5e41c291-6121-4335-84f6-41e04b8bdaa2' - PeerInterComAddr: 127.0.0.1:51910 - Type: danet - # quantum module of type emulated at the given address - QuantumModule: - Type: emulated - Address: 172.200.20.20 -QkdnManagerServer: - Address: ":8090" diff --git a/dev_env_data/debug_configs/config/kms/kms_2.json b/dev_env_data/debug_configs/config/kms/kms_2.json deleted file mode 100644 index d8d510d3188933a02e035b0697336f2f1290e744..0000000000000000000000000000000000000000 --- a/dev_env_data/debug_configs/config/kms/kms_2.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "path-id": "38e0588b-6a2d-42c9-85a0-887cc877c299", - "prev-hop": { - "node-id": "0ff33c82-7fe1-482b-a0ca-67565806ee4b", - "ip-address": "kms_1", - "port": 50910 - }, - "initiating-kms-address": { - "initiating-kms-ip": "kms_1", - "initiating-kms-port": 50910 - } -} diff --git a/dev_env_data/debug_configs/config/kms/kms_2.yaml b/dev_env_data/debug_configs/config/kms/kms_2.yaml deleted file mode 100644 index fb8834357f5bbfb1f627707b4ecf8a4f724eca39..0000000000000000000000000000000000000000 --- a/dev_env_data/debug_configs/config/kms/kms_2.yaml +++ /dev/null @@ -1,23 +0,0 @@ -Id: '5e41c291-6121-4335-84f6-41e04b8bdaa2' -Name: kms_2 -InterComAddr: 0.0.0.0:50910 -GRPCAddr: 0.0.0.0:50900 -QuantumAddr: 0.0.0.0:50911 -AkmsURL: "http://akms-simulator_2:4444/api/v1/keys/push_ksa_key" -AkmsCkmsServerPort: "9696" -KmsTLS: - TLS: true - CAFile: "ssl/ca.crt" - CertFile: "ssl/debug-kms/kms2-selfsigned.crt" - KeyFile: "ssl/debug-kms/kms2-selfsigned.key" -Peers: - # peer to kms_1 - - PeerId: '0ff33c82-7fe1-482b-a0ca-67565806ee4b' - PeerInterComAddr: 172.18.0.1:50910 - Type: danet - # quantum module of type emulated at the given address - QuantumModule: - Type: emulated - Hostname: quantumlayer_2 -QkdnManagerServer: - Address: ":8090" diff --git a/dev_env_data/debug_configs/config/kms/tlsConfigs/ekms01ReqConfig.txt b/dev_env_data/debug_configs/config/kms/tlsConfigs/ekms01ReqConfig.txt deleted file mode 100644 index 2aee4a01faaffa3d9f9530ded5d6b7cf14e99bb3..0000000000000000000000000000000000000000 --- a/dev_env_data/debug_configs/config/kms/tlsConfigs/ekms01ReqConfig.txt +++ /dev/null @@ -1,17 +0,0 @@ -[req] -default_bits = 4096 -default_md = sha256 -distinguished_name = req_distinguished_name -x509_extensions = v3_req -prompt = no -[req_distinguished_name] -C = DE -O = H_DA -CN = kms_1 -[v3_req] -keyUsage = keyEncipherment, dataEncipherment -extendedKeyUsage = serverAuth, clientAuth -subjectAltName = @alt_names -[alt_names] -IP.1 = 172.18.0.1 -IP.2 = 172.200.20.1 diff --git a/dev_env_data/debug_configs/config/kms/tlsConfigs/ekms02ReqConfig.txt b/dev_env_data/debug_configs/config/kms/tlsConfigs/ekms02ReqConfig.txt deleted file mode 100644 index e3628496f3704e6fa9ad4d979ddd5f2e5f3c010e..0000000000000000000000000000000000000000 --- a/dev_env_data/debug_configs/config/kms/tlsConfigs/ekms02ReqConfig.txt +++ /dev/null @@ -1,17 +0,0 @@ -[req] -default_bits = 4096 -default_md = sha256 -distinguished_name = req_distinguished_name -x509_extensions = v3_req -prompt = no -[req_distinguished_name] -C = DE -O = H_DA -CN = kms_2 -[v3_req] -keyUsage = keyEncipherment, dataEncipherment -extendedKeyUsage = serverAuth, clientAuth -subjectAltName = @alt_names -[alt_names] -IP.1 = 127.0.0.1 -IP.2 = 172.200.20.12 diff --git a/dev_env_data/debug_configs/config/quantumlayer/quantumlayer_1.yaml b/dev_env_data/debug_configs/config/quantumlayer/quantumlayer_1.yaml deleted file mode 100644 index cd6e9f54eca38cc06143fe93bd5326a519fe9479..0000000000000000000000000000000000000000 --- a/dev_env_data/debug_configs/config/quantumlayer/quantumlayer_1.yaml +++ /dev/null @@ -1 +0,0 @@ -KMSAddr: 'host.docker.internal:50911' diff --git a/dev_env_data/debug_configs/config/quantumlayer/quantumlayer_2.yaml b/dev_env_data/debug_configs/config/quantumlayer/quantumlayer_2.yaml deleted file mode 100644 index df8fec42cdc8c0dab2fdfb68cc0be7220d99ed21..0000000000000000000000000000000000000000 --- a/dev_env_data/debug_configs/config/quantumlayer/quantumlayer_2.yaml +++ /dev/null @@ -1 +0,0 @@ -KMSAddr: 'kms_2:50911' diff --git a/docker-compose.override.debug.yml b/docker-compose.override.debug.yml new file mode 100644 index 0000000000000000000000000000000000000000..be1b072847190b69737ecd37570e7e43f957acb8 --- /dev/null +++ b/docker-compose.override.debug.yml @@ -0,0 +1,24 @@ +services: + kms01: + image: gokms_debug + entrypoint: ["/usr/bin/dlv", "--listen=0.0.0.0:1337", "--headless=true", "--api-version=2", "exec", "/usr/bin/goKMS", "--", "--log", "debug", "--kms_config", "/tmp/kms/config/kms01.yaml"] + ports: + - "127.0.0.1:4401:1337" + + kms02: + image: gokms_debug + entrypoint: ["/usr/bin/dlv", "--listen=0.0.0.0:1337", "--headless=true", "--api-version=2", "exec", "/usr/bin/goKMS", "--", "--log", "debug", "--kms_config", "/tmp/kms/config/kms02.yaml"] + ports: + - "127.0.0.1:4402:1337" + + kms03: + image: gokms_debug + entrypoint: ["/usr/bin/dlv", "--listen=0.0.0.0:1337", "--headless=true", "--api-version=2", "exec", "/usr/bin/goKMS", "--", "--log", "debug", "--kms_config", "/tmp/kms/config/kms03.yaml"] + ports: + - "127.0.0.1:4403:1337" + + kms04: + image: gokms_debug + entrypoint: ["/usr/bin/dlv", "--listen=0.0.0.0:1337", "--headless=true", "--api-version=2", "exec", "/usr/bin/goKMS", "--", "--log", "debug", "--kms_config", "/tmp/kms/config/kms04.yaml"] + ports: + - "127.0.0.1:4404:1337" diff --git a/docker-compose.yml b/docker-compose.yml index e2cf0c11512b8de64ae7b046b30be4a86c663a5d..32355fb8cdc1d8074579e1d6e4bb62430ff3bc35 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,134 +1,128 @@ services: - kms_1: + kms01: image: gokms command: ["--log", "debug", "--kms_config", "/tmp/kms/config/kms01.yaml"] volumes: - ./config/goKMS/example01.yaml:/tmp/kms/config/kms01.yaml - ./artifacts/ssl:/ssl - networks: - kms-net: - ipv4_address: 172.100.20.10 + ports: + - "127.0.0.1:4401:1337" + - "127.0.0.1:9696:9696" - kms_2: + kms02: image: gokms command: ["--log", "debug", "--kms_config", "/tmp/kms/config/kms02.yaml"] volumes: - ./config/goKMS/example02.yaml:/tmp/kms/config/kms02.yaml - ./artifacts/ssl:/ssl - networks: - kms-net: - ipv4_address: 172.100.20.11 + ports: + - "127.0.0.1:4402:1337" - kms_3: + kms03: image: gokms command: ["--log", "debug", "--kms_config", "/tmp/kms/config/kms03.yaml"] volumes: - ./config/goKMS/example03.yaml:/tmp/kms/config/kms03.yaml - ./artifacts/ssl:/ssl - networks: - kms-net: - ipv4_address: 172.100.20.12 + ports: + - "127.0.0.1:4403:1337" - kms_4: + kms04: image: gokms command: ["--log", "debug", "--kms_config", "/tmp/kms/config/kms04.yaml"] volumes: - ./config/goKMS/example04.yaml:/tmp/kms/config/kms04.yaml - ./artifacts/ssl:/ssl - networks: - kms-net: - ipv4_address: 172.100.20.13 - + ports: + - "127.0.0.1:4404:1337" + - "127.0.0.1:9697:9696" qlayer01: image: quantumlayer command: ["--config", "/tmp/quantumlayer/config/quantumlayer01.yaml"] volumes: - ./config/quantumlayer/example01.yaml:/tmp/quantumlayer/config/quantumlayer01.yaml - networks: - kms-net: - ipv4_address: 172.100.20.14 qlayer02: image: quantumlayer command: ["--config", "/tmp/quantumlayer/config/quantumlayer02.yaml"] volumes: - ./config/quantumlayer/example02.yaml:/tmp/quantumlayer/config/quantumlayer02.yaml - networks: - kms-net: - ipv4_address: 172.100.20.15 qlayer03: image: quantumlayer command: ["--config", "/tmp/quantumlayer/config/quantumlayer03.yaml"] volumes: - ./config/quantumlayer/example03.yaml:/tmp/quantumlayer/config/quantumlayer03.yaml - networks: - kms-net: - ipv4_address: 172.100.20.16 qlayer04: image: quantumlayer command: ["--config", "/tmp/quantumlayer/config/quantumlayer04.yaml"] volumes: - ./config/quantumlayer/example04.yaml:/tmp/quantumlayer/config/quantumlayer04.yaml - networks: - kms-net: - ipv4_address: 172.100.20.17 qlayer05: image: quantumlayer command: ["--config", "/tmp/quantumlayer/config/quantumlayer05.yaml"] volumes: - ./config/quantumlayer/example05.yaml:/tmp/quantumlayer/config/quantumlayer05.yaml - networks: - kms-net: - ipv4_address: 172.100.20.18 qlayer06: image: quantumlayer command: ["--config", "/tmp/quantumlayer/config/quantumlayer06.yaml"] volumes: - ./config/quantumlayer/example06.yaml:/tmp/quantumlayer/config/quantumlayer06.yaml - networks: - kms-net: - ipv4_address: 172.100.20.19 qlayer07: image: quantumlayer command: ["--config", "/tmp/quantumlayer/config/quantumlayer07.yaml"] volumes: - ./config/quantumlayer/example07.yaml:/tmp/quantumlayer/config/quantumlayer07.yaml - networks: - kms-net: - ipv4_address: 172.100.20.20 qlayer08: image: quantumlayer command: ["--config", "/tmp/quantumlayer/config/quantumlayer08.yaml"] volumes: - ./config/quantumlayer/example08.yaml:/tmp/quantumlayer/config/quantumlayer08.yaml - networks: - kms-net: - ipv4_address: 172.100.20.21 akms-receiver01: image: akms-simulator - networks: - kms-net: - ipv4_address: 172.100.20.22 akms-receiver02: image: akms-simulator - networks: - kms-net: - ipv4_address: 172.100.20.23 - - -networks: - kms-net: - ipam: - driver: default - config: - - subnet: "172.100.20.0/24" - name: kms-net + + qkdn-controller: + image: registry.code.fbi.h-da.de/demoquandt/qkdn-controller:qkdn-main + volumes: + - ./config/controller/qkdn-gosdn.toml:/app/configs/qkdn-gosdn.toml + - ./config/controller/gNMISubscriptions.txt:/app/configs/gNMISubscriptions.txt + command: --config ./configs/qkdn-gosdn.toml + ports: + - "127.0.0.1:55055:55055" + environment: + GOSDN_ADMIN_PASSWORD: TestPassword + + gosdnc: + image: registry.code.fbi.h-da.de/demoquandt/qkdn-controller/gosdnc:qkdn-main + volumes: + - ./config/controller/add_devices.sh:/scripts/add_devices.sh + entrypoint: ["/scripts/add_devices.sh"] + + plugin-registry: + image: registry.code.fbi.h-da.de/demoquandt/qkdn-controller/plugin-registry:qkdn-main + + mongo: + image: mongo:7 + environment: + MONGO_INITDB_ROOT_USERNAME: root + MONGO_INITDB_ROOT_PASSWORD: example + + rabbitmq: + image: rabbitmq:3-management + + routing-app: + image: registry.code.fbi.h-da.de/demoquandt/qkdn-controller/routing-app:qkdn-main + entrypoint: ["./start_ra_sleep.sh"] + volumes: + - ./config/controller/start_ra_sleep.sh:/app/start_ra_sleep.sh + - ./config/controller/routing-config.yaml:/new/routing-config.yaml diff --git a/etsi14module/Dockerfile b/etsi14module/Dockerfile index d96da9fd8a1260399acb5a76214fd0fb9ebc98d6..5353cfb4ff7a3eced4a32eb561debe7bb21bef7a 100644 --- a/etsi14module/Dockerfile +++ b/etsi14module/Dockerfile @@ -2,8 +2,7 @@ ARG GOLANG_VERSION=1.22 ARG BUILDARGS ARG GITLAB_PROXY - -FROM ${GITLAB_PROXY}golang:$GOLANG_VERSION-bookworm as builder +FROM ${GITLAB_PROXY}golang:$GOLANG_VERSION-bookworm AS builder RUN apt-get update && apt-get upgrade -y WORKDIR /app/ diff --git a/goKMS/Dockerfile b/goKMS/Dockerfile index b35bc60a0694072ed6844a413d3310a16177f81a..3bf984ab7f66488250e301b3e48acb4cc711326d 100644 --- a/goKMS/Dockerfile +++ b/goKMS/Dockerfile @@ -2,7 +2,7 @@ ARG GOLANG_VERSION=1.22 ARG BUILDARGS ARG GITLAB_PROXY -FROM ${GITLAB_PROXY}golang:$GOLANG_VERSION-bookworm as builder +FROM ${GITLAB_PROXY}golang:${GOLANG_VERSION}-bookworm AS builder ARG GITLAB_LOGIN ARG GITLAB_TOKEN RUN echo "machine code.fbi.h-da.de login ${GITLAB_LOGIN} password ${GITLAB_TOKEN}" > ~/.netrc @@ -13,10 +13,22 @@ RUN --mount=type=cache,target=/root/go/pkg/mod \ --mount=type=cache,target=/root/.cache/go-build \ make build-gokms -FROM ${GITLAB_PROXY}debian:12-slim as debian +RUN go install github.com/go-delve/delve/cmd/dlv@latest + +FROM ${GITLAB_PROXY}debian:12-slim AS debug +RUN apt-get update && apt-get upgrade -y +COPY --from=builder /app/artifacts/goKMS /usr/bin/goKMS +COPY --from=builder /go/bin/dlv /usr/bin/dlv + +EXPOSE 7030 +EXPOSE 50910 +EXPOSE 1337 +ENTRYPOINT ["/usr/bin/dlv", "--listen=0.0.0.0:1337", "--headless=true", "--api-version=2", "run", "/usr/bin/goKMS"] + +FROM ${GITLAB_PROXY}debian:12-slim AS debian RUN apt-get update && apt-get upgrade -y COPY --from=builder app/artifacts/goKMS /usr/bin/goKMS EXPOSE 7030 -EXPOSE 50900 +EXPOSE 50910 ENTRYPOINT ["/usr/bin/goKMS"] diff --git a/goKMS/Dockerfile.debug b/goKMS/Dockerfile.debug deleted file mode 100644 index c459a6f8182df454bd18af22c4e5861468232a40..0000000000000000000000000000000000000000 --- a/goKMS/Dockerfile.debug +++ /dev/null @@ -1,25 +0,0 @@ -ARG GOLANG_VERSION=1.21 -ARG BUILDARGS - -FROM golang:$GOLANG_VERSION-bookworm as builder -ARG GITLAB_LOGIN -ARG GITLAB_TOKEN -RUN echo "machine code.fbi.h-da.de login ${GITLAB_LOGIN} password ${GITLAB_TOKEN}" > ~/.netrc -WORKDIR /app/ -COPY . . -RUN --mount=type=cache,target=/root/go/pkg/mod \ - --mount=type=cache,target=/root/.cache/go-build -RUN go install github.com/go-delve/delve/cmd/dlv@v1.20.2 -RUN make kms-build-debug - -FROM debian:12 as debian -EXPOSE 7030 -WORKDIR /debug/ -RUN apt-get update && apt-get upgrade -y -RUN apt-get install -y iproute2 -RUN apt-get install -y iputils-ping -RUN apt-get install -y openssh-client openssh-server -RUN apt-get install -y libssl-dev -COPY --from=builder /go/bin/dlv /debug/ -COPY --from=builder /app/artifacts/kms /debug/ -CMD [ "/debug/dlv", "--listen=:4000", "--headless=true", "--log=true", "--accept-multiclient", "--api-version=2", "exec", "/debug/kms", "start" ] diff --git a/goKMS/config/config.go b/goKMS/config/config.go index 6292e3475b01ad2673cb775dfcaf1cf2e0457b3e..7b9aadc9b9ca5149b63bf577875ea6f00facae8d 100644 --- a/goKMS/config/config.go +++ b/goKMS/config/config.go @@ -2,21 +2,26 @@ package config import "github.com/google/uuid" +const ( + DefaultGRPCTimeoutInSeconds = 10 +) + type Config struct { - Id string `yaml:"Id"` - Name string `yaml:"Name"` - InterComAddr string `yaml:"InterComAddr"` - QuantumAddr string `yaml:"QuantumAddr"` - AkmsURL string `yaml:"AkmsURL"` - AkmsCkmsServerPort string `yaml:"AkmsCkmsServerPort"` - GnmiBindAddress string `yaml:"GnmiBindAddress"` - Peers []Peer `yaml:"Peers"` - GnmiTLS TLSConfig `yaml:"GnmiTLS"` - KmsTLS TLSConfig `yaml:"KmsTLS"` - QuantumModuleTLS TLSConfig `yaml:"QuantumModuleTLS"` - AkmsCkmsTLS TLSConfig `yaml:"AkmsCkmsTLS"` - ETSI14Server *ETSI14Server `yaml:"ETSI14Server,omitempty"` - QkdnManagerServer *QkdnManagerServer `yaml:"QkdnManagerServer,omitempty"` + Id string `yaml:"Id"` + Name string `yaml:"Name"` + InterComAddr string `yaml:"InterComAddr"` + QuantumAddr string `yaml:"QuantumAddr"` + AkmsURL string `yaml:"AkmsURL"` + AkmsCkmsServerPort string `yaml:"AkmsCkmsServerPort"` + GnmiBindAddress string `yaml:"GnmiBindAddress"` + Peers []Peer `yaml:"Peers"` + GnmiTLS TLSConfig `yaml:"GnmiTLS"` + KmsTLS TLSConfig `yaml:"KmsTLS"` + QuantumModuleTLS TLSConfig `yaml:"QuantumModuleTLS"` + AkmsCkmsTLS TLSConfig `yaml:"AkmsCkmsTLS"` + ETSI14Server *ETSI14Server `yaml:"ETSI14Server,omitempty"` + QkdnManagerServer *QkdnManagerServer `yaml:"QkdnManagerServer,omitempty"` + GRPCTimeoutInSeconds int `yaml:"GRPCTimeoutInSeconds"` } type Peer struct { diff --git a/goKMS/kms/kms.go b/goKMS/kms/kms.go index ba74c0ad95ce152d79450f137555cbd2cbf77f31..c806d8e1b57fcaa13299ad861bba67c5d8e21d94 100644 --- a/goKMS/kms/kms.go +++ b/goKMS/kms/kms.go @@ -63,6 +63,7 @@ type KMS struct { interComAddr string quantumAddress string tlsConfig config.TLSConfig + gRPCTimeout time.Duration // TODO create a mapping between ids and address remoteKMSMapping map[string]*util.RemoteKMS remoteKMSMappingMutex sync.RWMutex @@ -122,12 +123,15 @@ func NewKMS(kmsUUID uuid.UUID, logOutput io.Writer, logLevel log.Level, logInJso ckmsAkmsClient = akmsClient.NewCkmsAkmsClient(config.AkmsURL) } + gRPCTimeoutInSecondsDuration := time.Duration(config.GRPCTimeoutInSeconds) * time.Second + createdKMS := &KMS{ kmsName: config.Name, kmsUUID: kmsUUID, interComAddr: config.InterComAddr, quantumAddress: config.QuantumAddr, tlsConfig: config.KmsTLS, + gRPCTimeout: gRPCTimeoutInSecondsDuration, remoteKMSMapping: make(map[string]*util.RemoteKMS), quantumModules: make(map[string]peers.QuantumModule), routingTable: make(map[uuid.UUID]*Route), @@ -295,7 +299,7 @@ func (kms *KMS) AddPeer(peerKmsId string, kmsPeerSocket string, servingQLE peers log.Errorf("Trying to add existing peer %s, with KMS ID %s", kmsPeerSocket, peerKmsId) return nil, fmt.Errorf("trying to add existing peer %s, with KMS ID %s", kmsPeerSocket, peerKmsId) } - peer, err := peers.NewKmsPeer(peerKmsId, servingQLE, kmsPeerSocket, client, kms.eventBus) + peer, err := peers.NewKmsPeer(peerKmsId, servingQLE, kmsPeerSocket, client, kms.eventBus, kms.gRPCTimeout) if err != nil { return nil, err } @@ -608,7 +612,7 @@ func (kms *KMS) sendKSAKeysToPlatformKmsPeer(kmsPeerAddress, platformKeyID, requ } remoteClient := pbIC.NewKmsTalkerClient(remoteConn) - ctx, cancel := context.WithTimeout(context.Background(), time.Second) + ctx, cancel := context.WithTimeout(context.Background(), kms.gRPCTimeout) // create a new context with some metadata md := metadata.Pairs("hostname", kms.kmsName) ctx = metadata.NewOutgoingContext(ctx, md) diff --git a/goKMS/kms/peers/kmsPeer.go b/goKMS/kms/peers/kmsPeer.go index a6828434065e0b49f2b3ec1bca9be3d5b88c661f..d8049675b8e499d146709d4da80d72ea314b57f0 100644 --- a/goKMS/kms/peers/kmsPeer.go +++ b/goKMS/kms/peers/kmsPeer.go @@ -41,6 +41,7 @@ type KmsPeer struct { peerStatus KmsPeerStatus peerKmsId uuid.UUID servingQuantumModul QuantumModule + gRPCTimeout time.Duration tcpSocket *net.TCPAddr // the IP address and TCP port (aka socket) of the kms peer TcpSocketStr string // string rep. of tcpSocket et crypto.CryptoAlgorithm @@ -51,7 +52,7 @@ type KmsPeer struct { } // TODO: check intercomaddr -> remove? -func NewKmsPeer(peerKmsId string, quantummodule QuantumModule, tcpSocketStr string, client *GRPCClient, eventBus *event.EventBus) (*KmsPeer, error) { +func NewKmsPeer(peerKmsId string, quantummodule QuantumModule, tcpSocketStr string, client *GRPCClient, eventBus *event.EventBus, gRPCTimeout time.Duration) (*KmsPeer, error) { var peerKmsIdUUID uuid.UUID if peerKmsId == "" { peerKmsIdUUID = uuid.New() @@ -89,6 +90,7 @@ func NewKmsPeer(peerKmsId string, quantummodule QuantumModule, tcpSocketStr stri et: crypto.NewAES(), quit: make(chan bool), eventBus: eventBus, + gRPCTimeout: gRPCTimeout, } if err := quantummodule.Initialize(); err != nil { @@ -161,7 +163,7 @@ func (kp *KmsPeer) SendPayload(payload *crypto.Key, pathId, processId uuid.UUID) } // Start the negotiation process for a transport key - ctx, cancel := context.WithTimeout(context.Background(), time.Second) + ctx, cancel := context.WithTimeout(context.Background(), kp.gRPCTimeout) defer cancel() _, err = kp.peerClient.InterComTransportKeyNegotiation(ctx, &pbIC.InterComTransportKeyNegotiationRequest{ Timestamp: time.Now().Unix(), @@ -184,7 +186,7 @@ func (kp *KmsPeer) SendPayload(payload *crypto.Key, pathId, processId uuid.UUID) log.Infof("Sent encrypted Payload: %s with nonce: %s", encryptedPayloadAsString, nonceAsString) - ctx2, cancel2 := context.WithTimeout(context.Background(), time.Second) + ctx2, cancel2 := context.WithTimeout(context.Background(), kp.gRPCTimeout) defer cancel2() _, err = kp.peerClient.KeyForwarding(ctx2, &pbIC.KeyForwardingRequest{ Timestamp: time.Now().Unix(), diff --git a/goKMS/main.go b/goKMS/main.go index 812d57c9ba0ea76cb86b86b5faaa6d7830c01b24..b9bbaa48d9da9d7a6bae6c24c01de2af2316ee20 100644 --- a/goKMS/main.go +++ b/goKMS/main.go @@ -94,6 +94,11 @@ func main() { log.Fatal(err) } + if kmsConfig.GRPCTimeoutInSeconds == 0 || kmsConfig.GRPCTimeoutInSeconds < 0 { + log.Warnf("gRPC timeout is set to 0 or lower, setting it to default value: %d", config.DefaultGRPCTimeoutInSeconds) + kmsConfig.GRPCTimeoutInSeconds = config.DefaultGRPCTimeoutInSeconds + } + // All gNMI settings which are provided via cli arguments should overwrite the settings in the config file. overwriteConfigFieldsWithFlags(kmsConfig, gnmiBindAddress, gnmiTLS, certFile, keyFile, caFile) @@ -155,9 +160,9 @@ func outputTlsSettings(config *config.Config) { currentDirectory, _ := os.Getwd() log.Debugf("current relative file path: %s", currentDirectory) - log.Infof("TLS enabled for gNMIC: %t", config.GnmiTLS.TLS) + log.Infof("TLS enabled for gNMI: %t", config.GnmiTLS.TLS) if config.GnmiTLS.TLS { - log.Infof("TLS filepaths for gNMIC: ca: %s, cert: %s, key: %s", config.GnmiTLS.CAFile, config.GnmiTLS.CertFile, config.GnmiTLS.KeyFile) + log.Infof("TLS filepaths for gNMI: ca: %s, cert: %s, key: %s", config.GnmiTLS.CAFile, config.GnmiTLS.CertFile, config.GnmiTLS.KeyFile) } log.Infof("TLS enabled for KMS: %t", config.KmsTLS.TLS) diff --git a/integration-tests/code/etsi14GetKeyTest/etsi14_GetKey_test.go b/integration-tests/code/etsi14GetKeyTest/etsi14_GetKey_test.go index 36d01bac89836db6022402375a1c59d739df3145..b0303a9413c703fed8f359bc6beb12f9f50b453a 100644 --- a/integration-tests/code/etsi14GetKeyTest/etsi14_GetKey_test.go +++ b/integration-tests/code/etsi14GetKeyTest/etsi14_GetKey_test.go @@ -4,26 +4,66 @@ import ( "bytes" "encoding/json" "fmt" + "io" "net/http" "os" - "strings" "testing" "time" - integration_test_utils "code.fbi.h-da.de/danet/quant/integration-tests/code/integrationTestUtils" + utils "code.fbi.h-da.de/danet/quant/integration-tests/code/integrationTestUtils" "github.com/stretchr/testify/assert" ) +type ETSI14RequestData struct { + Number int64 `json:"number,omitempty"` + KeyIDs []KeyIdsRequestKeyIdsInner `json:"key_IDs,omitempty"` +} + +type KeyIdsRequestKeyIdsInner struct { + KeyID string `json:"key_ID"` +} + +type ETSI14ResponseData struct { + Keys []KeyContainerKeysInner `json:"Keys,omitempty"` +} + +type KeyContainerKeysInner struct { + KeyID string `json:"key_ID,omitempty"` + + Key string `json:"key,omitempty"` +} + +func getKeyContainerFromResponse(kmsResp *http.Response) (*ETSI14ResponseData, error) { + defer kmsResp.Body.Close() //nolint:errcheck + body, err := io.ReadAll(kmsResp.Body) + if err != nil { + return nil, err + } + + kmsKeyContainer := &ETSI14ResponseData{} + err = json.Unmarshal([]byte(body), kmsKeyContainer) + if err != nil { + return nil, err + } + + return kmsKeyContainer, nil +} + func TestETSI14GetKey(t *testing.T) { //nolint:gocyclo - kms2URL := "127.0.0.1:7031" - kms2URL_ENV := os.Getenv("INTEGRATION_TEST_KMS2_URL") - if kms2URL_ENV != "" { - kms2URL = kms2URL_ENV + gosdncScript := "../../config/gosdnc/add_devices.sh" + gosdncScript_ENV := os.Getenv("INTEGRATION_TEST_GOSDNC_SCRIPT") + if gosdncScript_ENV != "" { + gosdncScript = gosdncScript_ENV + } + cleanupScript := "../../config/gosdnc/delete_devices.sh" + cleanupScript_ENV := os.Getenv("INTEGRATION_TEST_CLEANUP_SCRIPT") + if cleanupScript_ENV != "" { + cleanupScript = cleanupScript_ENV } - kms1URL := "127.0.0.1:7030" - kms1URL_ENV := os.Getenv("INTEGRATION_TEST_KMS1_URL") - if kms1URL_ENV != "" { - kms1URL = kms1URL_ENV + controllerURL := "127.0.0.1:55055" + controllerURL_ENV := os.Getenv("INTEGRATION_TEST_CONTROLLER_URL") + if controllerURL_ENV != "" { + controllerURL = controllerURL_ENV } kms1ETSI14URL := "127.0.0.1:1414" kms1ETSI14URL_ENV := os.Getenv("INTEGRATION_TEST_KMS1_ETSI14_URL") @@ -36,6 +76,14 @@ func TestETSI14GetKey(t *testing.T) { //nolint:gocyclo kms2ETSI14URL = kms2ETSI14URL_ENV } + // Tell the qkdn-controller what devices to use. + _, err := utils.RunGosdncScript(gosdncScript, controllerURL) + if err != nil { + currentFolderPath := os.Getenv("PWD") + t.Errorf("Error running gosdnc script. Current folder path: %s, Error: %s", currentFolderPath, err) + } + defer utils.RunGosdncScript(cleanupScript, controllerURL) //nolint:errcheck + url := fmt.Sprintf("http://%s/api/v1/keys/slave_SAE_ID/enc_keys", kms1ETSI14URL) data := ETSI14RequestData{ Number: 1, @@ -62,42 +110,6 @@ func TestETSI14GetKey(t *testing.T) { //nolint:gocyclo time.Sleep(time.Duration(2) * time.Second) - output, err := integration_test_utils.GnmicCommand(kms1URL, "get", "--path", "create-route-requests") - if err != nil { - t.Errorf("Error getting create-route-requests: %s; %s", err, output) - } - - output = strings.Split(output, "\"kms-path-id\": \"")[1] - output = strings.Split(output, "\",")[0] - - path := fmt.Sprintf("key-routing-sessions/routing-sessions[path-id=%s]", output) - - config01 := integration_test_utils.BuildKms1RoutingConfig(path, output) - - config02 := integration_test_utils.BuildKms2RoutingConfig(path, output) - - argsKMS1 := []string{"set"} - for _, update := range config01 { - argsKMS1 = append(argsKMS1, "--update-path", update.Path, "--update-value", update.JSON) - } - - argsKMS2 := []string{"set"} - for _, update := range config02 { - argsKMS2 = append(argsKMS2, "--update-path", update.Path, "--update-value", update.JSON) - } - - output, err = integration_test_utils.GnmicCommand(kms2URL, argsKMS2...) - if err != nil { - t.Errorf("Error setting routing-session: %s; %s", err, output) - } - - output, err = integration_test_utils.GnmicCommand(kms1URL, argsKMS1...) - if err != nil { - t.Errorf("Error setting routing-session: %s; %s", err, output) - } - - time.Sleep(time.Duration(2) * time.Second) - kms1KeyContainer, err := getKeyContainerFromResponse(respKms1) if err != nil { t.Errorf("Error getting Key Container from resp: %v, err: %v", respKms1, err) diff --git a/integration-tests/code/etsi14GetKeyTest/etsi14_GetKey_utility.go b/integration-tests/code/etsi14GetKeyTest/etsi14_GetKey_utility.go deleted file mode 100644 index 98188acd5f0f82e97d9a0ec45809aae04a68cc1c..0000000000000000000000000000000000000000 --- a/integration-tests/code/etsi14GetKeyTest/etsi14_GetKey_utility.go +++ /dev/null @@ -1,42 +0,0 @@ -package integration_tests - -import ( - "encoding/json" - "io" - "net/http" -) - -type ETSI14RequestData struct { - Number int64 `json:"number,omitempty"` - KeyIDs []KeyIdsRequestKeyIdsInner `json:"key_IDs,omitempty"` -} - -type KeyIdsRequestKeyIdsInner struct { - KeyID string `json:"key_ID"` -} - -type ETSI14ResponseData struct { - Keys []KeyContainerKeysInner `json:"Keys,omitempty"` -} - -type KeyContainerKeysInner struct { - KeyID string `json:"key_ID,omitempty"` - - Key string `json:"key,omitempty"` -} - -func getKeyContainerFromResponse(kmsResp *http.Response) (*ETSI14ResponseData, error) { - defer kmsResp.Body.Close() //nolint:errcheck - body, err := io.ReadAll(kmsResp.Body) - if err != nil { - return nil, err - } - - kmsKeyContainer := &ETSI14ResponseData{} - err = json.Unmarshal([]byte(body), kmsKeyContainer) - if err != nil { - return nil, err - } - - return kmsKeyContainer, nil -} diff --git a/integration-tests/code/getKSAKeyTest/getKSA_key_test.go b/integration-tests/code/getKSAKeyTest/getKSA_key_test.go index ba39bc2b0a7e499b019220c4f6d02b11daed8e88..e1e8464bc17dc1e113275a02c010f68cd3abf30f 100644 --- a/integration-tests/code/getKSAKeyTest/getKSA_key_test.go +++ b/integration-tests/code/getKSAKeyTest/getKSA_key_test.go @@ -4,15 +4,13 @@ import ( "bytes" "encoding/json" "fmt" - "strings" "io" "net/http" "os" "testing" - "time" - integration_test_utils "code.fbi.h-da.de/danet/quant/integration-tests/code/integrationTestUtils" + utils "code.fbi.h-da.de/danet/quant/integration-tests/code/integrationTestUtils" "github.com/google/uuid" "github.com/stretchr/testify/assert" ) @@ -48,15 +46,20 @@ type RequestData struct { } func TestGetKSAKey(t *testing.T) { //nolint:gocyclo - kms2URL := "127.0.0.1:7031" - kms2URL_ENV := os.Getenv("INTEGRATION_TEST_KMS2_URL") - if kms2URL_ENV != "" { - kms2URL = kms2URL_ENV + gosdncScript := "../../config/gosdnc/add_devices.sh" + gosdncScript_ENV := os.Getenv("INTEGRATION_TEST_GOSDNC_SCRIPT") + if gosdncScript_ENV != "" { + gosdncScript = gosdncScript_ENV } - kms1URL := "127.0.0.1:7030" - kms1URL_ENV := os.Getenv("INTEGRATION_TEST_KMS1_URL") - if kms1URL_ENV != "" { - kms1URL = kms1URL_ENV + cleanupScript := "../../config/gosdnc/delete_devices.sh" + cleanupScript_ENV := os.Getenv("INTEGRATION_TEST_CLEANUP_SCRIPT") + if cleanupScript_ENV != "" { + cleanupScript = cleanupScript_ENV + } + controllerURL := "127.0.0.1:55055" + controllerURL_ENV := os.Getenv("INTEGRATION_TEST_CONTROLLER_URL") + if controllerURL_ENV != "" { + controllerURL = controllerURL_ENV } kms1AkmsURL := "127.0.0.1:9696" kms1AkmsURL_ENV := os.Getenv("INTEGRATION_TEST_KMS1_AKMS_URL") @@ -74,6 +77,14 @@ func TestGetKSAKey(t *testing.T) { //nolint:gocyclo logFileURL2 = logFileURL_ENV2 } + // Tell the qkdn-controller what devices to use. + _, err := utils.RunGosdncScript(gosdncScript, controllerURL) + if err != nil { + currentFolderPath := os.Getenv("PWD") + t.Errorf("Error running gosdnc script. Current folder path: %s, Error: %s", currentFolderPath, err) + } + defer utils.RunGosdncScript(cleanupScript, controllerURL) //nolint:errcheck + requestId := uuid.New().String() url := fmt.Sprintf("http://%s/api/v1/keys/ksa_key_req", kms1AkmsURL) @@ -94,59 +105,19 @@ func TestGetKSAKey(t *testing.T) { //nolint:gocyclo return } - go func() { - resp, err := http.Post(url, "application/json", bytes.NewBuffer(jsonData)) - if err != nil { - t.Errorf("Error making HTTP request: %s", err) - return - } - defer resp.Body.Close() //nolint:errcheck - - if resp.StatusCode != http.StatusNoContent { - t.Errorf("Expected status code 204 No Content, but got %d", resp.StatusCode) - } - }() - - time.Sleep(time.Duration(2) * time.Second) - - output, err := integration_test_utils.GnmicCommand(kms1URL, "get", "--path", "create-route-requests") - if err != nil { - t.Errorf("Error getting create-route-requests: %s; %s", err, output) - } - - output = strings.Split(output, "\"kms-path-id\": \"")[1] - output = strings.Split(output, "\",")[0] - - path := fmt.Sprintf("key-routing-sessions/routing-sessions[path-id=%s]", output) - - config01 := integration_test_utils.BuildKms1RoutingConfig(path, output) - - config02 := integration_test_utils.BuildKms2RoutingConfig(path, output) - - argsKMS1 := []string{"set"} - for _, update := range config01 { - argsKMS1 = append(argsKMS1, "--update-path", update.Path, "--update-value", update.JSON) - } - - argsKMS2 := []string{"set"} - for _, update := range config02 { - argsKMS2 = append(argsKMS2, "--update-path", update.Path, "--update-value", update.JSON) - } - - output, err = integration_test_utils.GnmicCommand(kms2URL, argsKMS2...) + resp, err := http.Post(url, "application/json", bytes.NewBuffer(jsonData)) if err != nil { - t.Errorf("Error setting routing-session: %s; %s", err, output) + t.Errorf("Error making HTTP request: %s", err) + return } + defer resp.Body.Close() //nolint:errcheck - output, err = integration_test_utils.GnmicCommand(kms1URL, argsKMS1...) - if err != nil { - t.Errorf("Error setting routing-session: %s; %s", err, output) + if resp.StatusCode != http.StatusNoContent { + t.Errorf("Expected status code 204 No Content, but got %d", resp.StatusCode) } - time.Sleep(time.Duration(2) * time.Second) - // Get logfile of akms - resp, err := http.Get("http://" + logFileURL + "/debug/get_log_file") + resp, err = http.Get("http://" + logFileURL + "/debug/get_log_file") if err != nil { t.Errorf("Error making HTTP request: %s", err) return @@ -162,7 +133,7 @@ func TestGetKSAKey(t *testing.T) { //nolint:gocyclo var logFile LogFile err = json.Unmarshal(body, &logFile) if err != nil { - t.Errorf("Error parsing body into PushKSAKeyRequest: %s", err) + t.Errorf("Error parsing logFile answer from AKMS: %s. \n Most likely the AKMS never received a ksa key. It told us: %s", err, string(body)) return } assert.NotNil(t, logFile.Source) diff --git a/integration-tests/code/integrationTestUtils/integrationTestUtils.go b/integration-tests/code/integrationTestUtils/integrationTestUtils.go index 19ed596a2733311e2d6162f64fbb46ae99fc789e..03122ab70bbeee43d21fd2eb1184487646765dad 100644 --- a/integration-tests/code/integrationTestUtils/integrationTestUtils.go +++ b/integration-tests/code/integrationTestUtils/integrationTestUtils.go @@ -3,6 +3,7 @@ package utils import ( "fmt" "os/exec" + "strings" ) type Update struct { @@ -11,80 +12,15 @@ type Update struct { JSON string } -func GnmicCommand(address string, args ...string) (string, error) { - cmd := exec.Command("gnmic", "-a", address, "-u", "admin", "-p", "admin", "--insecure", "-e", "JSON_IETF") - cmd.Args = append(cmd.Args, args...) - //command := cmd.String() - output, err := cmd.Output() +func RunGosdncScript(script string, controllerURL string) (string, error) { + cmd := exec.Command(script, controllerURL) + + output, err := cmd.CombinedOutput() outputString := string(output) - if err != nil { - return outputString, err - } - return outputString, nil -} -func BuildKms1RoutingConfig(path, pathID string) []Update { - return []Update{ - { - Path: path, - JSON: fmt.Sprintf(`{"path-id": "%s"}`, pathID), - }, - { - Path: fmt.Sprint(path, "/next-hop"), - JSON: fmt.Sprintf(`{"node-id": "%s"}`, "5e41c291-6121-4335-84f6-41e04b8bdaa2"), - }, - { - Path: fmt.Sprint(path, "/next-hop"), - JSON: fmt.Sprintf(`{"hostname": "%s"}`, "kms_2"), - }, - { - Path: fmt.Sprint(path, "/next-hop"), - JSON: fmt.Sprintf(`{"port": %d}`, 50910), - }, - { - Path: fmt.Sprint(path, "/initiating-kms-address"), - JSON: fmt.Sprintf(`{"node-id": "%s"}`, "5e41c291-6121-4335-84f6-41e04b8bdaa2"), - }, - { - Path: fmt.Sprint(path, "/initiating-kms-address"), - JSON: fmt.Sprintf(`{"hostname": "%s"}`, "kms_2"), - }, - { - Path: fmt.Sprint(path, "/initiating-kms-address"), - JSON: fmt.Sprintf(`{"port": %d}`, 50910), - }, + if strings.Contains(outputString, "error") || strings.Contains(outputString, "ERROR") || err != nil { + err = fmt.Errorf("error in output: %s", outputString) } -} -func BuildKms2RoutingConfig(path, pathID string) []Update { - return []Update{ - { - Path: path, - JSON: fmt.Sprintf(`{"path-id": "%s"}`, pathID), - }, - { - Path: fmt.Sprint(path, "/prev-hop"), - JSON: fmt.Sprintf(`{"node-id": "%s"}`, "0ff33c82-7fe1-482b-a0ca-67565806ee4b"), - }, - { - Path: fmt.Sprint(path, "/prev-hop"), - JSON: fmt.Sprintf(`{"hostname": "%s"}`, "kms_1"), - }, - { - Path: fmt.Sprint(path, "/prev-hop"), - JSON: fmt.Sprintf(`{"port": %d}`, 50910), - }, - { - Path: fmt.Sprint(path, "/initiating-kms-address"), - JSON: fmt.Sprintf(`{"node-id": "%s"}`, "0ff33c82-7fe1-482b-a0ca-67565806ee4b"), - }, - { - Path: fmt.Sprint(path, "/initiating-kms-address"), - JSON: fmt.Sprintf(`{"hostname": "%s"}`, "kms_1"), - }, - { - Path: fmt.Sprint(path, "/initiating-kms-address"), - JSON: fmt.Sprintf(`{"port": %d}`, 50910), - }, - } + return outputString, err } diff --git a/integration-tests/config/controller/gNMISubscriptions.txt b/integration-tests/config/controller/gNMISubscriptions.txt new file mode 100644 index 0000000000000000000000000000000000000000..498a3fe0dc440aac549caca1203e5bf639b6fd95 --- /dev/null +++ b/integration-tests/config/controller/gNMISubscriptions.txt @@ -0,0 +1 @@ +create-route-requests diff --git a/integration-tests/config/controller/qkdn-gosdn.toml b/integration-tests/config/controller/qkdn-gosdn.toml new file mode 100644 index 0000000000000000000000000000000000000000..f8989af56d64b5efabb57d8460199ebfd29b0ee9 --- /dev/null +++ b/integration-tests/config/controller/qkdn-gosdn.toml @@ -0,0 +1,19 @@ +amqphost = 'rabbitmq' +amqppassword = 'guest' +amqpport = '5672' +amqpprefix = 'amqp://' +amqpuser = 'guest' +basepnduuid = '5f20f34b-cbd0-4511-9ddc-c50cf6a3b49d' +config = './configs/qkdn-gosdn.toml' +csbi-orchestrator = 'localhost:55056' +databaseconnection = 'mongodb://root:example@mongo:27017' +defaultjwtduration = 24 +filesystempathtostores = 'stores' +gnmisubscriptionspath = 'configs/gNMISubscriptions.txt' +help = false +log-level = 'debug' +nogrpcpassthrough = false +plugin-folder = 'plugins' +plugin-registry = 'plugin-registry:55057' +security = 'secure' +socket = ':55055' diff --git a/integration-tests/config/controller/routing-config.yaml b/integration-tests/config/controller/routing-config.yaml new file mode 100644 index 0000000000000000000000000000000000000000..4611c0842c061d85da88297ca962889d04a66f37 --- /dev/null +++ b/integration-tests/config/controller/routing-config.yaml @@ -0,0 +1,7 @@ +ControllerAddress: "qkdn-controller:55055" +PndID: "5f20f34b-cbd0-4511-9ddc-c50cf6a3b49d" +UserName: "admin" +UserPW: "TestPassword" +AppName: "dq-routing" +RegistrationToken: "SecurePresharedToken" +GrpcAddress: ":54321" diff --git a/integration-tests/config/controller/start_ra_sleep.sh b/integration-tests/config/controller/start_ra_sleep.sh new file mode 100755 index 0000000000000000000000000000000000000000..031b2443011daf857bdafcaad705b647787c2fde --- /dev/null +++ b/integration-tests/config/controller/start_ra_sleep.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +echo "Sleeping for 45 before starting" +sleep 45 +echo "Done sleeping" +./routing --log debug --config /new/routing-config.yaml diff --git a/integration-tests/config/gosdnc/add_devices.sh b/integration-tests/config/gosdnc/add_devices.sh new file mode 100755 index 0000000000000000000000000000000000000000..fac6c4f05e474d2aa7e049acfaa273bd733206f8 --- /dev/null +++ b/integration-tests/config/gosdnc/add_devices.sh @@ -0,0 +1,27 @@ +#!/bin/sh + +## Note: This script does not clean up network elements already existing in the storage. Running it repeatedly will +## create a garbage storage. + +GOSDNC_PATH="../../../artifacts/gosdnc" +CONTROLLER_ADDRESS=$1 +ADMINPW="TestPassword" +KMS_PLUGIN="823aad29-69be-42f0-b279-90f2c1b6a94d" +PND_UUID="5f20f34b-cbd0-4511-9ddc-c50cf6a3b49d" + +cd ../../config/gosdnc + +echo 'Logging in via gosdnc and setting up KMS in controller...' +echo "CONTROLLER_ADDRESS: $CONTROLLER_ADDRESS" + +echo 'Current folder path:' +pwd + +# TODO: Add --tls when adding certs to this! + +## Call login and create entries for all the network elements. +$GOSDNC_PATH login --controller $CONTROLLER_ADDRESS --u admin --p $ADMINPW +$GOSDNC_PATH pnd use $PND_UUID + +$GOSDNC_PATH mne create --address "kms01:7030" --name kms_1 --password admin --plugin-id $KMS_PLUGIN --username admin --uuid 0ff33c82-7fe1-482b-a0ca-67565806ee4b +$GOSDNC_PATH mne create --address "kms02:7030" --name kms_2 --password admin --plugin-id $KMS_PLUGIN --username admin --uuid 5e41c291-6121-4335-84f6-41e04b8bdaa2 diff --git a/integration-tests/config/gosdnc/delete_devices.sh b/integration-tests/config/gosdnc/delete_devices.sh new file mode 100755 index 0000000000000000000000000000000000000000..2d5955ec1c56407e79ed0e871b7fed2502a73450 --- /dev/null +++ b/integration-tests/config/gosdnc/delete_devices.sh @@ -0,0 +1,20 @@ +#!/bin/sh + +GOSDNC_PATH="../../../artifacts/gosdnc" +GOSDN_ADDRESS=$1 +ADMINPW="TestPassword" +KMS_PLUGIN="823aad29-69be-42f0-b279-90f2c1b6a94d" +PND_UUID="5f20f34b-cbd0-4511-9ddc-c50cf6a3b49d" + +cd ../../config/gosdnc + +echo 'Logging in via gosdnc and setting up KMS in controller...' + +echo 'Current folder path:' +pwd + +$GOSDNC_PATH login --controller $GOSDN_ADDRESS --u admin --p $ADMINPW +$GOSDNC_PATH pnd use $PND_UUID + +$GOSDNC_PATH mne remove 0ff33c82-7fe1-482b-a0ca-67565806ee4b +$GOSDNC_PATH mne remove 5e41c291-6121-4335-84f6-41e04b8bdaa2 diff --git a/integration-tests/config/kms/kms_1.json b/integration-tests/config/kms/kms_1.json deleted file mode 100644 index 2d7fb2041f5c6b1f6e5bfd7f2d36851489c0895b..0000000000000000000000000000000000000000 --- a/integration-tests/config/kms/kms_1.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "path-id": "38e0588b-6a2d-42c9-85a0-887cc877c299", - "next-hop": { - "node-id": "5e41c291-6121-4335-84f6-41e04b8bdaa2", - "hostname": "kms_2", - "port": 50910 - }, - "initiating-kms-address": { - "node-id": "5e41c291-6121-4335-84f6-41e04b8bdaa2", - "hostname": "kms_2", - "port": 50910 - } -} diff --git a/integration-tests/config/kms/kms_1.yaml b/integration-tests/config/kms/kms_1.yaml index 489cf28a85d625f36cf9c419bee52a6787683ba9..c65e69a22f8acdbaf30806f02d0dabc40b0dae84 100644 --- a/integration-tests/config/kms/kms_1.yaml +++ b/integration-tests/config/kms/kms_1.yaml @@ -1,18 +1,19 @@ Id: '0ff33c82-7fe1-482b-a0ca-67565806ee4b' -Name: kms_1 +Name: kms01 InterComAddr: 0.0.0.0:50910 QuantumAddr: 0.0.0.0:50911 AkmsURL: "http://akms-simulator_1:4444/api/v1/keys/push_ksa_key" AkmsCkmsServerPort: "9696" +GRPCTimeoutInSeconds: 600 KmsTLS: - TLS: true + TLS: false CAFile: "config/ssl/ca.crt" CertFile: "config/ssl/kms/kms1-selfsigned.crt" KeyFile: "config/ssl/kms/kms1-selfsigned.key" Peers: - # peer to kms_2 + # peer to kms02 - PeerId: '5e41c291-6121-4335-84f6-41e04b8bdaa2' - PeerInterComAddr: kms_2:50910 + PeerInterComAddr: kms02:50910 Type: danet # quantum module of type emulated at the given address QuantumModule: diff --git a/integration-tests/config/kms/kms_2.json b/integration-tests/config/kms/kms_2.json deleted file mode 100644 index 9654434be9ec1d16f9e43beca7e585132704369d..0000000000000000000000000000000000000000 --- a/integration-tests/config/kms/kms_2.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "path-id": "38e0588b-6a2d-42c9-85a0-887cc877c299", - "prev-hop": { - "node-id": "0ff33c82-7fe1-482b-a0ca-67565806ee4b", - "hostname": "kms_1", - "port": 50910 - }, - "initiating-kms-address": { - "node-id": "0ff33c82-7fe1-482b-a0ca-67565806ee4b", - "hostname": "kms_1", - "port": 50910 - } -} diff --git a/integration-tests/config/kms/kms_2.yaml b/integration-tests/config/kms/kms_2.yaml index 87bbde3231dc913c1201ef9fcdbafb4c6d50b026..3b8f226c18a2c99803a7dd1cc5f2819c4077147a 100644 --- a/integration-tests/config/kms/kms_2.yaml +++ b/integration-tests/config/kms/kms_2.yaml @@ -1,18 +1,19 @@ Id: '5e41c291-6121-4335-84f6-41e04b8bdaa2' -Name: kms_2 +Name: kms02 InterComAddr: 0.0.0.0:50910 QuantumAddr: 0.0.0.0:50911 AkmsURL: "http://akms-simulator_2:4444/api/v1/keys/push_ksa_key" AkmsCkmsServerPort: "9696" +GRPCTimeoutInSeconds: 600 KmsTLS: - TLS: true + TLS: false CAFile: "config/ssl/ca.crt" CertFile: "config/ssl/kms/kms2-selfsigned.crt" KeyFile: "config/ssl/kms/kms2-selfsigned.key" Peers: - # peer to kms_1 + # peer to kms01 - PeerId: '0ff33c82-7fe1-482b-a0ca-67565806ee4b' - PeerInterComAddr: kms_1:50910 + PeerInterComAddr: kms01:50910 Type: danet # quantum module of type emulated at the given address QuantumModule: diff --git a/integration-tests/config/kms/tlsConfigs/kms1ReqConfig.txt b/integration-tests/config/kms/tlsConfigs/kms1ReqConfig.txt index 1e6972b461a3c89669ac96c68c35529ce3a7e89d..7171d5753bec78b113c77faafd7194979b97a7d8 100644 --- a/integration-tests/config/kms/tlsConfigs/kms1ReqConfig.txt +++ b/integration-tests/config/kms/tlsConfigs/kms1ReqConfig.txt @@ -7,11 +7,10 @@ prompt = no [req_distinguished_name] C = DE O = H_DA -CN = kms_1 +CN = kms01 [v3_req] keyUsage = keyEncipherment, dataEncipherment extendedKeyUsage = serverAuth, clientAuth subjectAltName = @alt_names [alt_names] -IP.1 = 172.100.20.10 -DNS.1 = kms_1 +DNS.1 = kms01 diff --git a/integration-tests/config/kms/tlsConfigs/kms2ReqConfig.txt b/integration-tests/config/kms/tlsConfigs/kms2ReqConfig.txt index 09228aab372fa7584525a86639afa583ba3efb89..c990896c7f806945b55abde73504b112cab07e82 100644 --- a/integration-tests/config/kms/tlsConfigs/kms2ReqConfig.txt +++ b/integration-tests/config/kms/tlsConfigs/kms2ReqConfig.txt @@ -7,11 +7,10 @@ prompt = no [req_distinguished_name] C = DE O = H_DA -CN = kms_2 +CN = kms02 [v3_req] keyUsage = keyEncipherment, dataEncipherment extendedKeyUsage = serverAuth, clientAuth subjectAltName = @alt_names [alt_names] -IP.1 = 172.100.20.11 -DNS.1 = kms_2 +DNS.1 = kms02 diff --git a/integration-tests/config/quantumlayer/quantumlayer_1.yaml b/integration-tests/config/quantumlayer/quantumlayer_1.yaml index 2dce72c45e5336e5297bedf6211b17fb32f9af8d..8948e016f18a41092392ccda86eab6132464006f 100644 --- a/integration-tests/config/quantumlayer/quantumlayer_1.yaml +++ b/integration-tests/config/quantumlayer/quantumlayer_1.yaml @@ -1,4 +1,4 @@ -KMSAddr: 'kms_1:50911' +KMSAddr: 'kms01:50911' OperationMode: "normal" SleepTimerForGenerationInMs: 1000 Seed: 1337 diff --git a/integration-tests/config/quantumlayer/quantumlayer_2.yaml b/integration-tests/config/quantumlayer/quantumlayer_2.yaml index 1be33af344e65f0fc5e0249d24ba7fd482cbddc0..2a9491149df32a40ac780999859d41fc01773033 100644 --- a/integration-tests/config/quantumlayer/quantumlayer_2.yaml +++ b/integration-tests/config/quantumlayer/quantumlayer_2.yaml @@ -1,4 +1,4 @@ -KMSAddr: 'kms_2:50911' +KMSAddr: 'kms02:50911' OperationMode: "normal" SleepTimerForGenerationInMs: 1000 Seed: 1337 diff --git a/integration-tests/docker-compose.override.debug.yml b/integration-tests/docker-compose.override.debug.yml new file mode 100644 index 0000000000000000000000000000000000000000..a38bcb05cb4a36135d86925a5c02ba730de41c5c --- /dev/null +++ b/integration-tests/docker-compose.override.debug.yml @@ -0,0 +1,12 @@ +services: + kms01: + image: gokms_debug + entrypoint: ["/usr/bin/dlv", "--listen=0.0.0.0:1337", "--headless=true", "--api-version=2", "exec", "/usr/bin/goKMS", "--", "--log", "debug", "--kms_config", "/tmp/kms/config/kms_1.yaml"] + ports: + - "127.0.0.1:4401:1337" + + kms02: + image: gokms_debug + entrypoint: ["/usr/bin/dlv", "--listen=0.0.0.0:1337", "--headless=true", "--api-version=2", "exec", "/usr/bin/goKMS", "--", "--log", "debug", "--kms_config", "/tmp/kms/config/kms_2.yaml"] + ports: + - "127.0.0.1:4402:1337" diff --git a/integration-tests/docker-compose_integration_test.yml b/integration-tests/docker-compose.yml similarity index 53% rename from integration-tests/docker-compose_integration_test.yml rename to integration-tests/docker-compose.yml index 80eed98526f897103962b9f63c0ea41719409abd..b8a05d7624ea1c9c352d23a44b94898006fa1db4 100644 --- a/integration-tests/docker-compose_integration_test.yml +++ b/integration-tests/docker-compose.yml @@ -1,13 +1,8 @@ services: - kms_1: + kms01: image: gokms command: - [ - "--log", - "debug", - "--kms_config", - "/tmp/kms/config/kms_1.yaml", - ] + [ "--log", "debug", "--kms_config", "/tmp/kms/config/kms_1.yaml" ] volumes: - ./config/kms/kms_1.yaml:/tmp/kms/config/kms_1.yaml - ../artifacts/integration-tests/ssl:/config/ssl @@ -16,15 +11,10 @@ services: - "127.0.0.1:9696:9696" - "127.0.0.1:1414:1414" - kms_2: + kms02: image: gokms command: - [ - "--log", - "debug", - "--kms_config", - "/tmp/kms/config/kms_2.yaml", - ] + [ "--log", "debug", "--kms_config", "/tmp/kms/config/kms_2.yaml" ] volumes: - ./config/kms/kms_2.yaml:/tmp/kms/config/kms_2.yaml - ../artifacts/integration-tests/ssl:/config/ssl @@ -65,3 +55,35 @@ services: image: akms-simulator ports: - "127.0.0.1:4445:4444" + + qkdn-controller: + image: registry.code.fbi.h-da.de/demoquandt/qkdn-controller:qkdn-main + volumes: + - ./config/controller/qkdn-gosdn.toml:/app/configs/qkdn-gosdn.toml + - ./config/controller/gNMISubscriptions.txt:/app/configs/gNMISubscriptions.txt + command: --config ./configs/qkdn-gosdn.toml + ports: + - 0.0.0.0:55055:55055 + - 127.0.0.1:8080:8080 + - 127.0.0.1:40000:40000 + environment: + GOSDN_ADMIN_PASSWORD: TestPassword + + plugin-registry: + image: registry.code.fbi.h-da.de/demoquandt/qkdn-controller/plugin-registry:qkdn-main + + mongo: + image: mongo:7 + environment: + MONGO_INITDB_ROOT_USERNAME: root + MONGO_INITDB_ROOT_PASSWORD: example + + rabbitmq: + image: rabbitmq:3-management + + routing-app: + image: registry.code.fbi.h-da.de/demoquandt/qkdn-controller/routing-app:qkdn-main + entrypoint: ["./start_ra_sleep.sh"] + volumes: + - ./config/controller/start_ra_sleep.sh:/app/start_ra_sleep.sh + - ./config/controller/routing-config.yaml:/new/routing-config.yaml diff --git a/quantumlayer/Dockerfile b/quantumlayer/Dockerfile index ddffb90ede74ae74a40c028668b06d341169a6c5..cb231919fc97957ba331bc780fdbf7f93c71b2b5 100644 --- a/quantumlayer/Dockerfile +++ b/quantumlayer/Dockerfile @@ -1,7 +1,8 @@ ARG GOLANG_VERSION=1.22 ARG BUILDARGS +ARG GITLAB_PROXY -FROM ${GITLAB_PROXY}golang:$GOLANG_VERSION-bookworm as builder +FROM ${GITLAB_PROXY}golang:$GOLANG_VERSION-bookworm AS builder ARG GITLAB_LOGIN ARG GITLAB_TOKEN RUN echo "machine code.fbi.h-da.de login ${GITLAB_LOGIN} password ${GITLAB_TOKEN}" > ~/.netrc diff --git a/scripts/install_go_as_user.sh b/scripts/install_go_as_user.sh new file mode 100755 index 0000000000000000000000000000000000000000..ed378f468552ad587c61d144f9760f14bb33e1d5 --- /dev/null +++ b/scripts/install_go_as_user.sh @@ -0,0 +1,38 @@ +#!/bin/bash + +NEEDED_VERSION=$1 +INSTALL_DIR="$HOME/go" + +if [ -z "$NEEDED_VERSION" ]; then + echo "Please provide the latest version of Go as an argument." + exit 1 +fi + +# Check if the version of go defined in the file VERSION in $INSTALL_DIR is the same as the latest version +if [ -f "$INSTALL_DIR/go/VERSION" ]; then + INSTALLED_VERSION=$(grep -oP '^go\d+\.\d+\.\d+' $INSTALL_DIR/go/VERSION | cut -c 3-) + if [ "$INSTALLED_VERSION" == "$NEEDED_VERSION" ]; then + echo "Go $NEEDED_VERSION is already installed." + exit 0 + fi +fi + +rm -rf $INSTALL_DIR + +# Download the Go tarball +TARBALL_URL="https://go.dev/dl/go${NEEDED_VERSION}.linux-amd64.tar.gz" +wget $TARBALL_URL + +# Extract the tarball to a directory within the user's home directory +mkdir -p $INSTALL_DIR +tar -C $INSTALL_DIR -xzf "go${NEEDED_VERSION}.linux-amd64.tar.gz" +rm "go${NEEDED_VERSION}.linux-amd64.tar.gz" + +# Set up the environment variables +export PATH=$INSTALL_DIR/go/bin:$PATH +export GOROOT=$INSTALL_DIR/go +export GOPATH=$HOME/go_projects + +go version + +echo "Go has been installed successfully." diff --git a/scripts/install_gosdnc.sh b/scripts/install_gosdnc.sh new file mode 100755 index 0000000000000000000000000000000000000000..d4a3a505341f42cb6dfb1b05b85a0200dd0075a7 --- /dev/null +++ b/scripts/install_gosdnc.sh @@ -0,0 +1,13 @@ +#!/bin/sh + +if [ -f artifacts/gosdnc ] && [ "$(date -r artifacts/gosdnc +%Y-%m-%d)" = "$(date +%Y-%m-%d)" ]; then + echo "File artifacts/gosdnc already exists and was installed today. Skipping download. If you want to download it again, delete the file artifacts/gosdnc and start this script again." +else + echo "Downloading gosdnc..." + wget -O artifacts_gosdn.zip "https://code.fbi.h-da.de/danet/gosdn/-/jobs/artifacts/master/download?job=build-all-binaries" + unzip -o artifacts_gosdn.zip + rm artifacts_gosdn.zip + rm artifacts/gosdn artifacts/venv-manager + touch artifacts/gosdnc + echo "gosdnc installed" +fi diff --git a/scripts/remove_go_as_user.sh b/scripts/remove_go_as_user.sh new file mode 100755 index 0000000000000000000000000000000000000000..914c1b69549159c30ab64a81578b57f86b9c095c --- /dev/null +++ b/scripts/remove_go_as_user.sh @@ -0,0 +1,6 @@ +INSTALL_DIR="$HOME/go" + +# Clean up by removing the Go installation +rm -rf $INSTALL_DIR + +echo "Go has been removed successfully."