diff --git a/ui/details.ui b/ui/details.ui index e0689f4d..2e7b253b 100644 --- a/ui/details.ui +++ b/ui/details.ui @@ -1,5 +1,5 @@ - + @@ -1399,171 +1399,114 @@ - + True False - start vertical + 12 - + True False - vertical - 12 + 0 + none - + True False - 0 - none + 12 - + True False - 12 + 3 + 6 + 6 - + True False - 3 - 6 - 6 - - - True - False - end - Product name: - - - 0 - 2 - - - - - True - False - start - foo - True - - - 1 - 0 - - - - - True - False - end - Hostname: - - - 0 - 0 - - - - - True - False - end - Operating system: - - - 0 - 1 - - - - - True - False - start - foo - True - - - 1 - 2 - - - - - True - False - start - foo - - - 1 - 1 - - + end + Product name: + + 0 + 2 + - - - - - True - False - <b>Operating System</b> - True - - - - - False - True - 0 - - - - - True - True - - - True - False - 3 - 21 - - 150 + True - True - etched-in - - - True - True - - - - - + False + start + foo + True + + 1 + 0 + + + + + True + False + end + Hostname: + + + 0 + 0 + + + + + True + False + end + Operating system: + + + 0 + 1 + + + + + True + False + start + foo + True + + + 1 + 2 + + + + + True + False + start + foo + + + 1 + 1 + - - - True - False - <b>Applications</b> - True - - - - False - True - 1 - + + + + True + False + <b>Operating System</b> + True + @@ -1573,71 +1516,124 @@ - + True - False - start - end - vertical - 6 + True - + True False - start - start - gtk-dialog-warning + 3 + 21 + + + 150 + True + True + etched-in + + + True + True + + + + + + + - - 0 - 0 - - - + + True False - start - start - Error message bar - 80 + <b>Applications</b> + True - - 1 - 0 - - True + False True 1 - - Refresh + True - True - True - end - + False + 12 + + + True + False + start + center + vertical + 6 + + + True + False + start + start + gtk-dialog-warning + + + 0 + 0 + + + + + True + False + start + start + Error message baraaaaaaaa aaaaaaaaaaaaaa aaaaaaaaaaaaaaaa + fill + True + 60 + + + 1 + 0 + + + + + True + True + 0 + + + + + Refresh + True + True + True + end + start + + + + False + False + 1 + + False - False + True 2 - - - inspection-tab - - 1 - False diff --git a/virtManager/details.py b/virtManager/details.py index 2c7a4525..76ceff69 100644 --- a/virtManager/details.py +++ b/virtManager/details.py @@ -2372,10 +2372,11 @@ class vmmDetails(vmmGObjectUI): def refresh_inspection_page(self): inspection_supported = self.config.inspection_supported() uiutil.set_grid_row_visible(self.widget("details-overview-error"), - self.vm.inspection.error) - if self.vm.inspection.error: - msg = _("Error while inspecting the guest configuration") - self.widget("details-overview-error").set_text(msg) + bool(self.vm.inspection.errorstr)) + if self.vm.inspection.errorstr: + self.widget("details-overview-error").set_text( + self.vm.inspection.errorstr) + inspection_supported = False self.widget("details-inspection-os").set_visible(inspection_supported) self.widget("details-inspection-apps").set_visible(inspection_supported) diff --git a/virtManager/domain.py b/virtManager/domain.py index 1c3f5451..ca2d4266 100644 --- a/virtManager/domain.py +++ b/virtManager/domain.py @@ -146,7 +146,7 @@ class vmmInspectionData(object): self.product_variant = None self.icon = None self.applications = None - self.error = False + self.errorstr = None class vmmDomainSnapshot(vmmLibvirtObject): diff --git a/virtManager/inspection.py b/virtManager/inspection.py index a01ae963..c06d7653 100644 --- a/virtManager/inspection.py +++ b/virtManager/inspection.py @@ -26,6 +26,12 @@ from .baseclass import vmmGObject from .domain import vmmInspectionData +def _inspection_error(_errstr): + data = vmmInspectionData() + data.errorstr = _errstr + return data + + class vmmInspection(vmmGObject): # Can't find a way to make Thread release our reference _leak_check = False @@ -63,7 +69,6 @@ class vmmInspection(vmmGObject): self._q = queue.Queue() self._conns = {} - self._vmseen = {} self._cached_data = {} val = self.config.get_libguestfs_inspect_vms() @@ -78,7 +83,6 @@ class vmmInspection(vmmGObject): self._stop() self._q = queue.Queue() self._conns = {} - self._vmseen = {} self._cached_data = {} # Called by the main thread whenever a connection is added or @@ -135,9 +139,7 @@ class vmmInspection(vmmGObject): if cmd == "conn_added": conn = obj[1] uri = conn.get_uri() - if (conn.is_remote() or - conn.is_test() or - uri in self._conns): + if uri in self._conns: return self._conns[uri] = conn @@ -167,51 +169,45 @@ class vmmInspection(vmmGObject): # all we need is to remove it from the "seen" cache, # as the data itself will be replaced once the new # results are available. - self._vmseen.pop(vmuuid) + self._cached_data.pop(vmuuid, None) self._process_vm(conn, vm) - # Try processing a single VM, keeping into account whether it was - # visited already, and whether there are cached data for it. def _process_vm(self, conn, vm): - def set_inspection_error(vm): - data = vmmInspectionData() - data.error = True - self._set_vm_inspection_data(vm, data) + # Try processing a single VM, keeping into account whether it was + # visited already, and whether there are cached data for it. + def _set_vm_inspection_data(_data): + vm.inspection = _data + vm.inspection_data_updated() + self._cached_data[vm.get_uuid()] = _data + prettyvm = conn.get_uri() + ":" + vm.get_name() vmuuid = vm.get_uuid() - prettyvm = vmuuid + if vmuuid in self._cached_data: + data = self._cached_data.get(vmuuid) + if vm.inspection != data: + logging.debug("Found cached data for %s", prettyvm) + _set_vm_inspection_data(data) + return + try: - prettyvm = conn.get_uri() + ":" + vm.get_name() - - if vmuuid in self._vmseen: - data = self._cached_data.get(vmuuid) - if not data: - return - - if vm.inspection != data: - logging.debug("Found cached data for %s", prettyvm) - self._set_vm_inspection_data(vm, data) - return - - # Whether success or failure, we've "seen" this VM now. - self._vmseen[vmuuid] = True - try: - data = self._inspect_vm(conn, vm) - if data: - self._set_vm_inspection_data(vm, data) - else: - set_inspection_error(vm) - except Exception: - set_inspection_error(vm) - raise - except Exception: + data = self._inspect_vm(conn, vm) + except Exception as e: + data = _inspection_error(_("Error inspection VM: %s") % str(e)) logging.exception("%s: exception while processing", prettyvm) + _set_vm_inspection_data(data) + def _inspect_vm(self, conn, vm): if self._thread is None: return + if conn.is_remote(): + return _inspection_error( + _("Cannot inspect VM on remote connection")) + if conn.is_test(): + return _inspection_error("Cannot inspect VM on test connection") + import guestfs # pylint: disable=import-error g = guestfs.GuestFS(close_on_exit=False) @@ -222,14 +218,17 @@ class vmmInspection(vmmGObject): except Exception as e: logging.debug("%s: Error launching libguestfs appliance: %s", prettyvm, str(e)) - return None + return _inspection_error( + _("Error launching libguestfs appliance: %s") % str(e)) + logging.debug("%s: inspection appliance connected", prettyvm) # Inspect the operating system. roots = g.inspect_os() if len(roots) == 0: logging.debug("%s: no operating systems found", prettyvm) - return None + return _inspection_error( + _("Inspection found no operating systems.")) # Arbitrarily pick the first root device. root = roots[0] @@ -313,11 +312,5 @@ class vmmInspection(vmmGObject): data.product_variant = str(product_variant) data.icon = icon data.applications = list(apps or []) - data.error = False return data - - def _set_vm_inspection_data(self, vm, data): - vm.inspection = data - vm.inspection_data_updated() - self._cached_data[vm.get_uuid()] = data