Hello community, here is the log from the commit of package yast2-network for openSUSE:Factory checked in at 2015-05-07 09:21:55 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 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 2015-01-29 09:55:07.000000000 +0100 +++ /work/SRC/openSUSE:Factory/.yast2-network.new/yast2-network.changes 2015-05-07 09:21:56.000000000 +0200 @@ -1,0 +2,18 @@ +Mon Apr 27 07:06:18 UTC 2015 - mfilka@suse.com + +- bnc#912904 + - do not crash when adding new device and proposed configuration + name is changed to new one +- bnc#914833 + - do not crash when renaming virtual device via hardware tab +- bnc#910337 + - initialize configuration name in Hardware tab correctly. It + means according device type. Also uses custom name if user + used nonstandard one. +- bnc#905738 + - udev rules provided by AutoYaST profile gets applied +- bnc#918356 + - populate bond slave candidates list with proper device names +- 3.1.114 + +------------------------------------------------------------------- Old: ---- yast2-network-3.1.113.tar.bz2 New: ---- yast2-network-3.1.114.tar.bz2 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ yast2-network.spec ++++++ --- /var/tmp/diff_new_pack.jCGh2Q/_old 2015-05-07 09:21:57.000000000 +0200 +++ /var/tmp/diff_new_pack.jCGh2Q/_new 2015-05-07 09:21:57.000000000 +0200 @@ -17,7 +17,7 @@ Name: yast2-network -Version: 3.1.113 +Version: 3.1.114 Release: 0 BuildRoot: %{_tmppath}/%{name}-%{version}-build ++++++ yast2-network-3.1.113.tar.bz2 -> yast2-network-3.1.114.tar.bz2 ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-network-3.1.113/CONTRIBUTING.md new/yast2-network-3.1.114/CONTRIBUTING.md --- old/yast2-network-3.1.113/CONTRIBUTING.md 2015-01-28 14:17:13.000000000 +0100 +++ new/yast2-network-3.1.114/CONTRIBUTING.md 2015-05-06 15:17:14.000000000 +0200 @@ -12,13 +12,13 @@ ----------- If you find a problem, please report it either using -[Bugzilla](https://bugzilla.novell.com/enter_bug.cgi?format=guided&product=openSUSE+Factory&component=YaST2) +[Bugzilla](https://bugzilla.suse.com/enter_bug.cgi?format=guided&product=openSUSE+Factory&component=YaST2) or [GitHub issues](../../issues). (For Bugzilla, use the [simplified registration](https://secure-www.novell.com/selfreg/jsp/createSimpleAccount.jsp) if you don't have an account yet.) If you find a problem, please report it either using -[Bugzilla](https://bugzilla.novell.com/) or GitHub issues. We can't guarantee +[Bugzilla](https://bugzilla.suse.com/) or GitHub issues. We can't guarantee that every bug will be fixed, but we'll try. When creating a bug report, please follow our [bug reporting @@ -71,7 +71,7 @@ [widely used conventions](http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html). -If your commit is related to a bug in Buzgilla or an issue on GitHub, make sure +If your commit is related to a bug in Bugzilla or an issue on GitHub, make sure you mention it in the commit message for cross-reference. Use format like bnc#775814 or gh#yast/yast-foo#42. See also [GitHub autolinking](https://help.github.com/articles/github-flavored-markdown#references) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-network-3.1.113/package/yast2-network.changes new/yast2-network-3.1.114/package/yast2-network.changes --- old/yast2-network-3.1.113/package/yast2-network.changes 2015-01-28 14:17:13.000000000 +0100 +++ new/yast2-network-3.1.114/package/yast2-network.changes 2015-05-06 15:17:14.000000000 +0200 @@ -1,4 +1,22 @@ ------------------------------------------------------------------- +Mon Apr 27 07:06:18 UTC 2015 - mfilka@suse.com + +- bnc#912904 + - do not crash when adding new device and proposed configuration + name is changed to new one +- bnc#914833 + - do not crash when renaming virtual device via hardware tab +- bnc#910337 + - initialize configuration name in Hardware tab correctly. It + means according device type. Also uses custom name if user + used nonstandard one. +- bnc#905738 + - udev rules provided by AutoYaST profile gets applied +- bnc#918356 + - populate bond slave candidates list with proper device names +- 3.1.114 + +------------------------------------------------------------------- Wed Jan 28 13:12:16 UTC 2015 - lslezak@suse.cz - fixed a build failure when building against the latest yast2 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-network-3.1.113/package/yast2-network.spec new/yast2-network-3.1.114/package/yast2-network.spec --- old/yast2-network-3.1.113/package/yast2-network.spec 2015-01-28 14:17:13.000000000 +0100 +++ new/yast2-network-3.1.114/package/yast2-network.spec 2015-05-06 15:17:14.000000000 +0200 @@ -17,7 +17,7 @@ Name: yast2-network -Version: 3.1.113 +Version: 3.1.114 Release: 0 BuildRoot: %{_tmppath}/%{name}-%{version}-build diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-network-3.1.113/src/clients/lan_auto.rb new/yast2-network-3.1.114/src/clients/lan_auto.rb --- old/yast2-network-3.1.113/src/clients/lan_auto.rb 2015-01-28 14:17:13.000000000 +0100 +++ new/yast2-network-3.1.114/src/clients/lan_auto.rb 2015-05-06 15:17:14.000000000 +0200 @@ -47,7 +47,6 @@ Yast.include self, "network/lan/wizards.rb" Yast.include self, "network/routines.rb" - @ret = nil @func = "" @param = {} @@ -82,6 +81,7 @@ @func = "Import" end + Builtins.y2milestone("Lan autoinst callback: #{@func}") if @func == "Summary" @ret = Ops.get_string(Lan.Summary("summary"), 0, "") @@ -141,6 +141,7 @@ end @new = FromAY(@param) Lan.Import(@new) + LanUdevAuto.Import(@new) @ret = true elsif @func == "Read" @progress_orig = Progress.set(false) @@ -159,7 +160,15 @@ @ret = deep_copy(@autoyast) elsif @func == "Write" @progress_orig = Progress.set(false) - @ret = Lan.WriteOnly + + result = LanUdevAuto.Write + Builtins.y2error("Writing udev rules failed") if !result + @ret = result + + result = Lan.WriteOnly + Builtins.y2error("Writing lan config failed") if !result + @ret = @ret && result + if Ops.get(LanItems.autoinstall_settings, "strict_IP_check_timeout") != nil if Lan.isAnyInterfaceDown @timeout = Ops.get_integer( @@ -182,10 +191,8 @@ @ret = false end - Builtins.y2debug("ret=%1", @ret) - Builtins.y2milestone("Lan auto finished") + Builtins.y2milestone("Lan auto finished (#{@ret})") Builtins.y2milestone("----------------------------------------") - deep_copy(@ret) # EOF end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-network-3.1.113/src/clients/save_network.rb new/yast2-network-3.1.114/src/clients/save_network.rb --- old/yast2-network-3.1.113/src/clients/save_network.rb 2015-01-28 14:17:13.000000000 +0100 +++ new/yast2-network-3.1.114/src/clients/save_network.rb 2015-05-06 15:17:14.000000000 +0200 @@ -250,8 +250,6 @@ NetworkAutoconfiguration.instance.configure_dns NetworkAutoconfiguration.instance.configure_hosts - LanUdevAuto.Write if Mode.autoinst - DNS.create_hostname_link SCR.Execute(path(".target.bash"), "chkconfig network on") diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-network-3.1.113/src/include/network/lan/address.rb new/yast2-network-3.1.114/src/include/network/lan/address.rb --- old/yast2-network-3.1.113/src/include/network/lan/address.rb 2015-01-28 14:17:13.000000000 +0100 +++ new/yast2-network-3.1.114/src/include/network/lan/address.rb 2015-05-06 15:17:14.000000000 +0200 @@ -1536,10 +1536,6 @@ # address tab if LanItems.operation == :add LanItems.device = NetworkInterfaces.device_num(ifcfgname) - LanItems.type = NetworkInterfaces.GetTypeFromIfcfg(@settings) - if LanItems.type == nil - LanItems.type = NetworkInterfaces.device_type(ifcfgname) - end end LanItems.bootproto = Ops.get_string(@settings, "BOOTPROTO", "") diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-network-3.1.113/src/include/network/lan/hardware.rb new/yast2-network-3.1.114/src/include/network/lan/hardware.rb --- old/yast2-network-3.1.113/src/include/network/lan/hardware.rb 2015-01-28 14:17:13.000000000 +0100 +++ new/yast2-network-3.1.114/src/include/network/lan/hardware.rb 2015-05-06 15:17:14.000000000 +0200 @@ -834,6 +834,7 @@ if isNewDevice nm = devname_from_hw_dialog LanItems.type = UI.QueryWidget(Id(:type), :Value) + LanItems.device = nm NetworkInterfaces.Name = nm Ops.set(LanItems.Items, [LanItems.current, "ifcfg"], nm) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-network-3.1.113/src/include/network/lan/udev.rb new/yast2-network-3.1.114/src/include/network/lan/udev.rb --- old/yast2-network-3.1.113/src/include/network/lan/udev.rb 2015-01-28 14:17:13.000000000 +0100 +++ new/yast2-network-3.1.114/src/include/network/lan/udev.rb 2015-05-06 15:17:14.000000000 +0200 @@ -45,6 +45,31 @@ rule end + # Writes new persistent udev net rules and tells udevd to update its configuration + def write_update_udevd(udev_rules) + SCR.Write(path(".udev_persistent.rules"), udev_rules) + SCR.Write(path(".udev_persistent.nil"), []) + + update_udevd + end + + # Tells udevd to reload and update its configuration + # + # @return [boolean] false when new configuration cannot be activated + def update_udevd + SCR.Execute(path(".target.bash"), "udevadm control --reload") + + # When configuring a new s390 card, we neglect to fill + # its Items[i, "udev", "net"], causing jumbled names (bnc#721520) + # The udev trigger will make udev write the persistent names + # (which it already has done, but we have overwritten them now). + ret = SCR.Execute( + path(".target.bash"), + "udevadm trigger --subsystem-match=net --action=add" + ) + ret == 0 + end + # Removes (key,operator,value) tripplet from given udev rule. def RemoveKeyFromUdevRule(rule, key) rule = deep_copy(rule) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-network-3.1.113/src/include/network/routines.rb new/yast2-network-3.1.114/src/include/network/routines.rb --- old/yast2-network-3.1.113/src/include/network/routines.rb 2015-01-28 14:17:13.000000000 +0100 +++ new/yast2-network-3.1.114/src/include/network/routines.rb 2015-05-06 15:17:14.000000000 +0200 @@ -928,23 +928,35 @@ end def SetLinkUp(dev_name) + log.info("Setting link up for interface #{dev_name}") Run("ip link set #{dev_name} up") end def SetLinkDown(dev_name) + log.info("Setting link down for interface #{dev_name}") Run("ip link set #{dev_name} down") end + # Tries to set all available interfaces up + # + # @return [boolean] false if some of interfaces cannot be set up def SetAllLinksUp interfaces = GetAllInterfaces() - ret = !interfaces.empty? - interfaces.each do |ifc| - Builtins.y2milestone("Setting link up for interface %1", ifc) - ret = SetLinkUp(ifc) && ret - end + return false if interfaces.empty? - ret + interfaces.all? { |i| SetLinkUp(i) } + end + + # Tries to set all available interfaces down + # + # @return [boolean] false if some of interfaces cannot be set down + def SetAllLinksDown + interfaces = GetAllInterfaces() + + return false if interfaces.empty? + + interfaces.all? { |i| SetLinkDown(i) } end # Checks if given device has carrier diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-network-3.1.113/src/include/network/widgets.rb new/yast2-network-3.1.114/src/include/network/widgets.rb --- old/yast2-network-3.1.113/src/include/network/widgets.rb 2015-01-28 14:17:13.000000000 +0100 +++ new/yast2-network-3.1.114/src/include/network/widgets.rb 2015-05-06 15:17:14.000000000 +0200 @@ -559,46 +559,48 @@ # @param [Array<Fixnum>] itemIds list of indexes into LanItems::Items # @param [Array<String>] enslavedIfaces list of device names of already enslaved devices def CreateSlaveItems(itemIds, enslavedIfaces) - itemIds = deep_copy(itemIds) - enslavedIfaces = deep_copy(enslavedIfaces) + raise ArgumentError, "no slave device defined" if itemIds.nil? + items = [] - Builtins.foreach(itemIds) do |itemId| - description = "" + itemIds.each do |itemId| dev_name = LanItems.GetDeviceName(itemId) - ifcfg = LanItems.GetDeviceMap(itemId) - next if IsEmpty(dev_name) - ifcfg = { "dev_name" => dev_name } if ifcfg == nil + + next if dev_name.nil? || dev_name.empty? + dev_type = LanItems.GetDeviceType(itemId) - if Builtins.contains(["tun", "tap"], dev_type) + + if ["tun", "tap"].include? dev_type description = NetworkInterfaces.GetDevTypeDescription(dev_type, true) else + ifcfg = LanItems.GetDeviceMap(itemId) || {} + description = BuildDescription( - "", - "", + dev_type, + dev_name, ifcfg, - [Ops.get_map(LanItems.GetLanItem(itemId), "hwinfo", {})] + [LanItems.GetLanItem(itemId)["hwinfo"] || {}] ) # this conditions origin from bridge configuration # if enslaving a configured device then its configuration is rewritten # to "0.0.0.0/32" - if Ops.get_string(ifcfg, "IPADDR", "") != "0.0.0.0" - description = Builtins.sformat("%1 (%2)", description, "configured") - end + # + # translators: a note that listed device is already configured + description += " " + _("configured") if ifcfg["IPADDR"] != "0.0.0.0" end - selected = Builtins.contains(enslavedIfaces, dev_name) - items = Builtins.add( - items, - Item( - Id(dev_name), - Builtins.sformat("%1 - %2", dev_name, description), - selected - ) + + selected = false + selected = enslavedIfaces.include?(dev_name) if enslavedIfaces + + items << Item( + Id(dev_name), + "#{dev_name} - #{description}", + selected ) end - deep_copy(items) + items end end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-network-3.1.113/src/modules/LanItems.rb new/yast2-network-3.1.114/src/modules/LanItems.rb --- old/yast2-network-3.1.113/src/modules/LanItems.rb 2015-01-28 14:17:13.000000000 +0100 +++ new/yast2-network-3.1.114/src/modules/LanItems.rb 2015-05-06 15:17:14.000000000 +0200 @@ -539,17 +539,21 @@ # # Returns new name def SetItemName( itemId, name) + lan_items = LanItems.Items + if name && !name.empty? - updated_rule = update_udev_rule_key(GetItemUdevRule(itemId), "NAME", name) - @Items[itemId]["udev"]["net"] = updated_rule + if lan_items[itemId]["udev"] + updated_rule = update_udev_rule_key(GetItemUdevRule(itemId), "NAME", name) + lan_items[itemId]["udev"]["net"] = updated_rule + end else # rewrite rule for empty name is meaningless - @Items[itemId].delete("udev") + lan_items[itemId].delete("udev") end - if @Items[ itemId].has_key?( "ifcfg") - NetworkInterfaces.Delete2( @Items[ itemId][ "ifcfg"]) - @Items[ itemId][ "ifcfg"] = name.to_s + if lan_items[ itemId].has_key?( "ifcfg") + NetworkInterfaces.Delete2(lan_items[ itemId][ "ifcfg"]) + lan_items[ itemId][ "ifcfg"] = name.to_s end name @@ -630,19 +634,7 @@ Builtins.y2milestone("write net udev rules: %1", net_rules) - SCR.Write(path(".udev_persistent.rules"), net_rules) - SCR.Write(path(".udev_persistent.nil"), []) - - SCR.Execute(path(".target.bash"), "udevadm control --reload") - - # When configuring a new s390 card, we neglect to fill - # its Items[i, "udev", "net"], causing jumbled names (bnc#721520) - # The udev trigger will will make udev write the persistent names - # (which it already has done, but we have overwritten them now). - SCR.Execute( - path(".target.bash"), - "udevadm trigger --subsystem-match=net --action=add" - ) + write_update_udevd(net_rules) true end @@ -1886,24 +1878,24 @@ # @return true if success def Commit if @operation != :add && @operation != :edit - Builtins.y2error("Unknown operation: %1", @operation) + log.error("Unknown operation: #{@operation}") raise ArgumentError, "Unknown operation: #{@operation}" end newdev = {} # #104494 - always write IPADDR+NETMASK, even empty - Ops.set(newdev, "IPADDR", @ipaddr) - if Ops.greater_than(Builtins.size(@prefix), 0) - Ops.set(newdev, "PREFIXLEN", @prefix) + newdev["IPADDR"] = @ipaddr + if !@prefix.empty? + newdev["PREFIXLEN"] = @prefix else - Ops.set(newdev, "NETMASK", @netmask) + newdev["NETMASK"] = @netmask end # #50955 omit computable fields - Ops.set(newdev, "BROADCAST", "") - Ops.set(newdev, "NETWORK", "") + newdev["BROADCAST"] = "" + newdev["NETWORK"] = "" - Ops.set(newdev, "REMOTE_IPADDR", @remoteip) + newdev["REMOTE_IPADDR"] = @remoteip # set LLADDR to sysconfig only for device on layer2 and only these which needs it # do not write incorrect LLADDR. @@ -1925,45 +1917,43 @@ case @type when "bond" i = 0 - Builtins.foreach(@bond_slaves) do |slave| - Ops.set(newdev, Builtins.sformat("BONDING_SLAVE%1", i), slave) - i = Ops.add(i, 1) + @bond_slaves.each do |slave| + newdev["BONDING_SLAVE#{i}"] = slave + i += 1 end #assign nil to rest BONDING_SLAVEn to remove them - while Ops.less_than(i, @MAX_BOND_SLAVE) - Ops.set(newdev, Builtins.sformat("BONDING_SLAVE%1", i), nil) - i = Ops.add(i, 1) + while i < @MAX_BOND_SLAVE + newdev["BONDING_SLAVE#{i}"] = nil + i += 1 end - Ops.set(newdev, "BONDING_MODULE_OPTS", @bond_option) - - #BONDING_MASTER always is yes - Ops.set(newdev, "BONDING_MASTER", "yes") + newdev["BONDING_MODULE_OPTS"] = @bond_option + newdev["BONDING_MASTER"] = "yes" when "vlan" - Ops.set(newdev, "ETHERDEVICE", @vlan_etherdevice) - Ops.set(newdev, "VLAN_ID", @vlan_id) + newdev["ETHERDEVICE"] = @vlan_etherdevice + newdev["VLAN_ID"] = @vlan_id when "br" - Ops.set(newdev, "BRIDGE_PORTS", @bridge_ports) - Ops.set(newdev, "BRIDGE", "yes") - Ops.set(newdev, "BRIDGE_STP", "off") - Ops.set(newdev, "BRIDGE_FORWARDDELAY", "0") + newdev["BRIDGE_PORTS"] = @bridge_ports + newdev["BRIDGE"] = "yes" + newdev["BRIDGE_STP"] = "off" + newdev["BRIDGE_FORWARDDELAY"] = "0" when "wlan" - Ops.set(newdev, "WIRELESS_MODE", @wl_mode) - Ops.set(newdev, "WIRELESS_ESSID", @wl_essid) - Ops.set(newdev, "WIRELESS_NWID", @wl_nwid) - Ops.set(newdev, "WIRELESS_AUTH_MODE", @wl_auth_mode) - Ops.set(newdev, "WIRELESS_WPA_PSK", @wl_wpa_psk) - Ops.set(newdev, "WIRELESS_KEY_LENGTH", @wl_key_length) + newdev["WIRELESS_MODE"] = @wl_mode + newdev["WIRELESS_ESSID"] = @wl_essid + newdev["WIRELESS_NWID"] = @wl_nwid + newdev["WIRELESS_AUTH_MODE"] = @wl_auth_mode + newdev["WIRELESS_WPA_PSK"] = @wl_wpa_psk + newdev["WIRELESS_KEY_LENGTH"] = @wl_key_length # obsoleted by WIRELESS_KEY_0 - Ops.set(newdev, "WIRELESS_KEY", "") # TODO: delete the varlable - Ops.set(newdev, "WIRELESS_KEY_0", Ops.get(@wl_key, 0, "")) - Ops.set(newdev, "WIRELESS_KEY_1", Ops.get(@wl_key, 1, "")) - Ops.set(newdev, "WIRELESS_KEY_2", Ops.get(@wl_key, 2, "")) - Ops.set(newdev, "WIRELESS_KEY_3", Ops.get(@wl_key, 3, "")) + newdev["WIRELESS_KEY"] = "" # TODO: delete the varlable + newdev["WIRELESS_KEY_0"] = Ops.get(@wl_key, 0, "") + newdev["WIRELESS_KEY_1"] = Ops.get(@wl_key, 1, "") + newdev["WIRELESS_KEY_2"] = Ops.get(@wl_key, 2, "") + newdev["WIRELESS_KEY_3"] = Ops.get(@wl_key, 3, "") Ops.set( newdev, "WIRELESS_DEFAULT_KEY", @@ -2025,11 +2015,11 @@ ) end - Ops.set(newdev, "WIRELESS_CHANNEL", @wl_channel) - Ops.set(newdev, "WIRELESS_FREQUENCY", @wl_frequency) - Ops.set(newdev, "WIRELESS_BITRATE", @wl_bitrate) - Ops.set(newdev, "WIRELESS_AP", @wl_accesspoint) - Ops.set(newdev, "WIRELESS_POWER", @wl_power ? "yes" : "no") + newdev["WIRELESS_CHANNEL"] = @wl_channel + newdev["WIRELESS_FREQUENCY"] = @wl_frequency + newdev["WIRELESS_BITRATE"] = @wl_bitrate + newdev["WIRELESS_AP"] = @wl_accesspoint + newdev["WIRELESS_POWER"] = @wl_power ? "yes" : "no" when "ib" newdev["IPOIB_MODE"] = @ipoib_mode @@ -2046,7 +2036,7 @@ end end - if Builtins.contains(["tun", "tap"], @type) + if ["tun", "tap"].include?(@type) newdev = { "BOOTPROTO" => "static", "STARTMODE" => "auto", @@ -2061,7 +2051,7 @@ # Only test when newdev has enough info for GetTypeFromIfcfg to work. implied_type = NetworkInterfaces.GetTypeFromIfcfg(newdev) if implied_type != nil && implied_type != @type - Ops.set(newdev, "INTERFACETYPE", @type) + newdev["INTERFACETYPE"] = @type end NetworkInterfaces.Name = Ops.get_string(@Items, [@current, "ifcfg"], "") diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-network-3.1.113/src/modules/LanUdevAuto.rb new/yast2-network-3.1.114/src/modules/LanUdevAuto.rb --- old/yast2-network-3.1.113/src/modules/LanUdevAuto.rb 2015-01-28 14:17:13.000000000 +0100 +++ new/yast2-network-3.1.114/src/modules/LanUdevAuto.rb 2015-05-06 15:17:14.000000000 +0200 @@ -32,11 +32,15 @@ module Yast class LanUdevAutoClass < Module + + include Yast::Logger + def main Yast.import "UI" Yast.import "LanItems" Yast.import "Map" Yast.include self, "network/routines.rb" + Yast.include self, "network/lan/udev.rb" textdomain "network" @@ -194,39 +198,32 @@ end def Write - comment = [ - "# Generated by autoyast", - "# program run by the persistent-net-generator.rules rules file.", - "#", - "# You can modify it, as long as you keep each rule on a single line." - ] - rules = [] - Builtins.foreach(@udev_rules) do |rule| - rules = Builtins.add( - rules, - Builtins.sformat( - "SUBSYSTEM==\"net\", ACTION==\"add\", DRIVERS==\"?*\", %1==\"%2\", NAME=\"%3\"", - Ops.get_string(rule, "rule", ""), - Ops.get_string(rule, "value", ""), - Ops.get_string(rule, "name", "") - ) - ) + template = "SUBSYSTEM==\"net\", ACTION==\"add\", DRIVERS==\"?*\", %s==\"%s\", NAME=\"%s\"" + + rules = @udev_rules.map do |rule| + opt = rule["rule"] || "" + value = rule["value"] || "" + devname = rule["name"] || "" + + template % [opt, value.downcase, devname] end - if Ops.greater_than(Builtins.size(rules), 0) - Builtins.y2milestone( - "Writing AY udev rules for network (will replace original rules from 1st stage)" - ) - if AllowUdevModify() - SCR.Write(path(".udev_persistent.rules_comment"), comment) - SCR.Write(path(".udev_persistent.rules"), rules) - end + + if !rules.empty? && AllowUdevModify() + SetAllLinksDown() + + log.info("Writing AY udev rules for network") + + write_update_udevd(rules) + + SCR.Execute(path(".target.bash"), "udevadm settle") else - Builtins.y2milestone( - "No udev rules defined by AY, nothing to write (keep original file)" - ) + log.info("No udev rules created by AY") end + + # FIXME: In fact, this has nothing to do with udev. At least no + # directly. It creates linux emulation for s390 devices. if Arch.s390 - Builtins.foreach(@s390_devices) do |rule| + @s390_devices.each do |rule| LanItems.Select("") LanItems.type = Ops.get_string(rule, "type", "") LanItems.qeth_chanids = Ops.get_string(rule, "chanids", "") @@ -242,8 +239,9 @@ LanItems.createS390Device Builtins.y2milestone("rule %1", rule) end - Builtins.y2milestone("Writing s390 rules %1", @s390_devices) + log.info("Writing s390 rules #{@s390_devices}") end + true end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-network-3.1.113/test/bridge_test.rb new/yast2-network-3.1.114/test/bridge_test.rb --- old/yast2-network-3.1.113/test/bridge_test.rb 2015-01-28 14:17:13.000000000 +0100 +++ new/yast2-network-3.1.114/test/bridge_test.rb 2015-05-06 15:17:15.000000000 +0200 @@ -62,9 +62,9 @@ ] before(:each) do - NetworkInterfaces.stub(:FilterDevices).with("netcard") { NETCONFIG_ITEMS } + allow(NetworkInterfaces).to receive(:FilterDevices).with("netcard") { NETCONFIG_ITEMS } - LanItems.stub(:ReadHardware) { HWINFO_ITEMS } + allow(LanItems).to receive(:ReadHardware) { HWINFO_ITEMS } LanItems.Read end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-network-3.1.113/test/edit_nic_name_test.rb new/yast2-network-3.1.114/test/edit_nic_name_test.rb --- old/yast2-network-3.1.113/test/edit_nic_name_test.rb 2015-01-28 14:17:13.000000000 +0100 +++ new/yast2-network-3.1.114/test/edit_nic_name_test.rb 2015-05-06 15:17:15.000000000 +0200 @@ -21,10 +21,10 @@ NetworkInterfaces.as_null_object # mock devices configuration - LanItems.stub( :ReadHardware) { [ { "dev_name" => CURRENT_NAME } ] } - LanItems.stub( :getNetworkInterfaces) { [ CURRENT_NAME ] } - LanItems.stub( :GetItemUdev) { "" } - LanItems.stub( :GetItemUdev).with("NAME") { CURRENT_NAME } + allow(LanItems).to receive( :ReadHardware) { [ { "dev_name" => CURRENT_NAME } ] } + allow(LanItems).to receive( :getNetworkInterfaces) { [ CURRENT_NAME ] } + allow(LanItems).to receive( :GetItemUdev) { "" } + allow(LanItems).to receive( :GetItemUdev).with("NAME") { CURRENT_NAME } # LanItems initialization Yast.import "LanItems" @@ -43,19 +43,19 @@ context 'when closed without any change' do before( :each) do # emulate UI work - UI.stub( :QueryWidget).with( :dev_name, :Value) { CURRENT_NAME } - UI.stub( :QueryWidget).with( :udev_type, :CurrentButton) { :mac } + allow(UI).to receive( :QueryWidget).with( :dev_name, :Value) { CURRENT_NAME } + allow(UI).to receive( :QueryWidget).with( :udev_type, :CurrentButton) { :mac } end it 'returns current name when used Ok button' do - UI.stub( :UserInput) { :ok } + allow(UI).to receive( :UserInput) { :ok } expect( @edit_name_dlg.run).to be_equal CURRENT_NAME end it 'returns current name when used Cancel button' do - UI.stub( :UserInput) { :cancel } + allow(UI).to receive( :UserInput) { :cancel } expect( @edit_name_dlg.run).to be_equal CURRENT_NAME end @@ -64,18 +64,18 @@ context 'when closed after name change' do before( :each) do # emulate UI work - UI.stub( :QueryWidget).with( :dev_name, :Value) { NEW_NAME } - UI.stub( :QueryWidget).with( :udev_type, :CurrentButton) { :mac } + allow(UI).to receive( :QueryWidget).with( :dev_name, :Value) { NEW_NAME } + allow(UI).to receive( :QueryWidget).with( :udev_type, :CurrentButton) { :mac } end it 'returns new name when used Ok button' do - UI.stub( :UserInput) { :ok } + allow(UI).to receive( :UserInput) { :ok } expect( @edit_name_dlg.run).to be_equal NEW_NAME end it 'returns current name when used Cancel button' do - UI.stub( :UserInput) { :cancel } + allow(UI).to receive( :UserInput) { :cancel } expect( @edit_name_dlg.run).to be_equal CURRENT_NAME end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-network-3.1.113/test/install_inf_convertor_test.rb new/yast2-network-3.1.114/test/install_inf_convertor_test.rb --- old/yast2-network-3.1.113/test/install_inf_convertor_test.rb 2015-01-28 14:17:13.000000000 +0100 +++ new/yast2-network-3.1.114/test/install_inf_convertor_test.rb 2015-05-06 15:17:15.000000000 +0200 @@ -69,7 +69,7 @@ it "returns empty string even in autoinst mode" do Yast.import "Mode" - Mode.stub(:autoinst) { true } + allow(Mode).to receive(:autoinst) { true } expect(@install_inf_convertor.send(:dev_name)).to be_empty end @@ -95,16 +95,16 @@ @install_inf_convertor = Yast::InstallInfConvertor.instance - Yast::InstallInfConvertor::InstallInf - .stub(:[]) { "" } - Yast::InstallInfConvertor::InstallInf - .stub(:[]) + allow(Yast::InstallInfConvertor::InstallInf) + .to receive(:[]) { "" } + allow(Yast::InstallInfConvertor::InstallInf) + .to receive(:[]) .with("Netdevice") { @device } - Yast::InstallInfConvertor::InstallInf - .stub(:[]) + allow(Yast::InstallInfConvertor::InstallInf) + .to receive(:[]) .with("NetConfig") { @netconfig } - Yast::InstallInfConvertor::InstallInf - .stub(:[]) + allow(Yast::InstallInfConvertor::InstallInf) + .to receive(:[]) .with("NetCardName") { @netcardname } end @@ -146,22 +146,22 @@ @install_inf_convertor = Yast::InstallInfConvertor.instance - Yast::InstallInfConvertor::InstallInf - .stub(:[]) { "" } - Yast::InstallInfConvertor::InstallInf - .stub(:[]) + allow(Yast::InstallInfConvertor::InstallInf) + .to receive(:[]) { "" } + allow(Yast::InstallInfConvertor::InstallInf) + .to receive(:[]) .with("Netdevice") { @device } - Yast::InstallInfConvertor::InstallInf - .stub(:[]) + allow(Yast::InstallInfConvertor::InstallInf) + .to receive(:[]) .with("NetConfig") { @netconfig } - Yast::InstallInfConvertor::InstallInf - .stub(:[]) + allow(Yast::InstallInfConvertor::InstallInf) + .to receive(:[]) .with("IP") { @ip } - Yast::InstallInfConvertor::InstallInf - .stub(:[]) + allow(Yast::InstallInfConvertor::InstallInf) + .to receive(:[]) .with("Netmask") { @netmask } - Yast::InstallInfConvertor::InstallInf - .stub(:[]) + allow(Yast::InstallInfConvertor::InstallInf) + .to receive(:[]) .with("Nameserver") { @nameserver } end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-network-3.1.113/test/lan_items_helpers_test.rb new/yast2-network-3.1.114/test/lan_items_helpers_test.rb --- old/yast2-network-3.1.113/test/lan_items_helpers_test.rb 2015-01-28 14:17:13.000000000 +0100 +++ new/yast2-network-3.1.114/test/lan_items_helpers_test.rb 2015-05-06 15:17:15.000000000 +0200 @@ -9,19 +9,19 @@ describe "LanItemsClass#IsItemConfigured" do it "succeeds when item has configuration" do - Yast::LanItems.stub(:GetLanItem) { { "ifcfg" => "enp0s3" } } + allow(Yast::LanItems).to receive(:GetLanItem) { { "ifcfg" => "enp0s3" } } expect(Yast::LanItems.IsItemConfigured(0)).to be true end it "fails when item doesn't exist" do - Yast::LanItems.stub(:GetLanItem) { {} } + allow(Yast::LanItems).to receive(:GetLanItem) { {} } expect(Yast::LanItems.IsItemConfigured(0)).to be false end it "fails when item's configuration doesn't exist" do - Yast::LanItems.stub(:GetLanItem) { { "ifcfg" => nil } } + allow(Yast::LanItems).to receive(:GetLanItem) { { "ifcfg" => nil } } expect(Yast::LanItems.IsItemConfigured(0)).to be false end @@ -99,7 +99,7 @@ ] it "returns list of known interfaces" do - Yast::NetworkInterfaces.stub(:FilterDevices) { NETCONFIG_ITEMS } + allow(Yast::NetworkInterfaces).to receive(:FilterDevices) { NETCONFIG_ITEMS } expect(Yast::LanItems.getNetworkInterfaces).to match_array(EXPECTED_INTERFACES) end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-network-3.1.113/test/lan_udev_auto_test.rb new/yast2-network-3.1.114/test/lan_udev_auto_test.rb --- old/yast2-network-3.1.113/test/lan_udev_auto_test.rb 2015-01-28 14:17:13.000000000 +0100 +++ new/yast2-network-3.1.114/test/lan_udev_auto_test.rb 2015-05-06 15:17:15.000000000 +0200 @@ -4,9 +4,9 @@ require "yast" -module Yast +Yast.import "LanUdevAuto" - Yast.import "UI" +describe '#getDeviceName' do NEW_STYLE_NAME = "spec0" MAC_BASED_NAME = "spec-id-00:11:22:33:44:FF" @@ -19,61 +19,94 @@ INVALID_NAME = "some funny string" - describe '#getDeviceName' do - # general mocking stuff is placed here - before( :each) do - # mock devices configuration - Yast.import "LanUdevAuto" - - LanUdevAuto.stub( :ReadHardware) { - [ - { - "dev_name" => NEW_STYLE_NAME, - "mac" => "00:11:22:33:44:FF", - "busid" => "0000:00:19.0" - } - ] - } + # general mocking stuff is placed here + before(:each) do + # mock devices configuration + allow(Yast::LanUdevAuto).to receive(:ReadHardware) { + [ + { + "dev_name" => NEW_STYLE_NAME, + "mac" => "00:11:22:33:44:FF", + "busid" => "0000:00:19.0" + } + ] + } + end + + context 'when new style name is provided' do + it 'returns the new style name' do + expect(Yast::LanUdevAuto.getDeviceName(NEW_STYLE_NAME)).to be_equal NEW_STYLE_NAME + end + end + + context 'when old fashioned mac based name is provided' do + it 'returns corresponding new style name' do + expect(Yast::LanUdevAuto.getDeviceName(MAC_BASED_NAME)).to be_equal NEW_STYLE_NAME end - context 'when new style name is provided' do - it 'returns the new style name' do - expect( LanUdevAuto.getDeviceName( NEW_STYLE_NAME)).to be_equal NEW_STYLE_NAME - end - end - - context 'when old fashioned mac based name is provided' do - it 'returns corresponding new style name' do - expect( LanUdevAuto.getDeviceName( MAC_BASED_NAME)).to be_equal NEW_STYLE_NAME - end - - it 'returns same result despite of letter case in mac' do - expect( - LanUdevAuto.getDeviceName( LCASE_MAC_NAME) - ).to be_equal LanUdevAuto.getDeviceName( MAC_BASED_NAME) - end - - it 'returns given name if no known device is matched' do - expect( LanUdevAuto.getDeviceName( UNKNOWN_MAC_NAME)).to be_equal UNKNOWN_MAC_NAME - end - end - - context 'when old fashioned bus id based name is provided' do - it 'returns corresponding new style name' do - expect( LanUdevAuto.getDeviceName( BUS_BASED_NAME)).to be_equal NEW_STYLE_NAME - end - - it 'returns given name if no known device is matched' do - expect( LanUdevAuto.getDeviceName( UNKNOWN_MAC_NAME)).to be_equal UNKNOWN_MAC_NAME - end - end - - context 'when provided invalid input' do - # TODO: should raise an exception in future - it 'returns given input' do - expect( LanUdevAuto.getDeviceName( INVALID_NAME)).to be_equal INVALID_NAME - end + it 'returns same result despite of letter case in mac' do + expect( + Yast::LanUdevAuto.getDeviceName(LCASE_MAC_NAME) + ).to be_equal Yast::LanUdevAuto.getDeviceName(MAC_BASED_NAME) end + it 'returns given name if no known device is matched' do + expect(Yast::LanUdevAuto.getDeviceName(UNKNOWN_MAC_NAME)).to be_equal UNKNOWN_MAC_NAME + end + end + + context 'when old fashioned bus id based name is provided' do + it 'returns corresponding new style name' do + expect(Yast::LanUdevAuto.getDeviceName(BUS_BASED_NAME)).to be_equal NEW_STYLE_NAME + end + + it 'returns given name if no known device is matched' do + expect(Yast::LanUdevAuto.getDeviceName(UNKNOWN_MAC_NAME)).to be_equal UNKNOWN_MAC_NAME + end + end + + context 'when provided invalid input' do + # TODO: should raise an exception in future + it 'returns given input' do + expect(Yast::LanUdevAuto.getDeviceName(INVALID_NAME)).to be_equal INVALID_NAME + end + end + +end + +describe "LanUdevAuto#Write" do + include Yast + + ATTR = "ATTR{address}" + VALUE = "aa:BB:cc:DD:ee:FF" + NAME = "custom-name" + + it "writes MAC in lowercase" do + udev_rules = [ + { + "rule" => ATTR, + "value" => VALUE, + "name" => NAME + } + ] + + ay_rules = [ + "SUBSYSTEM==\"net\", ACTION==\"add\", DRIVERS==\"?*\", %s==\"%s\", NAME=\"%s\"" % + [ATTR, VALUE.downcase, NAME] + ] + + allow(Yast::LanUdevAuto) + .to receive(:AllowUdevModify) + .and_return true + + expect(Yast::SCR) + .to receive(:Write) + .with(path(".udev_persistent.rules"), ay_rules) + allow(Yast::SCR) + .to receive(:Write) + .and_return 0 + + Yast::LanUdevAuto.Import({ "net-udev" => udev_rules }) + Yast::LanUdevAuto.Write end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-network-3.1.113/test/link_handlers_test.rb new/yast2-network-3.1.114/test/link_handlers_test.rb --- old/yast2-network-3.1.113/test/link_handlers_test.rb 2015-01-28 14:17:13.000000000 +0100 +++ new/yast2-network-3.1.114/test/link_handlers_test.rb 2015-05-06 15:17:15.000000000 +0200 @@ -16,17 +16,17 @@ subject { LinkHandlersClass.new } before(:each) do - Yast::SCR.stub(:Execute).with(path(".target.bash"), //) { 0 } + allow(Yast::SCR).to receive(:Execute).with(path(".target.bash"), //) { 0 } allow(subject).to receive(:sleep) end it "returns true if PHY layer is available" do - Yast::SCR.stub(:Read).with(path(".target.string"), /\/sys\/class\/net/) { 1 } + allow(Yast::SCR).to receive(:Read).with(path(".target.string"), /\/sys\/class\/net/) { 1 } expect(subject.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 } + allow(Yast::SCR).to receive(:Read).with(path(".target.string"), /\/sys\/class\/net/) { 0 } expect(subject.phy_connected?("enp0s3")).to eql false end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-network-3.1.113/test/netcard_test.rb new/yast2-network-3.1.114/test/netcard_test.rb --- old/yast2-network-3.1.113/test/netcard_test.rb 2015-01-28 14:17:13.000000000 +0100 +++ new/yast2-network-3.1.114/test/netcard_test.rb 2015-05-06 15:17:15.000000000 +0200 @@ -144,7 +144,7 @@ end it "returns description and uses custom name if present" do - @lan_items.stub(:GetDeviceMap) { { "NAME" => "Custom name" } } + allow(@lan_items).to receive(:GetDeviceMap) { { "NAME" => "Custom name" } } @lan_items.BuildLanOverview @lan_items.Items.each_pair do |key, value| @@ -160,7 +160,7 @@ end it "returns description and uses type based name if hwinfo is not present" do - @lan_items.stub(:GetDeviceMap) { { "NAME" => "" } } + allow(@lan_items).to receive(:GetDeviceMap) { { "NAME" => "" } } @lan_items.BuildLanOverview @lan_items.Items.each_pair do |key, value| @@ -236,6 +236,20 @@ end end +describe "LanItemsClass#SetItemName" do + let(:new_name) { "new_name" } + + # this test covers bnc#914833 + it "doesn't try to update udev rules when none exists for the item" do + allow(LanItems) + .to receive(:Items) + .and_return(MOCKED_ITEMS) + + item_id = LanItems.Items.find { |k, v| !v.has_key?("udev") }.first + expect(LanItems.SetItemName(item_id, new_name)).to eql new_name + end +end + describe "LanItemsClass#FindAndSelect" do before(:each) do @lan_items = Yast::LanItems diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-network-3.1.113/test/new_device_startmode_test.rb new/yast2-network-3.1.114/test/new_device_startmode_test.rb --- old/yast2-network-3.1.113/test/new_device_startmode_test.rb 2015-01-28 14:17:13.000000000 +0100 +++ new/yast2-network-3.1.114/test/new_device_startmode_test.rb 2015-05-06 15:17:15.000000000 +0200 @@ -43,10 +43,10 @@ expect(Yast::ProductFeatures) .to receive(:GetStringFeature) .with("network", "startmode") { "ifplugd" } - Yast::LanItems.stub(:hotplug_usable?) { hwinfo_hotplug == "hotplug" } + allow(Yast::LanItems).to receive(:hotplug_usable?) { hwinfo_hotplug == "hotplug" } # setup stubs by default at results which doesn't need special handling - Yast::Arch.stub(:is_laptop) { true } - Yast::NetworkService.stub(:is_network_manager) { false } + allow(Yast::Arch).to receive(:is_laptop) { true } + allow(Yast::NetworkService).to receive(:is_network_manager) { false } end it "results to #{expected_startmode} when not running on laptop" do @@ -77,7 +77,7 @@ # check for virtual device type is done via Builtins.contains. I don't # want to stub it because it requires default stub value definition for # other calls of the function. It might have unexpected inpacts. - Yast::LanItems.stub(:type) { "bond" } + allow(Yast::LanItems).to receive(:type) { "bond" } result = Yast::LanItems.new_device_startmode expect(result).to be_eql expected_startmode diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-network-3.1.113/test/routing_test.rb new/yast2-network-3.1.114/test/routing_test.rb --- old/yast2-network-3.1.113/test/routing_test.rb 2015-01-28 14:17:13.000000000 +0100 +++ new/yast2-network-3.1.114/test/routing_test.rb 2015-05-06 15:17:15.000000000 +0200 @@ -25,7 +25,7 @@ @value4 = forward_v4 ? "1" : "0" @value6 = forward_v6 ? "1" : "0" - SCR.stub(:Execute) { nil } + allow(SCR).to receive(:Execute) { nil } end def fw_independent_write_expects @@ -46,7 +46,7 @@ context "when Firewall is enabled" do before(:each) do - SuSEFirewall.stub(:IsEnabled) { true } + allow(SuSEFirewall).to receive(:IsEnabled) { true } end describe "#WriteIPForwarding" do @@ -65,12 +65,12 @@ context "when Firewall is disabled" do before(:each) do - SuSEFirewall.stub(:IsEnabled) { false } + allow(SuSEFirewall).to receive(:IsEnabled) { false } end describe "#WriteIPForwarding" do it "Updates IPv4 and IPv6 forwarding in sysctl.conf" do - SCR.stub(:Write) { nil } + allow(SCR).to receive(:Write) { nil } expect(SCR) .to receive(:Write) .with(SYSCTL_IPV4_PATH, @value4) @@ -113,7 +113,7 @@ Popup.as_null_object Yast.import "UI" - UI.stub(:QueryWidget) { "" } + allow(UI).to receive(:QueryWidget) { "" } expect(UI) .to receive(:QueryWidget) .with(Id(:forward_v4), :Value) { ipv4 } @@ -271,7 +271,7 @@ context "when ipv4.ip_forward=#{ipv4} and .ipv6.conf.all.forwarding=#{ipv6}" do before(:each) do - SCR.stub(:Read) { nil } + allow(SCR).to receive(:Read) { nil } expect(SCR) .to receive(:Read) .with(path(".routes")) { MOCKED_ROUTES }