[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[libvirt] [PATCH 14/16] Listing running sandbox containers takes a long time using the current protocol.



So I am execing a virsh list command to show all of the running containers.
---
 bin/virt-sandbox-service | 17 +++++++++++------
 1 file changed, 11 insertions(+), 6 deletions(-)

diff --git a/bin/virt-sandbox-service b/bin/virt-sandbox-service
index b559cf5..ceb05b3 100755
--- a/bin/virt-sandbox-service
+++ b/bin/virt-sandbox-service
@@ -907,22 +907,27 @@ def usage(parser, msg):
     sys.exit(1)
 
 def sandbox_list(args):
+    if args.running:
+        import libvirt
+        conn = libvirt.open("lxc:///")
+        running = conn.listAllDomains(0)
+        conn.close()
+        running.sort()
+        for d in running:
+            print d.name()
+        return
+
     import glob
     g = glob.glob(CONFIG_PATH + "*.sandbox")
     g.sort()
     for gc in g:
         try:
             c = LibvirtSandbox.Config.load_from_path(gc)
-            if args.running:
-                if c.running():
-                    print c.get_name()
-            else:
-                print c.get_name()
+            print c.get_name()
 
         except OSError, e:
             print "Invalid container %s: %s", (gc, e)
 
-
 def sandbox_reload(args):
     config = read_config(args.name)
     if isinstance(config, gi.repository.LibvirtSandbox.ConfigInteractive):
-- 
1.8.2


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]