Skip to content

Commit

Permalink
Updates from code review
Browse files Browse the repository at this point in the history
  • Loading branch information
imobachgs committed Apr 1, 2019
1 parent 422df58 commit 7d12a24
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 28 deletions.
6 changes: 4 additions & 2 deletions src/lib/y2network/config.rb
Expand Up @@ -43,7 +43,8 @@ class Config

class << self
# @param source [Symbol] Source to read the configuration from
# @param opts [Hash] Reader options
# @param opts [Hash] Reader options. Check readers documentation to find out
# supported options.
def from(source, opts = {})
reader = ConfigReader.for(source, opts)
reader.config
Expand Down Expand Up @@ -79,7 +80,8 @@ def copy
#
# @return [Boolean] true if both configurations are equal; false otherwise
def ==(other)
source == other.source && (interfaces - other.interfaces).empty? &&
source == other.source &&
((interfaces - other.interfaces) | (other.interfaces - interfaces)).empty? &&
routing == other.routing
end

Expand Down
2 changes: 1 addition & 1 deletion src/lib/y2network/config_reader.rb
Expand Up @@ -31,7 +31,7 @@ def self.for(source, opts = {})
require "y2network/config_reader/#{source}"
name = source.to_s.split("_").map(&:capitalize).join
klass = const_get(name)
klass.new
klass.new(opts)
end
end
end
5 changes: 4 additions & 1 deletion src/lib/y2network/interface.rb
Expand Up @@ -30,8 +30,11 @@ def initialize(name)
end

# Determines whether two interfaces are equal
#
# @param other [Interface,:any] Interface to compare with
# @return [Boolean]
def ==(other)
return false unless other.respond_to?(:name)
return false if other == :any
name == other.name
end

Expand Down
2 changes: 2 additions & 0 deletions src/lib/y2network/presenters/routing_summary.rb
Expand Up @@ -34,6 +34,8 @@ def initialize(config)

# Returns the summary of network configuration settings in text form
#
# @todo Implement the real summary.
#
# @param mode [Symbol] Summary mode (:summary or :proposal)
# @return [String]
def text(mode:)
Expand Down
2 changes: 1 addition & 1 deletion src/lib/y2network/routing.rb
Expand Up @@ -45,7 +45,7 @@ def routes
# @return [Boolean]
def ==(other)
forward_ipv4 == other.forward_ipv4 && forward_ipv6 == other.forward_ipv6 &&
(tables - other.tables).empty?
((tables - other.tables) | (other.tables - tables)).empty?
end

alias_method :eql?, :==
Expand Down
44 changes: 22 additions & 22 deletions src/modules/Lan.rb
Expand Up @@ -110,7 +110,7 @@ def main
def Modified
return true if LanItems.GetModified
return true if DNS.modified
return true unless running_config == yast_config
return true unless system_config == yast_config
return true if NetworkConfig.Modified
return true if NetworkService.Modified
return true if Host.GetModified
Expand Down Expand Up @@ -265,9 +265,9 @@ def Read(cache)
return true
end

running_config = Y2Network::Config.from(:sysconfig)
add_config(:system, running_config)
add_config(:yast, running_config.copy)
system_config = Y2Network::Config.from(:sysconfig)
add_config(:system, system_config)
add_config(:yast, system_config.copy)

# Read dialog caption
caption = _("Initializing Network Configuration")
Expand Down Expand Up @@ -989,6 +989,24 @@ def clear_configs
configs.clear
end

# Returns the system configuration
#
# Just a convenience method.
#
# @return [Y2Network::Config]
def system_config
find_config(:system)
end

# Returns YaST configuration
#
# Just a convenience method.
#
# @return [Y2Network::Config]
def yast_config
find_config(:yast)
end

publish variable: :ipv6, type: "boolean"
publish variable: :AbortFunction, type: "block <boolean>"
publish variable: :bond_autoconf_slaves, type: "list <string>"
Expand Down Expand Up @@ -1121,24 +1139,6 @@ def routing_summary(mode)
presenter.text(mode: mode.to_sym)
end

# Returns the system configuration
#
# Just a convenience method.
#
# @return [Y2Network::Config]
def running_config
find_config(:system)
end

# Returns YaST configuration
#
# Just a convenience method.
#
# @return [Y2Network::Config]
def yast_config
find_config(:yast)
end

def firewalld
Y2Firewall::Firewalld.instance
end
Expand Down
2 changes: 1 addition & 1 deletion test/lan_test.rb
Expand Up @@ -110,7 +110,7 @@
end
end

describe "#Import" do
xdescribe "#Import" do
let(:ay_profile) do
{
"devices" => {
Expand Down

0 comments on commit 7d12a24

Please sign in to comment.