Skip to content

Commit

Permalink
Merge pull request #858 from yast/fixes
Browse files Browse the repository at this point in the history
Fixes
  • Loading branch information
jreidinger committed Jul 2, 2019
2 parents 8964ac5 + 282b2a1 commit ea14a45
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 24 deletions.
5 changes: 1 addition & 4 deletions src/include/network/lan/cmdline.rb
Original file line number Diff line number Diff line change
Expand Up @@ -238,10 +238,7 @@ def EditHandler(options)
LanItems.current = getItem(options, config)
builder = Y2Network::InterfaceConfigBuilder.for(LanItems.GetCurrentType())
builder.name = LanItems.GetCurrentName()
if LanItems.IsCurrentConfigured
builder.load_sysconfig(LanItems.GetCurrentMap())
builder.load_s390_config(LanItems.s390_ReadQethConfig(builder.name))
end

LanItems.SetItem(builder: builder)

if Builtins.size(Ops.get_string(LanItems.getCurrentItem, "ifcfg", "")) == 0
Expand Down
10 changes: 2 additions & 8 deletions src/include/network/lan/complex.rb
Original file line number Diff line number Diff line change
Expand Up @@ -311,10 +311,6 @@ def UpdateSlaves
if LanItems.FindAndSelect(dev)
builder = Y2Network::InterfaceConfigBuilder.for(LanItems.GetCurrentType())
builder.name = LanItems.GetCurrentName()
if LanItems.IsCurrentConfigured
builder.load_sysconfig(LanItems.GetCurrentMap())
builder.load_s390_config(LanItems.s390_ReadQethConfig(builder.name))
end
LanItems.SetItem(builder: builder)
else
dev_index = LanItems.FindDeviceIndex(dev)
Expand All @@ -325,9 +321,9 @@ def UpdateSlaves
LanItems.current = dev_index

AddInterface()
builder = Y2Network::InterfaceConfigBuilder.for(LanItems.GetDeviceType(current))
builder.name = LanItems.GetCurrentName
end
builder = Y2Network::InterfaceConfigBuilder.for(LanItems.GetDeviceType(current))
builder.name = LanItems.GetCurrentName
# clear defaults, some defaults are invalid for slaves and can cause troubles
# in related sysconfig scripts or makes no sence for slaves (e.g. ip configuration).
builder["NETMASK"] = ""
Expand Down Expand Up @@ -409,8 +405,6 @@ def handleOverview(_key, event)
builder = Y2Network::InterfaceConfigBuilder.for(LanItems.GetCurrentType())
builder.name = LanItems.GetCurrentName()
if LanItems.IsCurrentConfigured
builder.load_sysconfig(LanItems.GetCurrentMap())
builder.load_s390_config(LanItems.s390_ReadQethConfig(builder.name))
LanItems.SetItem(builder: builder)

if LanItems.startmode == "managed"
Expand Down
29 changes: 17 additions & 12 deletions src/lib/y2network/interface_config_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -167,24 +167,28 @@ def udev_name
#
# @return [Hash<String, String>] where key is sysconfig option and value is the option's value
def device_sysconfig
# with naive implementation of filtering options by type
config = @config

# initalize options which has to be known and was not set by the user explicitly
init_mandatory_options

# with naive implementation of filtering options by type
config = @config.dup

# filter out options which are not needed
config = config.delete_if { |k, _| k =~ /WIRELESS.*/ } if type != "wlan"
config = config.delete_if { |k, _| k =~ /BONDING.*/ } if type != "bond"
config = config.delete_if { |k, _| k =~ /BRIDGE.*/ } if type != "br"
config = config.delete_if { |k, _| k =~ /TUNNEL.*/ } if !["tun", "tap"].include?(type)
config = config.delete_if { |k, _| k == "VLAN_ID" || k == "ETHERDEVICE" } if type != "vlan"
config = config.delete_if { |k, _| k == "IPOIB_MODE" } if type != "ib"
config = config.delete_if { |k, _| k == "INTERFACE" } if type != "dummy"
config = config.delete_if { |k, _| k == "IFPLUGD_PRIORITY" } if config["STARTMODE"] != "ifplugd"
config.delete_if { |k, _| k =~ /WIRELESS.*/ } if type != "wlan"
config.delete_if { |k, _| k =~ /BONDING.*/ } if type != "bond"
config.delete_if { |k, _| k =~ /BRIDGE.*/ } if type != "br"
config.delete_if { |k, _| k =~ /TUNNEL.*/ } if !["tun", "tap"].include?(type)
config.delete_if { |k, _| k == "VLAN_ID" || k == "ETHERDEVICE" } if type != "vlan"
config.delete_if { |k, _| k == "IPOIB_MODE" } if type != "ib"
config.delete_if { |k, _| k == "INTERFACE" } if type != "dummy"
config.delete_if { |k, _| k == "IFPLUGD_PRIORITY" } if config["STARTMODE"] != "ifplugd"

# all keys / values has to be strings, agent won't write it otherwise
config.map { |k, v| [k, v.to_s] }.to_h
# JR: this does not work for aliases, BON_OPTIONS and SLAVES which are later processed
# so comment it for now and if works without it, just delete it.
# FIXME: test and remove
# config.map { |k, v| [k, v.to_s] }.to_h
config
end

# Updates itself according to the given sysconfig configuration
Expand Down Expand Up @@ -300,6 +304,7 @@ def save_aliases
end
log.info "setting new aliases #{lan_items_format.inspect}"
aliases_to_delete = Yast::LanItems.aliases.dup # #48191
Yast::NetworkInterfaces.Current["_aliases"] = lan_items_format
Yast::LanItems.aliases = lan_items_format
aliases_to_delete.each_pair do |a, v|
Yast::NetworkInterfaces.DeleteAlias(Yast::NetworkInterfaces.Name, a) if v
Expand Down

0 comments on commit ea14a45

Please sign in to comment.