[virt-tools-list] [PATCH 4/4] Add basic operating system inspection data to the VMM details page.

2011-07-18 Thread Richard W.M. Jones
From: Richard W.M. Jones rjo...@redhat.com

This adds hostname, product name, and list of applications.
---
 src/virtManager/details.py |   61 +++
 src/vmm-details.glade  |  137 +++-
 2 files changed, 196 insertions(+), 2 deletions(-)

diff --git a/src/virtManager/details.py b/src/virtManager/details.py
index 4164825..027dfeb 100644
--- a/src/virtManager/details.py
+++ b/src/virtManager/details.py
@@ -652,6 +652,34 @@ class vmmDetails(vmmGObjectUI):
 buf.connect(changed, self.enable_apply, EDIT_DESC)
 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.widget(overview-clock-combo)
 clock_model = gtk.ListStore(str)
@@ -2293,6 +2321,39 @@ class vmmDetails(vmmGObjectUI):
 self.widget(overview-arch).set_text(arch)
 self.widget(overview-emulator).set_text(emu)
 
+# Operating System (ie. inspection data)
+hostname = self.vm.inspection.hostname
+if not hostname:
+hostname = _(unknown)
+self.window.get_widget(inspection-hostname).set_text(hostname)
+product_name = self.vm.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.inspection.applications or []
+
+apps_list = self.window.get_widget(inspection-apps)
+apps_model = apps_list.get_model()
+apps_model.clear()
+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.append([name, version, summary])
+
 # Machine settings
 acpi = self.vm.get_acpi()
 apic = self.vm.get_apic()
diff --git a/src/vmm-details.glade b/src/vmm-details.glade
index 3817e7b..4934999 100644
--- a/src/vmm-details.glade
+++ b/src/vmm-details.glade
@@ -1139,6 +1139,139 @@
   /packing
 /child
 child
+  widget class=GtkFrame id=frame17
+property name=visibleTrue/property
+property name=label_xalign0/property
+property 
name=shadow_typenone/property
+child
+  widget class=GtkAlignment 
id=alignment43
+property 
name=visibleTrue/property
+property 
name=left_padding12/property
+child
+  widget class=GtkTable 
id=table17
+property 
name=visibleTrue/property
+property 
name=border_width3/property
+property 
name=n_rows2/property
+property 
name=n_columns2/property
+property 
name=column_spacing6/property
+property 
name=row_spacing6/property
+child
+  widget class=GtkLabel 
id=label71
+property 
name=visibleTrue/property
+  

Re: [virt-tools-list] [PATCH 4/4] Add basic operating system inspection data to the VMM details page.

2011-07-07 Thread Cole Robinson
On 06/30/2011 04:02 AM, Richard W.M. Jones wrote:
 From: Richard W.M. Jones rjo...@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

___
virt-tools-list mailing list
virt-tools-list@redhat.com
https://www.redhat.com/mailman/listinfo/virt-tools-list


[virt-tools-list] [PATCH 4/4] Add basic operating system inspection data to the VMM details page.

2011-06-30 Thread Richard W.M. Jones
From: Richard W.M. Jones rjo...@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()
+
+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
+
 # Machine settings
 acpi = self.vm.get_acpi()
 apic = self.vm.get_apic()
diff --git a/src/vmm-details.glade b/src/vmm-details.glade
index 2d69c27..dea9cbe 100644
--- a/src/vmm-details.glade
+++ b/src/vmm-details.glade
@@ -1138,6 +1138,139 @@
   /packing
 /child
 child
+  widget class=GtkFrame id=frame17
+property name=visibleTrue/property
+property name=label_xalign0/property
+property 
name=shadow_typenone/property
+child
+  widget class=GtkAlignment 
id=alignment43
+property 
name=visibleTrue/property
+property 
name=left_padding12/property
+child
+  widget class=GtkTable 
id=table17
+property 
name=visibleTrue/property
+property 
name=border_width3/property
+property 
name=n_rows2/property
+property 
name=n_columns2/property
+property 
name=column_spacing6/property
+property 
name=row_spacing6/property
+child
+