Skip to content

Commit

Permalink
Merge pull request #1038 from yast/merge_SLE-15-SP1
Browse files Browse the repository at this point in the history
merge 'SLE-15-SP1' into 'master'
  • Loading branch information
teclator committed Apr 3, 2020
2 parents 44fb803 + 830eefe commit 0666686
Show file tree
Hide file tree
Showing 6 changed files with 79 additions and 3 deletions.
3 changes: 3 additions & 0 deletions library/network/src/modules/NetworkInterfaces.rb
Original file line number Diff line number Diff line change
Expand Up @@ -954,6 +954,9 @@ def Write(devregex)

# Finish him
SCR.Write(path(".network"), nil)
# Reread all settings to avoid wrong values when reopen the network
# dialog during installation (bsc#1166778)
CleanCacheRead()

true
end
Expand Down
4 changes: 2 additions & 2 deletions library/network/test/data/etc/sysconfig/network/ifcfg-eth1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
DEVICE=eth1
DEVICE='eth1'
BOOTPROTO='static'
STARTMODE='auto'
SLAVE=YES
SLAVE='YES'
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
DEVICE='single'
BOOTPROTO='dhcp'
STARTMODE='auto'
DHCLIENT_SET_HOSTNAME='yes'
NAME='single 'quoted' name'
60 changes: 60 additions & 0 deletions library/network/test/network_interfaces_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ def mock_ppp

describe "#Read" do
let(:data_dir) { File.join(File.dirname(__FILE__), "data") }
let(:network_path) { File.join(data_dir, "etc/sysconfig/network") }
let(:single_template) { File.join(network_path, "single_quote.test") }
let(:single_file) { File.join(network_path, "ifcfg-single") }
# Defined in test/data/etc/sysconfig/ifcfg-*
let(:devices) { ["arc5", "bond0", "br1", "cold", "em1", "eth0", "eth1", "eth2", "ppp0", "vlan3"] }

Expand Down Expand Up @@ -89,6 +92,13 @@ def mock_ppp
expect(subject.GetValue("eth0", "NETMASK")).to eql("255.255.255.0")
end

# bsc#72164
it "reads the ifcfg files with single quote removed" do
::FileUtils.cp(single_template, single_file)
subject.Read
expect(subject.GetValue("single", "NAME")).to eql("single quoted name")
::FileUtils.rm(single_file)
end
end

describe "adapt_old_config!" do
Expand Down Expand Up @@ -306,4 +316,54 @@ def mock_ppp
expect(subject.Devices[device_type]).to include(device => device_map, "eth1" => {})
end
end

describe "#Write" do
let(:data_dir) { File.join(File.dirname(__FILE__), "data") }
let(:network_path) { File.join(data_dir, "etc/sysconfig/network") }
let(:ifcfg_copy) { File.join(network_path, "ifcfg-copy") }
let(:ifcfg_file) { File.join(network_path, "ifcfg-eth1") }

before do
subject.CleanCacheRead()
end

around do |example|
::FileUtils.cp(ifcfg_file, ifcfg_copy)
change_scr_root(data_dir, &example)
::FileUtils.rm(ifcfg_copy)
end

context "when the configuration has changed" do
it "writes interfaces configuration changes to ifcfg files" do
devmap = subject.devmap("eth1")
devmap["SOME_VALUE"] = "yes"
subject.Write("")
expect(::FileUtils.compare_file(ifcfg_copy, ifcfg_file)).to eq(false)
devmap = subject.devmap("eth1")
devmap["SOME_VALUE"] = nil
subject.Write("")
expect(::FileUtils.compare_file(ifcfg_copy, ifcfg_file)).to eq(true)
end

it "cleans the cache and read again the configuration after writing" do
expect(subject).to receive(:CleanCacheRead).twice.and_call_original
devmap = subject.devmap("eth1")
devmap["DHCLIENT_SET_HOSTNAME"] = "yes"
subject.Write("")
devmap = subject.devmap("eth1")
expect(devmap["DHCLIENT_SET_HOSTNAME"]).to eq("yes")
devmap["DHCLIENT_SET_HOSTNAME"] = nil
subject.Write("")
expect(::FileUtils.compare_file(ifcfg_copy, ifcfg_file)).to eq(true)
end

it "deletes removed interfaces" do
size = subject.List("").size
subject.Delete("copy")
subject.Commit()
subject.Write("")
expect(subject.List("").size).to eq(size - 1)
end
end
end
end
8 changes: 8 additions & 0 deletions package/yast2.changes
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
-------------------------------------------------------------------
Fri Mar 27 13:12:00 UTC 2020 - Knut Anderssen <kanderssen@suse.com>

- Reread network interfaces configuration after writing it avoiding
wrong values when reopen network configuration dialog during an
installation (bsc#1166778)
- 4.2.79

-------------------------------------------------------------------
Thu Mar 26 12:57:33 UTC 2020 - David Diaz <dgonzalez@suse.com>

Expand Down
2 changes: 1 addition & 1 deletion package/yast2.spec
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@


Name: yast2
Version: 4.2.78
Version: 4.2.79
Release: 0
Summary: YaST2 Main Package
License: GPL-2.0-only
Expand Down

0 comments on commit 0666686

Please sign in to comment.