[PATCH 2/2] Honor user's choice on NTP (ON/OFF)
Vratislav Podzimek
vpodzime at redhat.com
Fri Aug 24 14:24:10 UTC 2012
Iff user turned NTP ON, we need to make sure chrony gets installed
and enabled and save NTP configuration.
Resolves: rhbz#851323
Signed-off-by: Vratislav Podzimek <vpodzime at redhat.com>
---
pyanaconda/kickstart.py | 9 ++++++---
pyanaconda/ui/gui/spokes/datetime_spoke.py | 28 ++++++++++++++++++++++++++++
2 files changed, 34 insertions(+), 3 deletions(-)
diff --git a/pyanaconda/kickstart.py b/pyanaconda/kickstart.py
index 68db3b9..2d156c2 100644
--- a/pyanaconda/kickstart.py
+++ b/pyanaconda/kickstart.py
@@ -1261,9 +1261,12 @@ class Timezone(commands.timezone.F18_Timezone):
self.timezone = "America/New_York"
timezone.write_timezone_config(self, ROOT_PATH)
- chronyd_conf_path = os.path.normpath(ROOT_PATH + ntp.NTP_CONFIG_FILE)
- ntp.save_servers_to_config(self.ntpservers,
- conf_file_path=chronyd_conf_path)
+
+ # write out NTP configuration (if set)
+ if self.ntp and self.ntpservers:
+ chronyd_conf_path = os.path.normpath(ROOT_PATH + ntp.NTP_CONFIG_FILE)
+ ntp.save_servers_to_config(self.ntpservers,
+ conf_file_path=chronyd_conf_path)
class User(commands.user.F12_User):
def execute(self, storage, ksdata, instClass, users):
diff --git a/pyanaconda/ui/gui/spokes/datetime_spoke.py b/pyanaconda/ui/gui/spokes/datetime_spoke.py
index 2fcb333..1396293 100644
--- a/pyanaconda/ui/gui/spokes/datetime_spoke.py
+++ b/pyanaconda/ui/gui/spokes/datetime_spoke.py
@@ -309,6 +309,10 @@ class DatetimeSpoke(NormalSpoke):
self._amPmLabel = self.builder.get_object("amPmLabel")
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)
@@ -342,6 +346,30 @@ class DatetimeSpoke(NormalSpoke):
self.data.timezone.timezone = self._tzmap.get_timezone()
+ if self._ntpSwitch.get_active():
+ # turned ON
+ self.data.timezone.ntp = True
+ if not "chrony" in self.data.packages.packageList:
+ self.data.packages.packageList.append("chrony")
+ self._added_chrony = True
+
+ if (not "chronyd.service" in self.data.services.enabled) and \
+ (not "chronyd.service" in self.data.services.disabled):
+ self.data.services.enabled.append("chronyd.service")
+ self._enabled_chrony = True
+ else:
+ # turned OFF
+ self.data.timezone.ntp = False
+ 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.service" in \
+ self.data.services.enabled):
+ self.data.services.enabled.remove("chronyd.service")
+ self._enabled_chrony = False
+
@property
def completed(self):
return timezone.is_valid_timezone(self.data.timezone.timezone)
--
1.7.11.4
More information about the anaconda-patches
mailing list