def get_anaconda_version_string_test(self): # Disable the version module. sys.modules['pyanaconda.version'] = None self.assertEqual(util.get_anaconda_version_string(), "unknown") # Mock the version module. sys.modules['pyanaconda.version'] = Mock( __version__="1.0", __build_time_version__="1.0-1") self.assertEqual(util.get_anaconda_version_string(), "1.0") self.assertEqual( util.get_anaconda_version_string(build_time_version=True), "1.0-1")
def initExceptionHandling(anaconda): file_list = ["/tmp/anaconda.log", "/tmp/packaging.log", "/tmp/program.log", "/tmp/storage.log", "/tmp/dnf.librepo.log", "/tmp/hawkey.log", "/tmp/lvm.log", conf.target.system_root + "/root/install.log", "/proc/cmdline", "/root/lorax-packages.log", "/tmp/blivet-gui-utils.log", "/tmp/dbus.log"] if os.path.exists("/tmp/syslog"): file_list.extend(["/tmp/syslog"]) if anaconda.opts and anaconda.opts.ksfile: file_list.extend([anaconda.opts.ksfile]) config = Config(programName="anaconda", programVersion=util.get_anaconda_version_string(), programArch=os.uname()[4], attrSkipList=["_intf._actions", "_intf._currentAction._xklwrapper", "_intf._currentAction._spokes[\"KeyboardSpoke\"]._xkl_wrapper", "_intf._currentAction._storage_playground", "_intf._currentAction._spokes[\"CustomPartitioningSpoke\"]._storage_playground", "_intf._currentAction.language.translations", "_intf._currentAction.language.locales", "_intf._currentAction._spokes[\"PasswordSpoke\"]._oldweak", "_intf._currentAction._spokes[\"PasswordSpoke\"]._password", "_intf._currentAction._spokes[\"UserSpoke\"]._password", "_intf._currentAction._spokes[\"UserSpoke\"]._oldweak", "_intf.storage.bootloader.password", "_intf.storage.data", "_intf.storage.ksdata", "_intf.data", "_bootloader.encrypted_password", "_bootloader.password", "payload._groups"], localSkipList=["passphrase", "password", "_oldweak", "_password", "try_passphrase"], fileList=file_list) config.register_callback("lsblk_output", lsblk_callback, attchmnt_only=False) config.register_callback("nmcli_dev_list", nmcli_dev_list_callback, attchmnt_only=True) # provide extra information for libreport config.register_callback("type", lambda: "anaconda", attchmnt_only=True) config.register_callback("addons", list_addons_callback, attchmnt_only=False) if "/tmp/syslog" not in file_list: # no syslog, grab output from journalctl and put it also to the # anaconda-tb file config.register_callback("journalctl", journalctl_callback, attchmnt_only=False) if not product.isFinal: config.register_callback("release_type", lambda: "pre-release", attchmnt_only=True) handler = AnacondaExceptionHandler(config, anaconda.intf.meh_interface, AnacondaReverseExceptionDump, anaconda.intf.tty_num, anaconda.gui_initialized, anaconda.interactive_mode) handler.install(anaconda) return config
def _writeKS(ksdata): path = conf.target.system_root + "/root/anaconda-ks.cfg" # Make it so only root can read - could have passwords with util.open_with_perm(path, "w", 0o600) as f: f.write("# Generated by Anaconda {}\n".format(util.get_anaconda_version_string())) f.write(str(ksdata))
def test_get_anaconda_version_string(self): # Forget imported modules from pyanaconda. We have to forget every parent module of # pyanaconda.version but this is just more robust and easier. Without this the # version module is already imported and it's not loaded again. for name in list(sys.modules): if name.startswith('pyanaconda'): sys.modules.pop(name) # Disable the version module. sys.modules['pyanaconda.version'] = None from pyanaconda.core.util import get_anaconda_version_string assert get_anaconda_version_string() == "unknown" # Mock the version module. sys.modules['pyanaconda.version'] = Mock( __version__="1.0", __build_time_version__="1.0-1") assert get_anaconda_version_string() == "1.0" assert get_anaconda_version_string(build_time_version=True) == "1.0-1"
def _write_config(self, parser): """Write the user interaction config file.""" path = os.path.join(self._sysroot, "etc/sysconfig/anaconda") log.info("Writing out user interaction config at %s", path) try: with open(path, "wt") as f: f.write( "# This file has been generated by the Anaconda Installer " "{}\n\n".format(get_anaconda_version_string())) parser.write(f) except OSError: log.exception("Can't write user interaction config file.")
def parse_arguments(argv=None, boot_cmdline=None): """Parse command line/boot options and arguments. :param argv: command like arguments :param boot_cmdline: boot options :returns: namespace of parsed options and a list of deprecated anaconda options that have been found """ from pyanaconda.argument_parsing import getArgumentParser from pyanaconda.core.util import get_anaconda_version_string ap = getArgumentParser(get_anaconda_version_string(), boot_cmdline) namespace = ap.parse_args(argv, boot_cmdline=boot_cmdline) return (namespace, ap.deprecated_bootargs)
def print_startup_note(options): """Print Anaconda version and short usage instructions. Print Anaconda version and short usage instruction to the TTY where Anaconda is running. :param options: command line/boot options """ verdesc = "%s for %s %s" % (util.get_anaconda_version_string( build_time_version=True), product.productName, product.productVersion) logs_note = " * installation log files are stored in /tmp during the installation" shell_and_tmux_note = " * shell is available on TTY2" shell_only_note = " * shell is available on TTY2 and in second TMUX pane (ctrl+b, then press 2)" tmux_only_note = " * shell is available in second TMUX pane (ctrl+b, then press 2)" text_mode_note = " * if the graphical installation interface fails to start, try again with the\n"\ " inst.text bootoption to start text installation" separate_attachements_note = " * when reporting a bug add logs from /tmp as separate text/plain attachments" if product.isFinal: print("anaconda %s started." % verdesc) else: print("anaconda %s (pre-release) started." % verdesc) if not options.images and not options.dirinstall: print(logs_note) # no fancy stuff like TTYs on a s390... if not blivet.arch.is_s390(): if "TMUX" in os.environ and os.environ.get("TERM") == "screen": print(shell_and_tmux_note) else: print(shell_only_note) # TMUX is not running # ...but there is apparently TMUX during the manual installation on s390! elif not options.ksfile: print(tmux_only_note) # but not during kickstart installation # no need to tell users how to switch to text mode # if already in text mode if options.display_mode == constants.DisplayModes.TUI: print(text_mode_note) print(separate_attachements_note)
# check if logs should be saved if flags.nosave_logs: log.warning( "Installation logs will not be saved to the installed system due to the nosave option." ) util.touch('/tmp/NOSAVE_LOGS') # see if we're on s390x and if we've got an ssh connection uname = os.uname() if uname[4] == 's390x': if 'TMUX' not in os.environ and 'ks' not in flags.cmdline and conf.target.is_hardware: startup_utils.prompt_for_ssh() sys.exit(0) log.info("%s %s", sys.argv[0], util.get_anaconda_version_string(build_time_version=True)) if os.path.exists("/tmp/updates"): log.info("Using updates in /tmp/updates/ from %s", opts.updateSrc) # TODO: uncomment this when we're sure that we're doing the right thing # with flags.cmdline *everywhere* it appears... #for arg in depr: # stdout_log.warn("Boot argument '%s' is deprecated. " # "In the future, use 'inst.%s'.", arg, arg) from pyanaconda import isys util.ipmi_report(constants.IPMI_STARTED) if (opts.images or opts.dirinstall) and opts.liveinst: stdout_log.error(
# check if input kickstart should be saved if flags.nosave_input_ks: log.warning("Input kickstart will not be saved to the installed system due to the nosave option.") util.touch('/tmp/NOSAVE_INPUT_KS') # check if logs should be saved if flags.nosave_logs: log.warning("Installation logs will not be saved to the installed system due to the nosave option.") util.touch('/tmp/NOSAVE_LOGS') # see if we're on s390x and if we've got an ssh connection if startup_utils.prompt_for_ssh(opts): sys.exit(0) log.info("%s %s", sys.argv[0], util.get_anaconda_version_string(build_time_version=True)) if os.path.exists("/tmp/updates"): log.info("Using updates in /tmp/updates/ from %s", opts.updateSrc) # warn users that they should use inst. prefix all the time for arg in depr: stdout_log.warning("Boot argument '%s' is deprecated and will be removed in the future. " "Please use 'inst.%s' instead.", arg, arg) from pyanaconda import isys util.ipmi_report(constants.IPMI_STARTED) if (opts.images or opts.dirinstall) and opts.liveinst: stdout_log.error("--liveinst cannot be used with --images or --dirinstall")