From c57cbe4b00f13f64911daefe2d3bf9362a5f8a57 Mon Sep 17 00:00:00 2001 From: Josef Reidinger Date: Fri, 3 Nov 2017 16:48:42 +0100 Subject: [PATCH] adapt to chrony journalctl usage --- src/include/ntp-client/widgets.rb | 40 +++++++++++++++++++------------ src/modules/NtpClient.rb | 7 +----- 2 files changed, 26 insertions(+), 21 deletions(-) diff --git a/src/include/ntp-client/widgets.rb b/src/include/ntp-client/widgets.rb index b6ac32b7..f45afb2b 100644 --- a/src/include/ntp-client/widgets.rb +++ b/src/include/ntp-client/widgets.rb @@ -8,6 +8,9 @@ # $Id$ # # Main file for ntp-client configuration. Uses all other files. + +require "tempfile" + module Yast module NtpClientWidgetsInclude include Logger @@ -57,22 +60,29 @@ def SilentWrite # Show popup with NTP daemon's log def showLogPopup - LogView.Display( - "file" => "/var/log/ntp", - "save" => true, - "actions" => [ - # menubutton entry, try to keep short - [ - _("Restart NTP Daemon"), - fun_ref(method(:restartNtpDaemon), "void ()") - ], - # menubutton entry, try to keep short - [ - _("Save Settings and Restart NTP Daemon"), - fun_ref(method(:SilentWrite), "boolean ()") + tmp_file = Tempfile.new("yast_chronylog") + tmp_file.close + begin + SCR.Execute(path(".target.bash"), "/usr/bin/journalctl --boot --unit chronyd --no-pager --no-tail > '#{tmp_file.path}'") + LogView.Display( + "file" => tmp_file.path, + "save" => true, + "actions" => [ + # menubutton entry, try to keep short + [ + _("Restart NTP Daemon"), + fun_ref(method(:restartNtpDaemon), "void ()") + ], + # menubutton entry, try to keep short + [ + _("Save Settings and Restart NTP Daemon"), + fun_ref(method(:SilentWrite), "boolean ()") + ] ] - ] - ) + ) + ensure + tmp_file.unlink + end nil end diff --git a/src/modules/NtpClient.rb b/src/modules/NtpClient.rb index 9fe8498b..77b0a728 100644 --- a/src/modules/NtpClient.rb +++ b/src/modules/NtpClient.rb @@ -377,12 +377,7 @@ def Read # # @return [Array] of servers def GetUsedNtpServers - used_servers = [] - @ntp_records.each do |record| - used_servers << record["address"] if record["type"] == "server" - end - - used_servers + ntp_conf.pools.keys end # Checks whether all servers listed in the random_pool_servers list