enable auth in rest calls, and fix one error message
[integration/test.git] / tools / clustering / cluster-monitor / timed_isolation.py
index 8492575afcf572db7ffda166a8f5cc455be378d6..06b5d127870536b00eae1e60745045f03e362804 100644 (file)
@@ -19,12 +19,12 @@ The file should look like this:
     {
         "cluster": {
             "controllers": [
-                "172.17.10.93",
-                "172.17.10.94",
-                "172.17.10.95"
+                {"ip": "172.17.10.93", "port": "8181"},
+                {"ip": "172.17.10.93", "port": "8181"},
+                {"ip": "172.17.10.93", "port": "8181"}
             ],
             "user": "username",
-            "pass": "password"
+            "pass": "password",
         }
     }
 
@@ -32,11 +32,19 @@ Usage:python timed_isolation.py [controller to be isolated]  [duration of isolat
 """
 
 import sys
-sys.path.append('../../../csit/libraries')
-import UtilLibrary
-import json
 import time
 
+
+def import_utility_modules():
+    global UtilLibrary, json
+    import sys
+    sys.path.append('../../../csit/libraries')
+    import UtilLibrary
+    import json
+
+
+import_utility_modules()
+
 try:
     with open('cluster.json') as cluster_file:
         data = json.load(cluster_file)
@@ -45,7 +53,10 @@ except:
     print 'unable to open the file cluster.json'
     exit(1)
 try:
-    controllers = data["cluster"]["controllers"]
+    cluster_list = data["cluster"]["controllers"]
+    cluster_ips = []
+    for controller in cluster_list:
+        cluster_ips.append(controller["ip"])
     user_name = data["cluster"]["user"]
     user_pass = data["cluster"]["pass"]
 except:
@@ -61,9 +72,9 @@ except:
 
 print 'Isolating controller ' + str(isolate)
 
-print UtilLibrary.isolate_controller(controllers, user_name, user_pass, isolate)
+print UtilLibrary.isolate_controller(cluster_ips, user_name, user_pass, isolate)
 
 print 'Pausing for ' + str(duration) + ' seconds...'
 time.sleep(duration)
 
-print UtilLibrary.flush_iptables(controllers, user_name, user_pass)
+print UtilLibrary.flush_iptables(cluster_ips, user_name, user_pass)