Hi everyone, i have a question that can we schedule shutdown and restart CVMs, AHV host automatically? For example, I want to shutdown system at 9 P.M and restart it at 9 A.M. It could be scripts or anything else. Hope your helps
Schedule Shutdown and Restart CVM
Best answer by Ken.Moellman
As Alexander noted above, these are the likely steps. You will have to interact with the cluster in some way; at a minimum to start the cluster back up.
To add to what was said, the “start” process will require some work and proper hardware if you want to automate it. You will need to be able to log into the IPMI/iLO/iDRAC type interface and power-on the server. I would write a script that would run from an external server.
Shutdown would look like this:
- Get list of running VMs, store in a file on the local machine where the script is running
- Use list of running VMs to shutdown VMs
- Wait for all VMs to shut down
- Log into CVM
- Get list of all CVMs, hypervisors, and IPMI using “ncli host list” and store each list in a file (CVM file, Hypervisor file, IPMI file)
- Shut down cluster with “cluster stop” on CVM
- Wait for cluster to stop
- Log out of CVM
- Using the file with the CVM list, loop through the list of CVMs to connect to each one and shut the CVM down with “cvm_shutdown -P now”
- Using the file with the hypervisor list, loop through the list of hypervisor servers to connect to each one and shutdown each hypervisor with “shutdown -h” (can also try “poweroff”)
-
If your particular hardware doesn’t power off with this command, use the IPMI file to connect to each IPMI/iLO/iDRAC to power off the machine.
Power-on would probably look like this:
- Use a list of servers to connect to each IPMI/iDRAC/iLO and power-on the hardware
- Wait until the server is booted and the CVM is up and running on all servers. (ping, ssh checks, etc). You will likely need to connect to each hypervisor via SSH and then verify the status of the CVM.
- Connect to CVM and issue “cluster start”
- Wait until cluster is fully up and running (likely with “cluster status”)
- Start up VMs from the Running VMs file you created at the very beginning.
And then you would want to schedule cron or other task management to control this process timing.
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.