osdict: Refactor get_install_script()

Let's refactor get_install_script() in a way that any addition done in
order to get the install scripts from the media would be cleaner.

Signed-off-by: Fabiano Fidêncio <fidencio@redhat.com>
This commit is contained in:
Fabiano Fidêncio 2019-03-07 13:52:55 +01:00 committed by Cole Robinson
parent eae4ff3b42
commit fbcfc2147d

View File

@ -536,33 +536,36 @@ class _OsVariant(object):
(self.name, arch))
def get_install_script(self, profile):
def _get_install_script(script_list):
if not script_list:
raise RuntimeError(
_("'%s' does not support unattended installation.") %
self.name)
installscripts = []
profile_names = set()
for script in script_list:
profile_names.add(script.get_profile())
if script.get_profile() == profile:
installscripts.append(script)
if not installscripts:
raise RuntimeError(
_("'%s' does not support unattended installation for the "
"'%s' profile. Available profiles: %s") %
(self.name, profile, ", ".join(list(profile_names))))
logging.debug("Install script found for profile '%s'", profile)
# Some OSes (as Windows) have more than one installer script,
# depending on the OS version and profile choosen, to be used to
# perform the unattended installation. Let's just deal with
# multiple installer scripts when its actually needed, though.
return installscripts[0]
script_list = []
if self._os:
script_list = list(_OsinfoIter(self._os.get_install_script_list()))
if not script_list:
raise RuntimeError(
_("'%s' does not support unattended installation.") %
self.name)
installscripts = []
profile_names = set()
for script in script_list:
profile_names.add(script.get_profile())
if script.get_profile() == profile:
installscripts.append(script)
if not installscripts:
raise RuntimeError(
_("'%s' does not support unattended installation for the '%s' "
"profile. Available profiles: %s") %
(self.name, profile, ", ".join(list(profile_names))))
logging.debug("Install script found for profile '%s'", profile)
# Some OSes (as Windows) have more than one installer script, depending
# on the OS version and profile choosen, to be used to perform the
# unattended installation. Let's just deal with multiple installer
# scripts when its actually needed, though.
installscript = installscripts[0]
installscript = _get_install_script(script_list)
return installscript