diff options
-rw-r--r-- | pyanaconda/kickstart.py | 35 | ||||
-rw-r--r-- | pyanaconda/timezone.py | 3 | ||||
-rw-r--r-- | pyanaconda/ui/gui/spokes/datetime_spoke.py | 60 |
3 files changed, 56 insertions, 42 deletions
diff --git a/pyanaconda/kickstart.py b/pyanaconda/kickstart.py index 551b38d2b..c8e9d8eb1 100644 --- a/pyanaconda/kickstart.py +++ b/pyanaconda/kickstart.py @@ -37,6 +37,7 @@ import iutil import os import os.path import tempfile +import flags as flags_module from flags import flags from constants import * import shlex @@ -46,6 +47,7 @@ import pykickstart.commands as commands from pyanaconda import keyboard from pyanaconda import ntp from pyanaconda import timezone +from pyanaconda.timezone import NTP_PACKAGE, NTP_SERVICE from pyanaconda import localization from pyanaconda import network from pyanaconda import nm @@ -1179,6 +1181,39 @@ class Timezone(commands.timezone.F18_Timezone): #TODO: Do we need to set it to False in case of dual-boot? #default to UTC HW clock in Anaconda self.isUtc = True + self._added_chrony = False + self._enabled_chrony = False + + def setup(self, ksdata): + if self.nontp: + if iutil.service_running(NTP_SERVICE) and \ + flags_module.can_touch_runtime_system("stop NTP service"): + ret = iutil.stop_service(NTP_SERVICE) + if ret != 0: + log.error("Failed to stop NTP service") + + if self._added_chrony and NTP_PACKAGE in ksdata.packages.packageList: + ksdata.packages.packageList.remove(NTP_PACKAGE) + self._added_chrony = False + + if self._enabled_chrony and NTP_SERVICE in ksdata.services.enabled: + ksdata.services.enabled.remove(NTP_SERVICE) + self._enabled_chrony = False + + else: + if not iutil.service_running(NTP_SERVICE) and \ + flags_module.can_touch_runtime_system("start NTP service"): + ret = iutil.start_service(NTP_SERVICE) + if ret != 0: + log.error("Failed to start NTP service") + + if not NTP_PACKAGE in ksdata.packages.packageList: + ksdata.packages.packageList.append(NTP_PACKAGE) + self._added_chrony = True + + if not NTP_SERVICE in ksdata.services.enabled: + ksdata.services.enabled.append(NTP_SERVICE) + self._enabled_chrony = True def execute(self, *args): # write out timezone configuration diff --git a/pyanaconda/timezone.py b/pyanaconda/timezone.py index ff9e3f377..2e436c272 100644 --- a/pyanaconda/timezone.py +++ b/pyanaconda/timezone.py @@ -44,6 +44,9 @@ ETC_ZONES = ['GMT+1', 'GMT+2', 'GMT+3', 'GMT+4', 'GMT+5', 'GMT+6', 'GMT+7', 'GMT-8', 'GMT-9', 'GMT-10', 'GMT-11', 'GMT-12', 'GMT-13', 'GMT-14', 'UTC', 'GMT'] +NTP_PACKAGE = "chrony" +NTP_SERVICE = "chronyd" + class TimezoneConfigError(Exception): """Exception class for timezone configuration related problems""" pass diff --git a/pyanaconda/ui/gui/spokes/datetime_spoke.py b/pyanaconda/ui/gui/spokes/datetime_spoke.py index 0a0b6868b..09f843537 100644 --- a/pyanaconda/ui/gui/spokes/datetime_spoke.py +++ b/pyanaconda/ui/gui/spokes/datetime_spoke.py @@ -35,6 +35,7 @@ from pyanaconda.ui.gui.categories.localization import LocalizationCategory from pyanaconda.ui.gui.utils import enlightbox, gtk_thread_nowait, gtk_call_once from pyanaconda import timezone +from pyanaconda.timezone import NTP_SERVICE from pyanaconda import iutil from pyanaconda import network from pyanaconda import nm @@ -154,7 +155,7 @@ class NTPconfigDialog(GUIObject): if flags.can_touch_runtime_system("save NTP servers configuration"): ntp.save_servers_to_config(new_servers) - iutil.restart_service("chronyd") + iutil.restart_service(NTP_SERVICE) #Cancel clicked, window destroyed... else: @@ -357,8 +358,6 @@ class DatetimeSpoke(NormalSpoke): self._radioButton24h = self.builder.get_object("timeFormatRB") self._ntpSwitch = self.builder.get_object("networkTimeSwitch") - self._added_chrony = False - self._enabled_chrony = False if self._radioButton24h.get_active(): self._set_amPm_part_sensitive(False) @@ -392,44 +391,21 @@ class DatetimeSpoke(NormalSpoke): return _("Nothing selected") def apply(self): - GLib.source_remove(self._update_datetime_timer_id) - self._update_datetime_timer_id = None - - new_tz = self._tzmap.get_timezone() - - # get_timezone() may return "" if Etc/XXXXX is selected - if not new_tz: - # get selected "Etc/XXXXXX" zone - region = self._get_active_region() - city = self._get_active_city() - new_tz = region + "/" + city + # we could use self._tzmap.get_timezone() here, but it returns "" if + # Etc/XXXXXX timezone is selected + region = self._get_active_region() + city = self._get_active_city() + new_tz = region + "/" + city self.data.timezone.timezone = new_tz self.data.timezone.seen = True - if self._ntpSwitch.get_active(): - # turned ON - self.data.timezone.nontp = False - if not "chrony" in self.data.packages.packageList: - self.data.packages.packageList.append("chrony") - self._added_chrony = True - - if not "chronyd" in self.data.services.enabled and \ - not "chronyd" in self.data.services.disabled: - self.data.services.enabled.append("chronyd") - self._enabled_chrony = True - else: - # turned OFF - self.data.timezone.nontp = True - if self._added_chrony and ("chrony" in - self.data.packages.packageList): - self.data.packages.packageList.remove("chrony") - self._added_chrony = False - - if self._enabled_chrony and ("chronyd" in - self.data.services.enabled): - self.data.services.enabled.remove("chronyd") - self._enabled_chrony = False + self.data.timezone.nontp = not self._ntpSwitch.get_active() + + def execute(self): + GLib.source_remove(self._update_datetime_timer_id) + self._update_datetime_timer_id = None + self.data.timezone.setup(self.data) @property def completed(self): @@ -461,7 +437,7 @@ class DatetimeSpoke(NormalSpoke): gtk_call_once(self._config_dialog.refresh_servers_state) if flags.can_touch_runtime_system("get NTP service state"): - ntp_working = has_active_network and iutil.service_running("chronyd") + ntp_working = has_active_network and iutil.service_running(NTP_SERVICE) else: ntp_working = not self.data.timezone.nontp @@ -915,12 +891,12 @@ class DatetimeSpoke(NormalSpoke): #the time as drastically as we need ntp.one_time_sync_async(working_server) - ret = iutil.start_service("chronyd") + 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("chronyd"): + if (ret != 0) and not iutil.service_running(NTP_SERVICE): switch.set_active(False) else: @@ -930,11 +906,11 @@ class DatetimeSpoke(NormalSpoke): return self._set_date_time_setting_sensitive(True) - ret = iutil.stop_service("chronyd") + 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("chronyd"): + if (ret != 0) and iutil.service_running(NTP_SERVICE): switch.set_active(True) def on_ntp_config_clicked(self, *args): |