
On 05/30/2017 05:02 PM, Nicolas Ecarnot wrote:
Hello,
I'm trying to find a way to clean up the VMs list of my DCs. I think some of my users have created VM they're not using anymore, but it's difficult to sort them out. In some cases, I can shutdown some of them and wait. Is there somewhere stored in the db tables the date of the last VM exctinction?
Thank you.
Did you consider using the API? There is a 'stop_time' attribute that you can use. For example, to list all the VMs and sort them by stop time you can use the following Python script: ---8<--- import ovirtsdk4 as sdk import ovirtsdk4.types as types # Create the connection to the server: connection = sdk.Connection( url='https://engine.example.com/ovirt-engine/api', username='admin@internal', password='...', ca_file='/etc/pki/ovirt-engine/ca.pem' ) # List the virtual machines: vms_service = connection.system_service().vms_service() vms = vms_service.list() # Sort the them by stop time: vms.sort(key=lambda vm: vm.stop_time) # Print the result: for vm in vms: print("%s: %s" % (vm.name, vm.stop_time)) # Close the connection to the server: connection.close() --->8---