2019-02-22 11:40:08 +03:00
#
# Common code for unattended installations
#
# Copyright 2019 Red Hat, Inc.
#
# This work is licensed under the GNU GPLv2 or later.
# See the COPYING file in the top-level directory.
2019-02-22 11:40:16 +03:00
import os
from . import util
2019-03-05 19:53:20 +03:00
from . osdict import OSInstallScript
2019-02-22 11:40:16 +03:00
2019-02-22 11:40:08 +03:00
class UnattendedData ( ) :
profile = None
admin_password = None
user_password = None
2019-02-22 11:40:16 +03:00
def generate_install_script ( guest , unattended_data ) :
from gi . repository import Gio as gio
2019-03-05 19:53:20 +03:00
rawscript = guest . osinfo . get_install_script ( unattended_data . profile )
script = OSInstallScript ( rawscript , guest . osinfo )
2019-02-22 11:40:16 +03:00
# For all tree based installations we're going to perform initrd injection
# and install the systems via network.
2019-03-05 19:53:20 +03:00
script . set_preferred_injection_method ( " initrd " )
script . set_installation_source ( " network " )
2019-02-22 11:40:16 +03:00
2019-03-05 19:53:20 +03:00
config = script . get_config ( unattended_data , guest . os . arch , guest . name )
2019-02-22 11:40:16 +03:00
scratch = os . path . join ( util . get_cache_dir ( ) , " unattended " )
if not os . path . exists ( scratch ) :
os . makedirs ( scratch , 0o751 )
2019-03-05 19:53:20 +03:00
script . generate_output ( config , gio . File . new_for_path ( scratch ) )
2019-02-22 11:40:16 +03:00
path = os . path . join ( scratch , script . get_expected_filename ( ) )
2019-03-05 19:53:20 +03:00
cmdline = script . generate_cmdline ( config )
2019-02-22 11:40:16 +03:00
return path , cmdline