Create a restart-cluster.py.

 

#import time as systime
import time
import sys

def stopWLCluster():


    try:

               connect('Username', 'password', 't3://admin-host:admin-port')

               domainRuntime()
               clustername='myCluster'
               try:
                    print ("Stop Cluster")
                    #shutdown([name], [entityType], [ignoreSessions], [timeOut], [force], [block])
                    shutdown(clustername, "Cluster", "true",1200,"true")
                    time.sleep(10) #Wait for 10 sec to let the cluster shutdown
                    print ("Cluster stopped successfully..")
                    print ("Starting cluster...")
                    start(clustername, "Cluster",block='true')
                    print ("Cluster started successfully..")
            
               except Exception, e: 
                    print("ERROR WHILE START/STOP OF CLUSTER CAN'T PROCEED " + e) 
                    sys.exit()
       
               disconnect()
    except Exception, e: 
               print("PROBLEM CONNECTING TO ADMIN SERVER, CAN'T PROCEED " + e) 
               sys.exit()

def main():

    stopWLCluster()
    
main()