def setup(self, ksdata): timezone_proxy = TIMEZONE.get_proxy() services_proxy = SERVICES.get_proxy() enabled_services = services_proxy.EnabledServices disabled_services = services_proxy.DisabledServices # do not install and use NTP package if not timezone_proxy.NTPEnabled or NTP_PACKAGE in ksdata.packages.excludedList: if util.service_running(NTP_SERVICE) and conf.system.can_set_time_synchronization: ret = util.stop_service(NTP_SERVICE) if ret != 0: timezone_log.error("Failed to stop NTP service") if NTP_SERVICE not in disabled_services: disabled_services.append(NTP_SERVICE) services_proxy.SetDisabledServices(disabled_services) # install and use NTP package else: if not util.service_running(NTP_SERVICE) and conf.system.can_set_time_synchronization: ret = util.start_service(NTP_SERVICE) if ret != 0: timezone_log.error("Failed to start NTP service") self.packages.append(NTP_PACKAGE) if not NTP_SERVICE in enabled_services and \ not NTP_SERVICE in disabled_services: enabled_services.append(NTP_SERVICE) services_proxy.SetEnabledServices(enabled_services)
def setup(self, ksdata): timezone_proxy = TIMEZONE.get_proxy() services_proxy = SERVICES.get_proxy() enabled_services = services_proxy.EnabledServices disabled_services = services_proxy.DisabledServices # do not install and use NTP package if not timezone_proxy.NTPEnabled or NTP_PACKAGE in ksdata.packages.excludedList: if util.service_running( NTP_SERVICE) and conf.system.can_set_time_synchronization: ret = util.stop_service(NTP_SERVICE) if ret != 0: timezone_log.error("Failed to stop NTP service") if NTP_SERVICE not in disabled_services: disabled_services.append(NTP_SERVICE) services_proxy.SetDisabledServices(disabled_services) # install and use NTP package else: if not util.service_running( NTP_SERVICE) and conf.system.can_set_time_synchronization: ret = util.start_service(NTP_SERVICE) if ret != 0: timezone_log.error("Failed to start NTP service") self.packages.append(NTP_PACKAGE) if not NTP_SERVICE in enabled_services and \ not NTP_SERVICE in disabled_services: enabled_services.append(NTP_SERVICE) services_proxy.SetEnabledServices(enabled_services)
def on_ntp_switched(self, switch, *args): if switch.get_active(): #turned ON if not conf.system.can_set_time_synchronization: #cannot touch runtime system, not much to do here return if not self._network_module.proxy.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 = util.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 util.service_running(NTP_SERVICE): switch.set_active(False) else: #turned OFF if not conf.system.can_set_time_synchronization: #cannot touch runtime system, nothing to do here return self._set_date_time_setting_sensitive(True) ret = util.stop_service(NTP_SERVICE) #if stopping chronyd failed and chronyd is running, #set switch back to ON if (ret != 0) and util.service_running(NTP_SERVICE): switch.set_active(True) self.clear_info()
def on_ntp_switched(self, switch, *args): if switch.get_active(): #turned ON if not conf.system.can_set_time_synchronization: #cannot touch runtime system, not much to do here return if not self._network_module.Connected: self._show_no_network_warning() switch.set_active(False) return else: self.clear_info() working_server = self._get_working_server() if working_server is None: self._show_no_ntp_server_warning() ret = util.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 util.service_running(NTP_SERVICE): switch.set_active(False) else: #turned OFF if not conf.system.can_set_time_synchronization: #cannot touch runtime system, nothing to do here return self._set_date_time_setting_sensitive(True) ret = util.stop_service(NTP_SERVICE) #if stopping chronyd failed and chronyd is running, #set switch back to ON if (ret != 0) and util.service_running(NTP_SERVICE): switch.set_active(True) self.clear_info()