[virt-tools-list] [PATCH] [virt-manager] multiple graphs in manager window

Jon Nordby jononor at gmail.com
Tue Nov 10 19:14:10 UTC 2009


Attaching and inlining. What is the preferred way?
Network graphing did not work here, but seems unrelated to this patch.

# HG changeset patch
# User Jon Nordby <jononor at gmail.com>
# Date 1257879542 -3600
# Node ID 4cc78a5138a02eaa6f7b2ab7d1224eb9a9b2041c
# Parent  2907191a7a21c9eb51aad693f642ea9561d50ebc
manager: Bring back multiple graph as an option.

Essentially a revert of the changes in 09189003ddf9

diff -r 2907191a7a21 -r 4cc78a5138a0 src/virt-manager.schemas.in
--- a/src/virt-manager.schemas.in    Wed Oct 28 20:35:13 2009 -0400
+++ b/src/virt-manager.schemas.in    Tue Nov 10 19:59:02 2009 +0100
@@ -1,15 +1,41 @@
 <gconfschemafile>
   <schemalist>
     <schema>
-      <key>/schemas/apps/::PACKAGE::/vmlist-fields/stats-type</key>
-      <applyto>/apps/::PACKAGE::/vmlist-fields/stats-type</applyto>
+      <key>/schemas/apps/::PACKAGE::/vmlist-fields/disk_usage</key>
+      <applyto>/apps/::PACKAGE::/vmlist-fields/disk_usage</applyto>
       <owner>::PACKAGE::</owner>
-      <type>int</type>
+      <type>bool</type>
       <default>0</default>

       <locale name="C">
-        <short>Stats type in manager view</short>
-        <long>Type of stats to graph (cpu, disk, net) in manager
view</long>
+        <short>Show disk I/O in summary</short>
+        <long>Show the disk I/O field in the domain list summary
view</long>
+      </locale>
+    </schema>
+
+    <schema>
+      <key>/schemas/apps/::PACKAGE::/vmlist-fields/network_traffic</key>
+      <applyto>/apps/::PACKAGE::/vmlist-fields/network_traffic</applyto>
+      <owner>::PACKAGE::</owner>
+      <type>bool</type>
+      <default>0</default>
+
+      <locale name="C">
+        <short>Show network I/O in summary</short>
+        <long>Show the network I/O field in the domain list summary
view</long>
+      </locale>
+    </schema>
+
+    <schema>
+      <key>/schemas/apps/::PACKAGE::/vmlist-fields/cpu_usage</key>
+      <applyto>/apps/::PACKAGE::/vmlist-fields/cpu_usage</applyto>
+      <owner>::PACKAGE::</owner>
+      <type>bool</type>
+      <default>1</default>
+
+      <locale name="C">
+        <short>Show cpu usage in summary</short>
+        <long>Show the cpu usage field in the domain list summary
view</long>
       </locale>
     </schema>

diff -r 2907191a7a21 -r 4cc78a5138a0 src/virtManager/config.py
--- a/src/virtManager/config.py    Wed Oct 28 20:35:13 2009 -0400
+++ b/src/virtManager/config.py    Tue Nov 10 19:59:02 2009 +0100
@@ -245,12 +245,23 @@
             # Suggest gconf syncs, so that the unset dirs are fully removed
             self.conf.suggest_sync()

-    def get_vmlist_stats_type(self):
-        return self.conf.get_int(self.conf_dir +
"/vmlist-fields/stats_type")
+    def is_vmlist_cpu_usage_visible(self):
+        return self.conf.get_bool(self.conf_dir +
"/vmlist-fields/cpu_usage")

-    def set_vmlist_stats_type(self, val):
-        self.conf.set_int(self.conf_dir + "/vmlist-fields/stats_type", val)
+    def is_vmlist_disk_io_visible(self):
+        return self.conf.get_bool(self.conf_dir +
"/vmlist-fields/disk_usage")

+    def is_vmlist_network_traffic_visible(self):
+        return self.conf.get_bool(self.conf_dir +
"/vmlist-fields/network_traffic")
+
+    def set_vmlist_cpu_usage_visible(self, state):
+        self.conf.set_bool(self.conf_dir + "/vmlist-fields/cpu_usage",
state)
+
+    def set_vmlist_disk_io_visible(self, state):
+        self.conf.set_bool(self.conf_dir + "/vmlist-fields/disk_usage",
state)
+
+    def set_vmlist_network_traffic_visible(self, state):
+        self.conf.set_bool(self.conf_dir +
"/vmlist-fields/network_traffic", state)

     def get_default_directory(self, conn, _type):
         if not _type:
@@ -290,9 +301,14 @@
     def set_view_system_tray(self, val):
         self.conf.set_bool(self.conf_dir + "/system-tray", val)

-    def on_vmlist_stats_type_changed(self, callback):
-        self.conf.notify_add(self.conf_dir + "/vmlist-fields/stats_type",
-                             callback)
+    def on_vmlist_cpu_usage_visible_changed(self, callback):
+        self.conf.notify_add(self.conf_dir + "/vmlist-fields/cpu_usage",
callback)
+
+    def on_vmlist_disk_io_visible_changed(self, callback):
+        self.conf.notify_add(self.conf_dir + "/vmlist-fields/disk_usage",
callback)
+
+    def on_vmlist_network_traffic_visible_changed(self, callback):
+        self.conf.notify_add(self.conf_dir +
"/vmlist-fields/network_traffic", callback)

     def get_stats_update_interval(self):
         interval = self.conf.get_int(self.conf_dir +
"/stats/update-interval")
diff -r 2907191a7a21 -r 4cc78a5138a0 src/virtManager/manager.py
--- a/src/virtManager/manager.py    Wed Oct 28 20:35:13 2009 -0400
+++ b/src/virtManager/manager.py    Tue Nov 10 19:59:02 2009 +0100
@@ -34,8 +34,6 @@
 from virtManager.graphwidgets import CellRendererSparkline
 from virtManager import util as util

-VMLIST_SORT_NAME = 1
-VMLIST_SORT_STATS = 2

 # fields in the tree model data set
 ROW_HANDLE = 0
@@ -52,8 +50,9 @@

 # Columns in the tree view
 COL_NAME = 0
-COL_STATUS = 1
-COL_STATS = 2
+COL_CPU = 1
+COL_DISK = 2
+COL_NETWORK = 3

 rcstring = """
 style "toolbar-style" {
@@ -159,12 +158,11 @@
         self.startup_error = None
         self.ignore_pause = False

-        self.stats_column = None
-        self.stats_sparkline = None
-
         self.prepare_vmlist()

-        self.config.on_vmlist_stats_type_changed(self.stats_toggled_config)
+
self.config.on_vmlist_cpu_usage_visible_changed(self.toggle_cpu_usage_visible_widget)
+
self.config.on_vmlist_disk_io_visible_changed(self.toggle_disk_io_visible_widget)
+
self.config.on_vmlist_network_traffic_visible_changed(self.toggle_network_traffic_visible_widget)

         # Register callbacks with the global stats enable/disable values
         # that disable the associated vmlist widgets if reporting is
disabled
@@ -173,6 +171,11 @@
         self.config.on_stats_enable_net_poll_changed(self.enable_polling,
                                                      cfg.STATS_NETWORK)

+
self.window.get_widget("menu_view_stats_cpu").set_active(self.config.is_vmlist_cpu_usage_visible())
+
self.window.get_widget("menu_view_stats_disk").set_active(self.config.is_vmlist_disk_io_visible())
+
self.window.get_widget("menu_view_stats_network").set_active(self.config.is_vmlist_network_traffic_visible())
+
+
         self.vmmenu_icons = {}
         self.vmmenu_icons["run"] = gtk.Image()
         self.vmmenu_icons["run"].set_from_stock(gtk.STOCK_MEDIA_PLAY,
@@ -325,12 +328,12 @@
         self.connmenu.show()

         self.window.signal_autoconnect({
-            "on_menu_view_stats_disk_toggled" :     (self.stats_toggled,
-                                                     cfg.STATS_DISK),
-            "on_menu_view_stats_network_toggled" :  (self.stats_toggled,
-                                                     cfg.STATS_NETWORK),
-            "on_menu_view_stats_cpu_toggled" :      (self.stats_toggled,
-                                                     cfg.STATS_CPU),
+            "on_menu_view_cpu_usage_activate":  (self.toggle_stats_visible,
+                                                    cfg.STATS_CPU),
+            "on_menu_view_disk_io_activate" :   (self.toggle_stats_visible,
+                                                    cfg.STATS_DISK),
+            "on_menu_view_network_traffic_activate":
(self.toggle_stats_visible,
+                                                cfg.STATS_NETWORK),

             "on_vm_manager_delete_event": self.close,
             "on_menu_file_add_connection_activate": self.new_connection,
@@ -845,11 +848,15 @@
         nameCol.set_expand(True)
         nameCol.set_spacing(6)
         cpuUsageCol = gtk.TreeViewColumn(_("CPU usage"))
-        cpuUsageCol.set_min_width(150)
+#         cpuUsageCol.set_min_width(150)
+        diskIOCol = gtk.TreeViewColumn(_("Disk I/O"))
+        networkTrafficCol = gtk.TreeViewColumn(_("Network I/O"))

         statusCol = nameCol
         vmlist.append_column(nameCol)
         vmlist.append_column(cpuUsageCol)
+        vmlist.append_column(diskIOCol)
+        vmlist.append_column(networkTrafficCol)

         # For the columns which follow, we deliberately bind columns
         # to fields in the list store & on each update copy the info
@@ -868,7 +875,7 @@
         name_txt = gtk.CellRendererText()
         nameCol.pack_start(name_txt, True)
         nameCol.add_attribute(name_txt, 'markup', ROW_MARKUP)
-        nameCol.set_sort_column_id(VMLIST_SORT_NAME)
+        nameCol.set_sort_column_id(COL_NAME)

         cpuUsage_txt = gtk.CellRendererText()
         cpuUsage_img = CellRendererSparkline()
@@ -879,14 +886,37 @@
         cpuUsageCol.pack_start(cpuUsage_txt, False)
         cpuUsageCol.add_attribute(cpuUsage_img, 'visible', ROW_IS_VM)
         cpuUsageCol.add_attribute(cpuUsage_txt, 'visible', ROW_IS_CONN)
-        cpuUsageCol.set_sort_column_id(VMLIST_SORT_STATS)
-        self.stats_sparkline = cpuUsage_img
-        self.stats_column = cpuUsageCol
-        self.stats_toggled(None, self.get_stats_type())
+        cpuUsageCol.set_cell_data_func(cpuUsage_img, self.cpu_usage_img,
None)
+        cpuUsageCol.set_visible(self.config.is_vmlist_cpu_usage_visible())
+        cpuUsageCol.set_sort_column_id(COL_CPU)

-        model.set_sort_func(VMLIST_SORT_NAME, self.vmlist_name_sorter)
+        diskIO_img = CellRendererSparkline()
+        diskIO_img.set_property("xpad", 6)
+        diskIO_img.set_property("ypad", 12)
+        diskIO_img.set_property("reversed", True)
+        diskIOCol.pack_start(diskIO_img, True)
+        diskIOCol.add_attribute(diskIO_img, 'visible', ROW_IS_VM)
+        diskIOCol.set_cell_data_func(diskIO_img, self.disk_io_img, None)
+        diskIOCol.set_visible(self.config.is_vmlist_disk_io_visible())
+        diskIOCol.set_sort_column_id(COL_DISK)

-        model.set_sort_column_id(VMLIST_SORT_NAME, gtk.SORT_ASCENDING)
+        networkTraffic_img = CellRendererSparkline()
+        networkTraffic_img.set_property("xpad", 6)
+        networkTraffic_img.set_property("ypad", 12)
+        networkTraffic_img.set_property("reversed", True)
+        networkTrafficCol.pack_start(networkTraffic_img, True)
+        networkTrafficCol.add_attribute(networkTraffic_img, 'visible',
ROW_IS_VM)
+        networkTrafficCol.set_cell_data_func(networkTraffic_img,
+                                             self.network_traffic_img,
None)
+
networkTrafficCol.set_visible(self.config.is_vmlist_network_traffic_visible())
+        networkTrafficCol.set_sort_column_id(COL_NETWORK)
+
+        model.set_sort_func(COL_NAME, self.vmlist_name_sorter)
+        model.set_sort_func(COL_CPU, self.vmlist_cpu_usage_sorter)
+        model.set_sort_func(COL_DISK, self.vmlist_disk_io_sorter)
+        model.set_sort_func(COL_NETWORK, self.vmlist_network_usage_sorter)
+
+        model.set_sort_column_id(COL_NAME, gtk.SORT_ASCENDING)

     def vmlist_name_sorter(self, model, iter1, iter2):
         return cmp(model.get_value(iter1, ROW_NAME),
@@ -918,53 +948,31 @@
             widget.set_sensitive(False)
             tool_text = _("Disabled in preferences dialog.")

-            if self.get_stats_type() == userdata:
-                # Switch graphs over to guaranteed safe value
-                self.stats_toggled(None, cfg.STATS_CPU)
-
         util.tooltip_wrapper(widget, tool_text)

-    def stats_toggled_config(self, ignore1, ignore2, conf_entry, ignore4):
-        self.stats_toggled(None, conf_entry.get_value().get_int())
+    def toggle_network_traffic_visible_widget(self, *ignore):
+        vmlist = self.window.get_widget("vm-list")
+        col = vmlist.get_column(COL_NETWORK)
+        col.set_visible(self.config.is_vmlist_network_traffic_visible())

-    def get_stats_type(self):
-        return self.config.get_vmlist_stats_type()
+    def toggle_disk_io_visible_widget(self, *ignore):
+        vmlist = self.window.get_widget("vm-list")
+        col = vmlist.get_column(COL_DISK)
+        col.set_visible(self.config.is_vmlist_disk_io_visible())

-    def stats_toggled(self, src, stats_id):
-        if src and not src.get_active():
-            return
+    def toggle_cpu_usage_visible_widget(self, *ignore):
+        vmlist = self.window.get_widget("vm-list")
+        col = vmlist.get_column(COL_CPU)
+        col.set_visible(self.config.is_vmlist_cpu_usage_visible())

-        if stats_id == cfg.STATS_NETWORK:
-            column_name = _("Network I/O")
-            stats_func = self.network_traffic_img
-            sort_func = self.vmlist_network_usage_sorter
-            widg = "menu_view_stats_network"
-        elif stats_id == cfg.STATS_DISK:
-            column_name = _("Disk I/O")
-            stats_func = self.disk_io_img
-            sort_func = self.vmlist_disk_io_sorter
-            widg = "menu_view_stats_disk"
-        elif stats_id == cfg.STATS_CPU:
-            column_name = _("CPU Usage")
-            stats_func = self.cpu_usage_img
-            sort_func = self.vmlist_cpu_usage_sorter
-            widg = "menu_view_stats_cpu"
-        else:
-            return
-
-        if not src:
-            self.window.get_widget(widg).set_active(True)
-
-        if self.stats_column:
-            vmlist = self.window.get_widget("vm-list")
-            model = vmlist.get_model()
-            self.stats_column.set_title(column_name)
-            self.stats_column.set_cell_data_func(self.stats_sparkline,
-                                                 stats_func, None)
-            model.set_sort_func(VMLIST_SORT_STATS, sort_func)
-
-        if stats_id != self.get_stats_type():
-            self.config.set_vmlist_stats_type(stats_id)
+    def toggle_stats_visible(self, src, stats_id):
+        visible = src.get_active()
+        set_stats = {
+        cfg.STATS_CPU: self.config.set_vmlist_cpu_usage_visible,
+        cfg.STATS_DISK: self.config.set_vmlist_disk_io_visible,
+        cfg.STATS_NETWORK: self.config.set_vmlist_network_traffic_visible,
+        }
+        set_stats[stats_id](visible)

     def cpu_usage_img(self,  column, cell, model, _iter, data):
         if model.get_value(_iter, ROW_HANDLE) is None:
diff -r 2907191a7a21 -r 4cc78a5138a0 src/vmm-manager.glade
--- a/src/vmm-manager.glade    Wed Oct 28 20:35:13 2009 -0400
+++ b/src/vmm-manager.glade    Tue Nov 10 19:59:02 2009 +0100
@@ -158,33 +158,31 @@
                         <child>
                           <widget class="GtkMenu" id="menu1">
                             <property name="visible">True</property>
-                            <child>
-                              <widget class="GtkRadioMenuItem"
id="menu_view_stats_cpu">
+                           <child>
+                              <widget class="GtkCheckMenuItem"
id="menu_view_stats_cpu">
                                 <property name="visible">True</property>
-                                <property name="label"
translatable="yes">CPU</property>
+                                <property name="label"
translatable="yes">CPU Usage</property>
                                 <property
name="use_underline">True</property>
-                                <property
name="draw_as_radio">True</property>
-                                <signal name="toggled"
handler="on_menu_view_stats_cpu_toggled"/>
+                                <property name="active">True</property>
+                                <signal name="activate"
handler="on_menu_view_cpu_usage_activate"/>
+                              </widget>
+                            </child>
+                           <child>
+                              <widget class="GtkCheckMenuItem"
id="menu_view_stats_disk">
+                                <property name="visible">True</property>
+                                <property name="label"
translatable="yes">Disk I/O</property>
+                                <property
name="use_underline">True</property>
+                                <property name="active">True</property>
+                                <signal name="activate"
handler="on_menu_view_disk_io_activate"/>
                               </widget>
                             </child>
                             <child>
-                              <widget class="GtkRadioMenuItem"
id="menu_view_stats_disk">
+                              <widget class="GtkCheckMenuItem"
id="menu_view_stats_network">
                                 <property name="visible">True</property>
-                                <property name="label"
translatable="yes">Disk</property>
+                                <property name="label"
translatable="yes">Network I/O</property>
                                 <property
name="use_underline">True</property>
-                                <property
name="draw_as_radio">True</property>
-                                <property
name="group">menu_view_stats_cpu</property>
-                                <signal name="toggled"
handler="on_menu_view_stats_disk_toggled"/>
-                              </widget>
-                            </child>
-                            <child>
-                              <widget class="GtkRadioMenuItem"
id="menu_view_stats_network">
-                                <property name="visible">True</property>
-                                <property name="label"
translatable="yes">Network</property>
-                                <property
name="use_underline">True</property>
-                                <property
name="draw_as_radio">True</property>
-                                <property
name="group">menu_view_stats_cpu</property>
-                                <signal name="toggled"
handler="on_menu_view_stats_network_toggled"/>
+                                <property name="active">True</property>
+                                <signal name="activate"
handler="on_menu_view_network_traffic_activate"/>
                               </widget>
                             </child>
                           </widget>



-- 
Regards Jon Nordby - www.jonnor.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/virt-tools-list/attachments/20091110/739789a8/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: multiple_graphs.patch
Type: application/octet-stream
Size: 17982 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/virt-tools-list/attachments/20091110/739789a8/attachment.obj>


More information about the virt-tools-list mailing list