Exemplo n.º 1
0
    def test_set_from_detected_profile(self):
        conf = AnacondaConfiguration.from_defaults()

        # Test unknown os-release values.
        with self.assertLogs(level="WARNING") as cm:
            conf.set_from_detected_profile("unknown-os", "unknown-variant")

        expected = \
            "Unable to find any suitable configuration files for the detected " \
            "os-release values. No profile configuration will be used."

        self.assertIn(expected, "\n".join(cm.output))

        # Test known os-release values.
        conf.set_from_detected_profile("fedora", "workstation")

        self._check_configuration_sources(conf, [
            "anaconda.conf", "profile.d/fedora.conf",
            "profile.d/fedora-workstation.conf"
        ])
Exemplo n.º 2
0
    from pyanaconda.core.configuration.anaconda import conf
    conf.set_from_opts(opts)

    # Set up logging as early as possible.
    from pyanaconda import anaconda_logging
    from pyanaconda import anaconda_loggers
    anaconda_logging.init(write_to_journal=conf.target.is_hardware)
    anaconda_logging.logger.setupVirtio(opts.virtiolog)

    # Load the remaining configuration after a logging is set up.
    if opts.profile_id:
        conf.set_from_profile(opts.profile_id, )
    else:
        conf.set_from_detected_profile(
            util.get_os_release_value("ID"),
            util.get_os_release_value("VARIANT_ID"),
        )

    conf.set_from_files()
    conf.set_from_opts(opts)

    log = anaconda_loggers.get_main_logger()
    stdout_log = anaconda_loggers.get_stdout_logger()

    if os.geteuid() != 0:
        stdout_log.error("anaconda must be run as root.")
        sys.exit(1)

    # check if input kickstart should be saved
    if not conf.target.can_copy_input_kickstart:
        log.warning(