def initInterface(self): if self._intf: raise RuntimeError("Second attempt to initialize the InstallInterface") if self.gui_mode: from pyanaconda.ui.gui import GraphicalUserInterface # Run the GUI in non-fullscreen mode, so live installs can still # use the window manager self._intf = GraphicalUserInterface(self.storage, self.payload, gui_lock=self.gui_initialized, fullscreen=False, decorated=self.decorated) # needs to be refreshed now we know if gui or tui will take place addon_paths = addons.collect_addon_paths(constants.ADDON_PATHS, ui_subdir="gui") elif self.tui_mode: # TUI and noninteractive TUI are the same in this regard from pyanaconda.ui.tui import TextUserInterface self._intf = TextUserInterface(self.storage, self.payload) # needs to be refreshed now we know if gui or tui will take place addon_paths = addons.collect_addon_paths(constants.ADDON_PATHS, ui_subdir="tui") elif not self.display_mode: raise RuntimeError("Display mode not set.") else: # this should generally never happen, as display_mode now won't let # and invalid value to be set, but let's leave it here just in case # something ultra crazy happens raise RuntimeError("Unsupported display mode: %s" % self.display_mode) if addon_paths: self._intf.update_paths(addon_paths)
def initInterface(self, addon_paths=None): if self._intf: raise RuntimeError("Second attempt to initialize the InstallInterface") if self.displayMode == 'g': from pyanaconda.ui.gui import GraphicalUserInterface # Run the GUI in non-fullscreen mode, so live installs can still # use the window manager self._intf = GraphicalUserInterface(self.storage, self.payload, self.instClass, gui_lock=self.gui_initialized, fullscreen=False) # needs to be refreshed now we know if gui or tui will take place addon_paths = addons.collect_addon_paths(constants.ADDON_PATHS, ui_subdir="gui") elif self.displayMode in ['t', 'c']: # text and command line are the same from pyanaconda.ui.tui import TextUserInterface self._intf = TextUserInterface(self.storage, self.payload, self.instClass) # needs to be refreshed now we know if gui or tui will take place addon_paths = addons.collect_addon_paths(constants.ADDON_PATHS, ui_subdir="tui") else: raise RuntimeError("Unsupported displayMode: %s" % self.displayMode) if addon_paths: self._intf.update_paths(addon_paths)
def initInterface(self, addon_paths=None): if self._intf: raise RuntimeError( "Second attempt to initialize the InstallInterface") if self.displayMode == 'g': from pyanaconda.ui.gui import GraphicalUserInterface # Run the GUI in non-fullscreen mode, so live installs can still # use the window manager self._intf = GraphicalUserInterface(self.storage, self.payload, self.instClass, gui_lock=self.gui_initialized, fullscreen=False) # needs to be refreshed now we know if gui or tui will take place addon_paths = addons.collect_addon_paths(constants.ADDON_PATHS, ui_subdir="gui") elif self.displayMode in ['t', 'c']: # text and command line are the same from pyanaconda.ui.tui import TextUserInterface self._intf = TextUserInterface(self.storage, self.payload, self.instClass) # needs to be refreshed now we know if gui or tui will take place addon_paths = addons.collect_addon_paths(constants.ADDON_PATHS, ui_subdir="tui") else: raise RuntimeError("Unsupported displayMode: %s" % self.displayMode) if addon_paths: self._intf.update_paths(addon_paths)
def initInterface(self): if self._intf: raise RuntimeError("Second attempt to initialize the InstallInterface") if self.gui_mode: from pyanaconda.ui.gui import GraphicalUserInterface # Run the GUI in non-fullscreen mode, so live installs can still # use the window manager self._intf = GraphicalUserInterface(None, self.payload, gui_lock=self.gui_initialized, fullscreen=False) # needs to be refreshed now we know if gui or tui will take place addon_paths = addons.collect_addon_paths(constants.ADDON_PATHS, ui_subdir="gui") elif self.tui_mode: # TUI and noninteractive TUI are the same in this regard from pyanaconda.ui.tui import TextUserInterface self._intf = TextUserInterface(None, self.payload) # needs to be refreshed now we know if gui or tui will take place addon_paths = addons.collect_addon_paths(constants.ADDON_PATHS, ui_subdir="tui") elif not self.display_mode: raise RuntimeError("Display mode not set.") else: # this should generally never happen, as display_mode now won't let # and invalid value to be set, but let's leave it here just in case # something ultra crazy happens raise RuntimeError("Unsupported display mode: %s" % self.display_mode) if addon_paths: self._intf.update_paths(addon_paths)
def __init__(self, gui_mode): """Initialize the Initial Setup internals""" log.debug("initializing Initial Setup") # True if running in graphical mode, False otherwise (text mode) self.gui_mode = gui_mode # kickstart data self.data = None # reboot on quit flag self._reboot_on_quit = False # parse any command line arguments args = self._parse_arguments() # initialize logging initial_setup_log.init(stdout_log=not args.no_stdout_log) global logging_initialized logging_initialized = True log.info("Initial Setup %s" % __version__) # check if we are running as root if os.geteuid() != 0: log.critical("Initial Setup needs to be run as root") raise InitialSetupError # load configuration files from pyanaconda.core.configuration.anaconda import conf conf.set_from_files(["/etc/initial-setup/conf.d/"]) if self.gui_mode: log.debug("running in GUI mode") else: log.debug("running in TUI mode") self._external_reconfig = False # check if the reconfig mode should be enabled # by checking if at least one of the reconfig # files exist for reconfig_file in RECONFIG_FILES: if os.path.exists(reconfig_file): self.external_reconfig = True log.debug("reconfig trigger file found: %s", reconfig_file) if self.external_reconfig: log.debug("running in externally triggered reconfig mode") if self.gui_mode: # We need this so we can tell GI to look for overrides objects # also in anaconda source directories import gi.overrides for p in os.environ.get("ANACONDA_WIDGETS_OVERRIDES", "").split(":"): gi.overrides.__path__.insert(0, p) log.debug("GI overrides imported") from pyanaconda.addons import collect_addon_paths addon_paths = [ "/usr/share/initial-setup/modules", "/usr/share/anaconda/addons" ] # append ADDON_PATHS dirs at the end sys.path.extend(addon_paths) self._addon_module_paths = collect_addon_paths(addon_paths, self.gui_mode_id) log.info("found %d addon modules:", len(self._addon_module_paths)) for addon_path in self._addon_module_paths: log.debug(addon_path) # Too bad anaconda does not have modularized logging log.debug("initializing the Anaconda log") from pyanaconda import anaconda_logging anaconda_logging.init(write_to_journal=True) # create class for launching our dbus session self._dbus_launcher = AnacondaDBusLauncher() # group, user, root password set-before tracking self._groups_already_configured = False self._users_already_configured = False self._root_password_already_configured = False
log.info("anaconda called with cmdline = %s", sys.argv) log.info("Default encoding = %s ", sys.getdefaultencoding()) # start dbus session (if not already running) and run boss in it try: anaconda.dbus_launcher.start() except TimeoutError as e: stdout_log.error(str(e)) anaconda.dbus_launcher.stop() util.ipmi_report(constants.IPMI_ABORTED) time.sleep(10) sys.exit(1) # Collect all addon paths addon_paths = collect_addon_paths(constants.ADDON_PATHS) # If we were given a kickstart file on the command line, parse (but do not # execute) that now. Otherwise, load in defaults from kickstart files # shipped with the installation media. ksdata = startup_utils.parse_kickstart(opts, addon_paths, pass_to_boss=True) # Pick up any changes from interactive-defaults.ks that would # otherwise be covered by the dracut KS parser. from pyanaconda.modules.common.constants.services import STORAGE from pyanaconda.modules.common.constants.objects import BOOTLOADER bootloader_proxy = STORAGE.get_proxy(BOOTLOADER) if opts.extlinux:
def parseKickstart(f, strict_mode=False, pass_to_boss=False): # preprocessing the kickstart file has already been handled in initramfs. addon_paths = collect_addon_paths(ADDON_PATHS) handler = AnacondaKSHandler(addon_paths["ks"]) ksparser = AnacondaKSParser(handler) # So that drives onlined by these can be used in the ks file blivet.iscsi.iscsi.startup() # Note we do NOT call dasd.startup() here, that does not online drives, but # only checks if they need formatting, which requires zerombr to be known kswarnings = [] ksmodule = "pykickstart" kscategories = (UserWarning, SyntaxWarning, DeprecationWarning) showwarning = warnings.showwarning def ksshowwarning(message, category, filename, lineno, file=None, line=None): # Print the warning with default function. showwarning(message, category, filename, lineno, file, line) # Collect pykickstart warnings. if ksmodule in filename and issubclass(category, kscategories): kswarnings.append(message) try: # Process warnings differently in this part. with warnings.catch_warnings(): # Set up the warnings module. warnings.showwarning = ksshowwarning for category in kscategories: warnings.filterwarnings(action="always", module=ksmodule, category=category) # Parse the kickstart file in DBus modules. if pass_to_boss: boss = BOSS.get_proxy() boss.SplitKickstart(f) errors = boss.DistributeKickstart() if errors: message = "\n\n".join("{error_message}".format_map(e) for e in errors) raise KickstartError(message) # Parse the kickstart file in anaconda. ksparser.readKickstart(f) # Process pykickstart warnings in the strict mode: if strict_mode and kswarnings: raise KickstartError("Please modify your kickstart file to fix the warnings " "or remove the `ksstrict` option.") except (KickstartError, SplitKickstartError) as e: # We do not have an interface here yet, so we cannot use our error # handling callback. parsing_log.error(e) # Print kickstart warnings in the strict mode. if strict_mode and kswarnings: print(_("\nSome warnings occurred during reading the kickstart file:")) for w in kswarnings: print(str(w).strip()) # Print an error and terminate. print(_("\nAn error occurred during reading the kickstart file:" "\n%s\n\nThe installer will now terminate.") % str(e).strip()) util.ipmi_report(IPMI_ABORTED) time.sleep(10) sys.exit(1) return handler
def __init__(self, gui_mode): """Initialize the Initial Setup internals""" log.debug("initializing Initial Setup") # True if running in graphical mode, False otherwise (text mode) self.gui_mode = gui_mode # kickstart data self.data = None # parse any command line arguments args = self._parse_arguments() # initialize logging initial_setup_log.init(stdout_log=not args.no_stdout_log) log.info("Initial Setup %s" % __version__) # check if we are running as root if os.geteuid() != 0: log.critical("Initial Setup needs to be run as root") raise InitialSetupError if self.gui_mode: log.debug("running in GUI mode") else: log.debug("running in TUI mode") if external_reconfig: log.debug("running in externally triggered reconfig mode") if self.gui_mode: # We need this so we can tell GI to look for overrides objects # also in anaconda source directories import gi.overrides for p in os.environ.get("ANACONDA_WIDGETS_OVERRIDES", "").split(":"): gi.overrides.__path__.insert(0, p) log.debug("GI overrides imported") from pyanaconda.addons import collect_addon_paths addon_paths = [ "/usr/share/initial-setup/modules", "/usr/share/anaconda/addons" ] # append ADDON_PATHS dirs at the end sys.path.extend(addon_paths) self._addon_module_paths = collect_addon_paths(addon_paths, self.gui_mode_id) log.info("found %d addon modules:", len(self._addon_module_paths)) for addon_path in self._addon_module_paths: log.debug(addon_path) # Too bad anaconda does not have modularized logging log.debug("initializing the Anaconda log") from pyanaconda import anaconda_log anaconda_log.init() # init threading before Gtk can do anything and before we start using threads # initThreading initializes the threadMgr instance, import it afterwards log.debug("initializing threading") from pyanaconda.threads import initThreading initThreading() # initialize network logging (needed by the Network spoke that may be shown) log.debug("initializing network logging") from pyanaconda.network import setup_ifcfg_log setup_ifcfg_log()
def __init__(self, gui_mode): """Initialize the Initial Setup internals""" log.debug("initializing Initial Setup") # True if running in graphical mode, False otherwise (text mode) self.gui_mode = gui_mode # kickstart data self.data = None # reboot on quit flag self._reboot_on_quit = False # parse any command line arguments self.args = self._parse_arguments() # initialize logging initial_setup_log.init(stdout_log=not self.args.no_stdout_log, stdout_log_level=self.args.stdout_log_level) global logging_initialized logging_initialized = True log.info("Initial Setup %s" % __version__) # check if we are running as root if os.geteuid() != 0: log.critical("Initial Setup needs to be run as root") raise InitialSetupError if self.gui_mode: log.debug("running in GUI mode") else: log.debug("running in TUI mode") self._external_reconfig = False # check if the reconfig mode should be enabled # by checking if at least one of the reconfig # files exist for reconfig_file in RECONFIG_FILES: if os.path.exists(reconfig_file): self.external_reconfig = True log.debug("reconfig trigger file found: %s", reconfig_file) if self.external_reconfig: log.debug("running in externally triggered reconfig mode") if self.gui_mode: # We need this so we can tell GI to look for overrides objects # also in anaconda source directories import gi.overrides for p in os.environ.get("ANACONDA_WIDGETS_OVERRIDES", "").split(":"): gi.overrides.__path__.insert(0, p) log.debug("GI overrides imported") from pyanaconda.addons import collect_addon_paths addon_paths = [ "/usr/share/initial-setup/modules", "/usr/share/anaconda/addons" ] # append ADDON_PATHS dirs at the end sys.path.extend(addon_paths) self._addon_module_paths = collect_addon_paths(addon_paths, self.gui_mode_id) log.info("found %d addon modules:", len(self._addon_module_paths)) for addon_path in self._addon_module_paths: log.debug(addon_path) # Too bad anaconda does not have modularized logging log.debug("initializing the Anaconda log") from pyanaconda import anaconda_log anaconda_log.init() # initialize network logging (needed by the Network spoke that may be shown) log.debug("initializing network logging") from pyanaconda.network import setup_ifcfg_log setup_ifcfg_log()
def parseKickstart(f, strict_mode=False, pass_to_boss=False): # preprocessing the kickstart file has already been handled in initramfs. addon_paths = collect_addon_paths(ADDON_PATHS) handler = AnacondaKSHandler(addon_paths["ks"]) ksparser = AnacondaKSParser(handler) kswarnings = [] ksmodule = "pykickstart" kscategories = (UserWarning, SyntaxWarning, DeprecationWarning) showwarning = warnings.showwarning def ksshowwarning(message, category, filename, lineno, file=None, line=None): # Print the warning with default function. showwarning(message, category, filename, lineno, file, line) # Collect pykickstart warnings. if ksmodule in filename and issubclass(category, kscategories): kswarnings.append(message) try: # Process warnings differently in this part. with warnings.catch_warnings(): # Set up the warnings module. warnings.showwarning = ksshowwarning for category in kscategories: warnings.filterwarnings(action="always", module=ksmodule, category=category) # Parse the kickstart file in DBus modules. if pass_to_boss: boss = BOSS.get_proxy() boss.SplitKickstart(f) errors = boss.DistributeKickstart() if errors: message = "\n\n".join("{error_message}".format_map(e) for e in errors) raise KickstartError(message) # Parse the kickstart file in anaconda. ksparser.readKickstart(f) # Process pykickstart warnings in the strict mode: if strict_mode and kswarnings: raise KickstartError( "Please modify your kickstart file to fix the warnings " "or remove the `ksstrict` option.") except (KickstartError, SplitKickstartError) as e: # We do not have an interface here yet, so we cannot use our error # handling callback. parsing_log.error(e) # Print kickstart warnings in the strict mode. if strict_mode and kswarnings: print( _("\nSome warnings occurred during reading the kickstart file:" )) for w in kswarnings: print(str(w).strip()) # Print an error and terminate. print( _("\nAn error occurred during reading the kickstart file:" "\n%s\n\nThe installer will now terminate.") % str(e).strip()) util.ipmi_report(IPMI_ABORTED) time.sleep(10) sys.exit(1) return handler
# setup links required for all install types for i in ("services", "protocols", "nsswitch.conf", "joe", "selinux", "mke2fs.conf"): try: if os.path.exists("/mnt/runtime/etc/" + i): os.symlink("../mnt/runtime/etc/" + i, "/etc/" + i) except OSError: pass log.info("anaconda called with cmdline = %s", sys.argv) log.info("Default encoding = %s ", sys.getdefaultencoding()) iutil.execWithRedirect("udevadm", ["control", "--env=ANACONDA=1"]) # Collect all addon paths addon_paths = collect_addon_paths(constants.ADDON_PATHS) # If we were given a kickstart file on the command line, parse (but do not # execute) that now. Otherwise, load in defaults from kickstart files # shipped with the installation media. ksdata = None if opts.ksfile and not opts.liveinst: if not os.path.exists(opts.ksfile): stdoutLog.error("Kickstart file %s is missing.", opts.ksfile) iutil.ipmi_report(constants.IPMI_ABORTED) sys.exit(1) flags.automatedInstall = True flags.eject = False ksFiles = [opts.ksfile] elif os.path.exists("/run/install/ks.cfg") and not opts.liveinst:
if mode == "gui": # We need this so we can tell GI to look for overrides objects # also in anaconda source directories import gi.overrides for p in os.environ.get("ANACONDA_WIDGETS_OVERRIDES", "").split(":"): gi.overrides.__path__.insert(0, p) log.debug("GI overrides imported") from pyanaconda.addons import collect_addon_paths addon_paths = ["/usr/share/initial-setup/modules", "/usr/share/anaconda/addons"] # append ADDON_PATHS dirs at the end sys.path.extend(addon_paths) addon_module_paths = collect_addon_paths(addon_paths, mode) log.info("found %d addon modules:", len(addon_module_paths)) for addon_path in addon_module_paths: log.debug(addon_path) # Too bad anaconda does not have modularized logging log.debug("initializing the Anaconda log") from pyanaconda import anaconda_log anaconda_log.init() # init threading before Gtk can do anything and before we start using threads # initThreading initializes the threadMgr instance, import it afterwards log.debug("initializing threading") from pyanaconda.threads import initThreading initThreading()
def __init__(self, gui_mode): """Initialize the Initial Setup internals""" log.debug("initializing Initial Setup") # True if running in graphical mode, False otherwise (text mode) self.gui_mode = gui_mode # kickstart data self.data = None # parse any command line arguments args = self._parse_arguments() # initialize logging initial_setup_log.init(stdout_log=not args.no_stdout_log) log.info("Initial Setup %s" % __version__) # check if we are running as root if os.geteuid() != 0: log.critical("Initial Setup needs to be run as root") raise InitialSetupError if self.gui_mode: log.debug("running in GUI mode") else: log.debug("running in TUI mode") if external_reconfig: log.debug("running in externally triggered reconfig mode") if self.gui_mode: # We need this so we can tell GI to look for overrides objects # also in anaconda source directories import gi.overrides for p in os.environ.get("ANACONDA_WIDGETS_OVERRIDES", "").split(":"): gi.overrides.__path__.insert(0, p) log.debug("GI overrides imported") from pyanaconda.addons import collect_addon_paths addon_paths = ["/usr/share/initial-setup/modules", "/usr/share/anaconda/addons"] # append ADDON_PATHS dirs at the end sys.path.extend(addon_paths) self._addon_module_paths = collect_addon_paths(addon_paths, self.gui_mode_id) log.info("found %d addon modules:", len(self._addon_module_paths)) for addon_path in self._addon_module_paths: log.debug(addon_path) # Too bad anaconda does not have modularized logging log.debug("initializing the Anaconda log") from pyanaconda import anaconda_log anaconda_log.init() # init threading before Gtk can do anything and before we start using threads # initThreading initializes the threadMgr instance, import it afterwards log.debug("initializing threading") from pyanaconda.threads import initThreading initThreading() # initialize network logging (needed by the Network spoke that may be shown) log.debug("initializing network logging") from pyanaconda.network import setup_ifcfg_log setup_ifcfg_log()
# also in anaconda source directories import gi.overrides for p in os.environ.get("ANACONDA_WIDGETS_OVERRIDES", "").split(":"): gi.overrides.__path__.insert(0, p) log.debug("GI overrides imported") from pyanaconda.addons import collect_addon_paths addon_paths = [ "/usr/share/initial-setup/modules", "/usr/share/anaconda/addons" ] # append ADDON_PATHS dirs at the end sys.path.extend(addon_paths) addon_module_paths = collect_addon_paths(addon_paths, mode) log.info("found %d addon modules:", len(addon_module_paths)) for addon_path in addon_module_paths: log.debug(addon_path) # Too bad anaconda does not have modularized logging log.debug("initializing the Anaconda log") from pyanaconda import anaconda_log anaconda_log.init() # init threading before Gtk can do anything and before we start using threads # initThreading initializes the threadMgr instance, import it afterwards log.debug("initializing threading") from pyanaconda.threads import initThreading