[For the record]
Juan,
Thanks to your hint, I eventually found it more convenient for me to use
a SQL query to find out which VM was unsed for months :
SELECT
vm_static.vm_name,
vm_dynamic.status,
vm_dynamic.vm_ip,
vm_dynamic.vm_host,
vm_dynamic.last_start_time,
vm_dynamic.vm_guid,
vm_dynamic.last_stop_time
FROM
public.vm_dynamic,
public.vm_static
WHERE
vm_dynamic.vm_guid = vm_static.vm_guid AND
vm_dynamic.status = 0
ORDER BY
vm_dynamic.last_stop_time ASC;
Thank you.
--
Nicolas ECARNOT
Le 30/05/2017 à 17:29, Juan Hernández a écrit :
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---
--
Nicolas ECARNOT