Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix connection_config equality comparison #1119

Merged
merged 3 commits into from
Nov 20, 2020

Conversation

teclator
Copy link
Contributor

@teclator teclator commented Nov 20, 2020

Problem

Bond configuration is not modified after changing the bond options. For checking changes between configuration we created an alias eql? of the "==" method, but the sub-classes need to define it to in order to call its overridden "==" method.

Solution

Fix the detection of network config changes defining the alias_method :eql? :== in each of the connection config sub-classes that overrides the == method

Manual test without the fix
irb(main):003:0> Yast::Lan.Read(:cache)
=> true
irb(main):004:0> bond0 = Yast::Lan.yast_config.connections.by_name("bond0")
=> #<Y2Network::ConnectionConfig::Bonding:0x00005622102a6498 @id=1, @ip_aliases=[], @bootproto=#<Y2Network::BootProtocol:0x00005622102a63a8 @name="dhcp">, @ip=#<Y2Network::ConnectionConfig::IPConfig:0x00005622102a6308 @address=#<Y2Network::IPAddress:0x00005622102a6290 @address=#<IPAddr: IPv4:0.0.0.0/255.255.255.255>, @prefix=nil>, @id="", @label=nil, @remote_address=nil, @broadcast=nil>, @startmode=#<Y2Network::Startmodes::Auto:0x00005622102a6060 @my_textdomain=["network"], @name="auto">, @description=nil, @ethtool_options=nil, @firewall_zone=nil, @slaves=["eth1", "eth0"], @options="mode=active-backup miimon=300", @interface="bond0", @name="bond0", @lladdress=nil, @hostname=nil, @mtu=nil>
irb(main):005:0> system_bond0 = Yast::Lan.system_config.connections.by_name("bond0")
=> #<Y2Network::ConnectionConfig::Bonding:0x00005622101ae360 @id=1, @ip_aliases=[], @bootproto=#<Y2Network::BootProtocol:0x000056220f826d60 @name="dhcp">, @ip=#<Y2Network::ConnectionConfig::IPConfig:0x00005622101b50c0 @address=#<Y2Network::IPAddress:0x00005622101b5138 @address=#<IPAddr: IPv4:0.0.0.0/255.255.255.255>, @prefix=nil>, @id="", @label=nil, @remote_address=nil, @broadcast=nil>, @startmode=#<Y2Network::Startmodes::Auto:0x00005622101b4ee0 @my_textdomain=["network"], @name="auto">, @description=nil, @ethtool_options=nil, @firewall_zone=nil, @slaves=["eth1", "eth0"], @options="mode=active-backup miimon=300", @interface="bond0", @name="bond0", @lladdress=nil, @hostname=nil, @mtu=nil>
irb(main):006:0> bond0.eql?(system_bond0)
=> true
irb(main):007:0> bond0.options
=> "mode=active-backup miimon=300"
irb(main):008:0> bond0.options = "mode=active-backup miimon=100"
=> "mode=active-backup miimon=100"
irb(main):009:0> bond0.eql?(system_bond0)
=> true
irb(main):010:0> bond0 == system_bond0
=> false
irb(main):011:0> Yast::Lan.yast_config == Yast::Lan.system_config
=> true
Manual test with the fix
irb(main):004:0> bond0 = Yast::Lan.yast_config.connections.by_name("bond0")
=> #<Y2Network::ConnectionConfig::Bonding:0x000056477483cb58 @id=1, @ip_aliases=[], @bootproto=#<Y2Network::BootProtocol:0x000056477483ca68 @name="dhcp">, @ip=#<Y2Network::ConnectionConfig::IPConfig:0x000056477483c9c8 @address=#<Y2Network::IPAddress:0x000056477483c950 @address=#<IPAddr: IPv4:0.0.0.0/255.255.255.255>, @prefix=nil>, @id="", @label=nil, @remote_address=nil, @broadcast=nil>, @startmode=#<Y2Network::Startmodes::Auto:0x000056477483c720 @my_textdomain=["network"], @name="auto">, @description=nil, @ethtool_options=nil, @firewall_zone=nil, @slaves=["eth1", "eth0"], @options="mode=active-backup miimon=300", @interface="bond0", @name="bond0", @lladdress=nil, @hostname=nil, @mtu=nil>
irb(main):005:0> system_bond0 = Yast::Lan.system_config.connections.by_name("bond0")
=> #<Y2Network::ConnectionConfig::Bonding:0x00005647746150c8 @id=1, @ip_aliases=[], @bootproto=#<Y2Network::BootProtocol:0x0000564773ffae40 @name="dhcp">, @ip=#<Y2Network::ConnectionConfig::IPConfig:0x000056477461d098 @address=#<Y2Network::IPAddress:0x000056477461d110 @address=#<IPAddr: IPv4:0.0.0.0/255.255.255.255>, @prefix=nil>, @id="", @label=nil, @remote_address=nil, @broadcast=nil>, @startmode=#<Y2Network::Startmodes::Auto:0x000056477461ceb8 @my_textdomain=["network"], @name="auto">, @description=nil, @ethtool_options=nil, @firewall_zone=nil, @slaves=["eth1", "eth0"], @options="mode=active-backup miimon=300", @interface="bond0", @name="bond0", @lladdress=nil, @hostname=nil, @mtu=nil>
irb(main):006:0> bond0.eql?(system_bond0)
=> true
irb(main):007:0> bond0.options
=> "mode=active-backup miimon=300"
irb(main):008:0> bond0.options = "mode=active-backup miimon=100"
=> "mode=active-backup miimon=100"
irb(main):009:0> bond0.eql?(system_bond0)
=> false
irb(main):010:0> bond0 == system_bond0
=> false
irb(main):011:0> Yast::Lan.yast_config == Yast::Lan.system_config
=> false

@teclator teclator force-pushed the fix_connection_config_comparison branch from 6109285 to 7403165 Compare November 20, 2020 07:19
@teclator teclator merged commit 9947b68 into SLE-15-SP2 Nov 20, 2020
@teclator teclator deleted the fix_connection_config_comparison branch November 20, 2020 08:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants