Skip to content

Commit

Permalink
Merge pull request #70 from yast/review_170126_ay_write_config
Browse files Browse the repository at this point in the history
[Review] Request from 'schubi2' @ 'yast/yast-ntp-client/review_170126_ay_write_config'
  • Loading branch information
schubi2 committed Jan 26, 2017
2 parents 8596929 + cb3a259 commit 0954ad1
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 10 deletions.
7 changes: 7 additions & 0 deletions package/yast2-ntp-client.changes
@@ -1,3 +1,10 @@
-------------------------------------------------------------------
Thu Jan 26 10:17:50 CET 2017 - schubi@suse.de

- AutoYaST writing settings crash: Initialize CFA instance
correctly (bnc#1019292)
- 3.2.5

-------------------------------------------------------------------
Wed Jan 4 08:18:24 UTC 2017 - lslezak@suse.cz

Expand Down
2 changes: 1 addition & 1 deletion package/yast2-ntp-client.spec
Expand Up @@ -17,7 +17,7 @@


Name: yast2-ntp-client
Version: 3.2.4
Version: 3.2.5
Release: 0
Summary: YaST2 - NTP Client Configuration
License: GPL-2.0+
Expand Down
22 changes: 13 additions & 9 deletions src/modules/NtpClient.rb
Expand Up @@ -303,21 +303,20 @@ def read_ntp_conf
end

begin
@ntp_conf = CFA::NtpConf.new
@ntp_conf.load
ntp_conf.load
rescue StandardError => e
log.error("Failed to read #{NTP_FILE}: #{e.message}")
return false
end

load_ntp_records

log.info("Raw ntp conf #{@ntp_conf.raw}")
log.info("Raw ntp conf #{ntp_conf.raw}")
true
end

def load_ntp_records
@ntp_records = @ntp_conf.records.map do |record|
@ntp_records = ntp_conf.records.map do |record|
{
"type" => record.type,
"address" => record.value,
Expand All @@ -328,7 +327,7 @@ def load_ntp_records
end
end

# Read and parse /etc.ntp.conf
# Read and parse /etc/ntp.conf
# @return true on success
def ProcessNtpConf
if @config_has_been_read
Expand Down Expand Up @@ -414,7 +413,7 @@ def ProcessNtpConf
""
)
)
m["cfa_fudge_record"] = @ntp_conf.records.find do |record|
m["cfa_fudge_record"] = ntp_conf.records.find do |record|
record.type == "fudge" && record.value == m["address"]
end
end
Expand Down Expand Up @@ -1101,15 +1100,15 @@ def write_ntp_conf
records_for_write.each do |record|
unless record["cfa_record"]
record["cfa_record"] = CFA::NtpConf::Record.record_class(record["type"]).new
@ntp_conf.records << record["cfa_record"]
ntp_conf.records << record["cfa_record"]
end
update_cfa_record(record)
end

@ntp_conf.records.delete_if { |record| @deleted_records.include?(record) }
ntp_conf.records.delete_if { |record| @deleted_records.include?(record) }

begin
@ntp_conf.save
ntp_conf.save
rescue StandardError => e
log.error("Failed to write #{NTP_FILE}: #{e.message}")
end
Expand Down Expand Up @@ -1310,6 +1309,11 @@ def cache_server(server)
@ntp_servers[server["address"].to_s] = server
end

# CFA instance for reading/writing /etc/ntp.conf
def ntp_conf
@ntp_conf ||= CFA::NtpConf.new
end

publish variable: :AbortFunction, type: "boolean ()"
publish variable: :modified, type: "boolean"
publish variable: :write_only, type: "boolean"
Expand Down

0 comments on commit 0954ad1

Please sign in to comment.