for remote in remotes:
remote.run(
args=[
- 'sudo', 'service', 'ntp', 'stop',
+ 'sudo', 'systemctl', 'stop', 'ntp.service', run.Raw('||'),
+ 'sudo', 'systemctl', 'stop', 'ntpd.service', run.Raw('||'),
+ 'sudo', 'systemctl', 'stop', 'chronyd.service',
run.Raw('&&'),
- 'sudo', 'ntpdate-debian',
+ 'sudo', 'ntpdate-debian', run.Raw('||'),
+ 'sudo', 'ntp', '-gq', run.Raw('||'),
+ 'sudo', 'ntpd', '-gq', run.Raw('||'),
+ 'sudo', 'chronyc', 'sources',
run.Raw('&&'),
'sudo', 'hwclock', '--systohc', '--utc',
run.Raw('&&'),
- 'sudo', 'service', 'ntp', 'start',
+ 'sudo', 'systemctl', 'start', 'ntp.service', run.Raw('||'),
+ 'sudo', 'systemctl', 'start', 'ntpd.service', run.Raw('||'),
+ 'sudo', 'systemctl', 'start', 'chronyd.service',
run.Raw('||'),
'true', # ignore errors; we may be racing with ntpd startup
],
"""
import logging
import contextlib
-import os
-from ..orchestra import run
+from teuthology.orchestra import run
log = logging.getLogger(__name__)
log.info('Syncing clocks and checking initial clock skew...')
for rem in ctx.cluster.remotes.iterkeys():
- 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)
- # CentOS calls it ntpd, Xenial/Trusty are ntp. Thanks guys.
- args = [
- 'sudo', 'service', 'ntp', 'stop',
- run.Raw('||'),
- 'sudo', 'service', 'ntpd', 'stop',
- run.Raw(';'),
- 'sudo',
- 'ntpdate',
- ]
- args.extend(servers)
- args.extend([
- run.Raw(';'),
- 'sudo', 'service', 'ntp', 'start',
- run.Raw('||'),
- 'sudo', 'service', 'ntpd', 'start',
- run.Raw(';'),
- 'PATH=/usr/bin:/usr/sbin',
- 'ntpq', '-p',
- ])
- rem.run(args=args)
+ rem.run(
+ args = [
+ 'sudo', 'systemctl', 'stop', 'ntp.service', run.Raw('||'),
+ 'sudo', 'systemctl', 'stop', 'ntpd.service', run.Raw('||'),
+ 'sudo', 'systemctl', 'stop', 'chronyd.service',
+ run.Raw(';'),
+ 'sudo', 'ntpd', '-gq', run.Raw('||'),
+ 'sudo', 'chronyc', 'makestep',
+ run.Raw(';'),
+ 'sudo', 'systemctl', 'start', 'ntp.service', run.Raw('||'),
+ 'sudo', 'systemctl', 'start', 'ntpd.service', run.Raw('||'),
+ 'sudo', 'systemctl', 'start', 'chronyd.service',
+ run.Raw(';'),
+ 'PATH=/usr/bin:/usr/sbin', 'ntpq', '-p', run.Raw('||'),
+ 'PATH=/usr/bin:/usr/sbin', 'chronyc', 'sources',
+ run.Raw('||'),
+ 'true'
+ ],
+ )
try:
yield
for rem in ctx.cluster.remotes.iterkeys():
rem.run(
args=[
- 'PATH=/usr/bin:/usr/sbin',
- 'ntpq', '-p',
+ 'PATH=/usr/bin:/usr/sbin', 'ntpq', '-p', run.Raw('||'),
+ 'PATH=/usr/bin:/usr/sbin', 'chronyc', 'sources',
+ run.Raw('||'),
+ 'true'
],
)
for rem in ctx.cluster.remotes.iterkeys():
rem.run(
args=[
- 'PATH=/usr/bin:/usr/sbin',
- 'ntpq', '-p',
+ 'PATH=/usr/bin:/usr/sbin', 'ntpq', '-p', run.Raw('||'),
+ 'PATH=/usr/bin:/usr/sbin', 'chronyc', 'sources',
+ run.Raw('||'),
+ 'true'
],
)
for rem in ctx.cluster.remotes.iterkeys():
rem.run(
args=[
- 'PATH=/usr/bin:/usr/sbin',
- 'ntpq', '-p',
+ 'PATH=/usr/bin:/usr/sbin', 'ntpq', '-p', run.Raw('||'),
+ 'PATH=/usr/bin:/usr/sbin', 'chronyc', 'sources',
+ run.Raw('||'),
+ 'true'
],
)