Example #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)

        if os.path.exists(chronyd_conf_path):
            log.debug("Modifying installed chrony configuration")
            try:
                ntp.save_servers_to_config(self._ntp_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(self._ntp_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)
    def run(self):
        self.window.show()
        rc = self.window.run()
        self.window.hide()

        #OK clicked
        if rc == 1:
            new_servers = list()

            for row in self._serversStore:
                #if server checked
                if row[2]:
                    new_servers.append(row[0])

            if flags.can_touch_runtime_system("save NTP servers configuration"):
                ntp.save_servers_to_config(new_servers)
                iutil.restart_service(NTP_SERVICE)

        #Cancel clicked, window destroyed...
        else:
            self._epoch_lock.acquire()
            self._epoch += 1
            self._epoch_lock.release()

            self._initialize_store_from_config()

        return rc
Example #3
0
    def run(self):
        self.window.show()
        rc = self.window.run()
        self.window.hide()

        #OK clicked
        if rc == 1:
            new_servers = list()

            for row in self._serversStore:
                #if server checked
                if row[2]:
                    new_servers.append(row[0])

            if flags.can_touch_runtime_system(
                    "save NTP servers configuration"):
                ntp.save_servers_to_config(new_servers)
                iutil.restart_service(NTP_SERVICE)

        #Cancel clicked, window destroyed...
        else:
            self._epoch_lock.acquire()
            self._epoch += 1
            self._epoch_lock.release()

            self._initialize_store_from_config()

        return rc
Example #4
0
    def run(self):
        self.window.show()
        rc = self.window.run()
        self.window.hide()

        # OK clicked
        if rc == 1:
            # Clean up unedited entries
            self._cleanup_unedited_entry()
            # Restart the NTP service.
            if conf.system.can_set_time_synchronization:
                ntp.save_servers_to_config(self._servers)
                util.restart_service(NTP_SERVICE)

        return rc
Example #5
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)
Example #6
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")
Example #7
0
    def run(self):
        self.window.show()
        rc = self.window.run()
        self.window.hide()

        # OK clicked
        if rc == 1:
            # Remove servers.
            for row in self._serversStore:
                if not row[SERVER_USE]:
                    server = row[SERVER_OBJECT]
                    self._servers.remove(server)

            # Restart the NTP service.
            if conf.system.can_set_time_synchronization:
                ntp.save_servers_to_config(self._servers)
                util.restart_service(NTP_SERVICE)

        return rc
Example #8
0
    def run(self):
        self.window.show()
        rc = self.window.run()
        self.window.hide()

        #OK clicked
        if rc == 1:
            new_pools, new_servers = self.pools_servers

            if conf.system.can_set_time_synchronization:
                ntp.save_servers_to_config(new_pools, new_servers)
                util.restart_service(NTP_SERVICE)

        #Cancel clicked, window destroyed...
        else:
            self._epoch_lock.acquire()
            self._epoch += 1
            self._epoch_lock.release()

        return rc
Example #9
0
    def run(self):
        self.window.show()
        rc = self.window.run()
        self.window.hide()

        #OK clicked
        if rc == 1:
            new_pools, new_servers = self.pools_servers

            if conf.system.can_set_time_synchronization:
                ntp.save_servers_to_config(new_pools, new_servers)
                util.restart_service(NTP_SERVICE)

        #Cancel clicked, window destroyed...
        else:
            self._epoch_lock.acquire()
            self._epoch += 1
            self._epoch_lock.release()

            self._initialize_store_from_config()

        return rc
Example #10
0
    def run(self):
        self.window.show()
        rc = self.window.run()
        self.window.hide()

        #OK clicked
        if rc == 1:
            new_pools, new_servers = self.pools_servers

            if flags.can_touch_runtime_system("save NTP servers configuration"):
                ntp.save_servers_to_config(new_pools, new_servers)
                util.restart_service(NTP_SERVICE)

        #Cancel clicked, window destroyed...
        else:
            self._epoch_lock.acquire()
            self._epoch += 1
            self._epoch_lock.release()

            self._initialize_store_from_config()

        return rc
Example #11
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)
Example #12
0
    # 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)
Example #13
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