unattended: Simplify _generate_debug()
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. Reviewed-by: Cole Robinson <crobinso@redhat.com> Signed-off-by: Fabiano Fidêncio <fidencio@redhat.com>
This commit is contained in:
parent
e678d94b45
commit
6d8bf5dff1
|
@ -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())
|
||||
self._config.set_user_password("[SCRUBBLED]")
|
||||
self._config.set_admin_password("[SCRUBBLED]")
|
||||
|
||||
return self._script.generate(self._osobj.get_handle(), config)
|
||||
debug_content = self.generate()
|
||||
|
||||
self._config.set_user_password(original_user_password)
|
||||
self._config.set_admin_password(original_admin_password)
|
||||
|
||||
return debug_content
|
||||
|
||||
def write(self):
|
||||
fileobj = tempfile.NamedTemporaryFile(
|
||||
|
|
Loading…
Reference in New Issue