Skip to content

Commit

Permalink
Merge pull request #968 from yast/network-ng-merge_master
Browse files Browse the repository at this point in the history
network-ng: merge master
  • Loading branch information
imobachgs authored Sep 18, 2019
2 parents 7082a80 + ccf8580 commit 4f94017
Show file tree
Hide file tree
Showing 6 changed files with 81 additions and 7 deletions.
25 changes: 25 additions & 0 deletions package/yast2-network.changes
Original file line number Diff line number Diff line change
@@ -1,3 +1,28 @@
-------------------------------------------------------------------
Tue Sep 10 07:40:04 UTC 2019 - Michal Filka <mfilka@suse.com>

- bnc#1149234
- apply udev rule from AY profile according to device's mac
value when permanent_mac is missing in list of the device's
options
- bsc#1133442
- Increased the DHCP timeout when NetworkManager is in use to
its default (45 seconds).
- 4.2.12

-------------------------------------------------------------------
Tue Jul 30 11:14:04 UTC 2019 - Dominique Leuenberger <dimstar@opensuse.org>

- Requires hostname: there are many places where the module calls
/bin/hostname (boo#1142595).
- 4.2.11

-------------------------------------------------------------------
Fri Jul 19 08:10:14 UTC 2019 - Josef Reidinger <jreidinger@suse.com>

- avoid dependency on autoyast2-installation
- 4.2.10

-------------------------------------------------------------------
Wed Jul 17 10:30:31 UTC 2019 - Imobach Gonzalez Sosa <igonzalezsosa@suse.com>

Expand Down
6 changes: 2 additions & 4 deletions package/yast2-network.spec
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@


Name: yast2-network
Version: 4.2.9
Version: 4.2.12
Release: 0
Summary: YaST2 - Network Configuration
License: GPL-2.0-only
Expand Down Expand Up @@ -57,13 +57,11 @@ Requires: augeas-lenses
Requires: hwinfo >= 21.35
Requires: yast2-ruby-bindings >= 1.0.0
Requires: yast2-xml
Requires: hostname

# testsuite
BuildRequires: rubygem(%rb_default_ruby_abi:rspec)

# support for reading Profile etc.
BuildRequires: autoyast2-installation

# carrier detection
Conflicts: yast2-core < 2.10.6

Expand Down
21 changes: 20 additions & 1 deletion src/lib/y2network/hwinfo.rb
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ def initialize(hwinfo = {})
# @return [String,nil]
[
{ name: "dev_name", default: "" },
{ name: "mac", default: nil },
{ name: "permanent_mac", default: nil },
{ name: "busid", default: nil },
{ name: "link", default: false },
{ name: "driver", default: "" },
Expand Down Expand Up @@ -250,6 +250,25 @@ def present?
!!type
end

# Returns the MAC adress
#
# It usually returns the permanent MAC address (defined in the firmware). However, when
# missing, it will use the current MAC. See bsc#1136929 and bsc#1149234 for the reasons
# behind preferring the permanent MAC address.
#
# @return [String,nil] MAC address
def mac
return permanent_mac unless permanent_mac.nil? || permanent_mac.empty?
used_mac
end

# MAC address which is being used by the device
#
# @return [String,nil] MAC address
def used_mac
@hwinfo["mac"]
end

# Determines whether two objects are equivalent
#
# Ignores any element having a nil value.
Expand Down
4 changes: 3 additions & 1 deletion src/modules/Lan.rb
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,8 @@ def writeIPv6
nil
end

NM_DHCP_TIMEOUT = 45

# Update the SCR according to network settings
# @return true on success
def Write(gui: true)
Expand Down Expand Up @@ -572,7 +574,7 @@ def Write(gui: true)

if NetworkService.is_network_manager
network = false
timeout = 15
timeout = NM_DHCP_TIMEOUT
while Ops.greater_than(timeout, 0)
if NetworkService.isNetworkRunning
network = true
Expand Down
2 changes: 1 addition & 1 deletion src/modules/LanItems.rb
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ def getDeviceName(oldname)

hardware.each do |hw|
hw_dev_name = hw["dev_name"] || ""
hw_dev_mac = hw["permanent_mac"] || ""
hw_dev_mac = hw["permanent_mac"] || hw["mac"] || ""
hw_dev_busid = hw["busid"] || ""

case oldname
Expand Down
30 changes: 30 additions & 0 deletions test/y2network/hwinfo_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -167,4 +167,34 @@
end
end
end

describe "#mac" do
before do
allow(hwinfo).to receive(:permanent_mac).and_return(permanent_mac)
end

context "when the permanent MAC is defined" do
let(:permanent_mac) { "00:11:22:33:44:55" }

it "returns the permanent MAC" do
expect(hwinfo.mac).to eq(hwinfo.permanent_mac)
end
end

context "when the permanent MAC is empty" do
let(:permanent_mac) { "" }

it "returns the current MAC" do
expect(hwinfo.mac).to eq(hwinfo.used_mac)
end
end

context "when the permanent MAC is not defined" do
let(:permanent_mac) { nil }

it "returns the current MAC" do
expect(hwinfo.mac).to eq(hwinfo.used_mac)
end
end
end
end

0 comments on commit 4f94017

Please sign in to comment.