What is the best method to drain a host of all VMs

We frequently need to live-migrate all VMs off a host to perform maintenance on the host. This has historically been a manual process but I’d like to automate it. What is the recommended method of live-migrating all VMs off a host and on to a new compatible host?

Versions of the related components and OS (frontend, hypervisors, VMs):
OpenNebula 5.10 using KVM backends on Ubuntu 18.04.

Current results:
onevm migrate <vm name> <compatible host> --live works fine, but needs to be done for each VM, and a human has to pick the <compatible host>. I’d like to have the Nebula scheduler pick the host instead.

Expected results:
Run a simple script drain_host that will disable the KVM host in Nebula and live-migrate all the VMs from the old host to new KVM hosts that have available capacity in the same Nebula cluster.

Hello @tbenz9

You can use the command onehost flush this will resched all the VMs in another hosts and disable the host:

$ onehost flush -h
## USAGE
flush <range|hostid_list>
        Disables the host and reschedules all the running VMs in it.

## OPTIONS
     -h, --help                Show this message
     -V, --version             Show version and copyright information
     --user name               User name used to connect to OpenNebula
     --password password       Password to authenticate with OpenNebula
     --endpoint endpoint       URL of OpenNebula xmlrpc frontend

Best,
Álex.

2 Likes

Thanks very much, not sure why I didn’t find that during my search but you’ve saved me many hours that I would have spent writing my own solution.