[virt-tools-list] [virt-manager PATCH 9/9] inspection: add a way to refresh the inspection info

Pino Toscano ptoscano at redhat.com
Wed Feb 22 15:42:45 UTC 2017


Introduce a 'Refresh' button in the 'Information' page of a VM, and
wire it up so a refresh of the inspection data for it is triggered.
Also, make sure to refresh the page, so the new information can be seen
even without switching to a different page and back to 'Information'.
---
 ui/details.ui          | 15 +++++++++++++++
 virtManager/details.py |  7 +++++++
 virtManager/engine.py  | 16 ++++++++++++++++
 3 files changed, 38 insertions(+)

diff --git a/ui/details.ui b/ui/details.ui
index c85e0e4..6330106 100644
--- a/ui/details.ui
+++ b/ui/details.ui
@@ -1669,6 +1669,21 @@ if you know what you are doing.</small></property>
                                 <property name="position">1</property>
                               </packing>
                             </child>
+                            <child>
+                              <object class="GtkButton" id="details-inspection-refresh">
+                                <property name="label" translatable="yes">Refresh</property>
+                                <property name="visible">True</property>
+                                <property name="can_focus">True</property>
+                                <property name="receives_default">True</property>
+                                <property name="halign">end</property>
+                                <signal name="clicked" handler="on_details_inspection_refresh_clicked" swapped="no"/>
+                              </object>
+                              <packing>
+                                <property name="expand">False</property>
+                                <property name="fill">False</property>
+                                <property name="position">2</property>
+                              </packing>
+                            </child>
                           </object>
                           <packing>
                             <property name="position">1</property>
diff --git a/virtManager/details.py b/virtManager/details.py
index 0503a44..b85033b 100644
--- a/virtManager/details.py
+++ b/virtManager/details.py
@@ -345,6 +345,7 @@ class vmmDetails(vmmGObjectUI):
         "details-closed": (GObject.SignalFlags.RUN_FIRST, None, []),
         "details-opened": (GObject.SignalFlags.RUN_FIRST, None, []),
         "customize-finished": (GObject.SignalFlags.RUN_FIRST, None, []),
+        "inspection-refresh": (GObject.SignalFlags.RUN_FIRST, None, [str, str]),
     }
 
     def __init__(self, vm, parent=None):
@@ -484,6 +485,8 @@ class vmmDetails(vmmGObjectUI):
             "on_idmap_gid_count_changed": lambda *x: self.enable_apply(x, EDIT_IDMAP),
             "on_idmap_check_toggled": self.config_idmap_enable,
 
+            "on_details_inspection_refresh_clicked": self.inspection_refresh,
+
             "on_cpu_vcpus_changed": self.config_vcpus_changed,
             "on_cpu_maxvcpus_changed": self.config_maxvcpus_changed,
             "on_cpu_model_changed": lambda *x: self.config_cpu_model_changed(x),
@@ -1565,6 +1568,10 @@ class vmmDetails(vmmGObjectUI):
             return self.config.get_default_cpu_setting(for_cpu=True)
         return key
 
+    def inspection_refresh(self, src_ignore):
+        self.emit("inspection-refresh",
+                  self.vm.conn.get_uri(), self.vm.get_connkey())
+
 
     ##############################
     # Details/Hardware listeners #
diff --git a/virtManager/engine.py b/virtManager/engine.py
index a9998a6..6d89a61 100644
--- a/virtManager/engine.py
+++ b/virtManager/engine.py
@@ -502,6 +502,7 @@ class vmmEngine(vmmGObject):
         self.inspection.start()
         self.connect("conn-added", self.inspection.conn_added)
         self.connect("conn-removed", self.inspection.conn_removed)
+        self.inspection.connect("vm-inspected", self._inspection_refreshed)
         return
 
     def _find_error_parent_cb(self):
@@ -707,6 +708,12 @@ class vmmEngine(vmmGObject):
             else:
                 self.err.show_err(msg, details, title)
 
+    def _inspection_refreshed(self, src_ignore, uri, connkey):
+        if connkey not in self.conns[uri]["windowDetails"]:
+            return
+
+        self.conns[uri]["windowDetails"][connkey].refresh_inspection_page()
+
 
     ####################
     # Dialog launchers #
@@ -810,6 +817,7 @@ class vmmEngine(vmmGObject):
         obj.connect("action-clone-domain", self._do_show_clone)
         obj.connect("details-opened", self.increment_window_counter)
         obj.connect("details-closed", self.decrement_window_counter)
+        obj.connect("inspection-refresh", self._do_refresh_inspection)
 
         self.conns[uri]["windowDetails"][connkey] = obj
         return self.conns[uri]["windowDetails"][connkey]
@@ -931,6 +939,14 @@ class vmmEngine(vmmGObject):
         except Exception, e:
             src.err.show_err(_("Error setting clone parameters: %s") % str(e))
 
+    def _do_refresh_inspection(self, src_ignore, uri, connkey):
+        if not self.inspection:
+            return
+
+        conn = self._lookup_conn(uri)
+        vm = conn.get_vm(connkey)
+        self.inspection.vm_refresh(vm)
+
     ##########################################
     # Window launchers from virt-manager cli #
     ##########################################
-- 
2.9.3




More information about the virt-tools-list mailing list