def on_ntp_switched(self, switch, *args):
        if switch.get_active():
            #turned ON
            if not flags.can_touch_runtime_system("start NTP service"):
                #cannot touch runtime system, not much to do here
                return

            if not nm.nm_is_connected():
                self._show_no_network_warning()
                switch.set_active(False)
                return
            else:
                self.clear_info()

                working_server = self._config_dialog.working_server
                if working_server is None:
                    self._show_no_ntp_server_warning()
                else:
                    #we need a one-time sync here, because chronyd would not change
                    #the time as drastically as we need
                    ntp.one_time_sync_async(working_server)

            ret = iutil.start_service(NTP_SERVICE)
            self._set_date_time_setting_sensitive(False)

            #if starting chronyd failed and chronyd is not running,
            #set switch back to OFF
            if (ret != 0) and not iutil.service_running(NTP_SERVICE):
                switch.set_active(False)

        else:
            #turned OFF
            if not flags.can_touch_runtime_system("stop NTP service"):
                #cannot touch runtime system, nothing to do here
                return

            self._set_date_time_setting_sensitive(True)
            ret = iutil.stop_service(NTP_SERVICE)

            #if stopping chronyd failed and chronyd is running,
            #set switch back to ON
            if (ret != 0) and iutil.service_running(NTP_SERVICE):
                switch.set_active(True)

            self.clear_info()
Exemplo n.º 2
0
    def on_ntp_switched(self, switch, *args):
        if switch.get_active():
            #turned ON
            if not flags.can_touch_runtime_system("start NTP service"):
                #cannot touch runtime system, not much to do here
                return

            if not nm.nm_is_connected():
                self._show_no_network_warning()
                switch.set_active(False)
                return
            else:
                self.clear_info()

                working_server = self._config_dialog.working_server
                if working_server is None:
                    self._show_no_ntp_server_warning()
                else:
                    #we need a one-time sync here, because chronyd would not change
                    #the time as drastically as we need
                    ntp.one_time_sync_async(working_server)

            ret = iutil.start_service(NTP_SERVICE)
            self._set_date_time_setting_sensitive(False)

            #if starting chronyd failed and chronyd is not running,
            #set switch back to OFF
            if (ret != 0) and not iutil.service_running(NTP_SERVICE):
                switch.set_active(False)

        else:
            #turned OFF
            if not flags.can_touch_runtime_system("stop NTP service"):
                #cannot touch runtime system, nothing to do here
                return

            self._set_date_time_setting_sensitive(True)
            ret = iutil.stop_service(NTP_SERVICE)

            #if stopping chronyd failed and chronyd is running,
            #set switch back to ON
            if (ret != 0) and iutil.service_running(NTP_SERVICE):
                switch.set_active(True)

            self.clear_info()
Exemplo n.º 3
0
    # 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()

# vim:tw=78:ts=4:et:sw=4
Exemplo n.º 4
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