On 09/03/2013 01:15 PM, Petr Viktorin wrote: > On 09/02/2013 05:05 PM, Ana Krivokapic wrote: >> Hello, >> >> This patch addresses tickethttps://fedorahosted.org/freeipa/ticket/3797. >> > > Thanks! I have a question. > >> - # retry several times -- logic follows /etc/init.d/ntpdate >> - # implementation >> + # retry several times >> for retry in range(0, 3): > > What's the reason to try several times? Is it still necessary with ntpd? > I checked /etc/init.d/ntpdate in RHEL (since Fedora doesn't have it any more) > and I didn't see any repeating. >
I am not sure what the reason for trying several times was. My testing didn't reveal any need for that, but I left the code there mainly because it returns immediately after successful sync, so there is no harm. Attached is a version of the patch without the repetition. -- Regards, Ana Krivokapic Associate Software Engineer FreeIPA team Red Hat Inc.
From 4da51666f77ed2d8a1c95cfc32c52eebe0493e35 Mon Sep 17 00:00:00 2001 From: Ana Krivokapic <akriv...@redhat.com> Date: Mon, 2 Sep 2013 16:40:55 +0200 Subject: [PATCH] Replace ntpdate calls with ntpd Due to the upcoming deprecation of the ntpdate program (targeted for Fedora 20), replace ntpdate calls with ntpd. https://fedorahosted.org/freeipa/ticket/3797 --- ipa-client/ipaclient/ntpconf.py | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/ipa-client/ipaclient/ntpconf.py b/ipa-client/ipaclient/ntpconf.py index eb9afdeeefb24d994701b0f3e6859f69653be39d..714d4fb861d41642fea82b15a8749214a893d830 100644 --- a/ipa-client/ipaclient/ntpconf.py +++ b/ipa-client/ipaclient/ntpconf.py @@ -21,7 +21,6 @@ from ipapython import services as ipaservices import shutil import os -import sys ntp_conf = """# Permit time synchronization with our time source, but do not # permit the source to query or modify the service on this system. @@ -137,24 +136,23 @@ def config_ntp(server_fqdn, fstore = None, sysstore = None): def synconce_ntp(server_fqdn): """ - Syncs time with specified server using ntpdate. + Syncs time with specified server using ntpd. Primarily designed to be used before Kerberos setup to get time following the KDC time Returns True if sync was successful """ - ntpdate="/usr/sbin/ntpdate" - if os.path.exists(ntpdate): - # retry several times -- logic follows /etc/init.d/ntpdate - # implementation - cmd = [ntpdate, "-U", "ntp", "-s", "-b", "-v", server_fqdn] - for retry in range(0, 3): - try: - ipautil.run(cmd) - return True - except: - pass - return False + ntpd = '/usr/sbin/ntpd' + if not os.path.exists(ntpd): + return False + + tmp_ntp_conf = ipautil.write_tmp_file('server %s' % server_fqdn) + try: + ipautil.run([ntpd, '-qgc', tmp_ntp_conf.name]) + return True + except ipautil.CalledProcessError: + return False + class NTPConfigurationError(Exception): pass -- 188.8.131.52
_______________________________________________ Freeipa-devel mailing list Freeipafirstname.lastname@example.org https://www.redhat.com/mailman/listinfo/freeipa-devel