mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-05-06 10:20:43 +00:00
datetime: Fix diagnostic test for checking NTP server sync
Fixes: #2384 - This was missed during the original transition to DiagnosticCheck class for returning diagnostic results. Tests: - In vagrant container, test that the diagnostic test result shows up in datetime app and it passes. - Running full diagnostics on the system works. Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org> Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
parent
1f90047621
commit
e3c2546b79
@ -11,6 +11,7 @@ from plinth import app as app_module
|
||||
from plinth import menu
|
||||
from plinth.daemon import Daemon, RelatedDaemon
|
||||
from plinth.modules.backups.components import BackupRestore
|
||||
from plinth.modules.diagnostics.check import DiagnosticCheck, Result
|
||||
from plinth.package import Packages
|
||||
|
||||
from . import manifest
|
||||
@ -107,13 +108,14 @@ class DateTimeApp(app_module.App):
|
||||
|
||||
def _diagnose_time_synchronized():
|
||||
"""Check whether time is synchronized to NTP server."""
|
||||
result = 'failed'
|
||||
result = Result.FAILED
|
||||
try:
|
||||
output = subprocess.check_output(
|
||||
['timedatectl', 'show', '--property=NTPSynchronized', '--value'])
|
||||
if 'yes' in output.decode():
|
||||
result = 'passed'
|
||||
result = Result.PASSED
|
||||
except subprocess.CalledProcessError:
|
||||
pass
|
||||
|
||||
return [_('Time synchronized to NTP server'), result]
|
||||
return DiagnosticCheck('datetime-ntp-sync',
|
||||
_('Time synchronized to NTP server'), result)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user