3 Controller Isolation Tool
7 This tool isolates an indicated controller from the cluster. The tool takes
8 a single integer argument corresponding to the number of a controller
9 in a json file's ordered list of controllers. This is the controller to
12 A file named 'cluster.json' containing a list of the IP addresses, ports and
13 credentials of the controllers is required. It resides in the same
14 directory as monitor.py.
16 The file should look like this:
21 {"ip": "172.17.10.93", "port": "8181"},
22 {"ip": "172.17.10.93", "port": "8181"},
23 {"ip": "172.17.10.93", "port": "8181"}
30 Usage:python isolate.py [controller to be isolated]
36 def import_utility_modules():
37 global UtilLibrary, json
39 sys.path.append('../../../csit/libraries')
44 import_utility_modules()
47 with open('cluster.json') as cluster_file:
48 data = json.load(cluster_file)
50 print str(sys.exc_info())
51 print "unable to open the file cluster.json"
54 cluster_list = data["cluster"]["controllers"]
56 for controller in cluster_list:
57 cluster_ips.append(controller["ip"])
58 user_name = data["cluster"]["user"]
59 user_pass = data["cluster"]["pass"]
61 print str(sys.exc_info())
62 print 'Error reading the file cluster.json'
65 isolate = int(sys.argv[1])
67 print 'You must specify the number (e.g. 1, 2, 3) of the controller to isolate.'
70 print "isolating controller " + str(isolate)
72 print UtilLibrary.isolate_controller(cluster_ips, user_name, user_pass, isolate)