[virt-tools-list] [PATCH 1/4] Filter of listed domains works again.

Darryl L. Pierce dpierce at redhat.com
Mon May 23 21:47:20 UTC 2011


With the change to libvirtworker to re-use code from the GUI, the
specified filters for started/defined domains was lost. This patch
re-enables that functionality.
---
 src/virtManagerTui/configscreen.py  |    4 ++--
 src/virtManagerTui/libvirtworker.py |   14 ++++++++++++--
 2 files changed, 14 insertions(+), 4 deletions(-)

diff --git a/src/virtManagerTui/configscreen.py b/src/virtManagerTui/configscreen.py
index 77fe983..f9753f7 100644
--- a/src/virtManagerTui/configscreen.py
+++ b/src/virtManagerTui/configscreen.py
@@ -167,10 +167,10 @@ class DomainListConfigScreen(ConfigScreen):
         if self.__has_domains:
             self.__domain_list = Listbox(0)
             for uuid in domuuids:
-                dom = self.get_libvirt().get_domain(uuid)
+                domain = self.get_libvirt().get_domain(uuid)
 
                 # dom is a vmmDomain
-                self.__domain_list.append(dom.get_name(), dom)
+                self.__domain_list.append(domain.get_name(), domain)
             result = [self.__domain_list]
         else:
             grid = Grid(1, 1)
diff --git a/src/virtManagerTui/libvirtworker.py b/src/virtManagerTui/libvirtworker.py
index 185e673..0172fe1 100644
--- a/src/virtManagerTui/libvirtworker.py
+++ b/src/virtManagerTui/libvirtworker.py
@@ -120,11 +120,21 @@ class LibvirtWorker:
         '''Returns the capabilities for this libvirt host.'''
         return self.__capabilities
 
-    def list_domains(self, defined = True, started = True):
+    def list_domains(self, defined = True, created = True):
         '''Lists all domains.'''
         # XXX: This doesn't abide the passed parameters
         self.__vmmconn.tick()
-        return self.__vmmconn.list_vm_uuids()
+        uuids = self.__vmmconn.list_vm_uuids()
+        result = []
+        for uuid in uuids:
+            include = False
+            domain = self.get_domain(uuid)
+            if domain.status() in [libvirt.VIR_DOMAIN_RUNNING]:
+                if created: include = True
+            else:
+                if defined: include = True
+            if include: result.append(uuid)
+        return result
 
     def get_domain(self, uuid):
         '''Returns the specified domain.'''
-- 
1.7.4.4




More information about the virt-tools-list mailing list