Hello community, here is the log from the commit of package yast2-network for openSUSE:Factory checked in at 2019-01-05 14:40:37 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/yast2-network (Old) and /work/SRC/openSUSE:Factory/.yast2-network.new.28833 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Package is "yast2-network" Sat Jan 5 14:40:37 2019 rev:397 rq:662768 version:4.1.27 Changes: -------- --- /work/SRC/openSUSE:Factory/yast2-network/yast2-network.changes 2018-12-31 09:44:50.174292918 +0100 +++ /work/SRC/openSUSE:Factory/.yast2-network.new.28833/yast2-network.changes 2019-01-05 14:40:38.956567289 +0100 @@ -1,0 +2,13 @@ +Fri Jan 4 09:46:06 UTC 2019 - mfilka@suse.com + +- bnc#1116568 + - /etc/hosts load performance improvements +- 4.1.27 + +------------------------------------------------------------------- +Wed Jan 2 17:17:58 CET 2019 - schubi@suse.de + +- Showing correct start mode for nfsroot device (bsc#1105692). +- 4.1.26 + +------------------------------------------------------------------- Old: ---- yast2-network-4.1.25.tar.bz2 New: ---- yast2-network-4.1.27.tar.bz2 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ yast2-network.spec ++++++ --- /var/tmp/diff_new_pack.YsjQAV/_old 2019-01-05 14:40:39.492566834 +0100 +++ /var/tmp/diff_new_pack.YsjQAV/_new 2019-01-05 14:40:39.496566831 +0100 @@ -1,7 +1,7 @@ # # spec file for package yast2-network # -# Copyright (c) 2018 SUSE LINUX GmbH, Nuernberg, Germany. +# Copyright (c) 2019 SUSE LINUX GmbH, Nuernberg, Germany. # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -17,7 +17,7 @@ Name: yast2-network -Version: 4.1.25 +Version: 4.1.27 Release: 0 BuildArch: noarch ++++++ yast2-network-4.1.25.tar.bz2 -> yast2-network-4.1.27.tar.bz2 ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-network-4.1.25/package/yast2-network.changes new/yast2-network-4.1.27/package/yast2-network.changes --- old/yast2-network-4.1.25/package/yast2-network.changes 2018-12-19 10:54:51.000000000 +0100 +++ new/yast2-network-4.1.27/package/yast2-network.changes 2019-01-04 11:33:34.000000000 +0100 @@ -1,4 +1,17 @@ ------------------------------------------------------------------- +Fri Jan 4 09:46:06 UTC 2019 - mfilka@suse.com + +- bnc#1116568 + - /etc/hosts load performance improvements +- 4.1.27 + +------------------------------------------------------------------- +Wed Jan 2 17:17:58 CET 2019 - schubi@suse.de + +- Showing correct start mode for nfsroot device (bsc#1105692). +- 4.1.26 + +------------------------------------------------------------------- Tue Dec 18 12:49:47 UTC 2018 - mfilka@suse.com - bnc#1119723 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-network-4.1.25/package/yast2-network.spec new/yast2-network-4.1.27/package/yast2-network.spec --- old/yast2-network-4.1.25/package/yast2-network.spec 2018-12-19 10:54:51.000000000 +0100 +++ new/yast2-network-4.1.27/package/yast2-network.spec 2019-01-04 11:33:34.000000000 +0100 @@ -17,7 +17,7 @@ Name: yast2-network -Version: 4.1.25 +Version: 4.1.27 Release: 0 BuildArch: noarch diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-network-4.1.25/src/clients/host.rb new/yast2-network-4.1.27/src/clients/host.rb --- old/yast2-network-4.1.25/src/clients/host.rb 2018-12-19 10:54:51.000000000 +0100 +++ new/yast2-network-4.1.27/src/clients/host.rb 2019-01-04 11:33:34.000000000 +0100 @@ -96,12 +96,10 @@ # main ui function ret = HostsMainDialog(true) - Builtins.y2debug("ret == %1", ret) Host.Write if ret == :next && Host.GetModified UI.CloseDialog - deep_copy(ret) end # Handler for action "list" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-network-4.1.25/src/include/network/services/host.rb new/yast2-network-4.1.27/src/include/network/services/host.rb --- old/yast2-network-4.1.25/src/include/network/services/host.rb 2018-12-19 10:54:51.000000000 +0100 +++ new/yast2-network-4.1.27/src/include/network/services/host.rb 2019-01-04 11:33:34.000000000 +0100 @@ -30,6 +30,8 @@ # Hosts configuration dialogs module Yast module NetworkServicesHostInclude + include Logger + def initialize_network_services_host(include_target) Yast.import "UI" @@ -81,33 +83,27 @@ "<p>Enter a host <b>IP Address</b>, a <b>Hostname</b>, and optional\n<b>Host Aliases</b>, separated by spaces.</p>\n" ) - max = 0 table_items = [] deleted_items = [] hosts = Host.name_map - Builtins.y2debug("hosts=%1", hosts) - # make ui items from the hosts list - Builtins.maplist(hosts) do |host, names| - if Ops.less_than(Builtins.size(names), 1) - Builtins.y2error("Invalid host: %1, (%2)", host, names) + hosts.each do |host, names| + if names.empty? + log.error("Invalid host: %1, (%2)", host, names) next end - Builtins.foreach(names) do |s| - name = Builtins.regexpsub(s, "^([^ \t]+)[ \t]*.*$", "\\1") - aliases = Builtins.regexpsub(s, "^[^ \t]+[ \t]*(.*)[ \t]*$", "\\1") - item = Item( - Id(Builtins.size(table_items)), - host, - Punycode.DecodeDomainName(name), - Ops.get(Punycode.DecodePunycodes([aliases]), 0, "") - ) - table_items = Builtins.add(table_items, item) - end + + name, *aliases = names.first.split(/\s/).delete_if(&:empty?) + + item = Item( + Id(table_items.size), + host, + Punycode.DecodeDomainName(name), + Punycode.DecodePunycodes([aliases.join(" ")]).first || "" + ) + table_items.push(item) end - Builtins.y2debug("table_items=%1", table_items) - max = Builtins.size(table_items) # Hosts dialog contents contents = HBox( @@ -175,37 +171,31 @@ end UI.ChangeWidget(Id(:table), :Items, table_items) - UI.SetFocus(Id(:table)) if Ops.greater_than(Builtins.size(table_items), 0) + UI.SetFocus(Id(:table)) if table_items.any? ret = nil - loop do - UI.ChangeWidget( - Id(:edit), - :Enabled, - Ops.greater_than(Builtins.size(table_items), 0) - ) - UI.ChangeWidget( - Id(:delete), - :Enabled, - Ops.greater_than(Builtins.size(table_items), 0) - ) + modified = false + until [:abort, :cancel, :back, :next].include?(ret) + UI.ChangeWidget(Id(:edit), :Enabled, table_items.any?) + UI.ChangeWidget(Id(:delete), :Enabled, table_items.any?) ret = UI.UserInput - Builtins.y2debug("ret=%1", ret) # abort? if ret == :abort || ret == :cancel - ReallyAbortCond(Host.GetModified) ? break : next + ret = nil if !ReallyAbortCond(modified) # add host elsif ret == :add - item = HostDialog(max, term(:empty)) + new_item_position = table_items.size + item = HostDialog(new_item_position, term(:empty)) + next if item.nil? - table_items = Builtins.add(table_items, item) + + table_items.push(item) + UI.ChangeWidget(Id(:table), :Items, table_items) - UI.ChangeWidget(Id(:table), :CurrentItem, max) - max = Ops.add(max, 1) - Host.SetModified - next + UI.ChangeWidget(Id(:table), :CurrentItem, new_item_position) + modified = true # edit host elsif ret == :edit || ret == :table cur = Convert.to_integer(UI.QueryWidget(Id(:table), :CurrentItem)) @@ -213,9 +203,6 @@ cur == Ops.get(e, [0, 0]) end - Builtins.y2debug("cur=%1", cur) - Builtins.y2debug("cur_item=%1", cur_item) - olditem = Ops.get(cur_item, 0) next if !HostSystemPopup(Ops.get_string(olditem, 1, ""), false) @@ -225,15 +212,6 @@ table_items = Builtins.maplist(table_items) do |e| if cur == Ops.get_integer(e, [0, 0], -1) - oldentry = Builtins.mergestring( - [Ops.get_string(olditem, 2, ""), Ops.get_string(olditem, 3, "")], - " " - ) - - Builtins.y2debug("item: %1", item) - Builtins.y2debug("olditem: %1", olditem) - Builtins.y2debug("oldentry: %1", oldentry) - ip = Ops.get_string(item, 1, "") oldip = Ops.get_string(olditem, 1, "") @@ -246,8 +224,7 @@ end UI.ChangeWidget(Id(:table), :Items, table_items) UI.ChangeWidget(Id(:table), :CurrentItem, cur) - Host.SetModified - next + modified = true # delete host elsif ret == :delete cur = Convert.to_integer(UI.QueryWidget(Id(:table), :CurrentItem)) @@ -255,9 +232,6 @@ cur == Ops.get(e, [0, 0]) end - Builtins.y2debug("cur=%1", cur) - Builtins.y2debug("cur_item=%1", cur_item) - item = Ops.get(cur_item, 0) next if !HostSystemPopup(Ops.get_string(item, 1, ""), true) @@ -273,44 +247,32 @@ true end UI.ChangeWidget(Id(:table), :Items, table_items) - Host.SetModified - next - elsif ret == :back - break + modified = true elsif ret == :next # check_ - if Host.GetModified - Host.clear - Builtins.foreach(table_items) do |row| - value = Builtins.mergestring( - Builtins.prepend( - Punycode.EncodePunycodes([Ops.get_string(row, 3, "")]), - Punycode.EncodeDomainName(Ops.get_string(row, 2, "")) - ), - " " - ) - key = Ops.get_string(row, 1, "") - Host.add_name(key, value) - end + next if !modified + Host.clear + + table_items.each do |row| + encoded_aliases = Punycode.EncodePunycodes([row.fetch(3, "")]) + encoded_canonical = Punycode.EncodeDomainName(row.fetch(2, "")) + value = encoded_canonical + " " + encoded_aliases.join(" ") + key = row.fetch(1, "") + + Host.add_name(key, value) end - break else - Builtins.y2error("unexpected retcode: %1", ret) - next + log.error("unexpected retcode: %1", ret) end end - Builtins.y2debug("table_items=%1", table_items) - Builtins.y2debug("hosts=%1", hosts) - - Convert.to_symbol(ret) + ret end def HostDialog(id, entry) entry = deep_copy(entry) Builtins.y2debug("id=%1", id) Builtins.y2debug("entry=%1", entry) - # y2debug("forbidden=%1", forbidden); UI.OpenDialog( Opt(:decorated), @@ -346,9 +308,6 @@ ) UI.ChangeWidget(Id(:host), :ValidChars, IP.ValidChars) - # anything allowed here - will be converted to punycode (#448486) - # UI::ChangeWidget(`id(`name), `ValidChars, Hostname::ValidCharsFQ); - # UI::ChangeWidget(`id(`aliases), `ValidChars, Hostname::ValidCharsFQ + " "); if entry == term(:empty) UI.SetFocus(Id(:host)) @@ -360,7 +319,6 @@ host = nil loop do - host = nil ret = UI.UserInput break if ret != :ok @@ -412,8 +370,7 @@ UI.CloseDialog return nil if ret != :ok - Host.SetModified - deep_copy(host) + host end end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-network-4.1.25/src/lib/cfa/hosts.rb new/yast2-network-4.1.27/src/lib/cfa/hosts.rb --- old/yast2-network-4.1.25/src/lib/cfa/hosts.rb 2018-12-19 10:54:51.000000000 +0100 +++ new/yast2-network-4.1.27/src/lib/cfa/hosts.rb 2019-01-04 11:33:34.000000000 +0100 @@ -6,6 +6,17 @@ require "cfa/augeas_parser" module CFA + class AugeasTree + def initialize_clone(source) + # Cloning internal data representation + @data = source.data.map do |d| + nd = d.clone + nd[:value] = d[:value].clone if is_a? AugeasTree + nd + end + end + end + # class representings /etc/hosts file model. It provides helper to manipulate # with file. It uses CFA framework and Augeas parser. # @see http://www.rubydoc.info/github/config-files-api/config_files_api/CFA/BaseMod... @@ -18,6 +29,11 @@ super(AugeasParser.new("hosts.lns"), PATH, file_handler: file_handler) end + def initialize_clone(source) + # Cloning AugeasTree + @data = source.data.clone + end + # The old format used by {Yast::HostClass}. # @return [Hash{String => Array<String>}] keys are IPs, # values are lists of lines in /etc/hosts (not names!) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-network-4.1.25/src/modules/Host.rb new/yast2-network-4.1.27/src/modules/Host.rb --- old/yast2-network-4.1.25/src/modules/Host.rb 2018-12-19 10:54:51.000000000 +0100 +++ new/yast2-network-4.1.27/src/modules/Host.rb 2019-01-04 11:33:34.000000000 +0100 @@ -28,6 +28,8 @@ module Yast class HostClass < Module + include Logger + def main Yast.import "UI" textdomain "network" @@ -40,10 +42,6 @@ Yast.include self, "network/routines.rb" - # Data was modified? - # TODO: Drop the flag. It is useless since we have @hosts and @hosts_init - @modified = false - @initialized = false @hosts = CFA::Hosts.new @@ -54,7 +52,6 @@ @hosts.hosts.keys.each do |ip| @hosts.delete_by_ip(ip) end - @modified = true end # @return [hash] address->list of names @@ -77,8 +74,6 @@ def add_name(address, name) canonical, *aliases = name.split(" ") @hosts.add_entry(address, canonical, aliases) - - @modified = true end def NeedDummyIP @@ -95,13 +90,11 @@ fqhostname = Hostname.MergeFQ(DNS.hostname, DNS.domain) set_names(local_ip, ["#{fqhostname} #{DNS.hostname}"]) - @modified = true elsif @hosts.include_ip?(local_ip) # Do not add it if product default says no # and remove 127.0.02 entry if it exists @hosts.delete_by_ip(local_ip) - @modified = true end nil @@ -124,16 +117,11 @@ # Write hosts settings and apply changes # @return true if success def Write(gui: false) - Builtins.y2milestone("Writing hosts configuration") - - if !@modified - Builtins.y2milestone("No changes to Host -> nothing to write") - return true - end + log.info("Writing hosts configuration") # Check if there is anything to do - if @hosts_init == @hosts - Builtins.y2milestone("Hosts not modified") + if !GetModified() + log.info("No changes to Host -> nothing to write") return true end @@ -167,10 +155,9 @@ # expected format of settings["hosts"] is { "ip" => [list, of, names] } # @return true if success def Import(settings) - @modified = true # trigger Write @initialized = true # don't let Read discard our data - load_hosts + load_hosts(load_only: true) imported_hosts = settings.fetch("hosts", {}) @@ -228,8 +215,6 @@ log.info("Updating /etc/hosts: #{oldhn} -> #{newhn}: #{ip}") - @modified = true - # Remove old hostname from hosts @hosts.delete_hostname(oldhn) if !oldhn.empty? @@ -261,20 +246,16 @@ # Create summary # @return summary text def Summary - summary = "" return Summary.NotConfigured if @hosts.hosts.empty? - summary = Summary.OpenList(summary) + summary = Summary.OpenList("") @hosts.hosts.each do |k, v| - Builtins.foreach(v) do |hn| - summary = Summary.AddListItem(summary, Ops.add(Ops.add(k, " - "), hn)) - end if !Builtins.contains( - GetSystemHosts(), - k - ) + next if GetSystemHosts().include?(k) + # currently all names are placed as a one string in first array item + summary = Summary.AddListItem(summary, "#{k} - #{v.first}") end - summary = Summary.CloseList(summary) - summary + + Summary.CloseList(summary) end # Creates a list os static ips present in the system @@ -317,15 +298,7 @@ # Function which returns if the settings were modified # @return [Boolean] settings were modified def GetModified - @modified - end - - # Function sets internal variable, which indicates, that any - # settings were modified, to "true" - def SetModified - @modified = true - - nil + @hosts.hosts != @initial_hosts.hosts end publish function: :NeedDummyIP, type: "boolean ()" @@ -339,7 +312,6 @@ publish function: :Summary, type: "string ()" publish function: :ResolveHostnameToStaticIPs, type: "void ()" publish function: :GetModified, type: "boolean ()" - publish function: :SetModified, type: "void ()" private @@ -350,20 +322,22 @@ canonical, *aliases = name.split(" ") @hosts.add_entry(address, canonical, aliases) end - @modified = true end end # Initializes internal state according the /etc/hosts - def load_hosts + # + # @param load_only [Boolean] true if you want load data and do not need to + # detect changes later (@see Host::GetModified) + def load_hosts(load_only: false) return false if SCR.Read(path(".target.size"), CFA::Hosts::PATH) <= 0 @hosts = CFA::Hosts.new @hosts.load # save hosts to check for changes later - @hosts_init = CFA::Hosts.new - @hosts_init.load + @initial_hosts = nil + @initial_hosts = @hosts.clone if !load_only true @@ -374,7 +348,7 @@ # get clean environment, crashing due to exception is no option here @hosts = CFA::Hosts.new - @hosts_init = nil + @initial_hosts = nil # reraise the exception - let the gui takes care of it raise diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-network-4.1.25/src/modules/LanItems.rb new/yast2-network-4.1.27/src/modules/LanItems.rb --- old/yast2-network-4.1.25/src/modules/LanItems.rb 2018-12-19 10:54:51.000000000 +0100 +++ new/yast2-network-4.1.27/src/modules/LanItems.rb 2019-01-04 11:33:34.000000000 +0100 @@ -1384,6 +1384,10 @@ "hotplug" => _( "Started automatically at boot" ), + # summary description of STARTMODE=nfsroot + "nfsroot" => _( + "Started automatically at boot" + ), # summary description of STARTMODE=ifplugd "ifplugd" => _( "Started automatically on cable connection" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-network-4.1.25/test/build_lan_overview_test.rb new/yast2-network-4.1.27/test/build_lan_overview_test.rb --- old/yast2-network-4.1.25/test/build_lan_overview_test.rb 2018-12-19 10:54:51.000000000 +0100 +++ new/yast2-network-4.1.27/test/build_lan_overview_test.rb 2019-01-04 11:33:34.000000000 +0100 @@ -33,42 +33,95 @@ "WIRELESS_KEY_0" => "" } end + let(:lan_items) do + { + 0 => { "hwinfo" => { + "name" => "Ethernet Card 0", + "type" => "eth", + "udi" => "", + "sysfs_id" => "/devices/pci0000:00/0000:00:03.0/virtio0", + "dev_name" => "eth0", + "requires" => [], + "modalias" => "virtio:d00000001v00001AF4", + "unique" => "vWuh.VIRhsc57kTD", + "driver" => "virtio_net", + "num" => 0, + "active" => true, + "module" => "virtio_net", + "bus" => "Virtio", + "busid" => "virtio0", + "mac" => "02:00:00:12:34:56", + "link" => true + }, + "udev" => { + "net" => ["SUBSYSTEM==\"net\"", "ACTION==\"add\"", "DRIVERS==\"virtio-pci\"", + "ATTR{dev_id}==\"0x0\"", "KERNELS==\"0000:00:03.0\"", + "ATTR{type}==\"1\"", "KERNEL==\"eth*\"", "NAME=\"eth0\""], + "driver" => "" + }, + "ifcfg" => "eth0" } + } + end + let(:lan_ifcfg) do + { "STARTMODE" => "nfsroot", + "BOOTPROTO" => "dhcp", + "DHCLIENT_SET_DEFAULT_ROUTE" => "yes" } + end # targeted mainly against bnc#906694 - it "returns translated network device textual description for wlan device" do - allow(Yast::LanItems) - .to receive(:Items) - .and_return(wlan_items) - allow(Yast::LanItems) - .to receive(:GetDeviceMap) - .and_return(wlan_ifcfg) - allow(Yast::NetworkInterfaces) - .to receive(:Current) - .and_return(wlan_ifcfg) - allow(Yast::NetworkInterfaces) - .to receive(:GetType) - .and_call_original - allow(Yast::NetworkInterfaces) - .to receive(:GetType) - .with("wlan0") - .and_return("wlan") - allow(FastGettext) - .to receive(:locale) - .and_return("de") - - # locale search path - stub_const("Yast::I18n::LOCALE_DIR", File.expand_path("../locale", __FILE__)) - - textdomain("network") - - # other checks depends on this - # - output of BuildLanOverview changes according number of devices - # even for "failing" (unknown devices) path - expect(Yast::LanItems.Items.size).to eql 1 - - overview = Yast::LanItems.BuildLanOverview - expect(overview).not_to eql unknown_device_overview - expect(overview).to eql german_translation_overview + context "with an wlan interface" do + before do + allow(Yast::LanItems) + .to receive(:Items) + .and_return(wlan_items) + allow(Yast::LanItems) + .to receive(:GetDeviceMap) + .and_return(wlan_ifcfg) + allow(Yast::NetworkInterfaces) + .to receive(:Current) + .and_return(wlan_ifcfg) + allow(Yast::NetworkInterfaces) + .to receive(:GetType) + .and_call_original + allow(Yast::NetworkInterfaces) + .to receive(:GetType) + .with("wlan0") + .and_return("wlan") + allow(FastGettext) + .to receive(:locale) + .and_return("de") + end + it "returns translated network device textual description for wlan device" do + # locale search path + stub_const("Yast::I18n::LOCALE_DIR", File.expand_path("../locale", __FILE__)) + + textdomain("network") + + # other checks depends on this + # - output of BuildLanOverview changes according number of devices + # even for "failing" (unknown devices) path + expect(Yast::LanItems.Items.size).to eql 1 + + overview = Yast::LanItems.BuildLanOverview + expect(overview).not_to eql unknown_device_overview + expect(overview).to eql german_translation_overview + end + end + + context "with an lan interface" do + before do + allow(Yast::LanItems).to receive(:Items) + .and_return(lan_items) + allow(Yast::LanItems).to receive(:GetDeviceMap) + .and_return(lan_ifcfg) + allow(Yast::NetworkInterfaces).to receive(:Current) + .and_return(lan_ifcfg) + end + it "returns description for lan device with the correct start option" do + Yast::LanItems.BuildLanOverview + expect(Yast::LanItems.Items.size).to eql 1 + expect(Yast::LanItems.Items[0]["table_descr"]["rich_descr"].include?("Started automatically at boot")).to eql(true) + end end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-network-4.1.25/test/host_test.rb new/yast2-network-4.1.27/test/host_test.rb --- old/yast2-network-4.1.25/test/host_test.rb 2018-12-19 10:54:51.000000000 +0100 +++ new/yast2-network-4.1.27/test/host_test.rb 2019-01-04 11:33:34.000000000 +0100 @@ -374,9 +374,12 @@ CFA::MemoryFile.new(File.read(file_path)) end - it "does not set Host as modified" do + before do allow(Yast::DNS).to receive(:write_hostname).and_return(false) + Yast::Host.Read + end + it "does not set Host as modified" do expect { Yast::Host.EnsureHostnameResolvable } .not_to change { Yast::Host.GetModified }.from(false) end