From c0aebcbe91bee27176dfd241e16af2173c6637d2 Mon Sep 17 00:00:00 2001 From: neingeist Date: Wed, 3 Aug 2016 17:48:50 +0200 Subject: [PATCH] libvirt-check-trim: fail more elegantly if listAllDomains() is not available --- libvirt-check-trim.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libvirt-check-trim.py b/libvirt-check-trim.py index 2c9e7f1..1c054e7 100644 --- a/libvirt-check-trim.py +++ b/libvirt-check-trim.py @@ -13,6 +13,10 @@ if not conn: print('Failed to open connection to the hypervisor!') sys.exit(1) +if not hasattr(conn, "listAllDomains"): + print('connection does not have listAllDomains(), is python-libvirt too old?') + sys.exit(1) + for domain in conn.listAllDomains(): print('== {}'.format(domain.name()))