[virt-tools-list] [virt-manager PATCH 1/5] unattended: Simplify _generate_debug()

Fabiano Fidêncio fidencio at redhat.com
Fri Jul 12 13:02:19 UTC 2019


Instead of a creating a new Config object and setting and the needed
fields, let's just save the original user & admin passwords, set the
"[SCRUBBLED]" one for generating the debug output, and reset the
original values after that.

Signed-off-by: Fabiano Fidêncio <fidencio at redhat.com>
---
 virtinst/install/unattended.py | 24 +++++++++---------------
 1 file changed, 9 insertions(+), 15 deletions(-)

diff --git a/virtinst/install/unattended.py b/virtinst/install/unattended.py
index d7ff59a2..8e6a20c5 100644
--- a/virtinst/install/unattended.py
+++ b/virtinst/install/unattended.py
@@ -186,24 +186,18 @@ class OSInstallScript:
                 self._osobj.get_handle(), self._config)
 
     def _generate_debug(self):
-        config = Libosinfo.InstallConfig()
+        original_user_password = self._config.get_user_password()
+        original_admin_password = self._config.get_admin_password()
 
-        config.set_user_login(self._config.get_user_login())
-        config.set_user_realname(self._config.get_user_realname())
         config.set_user_password("[SCRUBBLED]")
         config.set_admin_password("[SCRUBBLED]")
-        config.set_target_disk(self._config.get_target_disk())
-        config.set_hardware_arch(self._config.get_hardware_arch())
-        config.set_hostname(self._config.get_hostname())
-        config.set_l10n_timezone(self._config.get_l10n_timezone())
-        config.set_l10n_language(self._config.get_l10n_language())
-        config.set_l10n_keyboard(self._config.get_l10n_keyboard())
-        if self._config.get_installation_url():  # pylint: disable=no-member
-            config.set_installation_url(self._config.get_installation_url())  # pylint: disable=no-member
-        if self._config.get_reg_product_key():
-            config.set_reg_product_key(self._config.get_reg_product_key())
-
-        return self._script.generate(self._osobj.get_handle(), config)
+
+        debug_content = self.generate()
+
+        config.set_user_password(original_user_password)
+        config.set_admin_password(original_admin_password)
+
+        return debug_content
 
     def write(self):
         fileobj = tempfile.NamedTemporaryFile(
-- 
2.21.0




More information about the virt-tools-list mailing list