datetime: Switch from ntp to chrony

Use the default config, which only runs as client.

Fixes #971

Signed-off-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
James Valleroy 2019-02-03 21:56:33 -05:00 committed by Sunil Mohan Adapa
parent 5a159f7d39
commit 2c7d1a09c1
No known key found for this signature in database
GPG Key ID: 43EA1CFF0AA7C5F2

View File

@ -31,9 +31,9 @@ version = 1
is_essential = True is_essential = True
managed_services = ['ntp'] managed_services = ['chrony']
managed_packages = ['ntp'] managed_packages = ['chrony']
name = _('Date & Time') name = _('Date & Time')
@ -55,8 +55,8 @@ def init():
global service global service
setup_helper = globals()['setup_helper'] setup_helper = globals()['setup_helper']
if setup_helper.get_state() != 'needs-setup': if setup_helper.get_state() != 'needs-setup':
service = service_module.Service(managed_services[0], name, service = service_module.Service(
ports=['ntp'], is_external=False) managed_services[0], name, is_external=True)
def setup(helper, old_version=None): def setup(helper, old_version=None):
@ -64,27 +64,27 @@ def setup(helper, old_version=None):
helper.install(managed_packages) helper.install(managed_packages)
global service global service
if service is None: if service is None:
service = service_module.Service(managed_services[0], name, service = service_module.Service(
ports=['ntp'], is_external=False) managed_services[0], name, is_external=True)
helper.call('post', service.notify_enabled, None, True) helper.call('post', service.notify_enabled, None, True)
def diagnose(): def diagnose():
"""Run diagnostics and return the results.""" """Run diagnostics and return the results."""
results = [] results = []
results.append(_diagnose_ntp_server_count()) results.append(_diagnose_chrony_server_count())
return results return results
def _diagnose_ntp_server_count(): def _diagnose_chrony_server_count():
"""Diagnose minimum NTP server count.""" """Diagnose minimum chrony server count."""
result = 'failed' result = 'failed'
try: try:
output = subprocess.check_output(['ntpq', '-n', '-c', 'lpeers']) output = subprocess.check_output(['chronyc', '-c', 'sources'])
if len(output.decode().splitlines()[2:]): if len(output.decode().splitlines()[2:]):
result = 'passed' result = 'passed'
except subprocess.CalledProcessError: except subprocess.CalledProcessError:
pass pass
return [_('NTP client in contact with servers'), result] return [_('chrony client in contact with servers'), result]