From 1446bcf00e3aff792a2a96b326b23bcafb5eab3d Mon Sep 17 00:00:00 2001 From: Dan Mick Date: Tue, 8 Dec 2015 17:39:40 -0800 Subject: [PATCH] clock: get the servers to use for ntpdate from ntp.conf Signed-off-by: Dan Mick --- teuthology/task/clock.py | 47 ++++++++++++++++++++-------------------- 1 file changed, 24 insertions(+), 23 deletions(-) diff --git a/teuthology/task/clock.py b/teuthology/task/clock.py index 5920cd52f4..73d95f9d3c 100644 --- a/teuthology/task/clock.py +++ b/teuthology/task/clock.py @@ -3,6 +3,7 @@ Clock synchronizer """ import logging import contextlib +import os from ..orchestra import run @@ -31,29 +32,29 @@ def task(ctx, config): log.info('Syncing clocks and checking initial clock skew...') for rem in ctx.cluster.remotes.iterkeys(): - rem.run( - args=[ - 'sudo', - 'service', 'ntp', 'stop', - run.Raw(';'), - 'sudo', - 'ntpdate', -# 'clock1.dreamhost.com', -# 'clock2.dreamhost.com', -# 'clock3.dreamhost.com', -# 'time.apple.com', - '0.debian.pool.ntp.org', - '1.debian.pool.ntp.org', - '2.debian.pool.ntp.org', - '3.debian.pool.ntp.org', - run.Raw(';'), - 'sudo', - 'service', 'ntp', 'start', - run.Raw(';'), - 'PATH=/usr/bin:/usr/sbin', - 'ntpdc', '-p', - ], - ) + ntpconf = rem.get_file('/etc/ntp.conf') + servers = [ + l.strip().split()[1] for l in open(ntpconf, 'r').readlines() + if l.startswith('server') + ] + os.remove(ntpconf) + args = [ + 'sudo', + 'service', 'ntp', 'stop', + run.Raw(';'), + 'sudo', + 'ntpdate', + ] + args.extend(servers) + args.extend([ + run.Raw(';'), + 'sudo', + 'service', 'ntp', 'start', + run.Raw(';'), + 'PATH=/usr/bin:/usr/sbin', + 'ntpdc', '-p', + ]) + rem.run(args) try: yield -- 2.39.5