Skip to content

Commit f7bc08e

Browse files
committed
Replace ntp-config and ntpd with chrony
Signed-off-by: Saikrishna Arcot <sarcot@microsoft.com>
1 parent 261a29e commit f7bc08e

File tree

3 files changed

+13
-21
lines changed

3 files changed

+13
-21
lines changed

config/main.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -7083,10 +7083,10 @@ def add_ntp_server(ctx, ntp_ip_address, association_type, iburst, version):
70837083
ctx.fail("Invalid ConfigDB. Error: {}".format(e))
70847084
click.echo("NTP server {} added to configuration".format(ntp_ip_address))
70857085
try:
7086-
click.echo("Restarting ntp-config service...")
7087-
clicommon.run_command(['systemctl', 'restart', 'ntp-config'], display_cmd=False)
7086+
click.echo("Restarting chrony service...")
7087+
clicommon.run_command(['systemctl', 'restart', 'chrony'], display_cmd=False)
70887088
except SystemExit as e:
7089-
ctx.fail("Restart service ntp-config failed with error {}".format(e))
7089+
ctx.fail("Restart service chrony failed with error {}".format(e))
70907090

70917091
@ntp.command('del')
70927092
@click.argument('ntp_ip_address', metavar='<ntp_ip_address>', required=True)
@@ -7107,10 +7107,10 @@ def del_ntp_server(ctx, ntp_ip_address):
71077107
else:
71087108
ctx.fail("NTP server {} is not configured.".format(ntp_ip_address))
71097109
try:
7110-
click.echo("Restarting ntp-config service...")
7111-
clicommon.run_command(['systemctl', 'restart', 'ntp-config'], display_cmd=False)
7110+
click.echo("Restarting chrony service...")
7111+
clicommon.run_command(['systemctl', 'restart', 'chrony'], display_cmd=False)
71127112
except SystemExit as e:
7113-
ctx.fail("Restart service ntp-config failed with error {}".format(e))
7113+
ctx.fail("Restart service chrony failed with error {}".format(e))
71147114

71157115
#
71167116
# 'sflow' group ('config sflow ...')

show/main.py

+7-14
Original file line numberDiff line numberDiff line change
@@ -1928,22 +1928,15 @@ def bgp(verbose):
19281928
@click.option('--verbose', is_flag=True, help="Enable verbose output")
19291929
def ntp(ctx, verbose):
19301930
"""Show NTP information"""
1931-
from pkg_resources import parse_version
1932-
ntpstat_cmd = ["ntpstat"]
1933-
ntpcmd = ["ntpq", "-p", "-n"]
1931+
chronyc_tracking_cmd = ["chronyc", "tracking"]
1932+
chronyc_sources_cmd = ["chronyc", "sources"]
19341933
if is_mgmt_vrf_enabled(ctx) is True:
1935-
#ManagementVRF is enabled. Call ntpq using "ip vrf exec" or cgexec based on linux version
1936-
os_info = os.uname()
1937-
release = os_info[2].split('-')
1938-
if parse_version(release[0]) > parse_version("4.9.0"):
1939-
ntpstat_cmd = ['sudo', 'ip', 'vrf', 'exec', 'mgmt', 'ntpstat']
1940-
ntpcmd = ['sudo', 'ip', 'vrf', 'exec', 'mgmt', 'ntpq', '-p', '-n']
1941-
else:
1942-
ntpstat_cmd = ['sudo', 'cgexec', '-g', 'l3mdev:mgmt', 'ntpstat']
1943-
ntpcmd = ['sudo', 'cgexec', '-g', 'l3mdev:mgmt', 'ntpq', '-p', '-n']
1934+
#ManagementVRF is enabled. Call chronyc using "ip vrf exec" based on linux version
1935+
chronyc_tracking_cmd = ["sudo", "ip", "vrf", "exec", "mgmt"] + chronyc_tracking_cmd
1936+
chronyc_sources_cmd = ["sudo", "ip", "vrf", "exec", "mgmt"] + chronyc_sources_cmd
19441937

1945-
run_command(ntpstat_cmd, display_cmd=verbose)
1946-
run_command(ntpcmd, display_cmd=verbose)
1938+
run_command(chronyc_tracking_cmd, display_cmd=verbose)
1939+
run_command(chronyc_sources_cmd, display_cmd=verbose)
19471940

19481941
#
19491942
# 'uptime' command ("show uptime")

tests/conftest.py

-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
sys.path.insert(0, modules_path)
2828

2929
generated_services_list = [
30-
'ntp-config.service',
3130
'warmboot-finalizer.service',
3231
'watchdog-control.service',
3332
'rsyslog-config.service',

0 commit comments

Comments
 (0)