From 8079c421bd8b377c14af4d094818a3ff589c03bb Mon Sep 17 00:00:00 2001 From: Cole Robinson Date: Mon, 1 Aug 2022 05:56:25 -0400 Subject: [PATCH] connection: De-duplicate ui and cli version logging Remove the open coded version logging in cli.py and virt-manager connection.py, and move it into virtinst connection open Signed-off-by: Cole Robinson --- virtManager/connection.py | 5 ----- virtinst/cli.py | 13 +------------ virtinst/connection.py | 20 ++++++++++++++++++++ 3 files changed, 21 insertions(+), 17 deletions(-) diff --git a/virtManager/connection.py b/virtManager/connection.py index 6585fef6b..8e7df402e 100644 --- a/virtManager/connection.py +++ b/virtManager/connection.py @@ -950,11 +950,6 @@ class vmmConnection(vmmGObject): return False, ConnectError def _populate_initial_state(self): - log.debug("libvirt version=%s", self._backend.local_libvirt_version()) - log.debug("daemon version=%s", self._backend.daemon_version()) - log.debug("conn version=%s", self._backend.conn_version()) - log.debug("%s capabilities:\n%s", self.get_uri(), self.caps.get_xml()) - if not self.support.conn_domain(): # pragma: no cover raise RuntimeError("Connection does not support required " "domain listing APIs") diff --git a/virtinst/cli.py b/virtinst/cli.py index 58fda2803..3c0252b1f 100644 --- a/virtinst/cli.py +++ b/virtinst/cli.py @@ -214,21 +214,10 @@ def getConnection(uri, conn=None): # preopened connection passed in via test suite return conn - def format_version(num): - log.debug(num) - maj = int(num / 1000000) - min = int(num / 1000) % 1000 - mic = num % 1000 - return "%s.%s.%s" % (maj, min, mic) - log.debug("Requesting libvirt URI %s", (uri or "default")) conn = VirtinstConnection(uri) conn.open(_openauth_cb, None) - log.debug("Received libvirt URI %s versions library=%s driver=%s hypervisor=%s", - conn.uri, - format_version(libvirt.getVersion()), - format_version(conn.getLibVersion()), - format_version(conn.getVersion())) + log.debug("Received libvirt URI %s", conn.uri) return conn diff --git a/virtinst/connection.py b/virtinst/connection.py index cf36a6d56..987560437 100644 --- a/virtinst/connection.py +++ b/virtinst/connection.py @@ -114,6 +114,23 @@ class VirtinstConnection(object): return self._libvirtconn + ################### + # Private helpers # + ################### + + def _log_versions(self): + def format_version(num): + major = int(num / 1000000) + minor = int(num / 1000) % 1000 + micro = num % 1000 + return "%s.%s.%s" % (major, minor, micro) + + log.debug("libvirt URI versions library=%s driver=%s hypervisor=%s", + format_version(self.local_libvirt_version()), + format_version(self.daemon_version()), + format_version(self.conn_version())) + + ############## # Public API # ############## @@ -163,6 +180,9 @@ class VirtinstConnection(object): self._uri = self._libvirtconn.getURI() self._uriobj = URI(self._uri) + self._log_versions() + self._get_caps() # cache and log capabilities + def get_libvirt_data_root_dir(self): if self.is_privileged(): return "/var/lib/libvirt"