Exemplo n.º 1
0
    def run(self):
        """Perform the actual work of setting up NTP."""
        if not (self._ntp_enabled and self._ntp_servers):
            return

        chronyd_conf_path = os.path.normpath(self._sysroot +
                                             ntp.NTP_CONFIG_FILE)
        pools, servers = ntp.internal_to_pools_and_servers(self._ntp_servers)

        if os.path.exists(chronyd_conf_path):
            log.debug("Modifying installed chrony configuration")
            try:
                ntp.save_servers_to_config(pools,
                                           servers,
                                           conf_file_path=chronyd_conf_path)
            except ntp.NTPconfigError as ntperr:
                log.warning("Failed to save NTP configuration: %s", ntperr)

        # use chrony conf file from installation environment when
        # chrony is not installed (chrony conf file is missing)
        else:
            log.debug("Creating chrony configuration based on the "
                      "configuration from installation environment")
            try:
                ntp.save_servers_to_config(pools,
                                           servers,
                                           conf_file_path=ntp.NTP_CONFIG_FILE,
                                           out_file_path=chronyd_conf_path)
            except ntp.NTPconfigError as ntperr:
                log.warning(
                    "Failed to save NTP configuration without chrony package: %s",
                    ntperr)
Exemplo n.º 2
0
    def execute(self):
        # get the DBus proxies
        timezone_proxy = TIMEZONE.get_proxy()

        # write out timezone configuration
        kickstart_timezone = timezone_proxy.Timezone

        if not timezone.is_valid_timezone(kickstart_timezone):
            # this should never happen, but for pity's sake
            timezone_log.warning(
                "Timezone %s set in kickstart is not valid, falling "
                "back to default (America/New_York).", kickstart_timezone)
            timezone_proxy.SetTimezone("America/New_York")

        timezone.write_timezone_config(timezone_proxy, conf.target.system_root)

        # write out NTP configuration (if set) and --nontp is not used
        kickstart_ntp_servers = timezone_proxy.NTPServers

        if timezone_proxy.NTPEnabled and kickstart_ntp_servers:
            chronyd_conf_path = os.path.normpath(conf.target.system_root +
                                                 ntp.NTP_CONFIG_FILE)
            pools, servers = ntp.internal_to_pools_and_servers(
                kickstart_ntp_servers)
            if os.path.exists(chronyd_conf_path):
                timezone_log.debug("Modifying installed chrony configuration")
                try:
                    ntp.save_servers_to_config(
                        pools, servers, conf_file_path=chronyd_conf_path)
                except ntp.NTPconfigError as ntperr:
                    timezone_log.warning(
                        "Failed to save NTP configuration: %s", ntperr)
            # use chrony conf file from installation environment when
            # chrony is not installed (chrony conf file is missing)
            else:
                timezone_log.debug(
                    "Creating chrony configuration based on the "
                    "configuration from installation environment")
                try:
                    ntp.save_servers_to_config(
                        pools,
                        servers,
                        conf_file_path=ntp.NTP_CONFIG_FILE,
                        out_file_path=chronyd_conf_path)
                except ntp.NTPconfigError as ntperr:
                    timezone_log.warning(
                        "Failed to save NTP configuration without chrony package: %s",
                        ntperr)
Exemplo n.º 3
0
    def _initialize_store_from_config(self):
        self._serversStore.clear()

        if self.data.timezone.ntpservers:
            pools, servers = ntp.internal_to_pools_and_servers(self.data.timezone.ntpservers)
        else:
            try:
                pools, servers = ntp.get_servers_from_config()
            except ntp.NTPconfigError:
                log.warning("Failed to load NTP servers configuration")
                return

        for pool in pools:
            self._add_server(pool, True)
        for server in servers:
            self._add_server(server, False)
Exemplo n.º 4
0
    def _initialize_store_from_config(self):
        self._serversStore.clear()

        if self.data.timezone.ntpservers:
            pools, servers = ntp.internal_to_pools_and_servers(self.data.timezone.ntpservers)
        else:
            try:
                pools, servers = ntp.get_servers_from_config()
            except ntp.NTPconfigError:
                log.warning("Failed to load NTP servers configuration")
                return

        for pool in pools:
            self._add_server(pool, True)
        for server in servers:
            self._add_server(server, False)
Exemplo n.º 5
0
    def _initialize_store_from_config(self):
        self._serversStore.clear()

        kickstart_ntp_servers = self._timezone_module.proxy.NTPServers

        if kickstart_ntp_servers:
            pools, servers = ntp.internal_to_pools_and_servers(kickstart_ntp_servers)
        else:
            try:
                pools, servers = ntp.get_servers_from_config()
            except ntp.NTPconfigError:
                log.warning("Failed to load NTP servers configuration")
                return

        for pool in pools:
            self._add_server(pool, True)
        for server in servers:
            self._add_server(server, False)
Exemplo n.º 6
0
    def _initialize_store_from_config(self):
        self._serversStore.clear()

        kickstart_ntp_servers = self._timezone_module.proxy.NTPServers

        if kickstart_ntp_servers:
            pools, servers = ntp.internal_to_pools_and_servers(kickstart_ntp_servers)
        else:
            try:
                pools, servers = ntp.get_servers_from_config()
            except ntp.NTPconfigError:
                log.warning("Failed to load NTP servers configuration")
                return

        for pool in pools:
            self._add_server(pool, True)
        for server in servers:
            self._add_server(server, False)
Exemplo n.º 7
0
    def execute(self):
        # get the DBus proxies
        timezone_proxy = TIMEZONE.get_proxy()

        # write out timezone configuration
        kickstart_timezone = timezone_proxy.Timezone

        if not timezone.is_valid_timezone(kickstart_timezone):
            # this should never happen, but for pity's sake
            timezone_log.warning("Timezone %s set in kickstart is not valid, falling "
                                 "back to default (America/New_York).", kickstart_timezone)
            timezone_proxy.SetTimezone("America/New_York")

        timezone.write_timezone_config(timezone_proxy, util.getSysroot())

        # write out NTP configuration (if set) and --nontp is not used
        kickstart_ntp_servers = timezone_proxy.NTPServers

        if timezone_proxy.NTPEnabled and kickstart_ntp_servers:
            chronyd_conf_path = os.path.normpath(util.getSysroot() + ntp.NTP_CONFIG_FILE)
            pools, servers = ntp.internal_to_pools_and_servers(kickstart_ntp_servers)
            if os.path.exists(chronyd_conf_path):
                timezone_log.debug("Modifying installed chrony configuration")
                try:
                    ntp.save_servers_to_config(pools, servers, conf_file_path=chronyd_conf_path)
                except ntp.NTPconfigError as ntperr:
                    timezone_log.warning("Failed to save NTP configuration: %s", ntperr)
            # use chrony conf file from installation environment when
            # chrony is not installed (chrony conf file is missing)
            else:
                timezone_log.debug("Creating chrony configuration based on the "
                                   "configuration from installation environment")
                try:
                    ntp.save_servers_to_config(pools, servers,
                                               conf_file_path=ntp.NTP_CONFIG_FILE,
                                               out_file_path=chronyd_conf_path)
                except ntp.NTPconfigError as ntperr:
                    timezone_log.warning("Failed to save NTP configuration without chrony package: %s", ntperr)
Exemplo n.º 8
0
                              fallback=fallback)

    # initialize the geolocation singleton
    geoloc.init_geolocation(geoloc_option=opts.geoloc,
                            options_override=opts.geoloc_use_with_ks)

    # start geolocation lookup if enabled
    if geoloc.geoloc.enabled:
        geoloc.geoloc.refresh()

    # setup ntp servers and start NTP daemon if not requested otherwise
    if conf.system.can_set_time_synchronization:
        kickstart_ntpservers = timezone_proxy.NTPServers

        if kickstart_ntpservers:
            pools, servers = ntp.internal_to_pools_and_servers(
                kickstart_ntpservers)
            ntp.save_servers_to_config(pools, servers)

        if timezone_proxy.NTPEnabled:
            util.start_service("chronyd")

    # Finish the initialization of the setup on boot action.
    # This should be done sooner and somewhere else once it is possible.
    from pyanaconda.core.constants import SETUP_ON_BOOT_DEFAULT, SETUP_ON_BOOT_ENABLED
    from pyanaconda.modules.common.constants.services import SERVICES
    services_proxy = SERVICES.get_proxy()

    if services_proxy.SetupOnBoot == SETUP_ON_BOOT_DEFAULT:
        if not flags.automatedInstall:
            # Enable by default for interactive installations.
            services_proxy.SetSetupOnBoot(SETUP_ON_BOOT_ENABLED)
Exemplo n.º 9
0
    fallback = not (flags.automatedInstall and ksdata.method.method)
    payloadMgr.restartThread(anaconda.storage, ksdata, anaconda.payload, anaconda.instClass, fallback=fallback)

    # initialize the geolocation singleton
    geoloc.init_geolocation(geoloc_option=opts.geoloc,
                            options_override=opts.geoloc_use_with_ks,
                            install_class_override=anaconda.instClass.use_geolocation_with_kickstart)

    # start geolocation lookup if enabled
    if geoloc.geoloc.enabled:
        geoloc.geoloc.refresh()

    # setup ntp servers and start NTP daemon if not requested otherwise
    if can_touch_runtime_system("start chronyd"):
        if anaconda.ksdata.timezone.ntpservers:
            pools, servers = ntp.internal_to_pools_and_servers(anaconda.ksdata.timezone.ntpservers)
            ntp.save_servers_to_config(pools, servers)

        if not anaconda.ksdata.timezone.nontp:
            iutil.start_service("chronyd")

    # Create pre-install snapshots
    from pykickstart.constants import SNAPSHOT_WHEN_PRE_INSTALL
    from pyanaconda.kickstart import check_kickstart_error
    if ksdata.snapshot.has_snapshot(SNAPSHOT_WHEN_PRE_INSTALL):
        with check_kickstart_error():
            ksdata.snapshot.pre_setup(anaconda.storage, ksdata, anaconda.instClass)
            ksdata.snapshot.pre_execute(anaconda.storage, ksdata, anaconda.instClass)

    anaconda._intf.setup(ksdata)
    anaconda._intf.run()
Exemplo n.º 10
0
        use_geolocation = flags.cmdline.getbool('geoloc', True)

    if use_geolocation:
        provider_id = constants.GEOLOC_DEFAULT_PROVIDER
        # check if a provider was specified by an option
        if opts.geoloc is not None:
            parsed_id = geoloc.get_provider_id_from_option(opts.geoloc)
            if parsed_id is None:
                log.error('geoloc: wrong provider id specified: %s', opts.geoloc)
            else:
                provider_id = parsed_id
        # instantiate the geolocation module and start location data refresh
        geoloc.init_geolocation(provider_id=provider_id)
        geoloc.refresh()

    # setup ntp servers and start NTP daemon if not requested otherwise
    if can_touch_runtime_system("start chronyd"):
        if anaconda.ksdata.timezone.ntpservers:
            pools, servers = ntp.internal_to_pools_and_servers(anaconda.ksdata.timezone.ntpservers)
            ntp.save_servers_to_config(pools, servers)

        if not anaconda.ksdata.timezone.nontp:
            iutil.start_service("chronyd")

    # FIXME:  This will need to be made cleaner once this file starts to take
    # shape with the new UI code.
    anaconda._intf.setup(ksdata)
    anaconda._intf.run()

# vim:tw=78:ts=4:et:sw=4
Exemplo n.º 11
0
    fallback = not (flags.automatedInstall and ksdata.method.method)
    payloadMgr.restartThread(anaconda.storage, ksdata, anaconda.payload, anaconda.instClass, fallback=fallback)

    # initialize the geolocation singleton
    geoloc.init_geolocation(geoloc_option=opts.geoloc, options_override=opts.geoloc_use_with_ks)

    # start geolocation lookup if enabled
    if geoloc.geoloc.enabled:
        geoloc.geoloc.refresh()

    # setup ntp servers and start NTP daemon if not requested otherwise
    if conf.system.can_set_time_synchronization:
        kickstart_ntpservers = timezone_proxy.NTPServers

        if kickstart_ntpservers:
            pools, servers = ntp.internal_to_pools_and_servers(kickstart_ntpservers)
            ntp.save_servers_to_config(pools, servers)

        if timezone_proxy.NTPEnabled:
            util.start_service("chronyd")

    # Finish the initialization of the setup on boot action.
    # This should be done sooner and somewhere else once it is possible.
    from pyanaconda.core.constants import SETUP_ON_BOOT_DEFAULT, SETUP_ON_BOOT_DISABLED
    from pyanaconda.modules.common.constants.services import SERVICES
    services_proxy = SERVICES.get_proxy()

    if services_proxy.SetupOnBoot == SETUP_ON_BOOT_DEFAULT:
        if flags.automatedInstall:
            # Disable by default after kickstart installations.
            services_proxy.SetSetupOnBoot(SETUP_ON_BOOT_DISABLED)