Hello community,
here is the log from the commit of package yast2-network for openSUSE:Factory checked in at 2014-04-26 11:45:19
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/yast2-network (Old)
and /work/SRC/openSUSE:Factory/.yast2-network.new (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "yast2-network"
Changes:
--------
--- /work/SRC/openSUSE:Factory/yast2-network/yast2-network.changes 2014-04-13 13:13:10.000000000 +0200
+++ /work/SRC/openSUSE:Factory/.yast2-network.new/yast2-network.changes 2014-04-26 11:45:24.000000000 +0200
@@ -1,0 +2,30 @@
+Fri Apr 25 07:15:25 UTC 2014 - mfilka@suse.com
+
+- bnc#872319
+ - accelerated dhcp automatic configuration which is done during
+ initial phase of installer
+- 3.1.50
+
+-------------------------------------------------------------------
+Thu Apr 17 11:44:20 UTC 2014 - mfilka@suse.com
+
+- fixed terminology confusion. "Alias name" turned into "IPv4
+ Address Label". "Alias name" is obsolete since kernel 2.0.0
+- 3.1.49
+
+-------------------------------------------------------------------
+Thu Apr 17 08:18:58 UTC 2014 - mfilka@suse.com
+
+- bnc#870406
+ - fixed assigning device name in ifcfg created during installation
+- 3.1.48
+
+-------------------------------------------------------------------
+Mon Apr 14 16:46:02 UTC 2014 - mfilka@suse.com
+
+- bnc#873149
+ - manual network configuration dialog changed to Next / Back
+ dialog
+- 3.1.47
+
+-------------------------------------------------------------------
Old:
----
yast2-network-3.1.46.tar.bz2
New:
----
yast2-network-3.1.50.tar.bz2
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ yast2-network.spec ++++++
--- /var/tmp/diff_new_pack.6ht7lQ/_old 2014-04-26 11:45:25.000000000 +0200
+++ /var/tmp/diff_new_pack.6ht7lQ/_new 2014-04-26 11:45:25.000000000 +0200
@@ -17,7 +17,7 @@
Name: yast2-network
-Version: 3.1.46
+Version: 3.1.50
Release: 0
BuildRoot: %{_tmppath}/%{name}-%{version}-build
++++++ yast2-network-3.1.46.tar.bz2 -> yast2-network-3.1.50.tar.bz2 ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-network-3.1.46/package/yast2-network.changes new/yast2-network-3.1.50/package/yast2-network.changes
--- old/yast2-network-3.1.46/package/yast2-network.changes 2014-04-07 11:32:47.000000000 +0200
+++ new/yast2-network-3.1.50/package/yast2-network.changes 2014-04-25 14:38:44.000000000 +0200
@@ -1,10 +1,40 @@
-------------------------------------------------------------------
+Fri Apr 25 07:15:25 UTC 2014 - mfilka@suse.com
+
+- bnc#872319
+ - accelerated dhcp automatic configuration which is done during
+ initial phase of installer
+- 3.1.50
+
+-------------------------------------------------------------------
+Thu Apr 17 11:44:20 UTC 2014 - mfilka@suse.com
+
+- fixed terminology confusion. "Alias name" turned into "IPv4
+ Address Label". "Alias name" is obsolete since kernel 2.0.0
+- 3.1.49
+
+-------------------------------------------------------------------
+Thu Apr 17 08:18:58 UTC 2014 - mfilka@suse.com
+
+- bnc#870406
+ - fixed assigning device name in ifcfg created during installation
+- 3.1.48
+
+-------------------------------------------------------------------
+Mon Apr 14 16:46:02 UTC 2014 - mfilka@suse.com
+
+- bnc#873149
+ - manual network configuration dialog changed to Next / Back
+ dialog
+- 3.1.47
+
+-------------------------------------------------------------------
Fri Apr 4 13:12:27 UTC 2014 - mfilka@suse.com
- bnc#868187
- implemented heuristics for setting DHCLIENT_SET_DEFAULT_ROUTE
during autoconfiguration in installation
--3.1.46
+- 3.1.46
-------------------------------------------------------------------
Fri Apr 4 12:41:36 UTC 2014 - jreidinger@suse.com
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-network-3.1.46/package/yast2-network.spec new/yast2-network-3.1.50/package/yast2-network.spec
--- old/yast2-network-3.1.46/package/yast2-network.spec 2014-04-07 11:32:47.000000000 +0200
+++ new/yast2-network-3.1.50/package/yast2-network.spec 2014-04-25 14:38:44.000000000 +0200
@@ -17,7 +17,7 @@
Name: yast2-network
-Version: 3.1.46
+Version: 3.1.50
Release: 0
BuildRoot: %{_tmppath}/%{name}-%{version}-build
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-network-3.1.46/src/Makefile.am new/yast2-network-3.1.50/src/Makefile.am
--- old/yast2-network-3.1.46/src/Makefile.am 2014-04-07 11:32:47.000000000 +0200
+++ new/yast2-network-3.1.50/src/Makefile.am 2014-04-25 14:38:44.000000000 +0200
@@ -111,7 +111,8 @@
ylib_DATA = \
lib/network/edit_nic_name.rb \
lib/network/confirm_virt_proposal.rb \
- lib/network/install_inf_convertor.rb
+ lib/network/install_inf_convertor.rb \
+ lib/network/network_autoconfiguration.rb
EXTRA_DIST = \
$(module_DATA) \
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-network-3.1.46/src/clients/inst_setup_dhcp.rb new/yast2-network-3.1.50/src/clients/inst_setup_dhcp.rb
--- old/yast2-network-3.1.46/src/clients/inst_setup_dhcp.rb 2014-04-07 11:32:47.000000000 +0200
+++ new/yast2-network-3.1.50/src/clients/inst_setup_dhcp.rb 2014-04-25 14:38:44.000000000 +0200
@@ -1,154 +1,6 @@
+require "yast"
+require "network/network_autoconfiguration"
-#enclose client into own namespace to prevent messing global namespace
-module SetupDHCPClient
-
- include Yast
-
- Yast.import "LanItems"
- Yast.import "NetworkInterfaces"
-
- BASH_PATH = Path.new(".target.bash")
-
- def self.network_cards
- LanItems.Read
- LanItems.GetNetcardNames
- end
-
- # Makes DHCP setup persistent
- #
- # instsys currently uses wicked as network services "manager" (including
- # dhcp client). wicked is currently able to configure a card for dhcp leases
- # only via loading config from file. All other ways are workarounds and
- # needn't to work when wickedd* services are already running
- def self.setup_dhcp card
- index = LanItems.FindDeviceIndex(card)
-
- if index == -1
- raise "Failed to save configuration for device #{card}"
- end
-
- LanItems.current = index
- LanItems.SetItem
-
- #tricky part if ifcfg is not set
- # yes, this code smell and show bad API of LanItems
- if !LanItems.IsCurrentConfigured
- NetworkInterfaces.Add
- current = LanItems.Items[LanItems.current]
- current["ifcfg"] = card
- end
-
- LanItems.bootproto = "dhcp"
- LanItems.startmode = "auto"
-
- LanItems.Commit
- end
-
- def self.reload_config(card)
- SCR.Execute(BASH_PATH, "wicked ifreload '#{card}'") == 0
- end
-
- def self.delete_config(devname)
- LanItems.delete_dev(devname)
- end
-
- def self.write_configuration
- NetworkInterfaces.Write("")
- end
-
- def self.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) }
- end
-
- def self.configured?(devname)
- # TODO:
- # one day there should be LanItems.IsItemConfigured, but we currently
- # miss index -> devname translation. As this LanItems internal structure
- # will be subject of refactoring, we will use NetworkInterfaces directly.
- # It currently doesn't hurt as it currently writes configuration for both
- # wicked even sysconfig.
- NetworkInterfaces.Check(devname)
- end
-
- # Checks if given device is active
- #
- # active device <=> a device which is reported as "up" by wicked
- def self.active_config?(devname)
- wicked_query = "wicked ifstatus --brief #{devname} | grep 'up$'"
- SCR.Execute(BASH_PATH, wicked_query) == 0
- end
-
- # Returns list of servers used for internet reachability test
- #
- # Basicaly servers with product release notes should be used.
- def self.target_servers
- ["scc.suse.com"]
- end
-
- # Check if given device can reach some of reference servers
- def self.set_default_route_flag_if_wan_dev?(devname)
- set_default_route_flag(devname, "yes")
- activate_changes([devname])
-
- reached = target_servers.any? do |server|
- ping_cmd = "ping -I #{devname} -c 3 #{server}"
- SCR.Execute(BASH_PATH, ping_cmd) == 0
- end
-
- log.info("Release notes can be reached via #{devname}: #{reached}")
-
- if !reached
- set_default_route_flag(devname, "no")
- activate_changes([devname])
- end
-
- reached
- end
-
- # Sets sysconfig's DHCLIENT_SET_DEFAULT_ROUTE option for given device
- #
- # @param [String] devname name of device as seen by system (e.g. enp0s3)
- # @param [String] value "yes" or "no", as in sysconfig
- def self.set_default_route_flag(devname, value)
- item_id = LanItems.FindDeviceIndex(devname)
- LanItems.SetItemSysconfigOpt(item_id, "DHCLIENT_SET_DEFAULT_ROUTE", value)
- end
-
- include Logger
-
- dhcp_cards = network_cards.select { |c| !configured?(c) }
- log.info "Candidates for enabling DHCP: #{dhcp_cards}"
-
- # TODO time consuming, some progress would be nice
- dhcp_cards.each { |d| setup_dhcp(d) }
-
- activate_changes(dhcp_cards)
-
- # drop devices without dhcp lease
- inactive_devices = dhcp_cards.select { |c| ! active_config?(c) }
- log.info "Inactive devices: #{inactive_devices}"
-
- inactive_devices.each { |c| delete_config(c) }
-
- # setup route flag
- active_devices = dhcp_cards - inactive_devices
-
- if active_devices.size == 1
- # just one dhcp device, nothing to care of
- set_default_route_flag(active_devices.first, "yes")
- else
- # try to find just one dhcp aware device for allowing default route
- # if there is more than one dhcp devices enabled for setting default
- # route (DHCLIENT_SET_DEFAULT_ROUTE = "yes"). bnc#868187
- active_devices.find { |d| set_default_route_flag_if_wan_dev?(d) }
- end
-
- activate_changes(dhcp_cards)
-end
+Yast::NetworkAutoconfiguration.instance.configure_dhcp
:next
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-network-3.1.46/src/include/network/lan/address.rb new/yast2-network-3.1.50/src/include/network/lan/address.rb
--- old/yast2-network-3.1.46/src/include/network/lan/address.rb 2014-04-07 11:32:47.000000000 +0200
+++ new/yast2-network-3.1.50/src/include/network/lan/address.rb 2014-04-25 14:38:44.000000000 +0200
@@ -93,7 +93,7 @@
Opt(:notify),
Header(
# Table header label
- _("Alias Name"),
+ _("IPv4 Address Label"),
# Table header label
_("IP Address"),
# Table header label
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-network-3.1.46/src/include/network/lan/complex.rb new/yast2-network-3.1.50/src/include/network/lan/complex.rb
--- old/yast2-network-3.1.46/src/include/network/lan/complex.rb 2014-04-07 11:32:47.000000000 +0200
+++ new/yast2-network-3.1.50/src/include/network/lan/complex.rb 2014-04-25 14:38:44.000000000 +0200
@@ -635,6 +635,19 @@
ret
end
+ # Evaluates if user should be asked again according dialogs result value
+ #
+ # it is basically useful if user aborts dialog and he has done some
+ # changes already. Calling this function may results in confirmation
+ # popup.
+ def input_done?(ret)
+ if ret == :abort && LanItems.modified
+ return ReallyAbort()
+ else
+ return true
+ end
+ end
+
def MainDialog(init_tab)
caption = _("Network Settings")
widget_descr = {
@@ -660,47 +673,47 @@
:to => "map >"
)
)
+
help = CWM.MergeHelps(w)
contents = CWM.PrepareDialog(contents, w)
+ running_installer = Mode.installation || Mode.update
Wizard.SetContentsButtons(
caption,
contents,
help,
Label.BackButton,
- Label.OKButton
+ running_installer ? Label.NextButton : Label.OKButton
)
- Wizard.SetNextButton(:next, Label.OKButton)
- Wizard.SetAbortButton(:abort, Label.CancelButton)
- Wizard.HideBackButton
- ret = nil
- while true
- ret = CWM.Run(w, {})
- if ret == :abort
- next if LanItems.modified && !ReallyAbort()
- return ret
- end
- return ret
+ if running_installer
+ Wizard.SetAbortButton(:abort, Label.AbortButton)
+ else
+ Wizard.SetAbortButton(:abort, Label.CancelButton)
+ Wizard.HideBackButton
end
- nil
+ begin
+ ret = CWM.Run(w, {})
+ end while !input_done?(ret)
+
+ return ret
end
- end
private
- def overview_buttons
- ret = {}
+ def overview_buttons
+ ret = {}
- # User should be able to configure existing devices during installation.
- # This can be achieved via "Edit" button on automatically detected
- # devices. Advanced configuration should be postponed to installed system.
- # Therefor adding devices is not available during installation
- ret[:add] = Label.AddButton if !Mode.installation
- ret[:edit] = Label.EditButton
- ret[:delete] = Label.DeleteButton
+ # User should be able to configure existing devices during installation.
+ # This can be achieved via "Edit" button on automatically detected
+ # devices. Advanced configuration should be postponed to installed system.
+ # Therefor adding devices is not available during installation
+ ret[:add] = Label.AddButton if !Mode.installation
+ ret[:edit] = Label.EditButton
+ ret[:delete] = Label.DeleteButton
- ret
- end
+ ret
+ end
+ end
end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-network-3.1.46/src/include/network/lan/help.rb new/yast2-network-3.1.50/src/include/network/lan/help.rb
--- old/yast2-network-3.1.46/src/include/network/lan/help.rb 2014-04-07 11:32:47.000000000 +0200
+++ new/yast2-network-3.1.50/src/include/network/lan/help.rb 2014-04-25 14:38:44.000000000 +0200
@@ -263,16 +263,16 @@
"additional" =>
# Aliases dialog help 1/4
_(
- "<p><b><big>Additional Addresses</big></b></p>\n<p>Configure additional addresses of an interface (its aliases) in this table.</p>\n"
+ "<p><b><big>Additional Addresses</big></b></p>\n<p>Configure additional addresses of an interface in this table.</p>\n"
) +
# Aliases dialog help 2/4
_(
- "<p>Enter an <b>Alias Name</b>, an <b>IP Address</b>, and\nthe <b>Netmask</b>.</p>"
+ "<p>Enter an <b>IPv4 Address Label</b>, an <b>IP Address</b>, and\nthe <b>Netmask</b>.</p>"
) +
# Aliases dialog help 3/4
_(
- "<p><b>Alias Name</b> is optional and legacy.The total\n" +
- " length of interface name (inclusive of the colon and label) is\n" +
+ "<p><b>IPv4 Address Label</b>, formerly known as Alias Name, is optional and legacy. The total\n" +
+ " length of interface name (inclusive of the colon and label) is\n" +
" limited to 15 characters and the obsolete ifconfig utility truncates it after 9 characters.</p>"
) +
# Aliases dialog help 3/4, #83766
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-network-3.1.46/src/include/network/lan/virtual.rb new/yast2-network-3.1.50/src/include/network/lan/virtual.rb
--- old/yast2-network-3.1.46/src/include/network/lan/virtual.rb 2014-04-07 11:32:47.000000000 +0200
+++ new/yast2-network-3.1.50/src/include/network/lan/virtual.rb 2014-04-25 14:38:44.000000000 +0200
@@ -211,7 +211,7 @@
HSpacing(1),
VBox(
# TextEntry label
- TextEntry(Id(:name), _("Alias &Name"), Ops.get_string(entry, 1, "")),
+ TextEntry(Id(:name), _("IPv4 &Address Label"), Ops.get_string(entry, 1, "")),
# TextEntry label
TextEntry(
Id(:ipaddr),
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-network-3.1.46/src/include/network/lan/wizards.rb new/yast2-network-3.1.50/src/include/network/lan/wizards.rb
--- old/yast2-network-3.1.46/src/include/network/lan/wizards.rb 2014-04-07 11:32:47.000000000 +0200
+++ new/yast2-network-3.1.50/src/include/network/lan/wizards.rb 2014-04-25 14:38:44.000000000 +0200
@@ -59,16 +59,28 @@
"write" => [lambda { WriteDialog() }, true]
}
- sequence = {
- "ws_start" => "read",
- "read" => { :abort => :abort, :next => "main" },
- "main" => { :abort => :abort, :next => "packages" },
- "packages" => { :abort => :abort, :next => "write" },
- "write" => { :abort => :abort, :next => :next }
- }
+ if Mode.installation || Mode.update
+ sequence = {
+ "ws_start" => "read",
+ "read" => { :abort => :abort, :back => :back, :next => "main" },
+ "main" => { :abort => :abort, :back => :back, :next => "packages" },
+ "packages" => { :abort => :abort, :back => :back, :next => "write" },
+ "write" => { :abort => :abort, :back => :back, :next => :next }
+ }
+
+ Wizard.OpenNextBackDialog
+ else
+ sequence = {
+ "ws_start" => "read",
+ "read" => { :abort => :abort, :next => "main" },
+ "main" => { :abort => :abort, :next => "packages" },
+ "packages" => { :abort => :abort, :next => "write" },
+ "write" => { :abort => :abort, :next => :next }
+ }
- Wizard.OpenCancelOKDialog
- Wizard.SetDesktopTitleAndIcon("lan")
+ Wizard.OpenCancelOKDialog
+ Wizard.SetDesktopTitleAndIcon("lan")
+ end
ret = Sequencer.Run(aliases, sequence)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-network-3.1.46/src/include/network/routines.rb new/yast2-network-3.1.50/src/include/network/routines.rb
--- old/yast2-network-3.1.46/src/include/network/routines.rb 2014-04-07 11:32:47.000000000 +0200
+++ new/yast2-network-3.1.50/src/include/network/routines.rb 2014-04-25 14:38:44.000000000 +0200
@@ -28,6 +28,9 @@
#
module Yast
module NetworkRoutinesInclude
+ include I18n
+ include Yast
+
def initialize_network_routines(include_target)
Yast.import "UI"
@@ -1015,18 +1018,18 @@
end
def SetLinkUp(dev_name)
- Run(Builtins.sformat("ip link set %1 up", dev_name))
+ Run("ip link set #{dev_name} up")
end
def SetLinkDown(dev_name)
- Run(Builtins.sformat("ip link set %1 down", dev_name))
+ Run("ip link set #{dev_name} down")
end
def SetAllLinksUp
interfaces = GetAllInterfaces()
- ret = Ops.greater_than(Builtins.size(interfaces), 0)
+ ret = !interfaces.empty?
- Builtins.foreach(interfaces) do |ifc|
+ interfaces.each do |ifc|
Builtins.y2milestone("Setting link up for interface %1", ifc)
ret = SetLinkUp(ifc) && ret
end
@@ -1034,6 +1037,27 @@
ret
end
+ # Checks if given device has carrier
+ #
+ # @return [boolean] true if device has carrier
+ def has_carrier?(dev_name)
+ SCR.Read(
+ path(".target.string"),
+ "/sys/class/net/#{dev_name}/carrier"
+ ).to_i != 0
+ end
+
+ # Checks if device is physically connected to a network
+ #
+ # It does neccessary steps which might be needed for proper initialization
+ # of devices driver.
+ #
+ # @return [boolean] true if physical layer is connected
+ def phy_connected?(dev_name)
+ # SetLinkUp ensures that driver is properly initialized
+ SetLinkUp(dev_name) && has_carrier?(dev_name)
+ end
+
def validPrefixOrNetmask(ip, mask)
valid_mask = false
if Builtins.substring(mask, 0, 1) == "/"
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-network-3.1.46/src/include/network/runtime.rb new/yast2-network-3.1.50/src/include/network/runtime.rb
--- old/yast2-network-3.1.46/src/include/network/runtime.rb 2014-04-07 11:32:47.000000000 +0200
+++ new/yast2-network-3.1.50/src/include/network/runtime.rb 2014-04-25 14:38:44.000000000 +0200
@@ -29,44 +29,21 @@
module Yast
module NetworkRuntimeInclude
def initialize_network_runtime(include_target)
-
- Yast.import "Arch"
- Yast.import "Desktop"
- Yast.import "Mode"
- Yast.import "NetworkInterfaces"
- Yast.import "Package"
- Yast.import "Service"
- Yast.import "PackageSystem"
-
textdomain "network"
end
- # Run SuSEconfig
- # @return true if success
- def RunSuSEconfig
+ # Runs external script which updates MTA's configuration.
+ #
+ # Currently supported MTAs:
+ # - sendmail
+ # - postfix
+ def update_mta_config
Builtins.y2milestone("Updating sendmail and/or postfix configuration.")
SCR.Execute(
path(".target.bash"),
"/usr/lib/sendmail.d/update 2>/dev/null"
)
SCR.Execute(path(".target.bash"), "/usr/sbin/config.postfix 2>/dev/null")
- true
- end
-
- # Link detection
- # @return true if link found
- # @see #ethtool(8)
- def HasLink
- ifname = "eth0"
-
- command = Builtins.sformat(
- "ethtool %1 | grep -q 'Link detected: no'",
- ifname
- )
- if Convert.to_integer(SCR.Execute(path(".target.bash"), command)) == 1
- return false
- end
- true
end
end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-network-3.1.46/src/lib/network/install_inf_convertor.rb new/yast2-network-3.1.50/src/lib/network/install_inf_convertor.rb
--- old/yast2-network-3.1.46/src/lib/network/install_inf_convertor.rb 2014-04-07 11:32:47.000000000 +0200
+++ new/yast2-network-3.1.50/src/lib/network/install_inf_convertor.rb 2014-04-25 14:38:44.000000000 +0200
@@ -11,6 +11,8 @@
BASH_PATH = Path.new(".target.bash")
+ # Class for accessing /etc/install.inf.
+ # See http://en.opensuse.org/SDB:Linuxrc_install.inf
class InstallInf
INSTALL_INF = Path.new(".etc.install_inf")
@@ -364,12 +366,13 @@
def create_device_name_ifcfg(hardware)
device_name = dev_name
- hw_name = BuildDescription(
- NetworkInterfaces.device_type(device_name),
- NetworkInterfaces.device_num(device_name),
- { "dev_name" => device_name },
- hardware
- )
+ # authoritative sources of device name are:
+ # - hwinfo
+ # - install.inf
+ # nobody else was able to edit device name so far (so ifcfg["NAME"])
+ # is empty
+ hw_name = HardwareName(hardware, device_name)
+ hw_name = InstallInf["NetCardName"] || "" if hw_name.empty?
return "" if hw_name.empty?
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-network-3.1.46/src/lib/network/network_autoconfiguration.rb new/yast2-network-3.1.50/src/lib/network/network_autoconfiguration.rb
--- old/yast2-network-3.1.46/src/lib/network/network_autoconfiguration.rb 1970-01-01 01:00:00.000000000 +0100
+++ new/yast2-network-3.1.50/src/lib/network/network_autoconfiguration.rb 2014-04-25 14:38:44.000000000 +0200
@@ -0,0 +1,171 @@
+# encoding: utf-8
+
+require "yast"
+
+module Yast
+
+ # The class is responsible for generating / proposing automatic
+ # configuration during installation workflow
+ class NetworkAutoconfiguration
+ include Singleton
+ include Logger
+ include Yast
+
+ Yast.import "LanItems"
+ Yast.import "NetworkInterfaces"
+
+ BASH_PATH = Path.new(".target.bash")
+
+ def configure_dhcp
+ Yast.include self, "network/routines.rb"
+
+ # find out network devices suitable for dhcp autoconfiguration.
+ # Such device has to:
+ # - be unconfigured
+ # - physically connected to a network (it speeds up initialization phase of
+ # installer - bnc#872319)
+ dhcp_cards = network_cards.select { |c| !configured?(c) && phy_connected?(c) }
+ log.info "Candidates for enabling DHCP: #{dhcp_cards}"
+
+ # 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
+ inactive_devices = dhcp_cards.select { |c| ! active_config?(c) }
+ log.info "Inactive devices: #{inactive_devices}"
+
+ inactive_devices.each { |c| delete_config(c) }
+
+ # setup route flag
+ active_devices = dhcp_cards - inactive_devices
+
+ if active_devices.size == 1
+ # just one dhcp device, nothing to care of
+ set_default_route_flag(active_devices.first, "yes")
+ else
+ # try to find just one dhcp aware device for allowing default route
+ # if there is more than one dhcp devices enabled for setting default
+ # route (DHCLIENT_SET_DEFAULT_ROUTE = "yes"). bnc#868187
+ active_devices.find { |d| set_default_route_flag_if_wan_dev?(d) }
+ end
+
+ activate_changes(dhcp_cards)
+ end
+
+ private
+ def network_cards
+ LanItems.Read
+ LanItems.GetNetcardNames
+ end
+
+ # Makes DHCP setup persistent
+ #
+ # instsys currently uses wicked as network services "manager" (including
+ # dhcp client). wicked is currently able to configure a card for dhcp leases
+ # only via loading config from file. All other ways are workarounds and
+ # needn't to work when wickedd* services are already running
+ def setup_dhcp card
+ index = LanItems.FindDeviceIndex(card)
+
+ if index == -1
+ raise "Failed to save configuration for device #{card}"
+ end
+
+ LanItems.current = index
+ LanItems.SetItem
+
+ #tricky part if ifcfg is not set
+ # yes, this code smell and show bad API of LanItems
+ if !LanItems.IsCurrentConfigured
+ NetworkInterfaces.Add
+ current = LanItems.Items[LanItems.current]
+ current["ifcfg"] = card
+ end
+
+ LanItems.bootproto = "dhcp"
+ LanItems.startmode = "auto"
+
+ LanItems.Commit
+ end
+
+ def reload_config(card)
+ SCR.Execute(BASH_PATH, "wicked ifreload '#{card}'") == 0
+ end
+
+ def delete_config(devname)
+ LanItems.delete_dev(devname)
+ end
+
+ def write_configuration
+ NetworkInterfaces.Write("")
+ end
+
+ 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) }
+ end
+
+ def configured?(devname)
+ # TODO:
+ # one day there should be LanItems.IsItemConfigured, but we currently
+ # miss index -> devname translation. As this LanItems internal structure
+ # will be subject of refactoring, we will use NetworkInterfaces directly.
+ # It currently doesn't hurt as it currently writes configuration for both
+ # wicked even sysconfig.
+ NetworkInterfaces.Check(devname)
+ end
+
+ # Checks if given device is active
+ #
+ # active device <=> a device which is reported as "up" by wicked
+ def active_config?(devname)
+ wicked_query = "wicked ifstatus --brief #{devname} | grep 'up$'"
+ SCR.Execute(BASH_PATH, wicked_query) == 0
+ end
+
+ # Returns list of servers used for internet reachability test
+ #
+ # Basicaly servers with product release notes should be used.
+ def target_servers
+ ["scc.suse.com"]
+ end
+
+ # 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])
+
+ reached = target_servers.any? do |server|
+ ping_cmd = "ping -I #{devname} -c 3 #{server}"
+ SCR.Execute(BASH_PATH, ping_cmd) == 0
+ end
+
+ log.info("Release notes can be reached via #{devname}: #{reached}")
+
+ if !reached
+ set_default_route_flag(devname, "no")
+ activate_changes([devname])
+ end
+
+ reached
+ end
+
+ # Sets sysconfig's DHCLIENT_SET_DEFAULT_ROUTE option for given device
+ #
+ # @param [String] devname name of device as seen by system (e.g. enp0s3)
+ # @param [String] value "yes" or "no", as in sysconfig
+ def set_default_route_flag(devname, value)
+ item_id = LanItems.FindDeviceIndex(devname)
+ LanItems.SetItemSysconfigOpt(item_id, "DHCLIENT_SET_DEFAULT_ROUTE", value)
+ end
+
+ end
+end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-network-3.1.46/src/modules/DNS.rb new/yast2-network-3.1.50/src/modules/DNS.rb
--- old/yast2-network-3.1.46/src/modules/DNS.rb 2014-04-07 11:32:47.000000000 +0200
+++ new/yast2-network-3.1.50/src/modules/DNS.rb 2014-04-25 14:38:44.000000000 +0200
@@ -429,7 +429,7 @@
ProgressNextStage(_("Updating configuration..."))
# Finish him
- RunSuSEconfig()
+ update_mta_config
Builtins.sleep(sl)
# if(SCR::Read(.target.size, resolv_conf) < 0)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-network-3.1.46/src/modules/Lan.rb new/yast2-network-3.1.50/src/modules/Lan.rb
--- old/yast2-network-3.1.46/src/modules/Lan.rb 2014-04-07 11:32:47.000000000 +0200
+++ new/yast2-network-3.1.50/src/modules/Lan.rb 2014-04-25 14:38:44.000000000 +0200
@@ -664,7 +664,7 @@
return false if Abort()
# Progress step 10
ProgressNextStage(_("Updating configuration..."))
- RunSuSEconfig() if !@write_only
+ update_mta_config if !@write_only
Builtins.sleep(sl)
if NetworkService.is_network_manager
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-network-3.1.46/test/Makefile.am new/yast2-network-3.1.50/test/Makefile.am
--- old/yast2-network-3.1.46/test/Makefile.am 2014-04-07 11:32:47.000000000 +0200
+++ new/yast2-network-3.1.50/test/Makefile.am 2014-04-25 14:38:44.000000000 +0200
@@ -7,7 +7,8 @@
new_device_startmode_test.rb \
widgets_test.rb \
install_inf_convertor_test.rb \
- lan_items_helpers_test.rb
+ lan_items_helpers_test.rb \
+ link_handlers_test.rb
TEST_EXTENSIONS = .rb
RB_LOG_COMPILER = rspec
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-network-3.1.46/test/install_inf_convertor_test.rb new/yast2-network-3.1.50/test/install_inf_convertor_test.rb
--- old/yast2-network-3.1.46/test/install_inf_convertor_test.rb 2014-04-07 11:32:47.000000000 +0200
+++ new/yast2-network-3.1.50/test/install_inf_convertor_test.rb 2014-04-25 14:38:44.000000000 +0200
@@ -89,6 +89,7 @@
before(:each) do
@device = "enp0s3"
@netconfig = "dhcp"
+ @netcardname = "Network card name"
@install_inf_convertor = Yast::InstallInfConvertor.instance
@@ -100,6 +101,9 @@
Yast::InstallInfConvertor::InstallInf
.stub(:[])
.with("NetConfig") { @netconfig }
+ Yast::InstallInfConvertor::InstallInf
+ .stub(:[])
+ .with("NetCardName") { @netcardname }
end
describe "#dev_name" do
@@ -122,7 +126,7 @@
expect(ifcfg = @install_inf_convertor.send(:create_ifcfg)).not_to be_empty
expect(ifcfg).to match /BOOTPROTO='dhcp4'/
expect(ifcfg).to match /STARTMODE='onboot'/
- expect(ifcfg).to match /NAME='.*'/
+ expect(ifcfg).to match /NAME='#{@netcardname}'/
end
end
end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-network-3.1.46/test/link_handlers_test.rb new/yast2-network-3.1.50/test/link_handlers_test.rb
--- old/yast2-network-3.1.46/test/link_handlers_test.rb 1970-01-01 01:00:00.000000000 +0100
+++ new/yast2-network-3.1.50/test/link_handlers_test.rb 2014-04-25 14:38:44.000000000 +0200
@@ -0,0 +1,23 @@
+#!/usr/bin/env rspec
+
+ENV["Y2DIR"] = File.expand_path("../../src", __FILE__)
+
+require "yast"
+
+describe "phy_connected?" do
+ before(:each) do
+ Yast.include self, "network/routines.rb"
+
+ Yast::SCR.stub(:Execute).with(path(".target.bash"), //) { 0 }
+ end
+
+ it "returns true if PHY layer is available" do
+ Yast::SCR.stub(:Read).with(path(".target.string"), /\/sys\/class\/net/) { 1 }
+ expect(phy_connected?("enp0s3")).to eql true
+ end
+
+ it "returns false if PHY layer is available" do
+ Yast::SCR.stub(:Read).with(path(".target.string"), /\/sys\/class\/net/) { 0 }
+ expect(phy_connected?("enp0s3")).to eql false
+ end
+end
--
To unsubscribe, e-mail: opensuse-commit+unsubscribe@opensuse.org
For additional commands, e-mail: opensuse-commit+help@opensuse.org