Skip to content

Commit

Permalink
Merge b917a17 into 36838fe
Browse files Browse the repository at this point in the history
  • Loading branch information
imobachgs committed Mar 3, 2021
2 parents 36838fe + b917a17 commit 9629532
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 6 deletions.
7 changes: 7 additions & 0 deletions package/yast2-network.changes
@@ -1,3 +1,10 @@
-------------------------------------------------------------------
Tue Mar 2 11:48:59 UTC 2021 - Imobach Gonzalez Sosa <igonzalezsosa@suse.com>

- Support both 'bridge_forwarddelay' and 'bridge_forward_delay'.
The latter takes precedence (bsc#1180944).
- 4.3.51

-------------------------------------------------------------------
Fri Feb 26 06:41:17 UTC 2021 - Imobach Gonzalez Sosa <igonzalezsosa@suse.com>

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


Name: yast2-network
Version: 4.3.50
Version: 4.3.51
Release: 0
Summary: YaST2 - Network Configuration
License: GPL-2.0-only
Expand Down
10 changes: 6 additions & 4 deletions src/autoyast-rnc/networking.rnc
Expand Up @@ -219,10 +219,12 @@ wireless_wpa_psk = element wireless_wpa_psk { STRING }
# Bridge
#
bridge_settings = (
element bridge { STRING_ATTR, ("yes" | "no") }? &
element bridge_ports { STRING }? &
element bridge_stp { STRING_ATTR, ("on" | "off") }? &
element bridge_forwarddelay { STRING }?
element bridge { STRING_ATTR, ("yes" | "no") }? &
element bridge_ports { STRING }? &
element bridge_stp { STRING_ATTR, ("on" | "off") }? &
element bridge_forward_delay { STRING }? &
# backward compatibility (bsc#1180944)
element bridge_forwarddelay { STRING }?
)

#
Expand Down
20 changes: 19 additions & 1 deletion src/lib/y2network/autoinst_profile/interface_section.rb
Expand Up @@ -278,7 +278,8 @@ def initialize(*_args)

# Overwrite base method to load also nested aliases
def init_from_hashes(hash)
super
hash = rename_key(hash, "bridge_forwarddelay", "bridge_forward_delay")
super(hash)

self.aliases = hash["aliases"] if hash["aliases"]
end
Expand Down Expand Up @@ -418,6 +419,23 @@ def init_from_wireless(config)
# peap version not supported yet
# on other hand ap scan mode is not in autoyast
end

# Renames a key from the hash
#
# It returns a new hash with the key {old_name} renamed to {new_name}. The rename will
# not happen if the {to} key already exists.
#
# @param hash [Hash]
# @param old_name [String] Original key name
# @param new_name [String] New key name
# @return [Hash]
def rename_key(hash, old_name, new_name)
return hash if hash[new_name] || hash[old_name].nil?

new_hash = hash.clone
new_hash[new_name] = new_hash.delete(old_name)
new_hash
end
end
end
end
31 changes: 31 additions & 0 deletions test/y2network/autoinst_profile/interface_section_test.rb
Expand Up @@ -89,6 +89,37 @@
section = described_class.new_from_hashes(hash, parent)
expect(section.parent).to eq(parent)
end

context "when bridge_forwarddelay is set" do
let(:hash) do
{
"bootproto" => "dhcp4",
"device" => "br0",
"bridge_forwarddelay" => "4"
}
end

it "sets bridge_forward_delay to the given value" do
section = described_class.new_from_hashes(hash)
expect(section.bridge_forward_delay).to eq("4")
end
end

context "when bridge_forwarddelay and bridge_forward_delay are both set" do
let(:hash) do
{
"bootproto" => "dhcp4",
"device" => "br0",
"bridge_forwarddelay" => "4",
"bridge_forward_delay" => "5"
}
end

it "bridge_forward_delay takes precedence" do
section = described_class.new_from_hashes(hash)
expect(section.bridge_forward_delay).to eq("5")
end
end
end

describe "#to_hashes" do
Expand Down

0 comments on commit 9629532

Please sign in to comment.