Skip to content

Commit

Permalink
Removed slaves from less visible parts of the code
Browse files Browse the repository at this point in the history
  • Loading branch information
mchf committed Jan 26, 2022
1 parent 5f697d0 commit ea35a08
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
10 changes: 5 additions & 5 deletions src/lib/y2network/autoinst_profile/interface_section.rb
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ def init_from_config(config)
@bridge_forward_delay = config.forward_delay.to_s
when ConnectionConfig::Bonding
@bonding_module_opts = config.options
config.slaves.each_with_index do |slave, index|
config.ports.each_with_index do |slave, index|
public_send(:"bonding_slave#{index}=", slave)
end
when ConnectionConfig::Wireless
Expand Down Expand Up @@ -358,14 +358,14 @@ def wireless_keys
# Helper to get devices in the bonding as array
# @return [Array<String>]
def bonding_slaves
slaves = []
ports = []

(0..9).each do |i|
slave = public_send(:"bonding_slave#{i}")
slaves << slave unless slave.empty?
port = public_send(:"bonding_slave#{i}")
ports << port unless port.empty?
end

slaves
ports
end

# Returns the collection name
Expand Down
4 changes: 2 additions & 2 deletions src/lib/y2network/widgets/bond_slave.rb
Original file line number Diff line number Diff line change
Expand Up @@ -220,8 +220,8 @@ def repeated_physical_port_ids(slaves)
# mapping to an array of device names
# @return [Boolean] true if continue with duplicates, otherwise false
def continue_with_duplicates?(physical_ports)
message = physical_ports.map do |port, slaves|
wrap_text("PhysicalPortID (#{port}): #{slaves.join(", ")}")
message = physical_ports.map do |port, port_names|
wrap_text("PhysicalPortID (#{port}): #{port_names.join(", ")}")
end.join("\n")

Yast::Popup.YesNoHeadline(
Expand Down
14 changes: 7 additions & 7 deletions src/lib/y2network/widgets/slave_items.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,21 +31,21 @@ module SlaveItems
# Builds content for port configuration dialog (used e.g. when configuring
# devices included in a bond)
#
# @param [Array<String>] slaves list of device names
# @param [Array<String>] add_ifaces list of device names
# @param [Array<String>] included_ifaces list of device names already included in
# a main device (bond, bridge, ...)
# @param [ConnectionConfig] config where port devices live
def slave_items_from(slaves, included_ifaces, config)
raise ArgumentError, "slaves cannot be nil" if slaves.nil?
def slave_items_from(add_ifaces, included_ifaces, config)
raise ArgumentError, "list of devices for adding cannot be nil" if add_ifaces.nil?
raise ArgumentError, "some interfaces must be selected" if included_ifaces.nil?
raise ArgumentError, "slaves cannot be empty" if slaves.empty? && !included_ifaces.empty?
raise ArgumentError, "list of devices cannot be empty" if add_ifaces.empty? && !included_ifaces.empty?

textdomain "network"

log.debug "creating list of slaves from #{slaves.inspect}"
log.debug "creating list of devices to be added from #{add_ifaces.inspect}"

slaves.each_with_object([]) do |slave, result|
interface = config.interfaces.by_name(slave)
add_ifaces.each_with_object([]) do |add_iface, result|
interface = config.interfaces.by_name(add_iface)

next unless interface

Expand Down

0 comments on commit ea35a08

Please sign in to comment.