with open('cluster.json') as cluster_file: data = json.load(cluster_file) except: print str(sys.exc_info()) print 'unable to open the file cluster.json' exit(1) try: controllers = data["cluster"]["controllers"] user_name = data["cluster"]["user"] user_pass = data["cluster"]["pass"] except: print str(sys.exc_info()) print 'Error reading the file cluster.json' exit(1) try: isolate = int(sys.argv[1]) duration = int(sys.argv[2]) except: print 'You must specify the number (e.g. 1, 2, 3) of the controller to isolate.' exit(1) print 'Isolating controller ' + str(isolate) print UtilLibrary.isolate_controller(controllers, user_name, user_pass, isolate) print 'Pausing for ' + str(duration) + ' seconds...' time.sleep(duration) print UtilLibrary.flush_iptables(controllers, user_name, user_pass)
"user": "******", "pass": "******" } } Usage:python rejoin.py """ import sys sys.path.append('../../../csit/libraries') import UtilLibrary import json try: with open('cluster.json') as cluster_file: data = json.load(cluster_file) except: print str(sys.exc_info()) print "unable to open the file cluster.json" exit(1) try: cluster_list = data["cluster"]["controllers"] user_name = data["cluster"]["user"] user_pass = data["cluster"]["pass"] except: print str(sys.exc_info()) print 'Error reading the file cluster.json' exit(1) print UtilLibrary.flush_iptables(cluster_list, user_name, user_pass)
try: with open('cluster.json') as cluster_file: data = json.load(cluster_file) except: print str(sys.exc_info()) print 'unable to open the file cluster.json' exit(1) try: controllers = data["cluster"]["controllers"] user_name = data["cluster"]["user"] user_pass = data["cluster"]["pass"] except: print str(sys.exc_info()) print 'Error reading the file cluster.json' exit(1) try: isolate = int(sys.argv[1]) duration = int(sys.argv[2]) except: print 'You must specify the number (e.g. 1, 2, 3) of the controller to isolate.' exit(1) print 'Isolating controller ' + str(isolate) print UtilLibrary.isolate_controller(controllers, user_name, user_pass, isolate) print 'Pausing for ' + str(duration) + ' seconds...' time.sleep(duration) print UtilLibrary.flush_iptables(controllers, user_name, user_pass)