From 34ec819462d5f81ceeb723e47467bf50a8454f34 Mon Sep 17 00:00:00 2001 From: Alex Stancu Date: Mon, 9 Mar 2020 14:43:23 +0200 Subject: [PATCH] Allow multiple NTS Manager instances to run on the same machine. Signed-off-by: Alex Stancu Change-Id: I1a1f6e43318fef87ce3f0fd5421a10cdeffd2d36 --- docker-build-manager.sh | 2 +- docker-build-model.sh | 2 +- ntsimulator/deploy/container-tag.yaml | 2 +- ntsimulator/deploy/manager/container-tag.yaml | 2 +- ntsimulator/scripts/clean.sh | 23 ++++++++++++++-------- ntsimulator/scripts/docker-compose.yml | 8 ++++---- .../src/ntsimulator-manager/simulator-operations.c | 10 ++++++++-- ntsimulator/yang/auto-load-yangs.sh | 7 +++++++ 8 files changed, 38 insertions(+), 18 deletions(-) diff --git a/docker-build-manager.sh b/docker-build-manager.sh index 6a61958..c6a8487 100755 --- a/docker-build-manager.sh +++ b/docker-build-manager.sh @@ -1 +1 @@ -docker build --build-arg BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ') -t ntsim_manager -f ntsimulator/deploy/manager/Dockerfile . +docker build -t o-ran-sc_ntsim_manager -f ntsimulator/deploy/manager/Dockerfile . diff --git a/docker-build-model.sh b/docker-build-model.sh index b307c53..168f314 100755 --- a/docker-build-model.sh +++ b/docker-build-model.sh @@ -1 +1 @@ -docker build --build-arg BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ') -t ntsim_oran -f ntsimulator/deploy/Dockerfile . +docker build -t o-ran-sc_ntsim_oran -f ntsimulator/deploy/Dockerfile . diff --git a/ntsimulator/deploy/container-tag.yaml b/ntsimulator/deploy/container-tag.yaml index 079c0dc..12585e7 100644 --- a/ntsimulator/deploy/container-tag.yaml +++ b/ntsimulator/deploy/container-tag.yaml @@ -1,2 +1,2 @@ --- -tag: 0.0.1 +tag: 0.0.2 diff --git a/ntsimulator/deploy/manager/container-tag.yaml b/ntsimulator/deploy/manager/container-tag.yaml index 079c0dc..12585e7 100644 --- a/ntsimulator/deploy/manager/container-tag.yaml +++ b/ntsimulator/deploy/manager/container-tag.yaml @@ -1,2 +1,2 @@ --- -tag: 0.0.1 +tag: 0.0.2 diff --git a/ntsimulator/scripts/clean.sh b/ntsimulator/scripts/clean.sh index 7e9735b..2d9bd56 100755 --- a/ntsimulator/scripts/clean.sh +++ b/ntsimulator/scripts/clean.sh @@ -1,7 +1,7 @@ -#/bin/bash +#!/bin/bash ################################################################################ # -# Copyright 2019 highstreet technologies GmbH and others +# Copyright 2020 highstreet technologies GmbH and others # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,10 +15,17 @@ # See the License for the specific language governing permissions and # limitations under the License. ################################################################################ +if [ "$#" -ne 1 ]; then + echo "ID Parameter missing." + echo "Usage: $0 id + +where id is the docker container id of the NTS Manager instance that we want to clean. " + exit 1 +fi -echo "Cleaning up..." +echo "Cleaning up containers started by the NTS Manager $1..." -mapfile -t NTS_containers < <( docker ps -a --filter "label=NTS" --format "{{.ID}}" ) +mapfile -t NTS_containers < <( docker ps -a --filter "label=NTS_Manager=$1" --format "{{.ID}}" ) CONTAINERS="" @@ -29,13 +36,13 @@ then do CONTAINERS="$CONTAINERS $container" done - echo "Cleaning up ontainers: $CONTAINERS" + echo "Cleaning up containers: $CONTAINERS" docker kill $CONTAINERS > /dev/null 2>&1 docker rm $CONTAINERS > /dev/null 2>&1 fi -echo "Cleaning NTS Manager container" -docker kill NTS_Manager > /dev/null 2>&1 -docker rm NTS_Manager > /dev/null 2>&1 +echo "Cleaning NTS Manager $1..." +docker kill $1 > /dev/null 2>&1 +docker rm $1 > /dev/null 2>&1 echo "All cleaned up!" diff --git a/ntsimulator/scripts/docker-compose.yml b/ntsimulator/scripts/docker-compose.yml index 14741b7..7594ba9 100644 --- a/ntsimulator/scripts/docker-compose.yml +++ b/ntsimulator/scripts/docker-compose.yml @@ -1,13 +1,13 @@ version: '3' services: ntsimulator: - image: "ntsim_manager:latest" + image: "o-ran-sc_ntsim_manager:latest" container_name: NTS_Manager ports: - - "172.17.0.1:8300:830" + - "8300:830" volumes: - "/var/run/docker.sock:/var/run/docker.sock" - - "/home/parallels/workspace/highstreet/ntsimulator-o-ran/ntsimulator/scripts:/opt/dev/scripts" + - "/home/parallels/workspace/highstreet/o-ran-sc-repositories/o1-interface/ntsimulator/scripts:/opt/dev/scripts" - "/usr/bin/docker:/usr/bin/docker" labels: "NTS-manager": "" @@ -15,5 +15,5 @@ services: NTS_IP: "172.17.0.1" NETCONF_BASE: 50000 DOCKER_ENGINE_VERSION: "1.40" - MODELS_IMAGE: "ntsim_oran" + MODELS_IMAGE: "o-ran-sc_ntsim_oran" diff --git a/ntsimulator/src/ntsimulator-manager/simulator-operations.c b/ntsimulator/src/ntsimulator-manager/simulator-operations.c index 8520d2b..a4adcc3 100644 --- a/ntsimulator/src/ntsimulator-manager/simulator-operations.c +++ b/ntsimulator/src/ntsimulator-manager/simulator-operations.c @@ -92,8 +92,8 @@ static cJSON* get_docker_container_bindings(void) curl_easy_reset(curl); set_curl_common_info(); - char url[100]; - sprintf(url, "http:/v%s/containers/NTS_Manager/json", getenv("DOCKER_ENGINE_VERSION")); + char url[200]; + sprintf(url, "http:/v%s/containers/%s/json", getenv("DOCKER_ENGINE_VERSION"), getenv("HOSTNAME")); curl_easy_setopt(curl, CURLOPT_URL, url); @@ -253,6 +253,12 @@ static char* create_docker_container_curl(int base_netconf_port, cJSON* managerB return NULL; } + if (cJSON_AddStringToObject(labels, "NTS_Manager", getenv("HOSTNAME")) == NULL) + { + printf("Could not create JSON object: NTS Manager\n"); + return NULL; + } + cJSON *env_variables_array = cJSON_CreateArray(); if (env_variables_array == NULL) { diff --git a/ntsimulator/yang/auto-load-yangs.sh b/ntsimulator/yang/auto-load-yangs.sh index 3c4f409..402d076 100755 --- a/ntsimulator/yang/auto-load-yangs.sh +++ b/ntsimulator/yang/auto-load-yangs.sh @@ -28,6 +28,13 @@ shopt -s failglob declare -a excludedModules=() +# Uninstall the NTS Manager YANG model +$SYSREPOCTL -u -m network-topology-simulator +# $SYSREPOCTL -u -m iana-if-type +# $SYSREPOCTL -u -m ietf-ip +# $SYSREPOCTL -u -m ietf-interfaces + + sleep 5 pyang -f clearmust *.yang -- 2.16.6