Skip to content

Commit

Permalink
Merge 810f659 into 750a407
Browse files Browse the repository at this point in the history
  • Loading branch information
teclator committed Nov 5, 2021
2 parents 750a407 + 810f659 commit 2fb2617
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 1 deletion.
10 changes: 10 additions & 0 deletions package/yast2-network.changes
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
-------------------------------------------------------------------
Thu Nov 4 15:02:24 UTC 2021 - Knut Anderssen <kanderssen@suse.com>

- AutoYaST
- When the interface section contains the "device" (deprecated)
and "name" elements then use the "device" as the "name" and the
"name" as the "description". (bsc#1192270)
- Add the "description" element to the interface section.
- 4.4.29

-------------------------------------------------------------------
Wed Nov 3 22:19:45 UTC 2021 - Knut Anderssen <kanderssen@suse.com>

Expand Down
2 changes: 1 addition & 1 deletion 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.4.28
Version: 4.4.29
Release: 0
Summary: YaST2 - Network Configuration
License: GPL-2.0-only
Expand Down
1 change: 1 addition & 0 deletions src/autoyast-rnc/networking.rnc
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ interface =
(
element device { STRING }? & #overloaded
element name { STRING }? &
element description { STRING }? &

lladdr? &
bootproto? &
Expand Down
3 changes: 3 additions & 0 deletions src/lib/y2network/autoinst/interfaces_reader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,9 @@ def load_generic(config, interface_section)

config.lladdress = interface_section.lladdr if !interface_section.lladdr.to_s.empty?
config.interface = config.name # in autoyast name and interface is same
description = interface_section.description.to_s
config.description = interface_section.description if !description.empty?

config.ip = load_ipaddr(interface_section)

# handle aliases
Expand Down
8 changes: 8 additions & 0 deletions src/lib/y2network/autoinst_profile/interface_section.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ def self.attributes
{ name: :device },
{ name: :name }, # has precedence over device
{ name: :lladdr },
{ name: :description },
{ name: :ipaddr },
{ name: :remote_ipaddr },
{ name: :netmask },
Expand Down Expand Up @@ -266,6 +267,13 @@ def init_from_hashes(hash)
hash = rename_key(hash, "bridge_forwarddelay", "bridge_forward_delay")
super(hash)

# When the name and the device attributes are given then the pre network-ng behavior will be
# adopted using the name as the description and the device as the name (bsc#1192270).
unless hash.fetch("name", "").empty? || hash.fetch("device", "").empty?
self.name = hash["device"]
self.description = hash["name"]
end

return unless hash["aliases"].is_a?(Hash)

self.aliases = hash["aliases"].values.map { |h| AliasSection.new_from_hashes(h) }
Expand Down
2 changes: 2 additions & 0 deletions test/y2network/autoinst/interfaces_reader_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
{
"bootproto" => "dhcp",
"name" => "eth0",
"description" => "Ethernet Card 0",
"startmode" => "boot",
"dhclient_set_hostname" => "yes",
"lladdr" => "02:0b:0c:0d:0e:02",
Expand Down Expand Up @@ -88,6 +89,7 @@
it "assign properly all values in profile" do
eth0_config = subject.config.by_name("eth0")
expect(eth0_config.startmode.name).to eq("auto")
expect(eth0_config.description).to eq("Ethernet Card 0")
expect(eth0_config.startmode.alias_name).to eq("boot")
expect(eth0_config.bootproto).to eq Y2Network::BootProtocol.from_name("dhcp")
expect(eth0_config.ip_aliases.size).to eq 3
Expand Down
11 changes: 11 additions & 0 deletions test/y2network/autoinst_profile/interface_section_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,17 @@
end
end

context "when the device and name are given" do
let(:descr) { "Virtual Interface Card 4" }

it "sets the device as the name and the name as the description" do
hash["name"] = descr
section = described_class.new_from_hashes(hash)
expect(section.name).to eq("eth0")
expect(section.description). to eq(descr)
end
end

context "when bridge_forwarddelay and bridge_forward_delay are both set" do
let(:hash) do
{
Expand Down

0 comments on commit 2fb2617

Please sign in to comment.