Allow multiple NTS Manager instances to run on the same machine. 07/2707/2 x-ran-models
authorAlex Stancu <alexandru.stancu@highstreet-technologies.com>
Mon, 9 Mar 2020 12:43:23 +0000 (14:43 +0200)
committerAlex Stancu <alexandru.stancu@highstreet-technologies.com>
Mon, 9 Mar 2020 12:57:06 +0000 (14:57 +0200)
Signed-off-by: Alex Stancu <alexandru.stancu@highstreet-technologies.com>
Change-Id: I1a1f6e43318fef87ce3f0fd5421a10cdeffd2d36

docker-build-manager.sh
docker-build-model.sh
ntsimulator/deploy/container-tag.yaml
ntsimulator/deploy/manager/container-tag.yaml
ntsimulator/scripts/clean.sh
ntsimulator/scripts/docker-compose.yml
ntsimulator/src/ntsimulator-manager/simulator-operations.c
ntsimulator/yang/auto-load-yangs.sh

index 6a61958..c6a8487 100755 (executable)
@@ -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 .
index b307c53..168f314 100755 (executable)
@@ -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 .
index 7e9735b..2d9bd56 100755 (executable)
@@ -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.
 # 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!"
index 14741b7..7594ba9 100644 (file)
@@ -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"
 
index 8520d2b..a4adcc3 100644 (file)
@@ -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)
        {
index 3c4f409..402d076 100755 (executable)
@@ -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