Here's a, small, collection of scripts that I've made for managing oVirt VMs.
scripts\suspend_vms.py
: As the name suggests it suspends all the running VMs; The VMs in a different state than "UP", will be ignored. This script can be run as a normal userscripts\resume_vms.py
: As the name suggests it resume all the VMs marked as SUSPENDED; The VMs in a different state than "SUSPENDED", will be ignored. This script must be run asroot
, because, in the end, it will execute theengine-backup
command to backup the state of the oVirt Engine. This file, also, should be run directly on the oVirt Host machine or, more in general, in the machine where theengine-backup
program is installed.
I use them on my oVirt installation that is a simple oVirt Standalone Server, but they should be ok, with minor modifications, even with more complex deploy.
The scripts are written in Python 3 and they need the Python ovirtsdk4, because of this dependence, they can be used only with oVirt 4.0+ (the script are used/tested on an oVirt 4.4+ environment).
More info about the SDK can be found on their GitHub repo.
Before using the scripts you need to modify them. Just replace the placeholders with your actual values:
_URL_
: Your API endpoint, something likehttps://<host>/ovirt-engine/api
_USER_NAME_
: An admin login for oVirt, usuallyadmin@internal
_PASSWORD_
: The admin user password_CA_FILE_
: Complete path to the CA file used on the server, usually something like/etc/pki/ovirt-engine/ca.pem
Only for the resume_vms.py
, you need to set also the:
_BACKUP_PATH_
: The full path where to place the backup files
The scripts are released under CC0 1.0 Universal license.