Skip to content

Commit

Permalink
Merge pull request #240 from mchf/bnc886434-speed-up-autoconfig
Browse files Browse the repository at this point in the history
Accelerated up autoconfig
  • Loading branch information
mchf committed Sep 3, 2014
2 parents cbec7cc + 0dc09b3 commit 0abb334
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 8 deletions.
7 changes: 7 additions & 0 deletions package/yast2-network.changes
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
-------------------------------------------------------------------
Mon Sep 1 19:16:58 UTC 2014 - mfilka@suse.com

- bnc#886434
- accelerated autoconfiguration at the beginning of installer
- 3.1.91

-------------------------------------------------------------------
Tue Sep 2 08:45:30 UTC 2014 - ancor@suse.com

Expand Down
2 changes: 1 addition & 1 deletion package/yast2-network.spec
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@


Name: yast2-network
Version: 3.1.90
Version: 3.1.91
Release: 0

BuildRoot: %{_tmppath}/%{name}-%{version}-build
Expand Down
26 changes: 19 additions & 7 deletions src/lib/network/network_autoconfiguration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,6 @@ def configure_dhcp
# TODO time consuming, some progress would be nice
dhcp_cards.each { |d| setup_dhcp(d) }

# FIXME this can be really slow as it calls wicked one-by-one.
# So for n devices connected to a network but without dhcp
# it takes n * <dhcp lease wait timeout>.
activate_changes(dhcp_cards)

# drop devices without dhcp lease
Expand Down Expand Up @@ -145,8 +142,15 @@ def setup_dhcp card
LanItems.Commit
end

def reload_config(card)
SCR.Execute(BASH_PATH, "wicked ifreload '#{card}'") == 0
# Reloads configuration for each device named in devs
#
# @devs [Array] list of device names
# @return true if configuration was reloaded
def reload_config(devs)
raise ArgumentError if devs.nil?
return true if devs.empty?

SCR.Execute(BASH_PATH, "wicked ifreload #{devs.join(" ")}") == 0
end

def delete_config(devname)
Expand All @@ -157,13 +161,17 @@ def write_configuration
NetworkInterfaces.Write("")
end

# Writes and activates changes in devices configurations
#
# @devnames [Array] list of device names
# @return true when changes were successfully applied
def activate_changes(devnames)
return false if !write_configuration

# workaround for gh#yast/yast-core#74 (https://github.com/yast/yast-core/issues/74)
NetworkInterfaces.CleanCacheRead()

devnames.map { |d| reload_config(d) }
reload_config(devnames)
end

def configured?(devname)
Expand Down Expand Up @@ -194,7 +202,11 @@ def target_servers
# Check if given device can reach some of reference servers
def set_default_route_flag_if_wan_dev?(devname)
set_default_route_flag(devname, "yes")
activate_changes([devname])

if !activate_changes([devname])
log.warn("Cannot reach reference server via #{devname}")
return false
end

reached = target_servers.any? do |server|
ping_cmd = "ping -I #{devname} -c 3 #{server}"
Expand Down

0 comments on commit 0abb334

Please sign in to comment.