[virt-tools-list] [RFC PATCH 10/10] tui: Example instantiation of vmmConnection

Cole Robinson crobinso at redhat.com
Mon Apr 18 18:17:30 UTC 2011


Right now this doesn't do anything, but it shows that we've removed
gtk and gobject deps from a lot of the code that needs to be shared from
virt-manager.

To proceed from here, all the commented out classes in vmmConnection
would need to be converted to use vmmGObject.signal_new to allow dropping
their gtk/gobject imports. Then the TUI can use the vmmConnection for
polling and instantiating virt-manager's libvirt object classes

Signed-off-by: Cole Robinson <crobinso at redhat.com>
---
 src/virtManager/connection.py       |   20 ++++++++++++--------
 src/virtManagerTui/libvirtworker.py |    4 ++++
 2 files changed, 16 insertions(+), 8 deletions(-)

diff --git a/src/virtManager/connection.py b/src/virtManager/connection.py
index c71ed2a..1764a2d 100644
--- a/src/virtManager/connection.py
+++ b/src/virtManager/connection.py
@@ -34,13 +34,13 @@ import virtinst
 from virtManager import util
 from virtManager.baseclass import vmmGObject
 
-from virtManager.domain import vmmDomain
-from virtManager.network import vmmNetwork
-from virtManager.storagepool import vmmStoragePool
-from virtManager.interface import vmmInterface
-from virtManager.netdev import vmmNetDevice
-from virtManager.mediadev import vmmMediaDevice
-from virtManager.nodedev import vmmNodeDevice
+#from virtManager.domain import vmmDomain
+#from virtManager.network import vmmNetwork
+#from virtManager.storagepool import vmmStoragePool
+#from virtManager.interface import vmmInterface
+#from virtManager.netdev import vmmNetDevice
+#from virtManager.mediadev import vmmMediaDevice
+#from virtManager.nodedev import vmmNodeDevice
 
 class vmmConnection(vmmGObject):
 
@@ -49,7 +49,7 @@ class vmmConnection(vmmGObject):
     STATE_ACTIVE = 2
     STATE_INACTIVE = 3
 
-    def __init__(self, uri, readOnly=False):
+    def __init__(self, uri, readOnly=False, rawconn=None):
         vmmGObject.__init__(self)
 
         self.connectThread = None
@@ -102,6 +102,10 @@ class vmmConnection(vmmGObject):
         self.mediadev_error = ""
         self.mediadev_use_libvirt = False
 
+        if rawconn:
+            self.vmm = rawconn
+            self._change_state(self.STATE_ACTIVE)
+
     #################
     # Init routines #
     #################
diff --git a/src/virtManagerTui/libvirtworker.py b/src/virtManagerTui/libvirtworker.py
index 6c1484f..e75d3c0 100644
--- a/src/virtManagerTui/libvirtworker.py
+++ b/src/virtManagerTui/libvirtworker.py
@@ -23,6 +23,8 @@ import virtinst
 import utils
 import logging
 
+from virtManager.connection import vmmConnection
+
 from domainconfig import DomainConfig
 
 DEFAULT_POOL_TARGET_PATH="/var/lib/libvirt/images"
@@ -84,6 +86,8 @@ class LibvirtWorker:
         self.__net.setup(self.__conn)
         (self.__new_guest, self.__new_domain) = virtinst.CapabilitiesParser.guest_lookup(conn = self.__conn)
 
+        self.__conn_obj = vmmConnection(self.__url, rawconn=self.__conn)
+
     def get_connection(self):
         '''Returns the underlying connection.'''
         return self.__conn
-- 
1.7.4




More information about the virt-tools-list mailing list