Exemple #1
0
    def initialize(self):
        self.initialize_start()
        # We get the initial NTP servers (if any):
        # - from kickstart when running inside of Anaconda
        #   during the installation
        # - from config files when running in Initial Setup
        #   after the installation
        if constants.ANACONDA_ENVIRON in flags.environs:
            self._ntp_servers = TimeSourceData.from_structure_list(
                self._timezone_module.TimeSources)
        elif constants.FIRSTBOOT_ENVIRON in flags.environs:
            self._ntp_servers = ntp.get_servers_from_config()
        else:
            log.error(
                "tui time spoke: unsupported environment configuration %s,"
                "can't decide where to get initial NTP servers",
                flags.environs)

        # check if the newly added NTP servers work fine
        for server in self._ntp_servers:
            self._ntp_servers_states.check_status(server)

        # we assume that the NTP spoke is initialized enough even if some NTP
        # server check threads might still be running
        self.initialize_done()
    def TimeSources(self, sources: List[Structure]):
        """Set the time sources.

        :param sources: a list of time sources
        :type sources: a list of structures of the type TimeSourceData
        """
        self.implementation.set_time_sources(
            TimeSourceData.from_structure_list(sources))
    def refresh(self):
        self._shown = True

        # update the displayed time
        self._update_datetime_timer = Timer()
        self._update_datetime_timer.timeout_sec(1, self._update_datetime)
        self._start_updating_timer = None

        kickstart_timezone = self._timezone_module.Timezone

        if is_valid_timezone(kickstart_timezone):
            self._tzmap.set_timezone(kickstart_timezone)
            time.tzset()

        self._update_datetime()

        # update the ntp configuration
        self._ntp_servers = TimeSourceData.from_structure_list(
            self._timezone_module.TimeSources)

        if not self._ntp_servers:
            try:
                self._ntp_servers = ntp.get_servers_from_config()
            except ntp.NTPconfigError:
                log.warning("Failed to load NTP servers configuration")

        self._ntp_servers_states = NTPServerStatusCache()
        self._ntp_servers_states.changed.connect(
            self._update_ntp_server_warning)

        has_active_network = self._network_module.Connected

        if not has_active_network:
            self._show_no_network_warning()
        else:
            self.clear_info()

            for server in self._ntp_servers:
                self._ntp_servers_states.check_status(server)

        if conf.system.can_set_time_synchronization:
            ntp_working = has_active_network and is_service_running(
                NTP_SERVICE)
        else:
            ntp_working = self._timezone_module.NTPEnabled

        self._ntpSwitch.set_active(ntp_working)
Exemple #4
0
def start_chronyd():
    """Start the NTP daemon chronyd.

    Set up NTP servers and start NTP daemon if not requested otherwise.
    """
    if not conf.system.can_set_time_synchronization:
        log.debug("Skip the time synchronization.")
        return

    timezone_proxy = TIMEZONE.get_proxy()
    enabled = timezone_proxy.NTPEnabled
    servers = TimeSourceData.from_structure_list(timezone_proxy.TimeSources)

    if servers:
        ntp.save_servers_to_config(servers)

    if enabled:
        util.start_service("chronyd")