Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/SLE-12-SP3' into merge_sp3_branch
Browse files Browse the repository at this point in the history
  • Loading branch information
lslezak committed Jul 10, 2017
2 parents 8705d20 + 3c2b4e4 commit 6f823b0
Show file tree
Hide file tree
Showing 5 changed files with 101 additions and 22 deletions.
16 changes: 15 additions & 1 deletion package/yast2-network.changes
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
-------------------------------------------------------------------
Tue Jul 4 09:18:21 UTC 2017 - mfilka@suse.com
Tue Jul 4 15:06:40 UTC 2017 - lslezak@suse.cz

- Display a warning in AutoYaST installation when importing the DNS
configuration with disabled seconds stage (the second stage is
currently required for writing the config) (bsc#1046198)
- 3.3.1

-------------------------------------------------------------------
Tue Jul 4 12:57:05 UTC 2017 - mfilka@suse.com

- bnc#1046735
- do not update sysconfig when no IP is given in case of static
NIC configuration.

-------------------------------------------------------------------

- bsc#1044982
- handle bad pci class/subclass ids used by Mellanox ConnectX-3
Expand Down
8 changes: 4 additions & 4 deletions package/yast2-network.spec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#
# spec file for package yast2-network
#
# Copyright (c) 2016 SUSE LINUX GmbH, Nuernberg, Germany.
# Copyright (c) 2017 SUSE LINUX GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
Expand All @@ -17,15 +17,13 @@


Name: yast2-network
Version: 3.3.0
Version: 3.3.1
Release: 0
BuildArch: noarch

BuildRoot: %{_tmppath}/%{name}-%{version}-build
Source0: %{name}-%{version}.tar.bz2

Group: System/YaST
License: GPL-2.0
BuildRequires: update-desktop-files
BuildRequires: yast2-devtools >= 3.1.15
Requires: yast2-proxy
Expand Down Expand Up @@ -70,6 +68,8 @@ Requires: yast2-ruby-bindings >= 1.0.0
Obsoletes: yast2-network-devel-doc

Summary: YaST2 - Network Configuration
License: GPL-2.0
Group: System/YaST

%description
This package contains the YaST2 component for network configuration.
Expand Down
35 changes: 18 additions & 17 deletions src/include/network/lan/address.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1482,30 +1482,31 @@ def AddressDialog
LanItems.device = NetworkInterfaces.device_num(ifcfgname)
end

LanItems.bootproto = Ops.get_string(@settings, "BOOTPROTO", "")
if LanItems.bootproto == "static" # #104494
ip_changed = LanItems.ipaddr !=
Ops.get_string(@settings, "IPADDR", "")
if ip_changed
bootproto = @settings.fetch("BOOTPROTO", "")
ipaddr = @settings.fetch("IPADDR", "")

# IP is mandatory for static configuration. Makes no sense to write static
# configuration without that.
return ret if bootproto == "static" && ipaddr.empty?

LanItems.bootproto = bootproto

if bootproto == "static"
ip_changed = LanItems.ipaddr != ipaddr
hostname = @settings.fetch("HOSTNAME", "")

if ip_changed || hostname.empty?
log.info("Dropping record for #{LanItems.ipaddr} from /etc/hosts")
Host.remove_ip(LanItems.ipaddr)
Builtins.y2milestone("IP has changed")
end

LanItems.ipaddr = Ops.get_string(@settings, "IPADDR", "")
LanItems.ipaddr = ipaddr
LanItems.netmask = Ops.get_string(@settings, "NETMASK", "")
LanItems.prefix = Ops.get_string(@settings, "PREFIXLEN", "")
LanItems.remoteip = Ops.get_string(@settings, "REMOTEIP", "")

if @hostname_initial != Ops.get_string(@settings, "HOSTNAME", "") || ip_changed
if Ops.get_string(@settings, "HOSTNAME", "") == ""
Host.remove_ip(LanItems.ipaddr)
else
Host.Update(
@hostname_initial,
Ops.get_string(@settings, "HOSTNAME", ""),
Ops.get_string(@settings, "IPADDR", "")
)
end
if (@hostname_initial != hostname && !hostname.empty?) || ip_changed
Host.Update(@hostname_initial, hostname, LanItems.ipaddr)
end
else
LanItems.ipaddr = ""
Expand Down
29 changes: 29 additions & 0 deletions src/modules/DNS.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ def main
Yast.import "Service"
Yast.import "String"
Yast.import "FileUtils"
Yast.import "Stage"
Yast.import "Mode"
Yast.import "Report"

Yast.include self, "network/routines.rb"
Yast.include self, "network/runtime.rb"
Expand Down Expand Up @@ -83,6 +86,9 @@ def main

# True if DNS is already read
@initialized = false

# report the profile error only once
@error_reported = false
end

# Use the parameter, coming usually from install.inf, if it is defined.
Expand Down Expand Up @@ -479,6 +485,23 @@ def Import(settings)

@nameservers = Builtins.eval(Ops.get_list(settings, "nameservers", []))
@searchlist = Builtins.eval(Ops.get_list(settings, "searchlist", []))

# check for AY unsupported scenarios, the name servers and the search domains
# are written in the 2nd stage, if is disabled then it cannot work (bsc#1046198)
if Stage.initial && Mode.auto && !@error_reported && !empty?
# lazy loading to avoid the dependency on AutoYaST, this can be imported only
# in the initial stage otherwise it might fail!
Yast.import "AutoinstConfig"

if !AutoinstConfig.second_stage
# TRANSLATORS: Warning message, the AutoYaST XML profile is incorrect
Report.Warning(_("DNS configuration error: The DNS configuration\n" \
"is written in the second installation stage (after reboot)\n" \
"but the second stage is disabled in the AutoYaST XML profile."))
@error_reported = true
end
end

@modified = true
# empty settings means that we're probably resetting the config
# thus, setup is not initialized anymore
Expand Down Expand Up @@ -691,6 +714,12 @@ def read_hostname_from_install_inf
fqhostname
end

# empty configuration?
# @return [Boolean] true if the configuration is empty (or contains defaults)
def empty?
@nameservers.empty? && @searchlist.empty? && @hostname.empty? && @domain.empty?
end

publish variable: :proposal_valid, type: "boolean"
publish variable: :hostname, type: "string"
publish variable: :domain, type: "string"
Expand Down
35 changes: 35 additions & 0 deletions test/dns_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ module Yast
end

describe ".Import" do
before do
allow(Yast::Stage).to receive(:initial).and_return(false)
end

context "with present dhcp_hostname and write_hostname" do
let(:settings) { { "hostname" => "host", "dhcp_hostname" => true, "write_hostname" => true } }

Expand All @@ -101,6 +105,37 @@ module Yast
expect(DNS.dhcp_hostname).to eql(false)
end
end

context "The AutoYaST first stage installation" do
let(:settings) { { "hostname" => "host", "searchlist" => ["example.com"] } }

before do
allow(Yast::Stage).to receive(:initial).and_return(true)
allow(Yast::Mode).to receive(:auto).and_return(true)
allow(Yast).to receive(:import).with("AutoinstConfig")
# reset the internal counter
DNS.instance_variable_set(:@error_reported, false)
end

it "prints a warning when the 2nd stage is disabled for writing the search list" do
stub_const("Yast::AutoinstConfig", double(second_stage: false))
expect(Yast::Report).to receive(:Warning)
DNS.Import(settings)
end

it "prints the warning only once on multiple calls" do
stub_const("Yast::AutoinstConfig", double(second_stage: false))
expect(Yast::Report).to receive(:Warning).once
DNS.Import(settings)
DNS.Import(settings)
end

it "does not print a warning when the 2nd stage is enabled for writing the search list" do
stub_const("Yast::AutoinstConfig", double(second_stage: true))
expect(Yast::Report).to_not receive(:Warning)
DNS.Import(settings)
end
end
end
end
end

0 comments on commit 6f823b0

Please sign in to comment.