[virt-tools-list] [PATCH 4/4] Add basic operating system inspection data to the VMM details page.
Cole Robinson
crobinso at redhat.com
Thu Jul 7 14:59:28 UTC 2011
On 06/30/2011 04:02 AM, Richard W.M. Jones wrote:
> From: "Richard W.M. Jones" <rjones at redhat.com>
>
> This adds hostname, product name, and list of applications.
> ---
> src/virtManager/details.py | 62 ++++++++++++++++++++
> src/vmm-details.glade | 137 +++++++++++++++++++++++++++++++++++++++++++-
> 2 files changed, 197 insertions(+), 2 deletions(-)
>
> diff --git a/src/virtManager/details.py b/src/virtManager/details.py
> index e3d7c4a..0cb798f 100644
> --- a/src/virtManager/details.py
> +++ b/src/virtManager/details.py
> @@ -575,6 +575,34 @@ class vmmDetails(vmmGObjectUI):
> buf.connect("changed", self.config_enable_apply)
> desc.set_buffer(buf)
>
> + # List of applications.
> + apps_list = self.window.get_widget("inspection-apps")
> + apps_model = gtk.ListStore (str, str, str)
> + apps_list.set_model(apps_model)
> +
> + name_col = gtk.TreeViewColumn(_("Name"))
> + version_col = gtk.TreeViewColumn(_("Version"))
> + summary_col = gtk.TreeViewColumn()
> +
> + apps_list.append_column(name_col)
> + apps_list.append_column(version_col)
> + apps_list.append_column(summary_col)
> +
> + name_text = gtk.CellRendererText()
> + name_col.pack_start(name_text, True)
> + name_col.add_attribute(name_text, 'text', 0)
> + name_col.set_sort_column_id(0)
> +
> + version_text = gtk.CellRendererText()
> + version_col.pack_start(version_text, True)
> + version_col.add_attribute(version_text, 'text', 1)
> + version_col.set_sort_column_id(1)
> +
> + summary_text = gtk.CellRendererText()
> + summary_col.pack_start(summary_text, True)
> + summary_col.add_attribute(summary_text, 'text', 2)
> + summary_col.set_sort_column_id(2)
> +
> # Clock combo
> clock_combo = self.window.get_widget("overview-clock-combo")
> clock_model = gtk.ListStore(str)
> @@ -2106,6 +2134,40 @@ class vmmDetails(vmmGObjectUI):
> self.window.get_widget("overview-arch").set_text(arch)
> self.window.get_widget("overview-emulator").set_text(emu)
>
> + # Operating System (ie. inspection data)
> + hostname = self.vm.get_inspection_hostname()
> + if not hostname: hostname = _("unknown")
> + self.window.get_widget("inspection-hostname").set_text(hostname)
> + product_name = self.vm.get_inspection_product_name()
> + if not product_name: product_name = _("unknown")
> + self.window.get_widget("inspection-product-name").set_text(product_name)
> +
> + # Applications (also inspection data)
> + apps = self.vm.get_inspection_applications()
> +
I'd just do
apps = self.vm.get_inspection_applications() or []
then you don't need to do any 'if apps', the 'for' loop will just be a nop.
> + if apps:
> + apps_list = self.window.get_widget("inspection-apps")
> + apps_model = apps_list.get_model()
> + apps_model.clear()
> + i = 0
> + for app in apps:
> + name = ""
> + if app["app_name"]:
> + name = app["app_name"]
> + if app["app_display_name"]:
> + name = app["app_display_name"]
> + version = ""
> + if app["app_version"]:
> + version = app["app_version"]
> + if app["app_release"]:
> + version += "-" + app["app_release"]
> + summary = ""
> + if app["app_summary"]:
> + summary = app["app_summary"]
> +
> + apps_model.insert(i, [name, version, summary])
> + i += 1
You can drop 'i' and just do app_model.append([name, version, summary])
I like the idea though.
Thanks,
Cole
More information about the virt-tools-list
mailing list