Improve the dockerized auto test

The auto test can bring up any number of near rt ric simulators
as requied.

Issue-ID: NONRTRIC-115
Signed-off-by: YongchaoWu <yongchao.wu@est.tech>
Change-Id: I88461b6b5d3fa33a9fccd7cedf15535e06143bb6
diff --git a/near-rt-ric-simulator/simulator-group/ric/cleanConsul.py b/near-rt-ric-simulator/simulator-group/ric/cleanConsul.py
new file mode 100644
index 0000000..1e40416
--- /dev/null
+++ b/near-rt-ric-simulator/simulator-group/ric/cleanConsul.py
@@ -0,0 +1,24 @@
+import json
+import subprocess
+import os
+
+print("Clean old ric configurations in Consul config file")
+
+p = os.path.abspath('..')
+consul_config = p + '/consul_cbs' + '/config.json'
+
+
+def write_json(data, filename=consul_config):
+    with open(filename, 'w') as f:
+        json.dump(data, f, indent=4)
+
+
+with open(consul_config) as json_file:
+    clean = json.load(json_file)
+    clean['ric'] = []
+
+
+write_json(clean)
+print("Clean old ric configurations from Consul config file, done")
+
+
diff --git a/near-rt-ric-simulator/simulator-group/ric/docker-compose.yml b/near-rt-ric-simulator/simulator-group/ric/docker-compose.yml
new file mode 100644
index 0000000..e45e0e4
--- /dev/null
+++ b/near-rt-ric-simulator/simulator-group/ric/docker-compose.yml
@@ -0,0 +1,12 @@
+networks:
+  nonrtric-docker-net:
+    external:
+      name: nonrtric-docker-net
+services:
+  ric-simulator:
+    image: ric-simulator:latest
+    networks:
+      nonrtric-docker-net: null
+    ports:
+    - 8085/tcp
+version: '3.0'
\ No newline at end of file
diff --git a/near-rt-ric-simulator/simulator-group/ric/prepareConsul.py b/near-rt-ric-simulator/simulator-group/ric/prepareConsul.py
new file mode 100644
index 0000000..5cb482b
--- /dev/null
+++ b/near-rt-ric-simulator/simulator-group/ric/prepareConsul.py
@@ -0,0 +1,43 @@
+import json
+import subprocess
+import os
+
+print("Update fresh ric configuration in Consul configuration file")
+
+p = os.path.abspath('..')
+consul_config = p + '/consul_cbs' + '/config.json'
+
+
+def write_json(data, filename=consul_config):
+    with open(filename, 'w') as f:
+        json.dump(data, f, indent=4)
+
+
+def bash_command(cmd):
+    result = []
+    sp = subprocess.Popen(['/bin/bash', '-c', cmd], stdout=subprocess.PIPE)
+    for line in sp.stdout.readlines():
+        result.append(line.decode().strip())
+    return result
+
+
+command = "docker ps | grep simulator | awk '{print $NF}'"
+
+ric_list = bash_command(command)
+
+with open(consul_config) as json_file:
+    data = json.load(json_file)
+    temp = data['ric']
+    for ric in ric_list:
+        y = {"name": ric,
+             "baseUrl": "http://" + ric + ":8085/",
+             "managedElementIds": [
+                 "kista_" + ric,
+                 "stockholm_" + ric
+             ]
+             }
+        temp.append(y)
+
+
+write_json(data)
+print("Update Consul config file with fresh ric configuration,  done")