Skip to content

Commit

Permalink
Merge pull request #787 from yast/settings_moved_poc
Browse files Browse the repository at this point in the history
exterimental move of settings that does not work
  • Loading branch information
jreidinger committed Apr 17, 2019
2 parents faea5cd + bbc8711 commit 0f42d0b
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 28 deletions.
11 changes: 11 additions & 0 deletions src/include/network/lan/address.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1167,6 +1167,12 @@ def AddressDialog
LanItems.vlan_id = Builtins.tostring(
Ops.get_integer(@settings, "VLAN_ID", 0)
)
elsif LanItems.type == "bond"
new_slaves = @settings.fetch("SLAVES", []).select { |s| !LanItems.bond_slaves.include? s }
LanItems.bond_slaves = @settings["SLAVES"]
LanItems.bond_option = @settings["BONDOPTION"]
Lan.autoconf_slaves = (Lan.autoconf_slaves + new_slaves).uniq.sort
log.info "bond settings #{LanItems.bond_slaves}"
elsif Builtins.contains(["tun", "tap"], LanItems.type)
LanItems.tunnel_set_owner = Ops.get_string(
@settings,
Expand Down Expand Up @@ -1210,6 +1216,9 @@ def initialize_address_settings
if LanItems.type == "vlan"
@settings["ETHERDEVICE"] = LanItems.vlan_etherdevice
@settings["VLAN_ID"] = LanItems.vlan_id.to_i
elsif LanItems.type == "bond"
@settings["BONDOPTION"] = Yast::LanItems.bond_option
@settings["SLAVES"] = Yast::LanItems.bond_slaves || []
end

if ["tun", "tap"].include?(LanItems.type)
Expand All @@ -1222,6 +1231,8 @@ def initialize_address_settings

# #65524
@settings["BOOTPROTO"] = "static" if LanItems.operation == :add && @force_static_ip

log.info "settings after init #{@settings.inspect}"
end

# Performs hostname update
Expand Down
2 changes: 0 additions & 2 deletions src/lib/y2network/widgets/bond_options.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,11 @@ def opt
end

def init
@settings["BONDOPTION"] = Yast::LanItems.bond_option # TODO: not here
self.value = @settings["BONDOPTION"]
end

def store
@settings["BONDOPTION"] = value
Yast::LanItems.bond_option = @settings["BONDOPTION"] # TODO: not here
end
end
end
Expand Down
34 changes: 8 additions & 26 deletions src/lib/y2network/widgets/bond_slave.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,9 @@ def help

# Default function to init the value of slave devices box for bonding.
def init
# TODO: why? it should respect previous @settings, not?
@settings["SLAVES"] = Yast::LanItems.bond_slaves || []

items = slave_items_from(
Yast::LanItems.GetBondableInterfaces(Yast::LanItems.GetCurrentName),
Yast::LanItems.bond_slaves
@settings["SLAVES"]
)

# reorder the items
Expand All @@ -93,22 +90,7 @@ def init

# Default function to store the value of slave devices box.
def store
configured_slaves = @settings["SLAVES"] || []

selected_slaves = selected_items

@settings["SLAVES"] = selected_slaves

Yast::LanItems.bond_slaves = @settings["SLAVES"]

# create list of "unconfigured" slaves
new_slaves = @settings["SLAVES"].select do |slave|
!configured_slaves.include? slave
end

Yast::Lan.autoconf_slaves = (Yast::Lan.autoconf_slaves + new_slaves).uniq.sort

nil
@settings["SLAVES"] = selected_items
end

# Validates created bonding. Currently just prevent the user to create a
Expand All @@ -123,15 +105,15 @@ def validate

def value
# TODO: it is multiselection, so does it make sense?
Yast::UI.QueryWidget(:slave_bonds_items, :CurrentItem)
Yast::UI.QueryWidget(:bond_slaves_items, :CurrentItem)
end

def selected_items
Yast::UI.QueryWidget(:bond_slaves_items, :SelectedItems) || []
end

def ui_items
Yast::UI.QueryWidget(:slave_bonds_items, :Items) || []
Yast::UI.QueryWidget(:bond_slaves_items, :Items) || []
end

def value_index
Expand All @@ -140,11 +122,11 @@ def value_index

def enable_slave_buttons
if value_index
Yast::UI.ChangeWidget(:slave_bonds_up, :Enabled, value_index > 0)
Yast::UI.ChangeWidget(:slave_bonds_down, :Enabled, value_index < ui_items.size - 1)
Yast::UI.ChangeWidget(:bond_slaves_up, :Enabled, value_index > 0)
Yast::UI.ChangeWidget(:bond_slaves_down, :Enabled, value_index < ui_items.size - 1)
else
Yast::UI.ChangeWidget(:slave_bonds_up, :Enabled, false)
Yast::UI.ChangeWidget(:slave_bonds_down, :Enabled, false)
Yast::UI.ChangeWidget(:bond_slaves_up, :Enabled, false)
Yast::UI.ChangeWidget(:bond_slaves_down, :Enabled, false)
end
end

Expand Down

0 comments on commit 0f42d0b

Please sign in to comment.