Improve the dockerized auto test
[nonrtric.git] / near-rt-ric-simulator / simulator-group / ric / cleanConsul.py
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 (file)
index 0000000..1e40416
--- /dev/null
@@ -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")
+
+