[virt-tools-list] [PATCH 2/4] Add inspection data to the domain object.

Richard W.M. Jones rjones at redhat.com
Mon Jul 18 14:18:20 UTC 2011


From: "Richard W.M. Jones" <rjones at redhat.com>

Create a new (sub-)object vmmInspectionData, and add an instance of
this data to each domain object.  This data is passed up from from the
inspection thread.

Also an inspection-changed signal has been added so that UI elements
can find out when inspection has finished for a particular VM and
update the UI.
---
 src/virtManager/domain.py         |    8 ++++
 src/virtManager/inspection.py     |   15 +++++++
 src/virtManager/inspectiondata.py |   76 +++++++++++++++++++++++++++++++++++++
 3 files changed, 99 insertions(+), 0 deletions(-)
 create mode 100644 src/virtManager/inspectiondata.py

diff --git a/src/virtManager/domain.py b/src/virtManager/domain.py
index 4ec92b6..332ac57 100644
--- a/src/virtManager/domain.py
+++ b/src/virtManager/domain.py
@@ -30,6 +30,8 @@ import virtinst.support as support
 from virtManager import util
 from virtManager.libvirtobject import vmmLibvirtObject
 
+from inspectiondata import vmmInspectionData
+
 def compare_device(origdev, newdev, idx):
     devprops = {
         "disk"      : ["target", "bus"],
@@ -164,6 +166,8 @@ class vmmDomain(vmmLibvirtObject):
         self._stats_disk_supported = True
         self._stats_disk_skip = []
 
+        self.inspection = vmmInspectionData()
+
         if isinstance(self._backend, virtinst.Guest):
             return
 
@@ -1418,6 +1422,9 @@ class vmmDomain(vmmLibvirtObject):
         return self.config.get_pervm(self.connection.get_uri(), self.uuid,
                                      self.config.get_details_window_size)
 
+    def inspection_data_updated(self):
+        self.idle_emit("inspection-changed")
+
 
     ###################
     # Polling helpers #
@@ -1609,5 +1616,6 @@ class vmmDomainVirtinst(vmmDomain):
 vmmLibvirtObject.type_register(vmmDomain)
 vmmDomain.signal_new(vmmDomain, "status-changed", [int, int])
 vmmDomain.signal_new(vmmDomain, "resources-sampled", [])
+vmmDomain.signal_new(vmmDomain, "inspection-changed", [])
 
 vmmLibvirtObject.type_register(vmmDomainVirtinst)
diff --git a/src/virtManager/inspection.py b/src/virtManager/inspection.py
index 91536bf..2836a29 100644
--- a/src/virtManager/inspection.py
+++ b/src/virtManager/inspection.py
@@ -24,6 +24,8 @@ from threading import Thread
 
 from guestfs import GuestFS
 
+from inspectiondata import vmmInspectionData
+
 import logging
 import util
 
@@ -198,6 +200,19 @@ class vmmInspection(Thread):
         # Force the libguestfs handle to close right now.
         del g
 
+        vm.inspection.type = typ
+        vm.inspection.distro = distro
+        vm.inspection.major_version = major_version
+        vm.inspection.minor_version = minor_version
+        vm.inspection.hostname = hostname
+        vm.inspection.product_name = product_name
+
+        vm.inspection.product_variant = product_variant
+        vm.inspection.icon = icon
+        vm.inspection.applications = apps
+
+        vm.inspection_data_updated()
+
         # Log what we found.
         logging.debug("%s: detected operating system: %s %s %d.%d (%s)",
                       self._name, typ, distro, major_version, minor_version,
diff --git a/src/virtManager/inspectiondata.py b/src/virtManager/inspectiondata.py
new file mode 100644
index 0000000..c848f03
--- /dev/null
+++ b/src/virtManager/inspectiondata.py
@@ -0,0 +1,76 @@
+#
+# Copyright (C) 2011 Red Hat, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+# MA 02110-1301 USA.
+#
+
+class vmmInspectionData(object):
+    def __init__(self):
+        self._type = None
+        self._distro = None
+        self._major_version = None
+        self._minor_version = None
+        self._hostname = None
+        self._product_name = None
+        self._product_variant = None
+        self._icon = None
+        self._applications = None
+
+    def _set_type(self, new):
+        self._type = str(new)
+    def _get_type(self):
+        return self._type
+    type = property(_get_type, _set_type)
+    def _set_distro(self, new):
+        self._distro = str(new)
+    def _get_distro(self):
+        return self._distro
+    distro = property(_get_distro, _set_distro)
+    def _set_major_version(self, new):
+        self._major_version = int(new)
+    def _get_major_version(self):
+        return self._major_version
+    major_version = property(_get_major_version, _set_major_version)
+    def _set_minor_version(self, new):
+        self._minor_version = int(new)
+    def _get_minor_version(self):
+        return self._minor_version
+    minor_version = property(_get_minor_version, _set_minor_version)
+    def _set_hostname(self, new):
+        self._hostname = str(new)
+    def _get_hostname(self):
+        return self._hostname
+    hostname = property(_get_hostname, _set_hostname)
+    def _set_product_name(self, new):
+        self._product_name = str(new)
+    def _get_product_name(self):
+        return self._product_name
+    product_name = property(_get_product_name, _set_product_name)
+    def _set_product_variant(self, new):
+        self._product_variant = str(new)
+    def _get_product_variant(self):
+        return self._product_variant
+    product_variant = property(_get_product_variant, _set_product_variant)
+    def _set_icon(self, new):
+        self._icon = str(new)
+    def _get_icon(self):
+        return self._icon
+    icon = property(_get_icon, _set_icon)
+    def _set_applications(self, new):
+        self._applications = list(new)
+    def _get_applications(self):
+        return self._applications
+    applications = property(_get_applications, _set_applications)
-- 
1.7.5.2




More information about the virt-tools-list mailing list