def start_rescue_mode_ui(anaconda): """Start the rescue mode UI.""" ksdata_rescue = None if anaconda.ksdata.rescue.seen: ksdata_rescue = anaconda.ksdata.rescue scripts = anaconda.ksdata.scripts storage = anaconda.storage reboot = True if flags.imageInstall: reboot = False if flags.automatedInstall and anaconda.ksdata.reboot.action not in [ KS_REBOOT, KS_SHUTDOWN ]: reboot = False rescue = Rescue(storage, ksdata_rescue, reboot, scripts) rescue.initialize() # We still want to choose from multiple roots, or unlock encrypted devices # if needed, so we run UI even for kickstarts (automated install). app = App("Rescue Mode") spoke = RescueModeSpoke(app, rescue) app.schedule_screen(spoke) app.run()
def start_rescue_mode_ui(anaconda): """Start the rescue mode TUI. :param anaconda: instance of the Anaconda class """ app = App("Rescue Mode") spoke = RescueMode(app, anaconda.ksdata, anaconda.storage) app.schedule_screen(spoke) app.run()
def changeVNCPasswdWindow(self): """ Change the password to a sane parameter. We ask user to input a password that (len(password) > 6 and len(password) <= 8) or password == ''. """ message = _("VNC password must be six to eight characters long.\n" "Please enter a new one, or leave blank for no password.") app = App("VNC PASSWORD") spoke = VNCPassSpoke(app, self.anaconda.ksdata, None, None, None, message) app.schedule_screen(spoke) app.run() self.password = self.anaconda.ksdata.vnc.password
def changeVNCPasswdWindow(self): """ Change the password to a sane parameter. We ask user to input a password that len(password) > 6 or password == ''. """ message = _("VNC password provided was not at least 6 characters long.\n" "Please enter a new one. Leave blank for no password.") app = App("VNC PASSWORD") spoke = VNCPassSpoke(app, self.anaconda.ksdata, None, None, None, message) app.schedule_screen(spoke) app.run() self.password = self.anaconda.ksdata.vnc.password
def changeVNCPasswdWindow(self): """ Change the password to a sane parameter. We ask user to input a password that len(password) > 6 or password == ''. """ message = _( "VNC password provided was not at least 6 characters long.\n" "Please enter a new one. Leave blank for no password.") app = App("VNC PASSWORD") spoke = VNCPassSpoke(app, self.anaconda.ksdata, None, None, None, message) app.schedule_screen(spoke) app.run() self.password = self.anaconda.ksdata.vnc.password
def ask_vnc_question(anaconda, vnc_server, message): """ Ask the user if TUI or GUI-over-VNC should be started. :param anaconda: instance of the Anaconda class :param vnc_server: instance of the VNC server object :param str message: a message to show to the user together with the question """ app = App("VNC Question") spoke = AskVNCSpoke(app, anaconda.ksdata, message) app.schedule_screen(spoke) app.run() if anaconda.ksdata.vnc.enabled: if not anaconda.gui_mode: log.info("VNC requested via VNC question, switching Anaconda to GUI mode.") anaconda.display_mode = constants.DisplayModes.GUI flags.usevnc = True vnc_server.password = anaconda.ksdata.vnc.password
def ask_vnc_question(anaconda, vnc_server, message): """ Ask the user if TUI or GUI-over-VNC should be started. :param anaconda: instance of the Anaconda class :param vnc_server: instance of the VNC server object :param str message: a message to show to the user together with the question """ app = App("VNC Question") spoke = AskVNCSpoke(app, anaconda.ksdata, message) app.schedule_screen(spoke) app.run() if anaconda.ksdata.vnc.enabled: if not anaconda.gui_mode: log.info( "VNC requested via VNC question, switching Anaconda to GUI mode." ) anaconda.display_mode = constants.DisplayModes.GUI flags.usevnc = True vnc_server.password = anaconda.ksdata.vnc.password
def setupDisplay(anaconda, options, addons=None): from pyanaconda.ui.tui.simpleline import App from pyanaconda.ui.tui.spokes.askvnc import AskVNCSpoke from pykickstart.constants import DISPLAY_MODE_TEXT from pyanaconda.nm import nm_is_connected, nm_is_connecting from blivet import arch graphical_failed = 0 vncS = vnc.VncServer() # The vnc Server object. vncS.anaconda = anaconda anaconda.displayMode = options.display_mode anaconda.isHeadless = arch.is_s390() if options.vnc: flags.usevnc = True anaconda.displayMode = 'g' vncS.password = options.vncpassword # Only consider vncconnect when vnc is a param if options.vncconnect: cargs = options.vncconnect.split(":") vncS.vncconnecthost = cargs[0] if len(cargs) > 1 and len(cargs[1]) > 0: if len(cargs[1]) > 0: vncS.vncconnectport = cargs[1] if options.xdriver: anaconda.xdriver = options.xdriver anaconda.writeXdriver(root="/") if flags.rescue_mode: return if anaconda.ksdata.vnc.enabled: flags.usevnc = True anaconda.displayMode = 'g' if vncS.password == "": vncS.password = anaconda.ksdata.vnc.password if vncS.vncconnecthost == "": vncS.vncconnecthost = anaconda.ksdata.vnc.host if vncS.vncconnectport == "": vncS.vncconnectport = anaconda.ksdata.vnc.port if anaconda.displayMode == "g": import pkgutil import pyanaconda.ui mods = (tup[1] for tup in pkgutil.iter_modules(pyanaconda.ui.__path__, "pyanaconda.ui.")) if "pyanaconda.ui.gui" not in mods: stdoutLog.warning( "Graphical user interface not available, falling back to text mode" ) anaconda.displayMode = "t" flags.usevnc = False flags.vncquestion = False # disable VNC over text question when not enough memory is available if blivet.util.total_memory() < isys.MIN_GUI_RAM: stdoutLog.warning( "Not asking for VNC because current memory (%d) < MIN_GUI_RAM (%d)", blivet.util.total_memory(), isys.MIN_GUI_RAM) flags.vncquestion = False # disable VNC question if text mode is requested and this is a ks install if anaconda.displayMode == 't' and flags.automatedInstall: stdoutLog.warning("Not asking for VNC because of an automated install") flags.vncquestion = False # disable VNC question if we were explicitly asked for text in kickstart if anaconda.ksdata.displaymode.displayMode == DISPLAY_MODE_TEXT: stdoutLog.warning( "Not asking for VNC because text mode was explicitly asked for in kickstart" ) flags.vncquestion = False # disable VNC question if we don't have network if not nm_is_connecting() and not nm_is_connected(): stdoutLog.warning("Not asking for VNC because we don't have a network") flags.vncquestion = False # disable VNC question if we don't have Xvnc if not os.access('/usr/bin/Xvnc', os.X_OK): stdoutLog.warning("Not asking for VNC because we don't have Xvnc") flags.vncquestion = False # Should we try to start Xorg? want_x = anaconda.displayMode == 'g' and \ not (flags.preexisting_x11 or flags.usevnc) # X on a headless (e.g. s390) system? Nonsense! if want_x and anaconda.isHeadless: stdoutLog.warning(_("DISPLAY variable not set. Starting text mode.")) anaconda.displayMode = 't' graphical_failed = 1 time.sleep(2) want_x = False # Is Xorg is actually available? if want_x and not os.access("/usr/bin/Xorg", os.X_OK): stdoutLog.warning( _("Graphical installation is not available. " "Starting text mode.")) time.sleep(2) anaconda.displayMode = 't' want_x = False if anaconda.displayMode == 't' and flags.vncquestion: #we prefer vnc over text mode, so ask about that message = _("Text mode provides a limited set of installation " "options. It does not offer custom partitioning for " "full control over the disk layout. Would you like " "to use VNC mode instead?") app = App("VNC Question") spoke = AskVNCSpoke(app, anaconda.ksdata, message=message) app.schedule_screen(spoke) app.run() if anaconda.ksdata.vnc.enabled: anaconda.displayMode = 'g' flags.usevnc = True vncS.password = anaconda.ksdata.vnc.password else: # user has explicitly specified text mode flags.vncquestion = False log.info("Display mode = %s", anaconda.displayMode) check_memory(anaconda, options) # check_memory may have changed the display mode want_x = want_x and (anaconda.displayMode == "g") if want_x: try: startX11() doStartupX11Actions() except (OSError, RuntimeError) as e: log.warning("X startup failed: %s", e) stdoutLog.warning("X startup failed, falling back to text mode") anaconda.displayMode = 't' graphical_failed = 1 time.sleep(2) if not graphical_failed: doExtraX11Actions(options.runres) if anaconda.displayMode == 't' and graphical_failed and \ flags.vncquestion and not anaconda.ksdata.vnc.enabled: app = App("VNC Question") spoke = AskVNCSpoke(app, anaconda.ksdata) app.schedule_screen(spoke) app.run() if anaconda.ksdata.vnc.enabled: anaconda.displayMode = 'g' flags.usevnc = True vncS.password = anaconda.ksdata.vnc.password # if they want us to use VNC do that now if anaconda.displayMode == 'g' and flags.usevnc: vncS.startServer() doStartupX11Actions() # with X running we can initialize the UI interface anaconda.initInterface(addons) anaconda.instClass.configure(anaconda) # report if starting the GUI failed anaconda.gui_startup_failed = bool(graphical_failed)
anaconda.protected))) if can_touch_runtime_system("initialize time", touch_live=True): threadMgr.add( AnacondaThread(name=constants.THREAD_TIME_INIT, target=time_initialize, args=(ksdata.timezone, anaconda.storage, anaconda.bootloader))) if flags.rescue_mode: from pyanaconda.ui.tui.simpleline import App from pyanaconda.rescue import RescueMode app = App("Rescue Mode") spoke = RescueMode(app, anaconda.ksdata, anaconda.storage) app.schedule_screen(spoke) app.run() else: cleanPStore() # only install interactive exception handler in interactive modes if ksdata.displaymode.displayMode != DISPLAY_MODE_CMDLINE or flags.debug: from pyanaconda import exception anaconda.mehConfig = exception.initExceptionHandling(anaconda) # add our own additional signal handlers signal.signal(signal.SIGUSR1, lambda signum, frame: exception.test_exception_handling()) signal.signal(signal.SIGUSR2, lambda signum, frame: anaconda.dumpState()) atexit.register(exitHandler, ksdata.reboot, anaconda.storage) from pyanaconda import exception
except KeyError: print "%s %s could not be found in %s" % (SpokeText, spokeClassName, spokeModuleName) sys.exit(1) print "Running %s %s from %s" % (spokeText, spokeClass, spokeModule) ksdata = makeVersion() storage = Blivet(ksdata=ksdata) storage.reset() instclass = DefaultInstall() app = App("TEST HARNESS", yes_or_no_question = YesNoDialog) payload = YumPayload(ksdata) payload.setup(storage) payload.install_log = sys.stdout spoke = spokeClass(app, ksdata, storage, payload, instclass) if not spoke.showable: print "This %s is not showable, but I'll continue anyway." % spokeText app.schedule_screen(spoke) app.run() if hasattr(spoke, "status"): print "%s status:\n%s\n" % (SpokeText, spoke.status) if hasattr(spoke, "completed"): print "%s completed:\n%s\n" % (SpokeText, spoke.completed) print "%s kickstart fragment:\n%s" % (SpokeText, ksdata)
def setupDisplay(anaconda, options, addons=None): from pyanaconda.ui.tui.simpleline import App from pyanaconda.ui.tui.spokes.askvnc import AskVNCSpoke from pykickstart.constants import DISPLAY_MODE_TEXT from pyanaconda.nm import nm_is_connected, nm_is_connecting from blivet import arch graphical_failed = 0 vncS = vnc.VncServer() # The vnc Server object. vncS.anaconda = anaconda anaconda.displayMode = options.display_mode anaconda.isHeadless = arch.is_s390() if options.vnc: flags.usevnc = True anaconda.displayMode = 'g' vncS.password = options.vncpassword # Only consider vncconnect when vnc is a param if options.vncconnect: cargs = options.vncconnect.split(":") vncS.vncconnecthost = cargs[0] if len(cargs) > 1 and len(cargs[1]) > 0: if len(cargs[1]) > 0: vncS.vncconnectport = cargs[1] if options.xdriver: anaconda.xdriver = options.xdriver anaconda.writeXdriver(root="/") if flags.rescue_mode: return if anaconda.ksdata.vnc.enabled: flags.usevnc = True anaconda.displayMode = 'g' if vncS.password == "": vncS.password = anaconda.ksdata.vnc.password if vncS.vncconnecthost == "": vncS.vncconnecthost = anaconda.ksdata.vnc.host if vncS.vncconnectport == "": vncS.vncconnectport = anaconda.ksdata.vnc.port if anaconda.displayMode == "g": import pkgutil import pyanaconda.ui mods = (tup[1] for tup in pkgutil.iter_modules(pyanaconda.ui.__path__, "pyanaconda.ui.")) if "pyanaconda.ui.gui" not in mods: stdoutLog.warning("Graphical user interface not available, falling back to text mode") anaconda.displayMode = "t" flags.usevnc = False flags.vncquestion = False # disable VNC over text question when not enough memory is available if blivet.util.total_memory() < isys.MIN_GUI_RAM: stdoutLog.warning("Not asking for VNC because current memory (%d) < MIN_GUI_RAM (%d)", blivet.util.total_memory(), isys.MIN_GUI_RAM) flags.vncquestion = False # disable VNC question if text mode is requested and this is a ks install if anaconda.displayMode == 't' and flags.automatedInstall: stdoutLog.warning("Not asking for VNC because of an automated install") flags.vncquestion = False # disable VNC question if we were explicitly asked for text in kickstart if anaconda.ksdata.displaymode.displayMode == DISPLAY_MODE_TEXT: stdoutLog.warning("Not asking for VNC because text mode was explicitly asked for in kickstart") flags.vncquestion = False # disable VNC question if we don't have network if not nm_is_connecting() and not nm_is_connected(): stdoutLog.warning("Not asking for VNC because we don't have a network") flags.vncquestion = False # disable VNC question if we don't have Xvnc if not os.access('/usr/bin/Xvnc', os.X_OK): stdoutLog.warning("Not asking for VNC because we don't have Xvnc") flags.vncquestion = False # Should we try to start Xorg? want_x = anaconda.displayMode == 'g' and \ not (flags.preexisting_x11 or flags.usevnc) # X on a headless (e.g. s390) system? Nonsense! if want_x and anaconda.isHeadless: stdoutLog.warning(_("DISPLAY variable not set. Starting text mode.")) anaconda.displayMode = 't' graphical_failed = 1 time.sleep(2) want_x = False # Is Xorg is actually available? if want_x and not os.access("/usr/bin/Xorg", os.X_OK): stdoutLog.warning(_("Graphical installation is not available. " "Starting text mode.")) time.sleep(2) anaconda.displayMode = 't' want_x = False if anaconda.displayMode == 't' and flags.vncquestion: #we prefer vnc over text mode, so ask about that message = _("Text mode provides a limited set of installation " "options. It does not offer custom partitioning for " "full control over the disk layout. Would you like " "to use VNC mode instead?") app = App("VNC Question") spoke = AskVNCSpoke(app, anaconda.ksdata, message=message) app.schedule_screen(spoke) app.run() if anaconda.ksdata.vnc.enabled: anaconda.displayMode = 'g' flags.usevnc = True vncS.password = anaconda.ksdata.vnc.password else: # user has explicitly specified text mode flags.vncquestion = False log.info("Display mode = %s", anaconda.displayMode) check_memory(anaconda, options) # check_memory may have changed the display mode want_x = want_x and (anaconda.displayMode == "g") if want_x: try: startX11() doStartupX11Actions() except (OSError, RuntimeError) as e: log.warning("X startup failed: %s", e) stdoutLog.warning("X startup failed, falling back to text mode") anaconda.displayMode = 't' graphical_failed = 1 time.sleep(2) if not graphical_failed: doExtraX11Actions(options.runres) if anaconda.displayMode == 't' and graphical_failed and \ flags.vncquestion and not anaconda.ksdata.vnc.enabled: app = App("VNC Question") spoke = AskVNCSpoke(app, anaconda.ksdata) app.schedule_screen(spoke) app.run() if anaconda.ksdata.vnc.enabled: anaconda.displayMode = 'g' flags.usevnc = True vncS.password = anaconda.ksdata.vnc.password # if they want us to use VNC do that now if anaconda.displayMode == 'g' and flags.usevnc: vncS.startServer() doStartupX11Actions() # with X running we can initialize the UI interface anaconda.initInterface(addons) anaconda.instClass.configure(anaconda) # report if starting the GUI failed anaconda.gui_startup_failed = bool(graphical_failed)