Hello community, here is the log from the commit of package yast2-network for openSUSE:Factory checked in at 2016-09-08 17:38:13 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 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 2016-08-31 00:01:52.000000000 +0200 +++ /work/SRC/openSUSE:Factory/.yast2-network.new/yast2-network.changes 2016-09-08 17:38:15.000000000 +0200 @@ -1,0 +2,8 @@ +Sat Sep 3 20:02:55 UTC 2016 - mfi...@suse.com + +- bnc#988157 + - disable DHCP autoconfiguration in installer when an interface + configuration is provided via linuxrc +- 3.1.169 + +------------------------------------------------------------------- Old: ---- yast2-network-3.1.168.tar.bz2 New: ---- yast2-network-3.1.169.tar.bz2 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ yast2-network.spec ++++++ --- /var/tmp/diff_new_pack.ppZDTO/_old 2016-09-08 17:38:16.000000000 +0200 +++ /var/tmp/diff_new_pack.ppZDTO/_new 2016-09-08 17:38:16.000000000 +0200 @@ -17,7 +17,7 @@ Name: yast2-network -Version: 3.1.168 +Version: 3.1.169 Release: 0 BuildRoot: %{_tmppath}/%{name}-%{version}-build ++++++ yast2-network-3.1.168.tar.bz2 -> yast2-network-3.1.169.tar.bz2 ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-network-3.1.168/package/yast2-network.changes new/yast2-network-3.1.169/package/yast2-network.changes --- old/yast2-network-3.1.168/package/yast2-network.changes 2016-08-25 16:43:51.000000000 +0200 +++ new/yast2-network-3.1.169/package/yast2-network.changes 2016-09-06 10:01:22.000000000 +0200 @@ -1,4 +1,12 @@ ------------------------------------------------------------------- +Sat Sep 3 20:02:55 UTC 2016 - mfi...@suse.com + +- bnc#988157 + - disable DHCP autoconfiguration in installer when an interface + configuration is provided via linuxrc +- 3.1.169 + +------------------------------------------------------------------- Wed Aug 24 10:54:55 UTC 2016 - mfi...@suse.com - bnc#993587 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-network-3.1.168/package/yast2-network.spec new/yast2-network-3.1.169/package/yast2-network.spec --- old/yast2-network-3.1.168/package/yast2-network.spec 2016-08-25 16:43:51.000000000 +0200 +++ new/yast2-network-3.1.169/package/yast2-network.spec 2016-09-06 10:01:22.000000000 +0200 @@ -17,7 +17,7 @@ Name: yast2-network -Version: 3.1.168 +Version: 3.1.169 Release: 0 BuildRoot: %{_tmppath}/%{name}-%{version}-build diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-network-3.1.168/src/clients/inst_setup_dhcp.rb new/yast2-network-3.1.169/src/clients/inst_setup_dhcp.rb --- old/yast2-network-3.1.168/src/clients/inst_setup_dhcp.rb 2016-08-25 16:43:51.000000000 +0200 +++ new/yast2-network-3.1.169/src/clients/inst_setup_dhcp.rb 2016-09-06 10:01:22.000000000 +0200 @@ -1,12 +1,24 @@ require "yast" require "network/network_autoconfiguration" -def main - Yast::NetworkAutoconfiguration.instance.configure_dhcp +module Yast + class SetupDhcp + include Singleton + include Logger - # if this is not wrapped in a def, ruby -cw says - # warning: possibly useless use of a literal in void context - :next + def main + nac = Yast::NetworkAutoconfiguration.instance + if !nac.any_iface_active? + nac.configure_dhcp + else + log.info("Automatic DHCP configuration not started - an interface is already configured") + end + + # if this is not wrapped in a def, ruby -cw says + # warning: possibly useless use of a literal in void context + :next + end + end end -main +Yast::SetupDhcp.instance.main diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-network-3.1.168/src/include/network/devices.rb new/yast2-network-3.1.169/src/include/network/devices.rb --- old/yast2-network-3.1.168/src/include/network/devices.rb 2016-08-25 16:43:51.000000000 +0200 +++ new/yast2-network-3.1.169/src/include/network/devices.rb 2016-09-06 10:01:22.000000000 +0200 @@ -88,51 +88,5 @@ Builtins.y2debug("Free device=%1", ret) ret end - - # Update Devices map - # @param [String] type device type - # @param [String] device device number - # @param [Hash] newdev new device map - # @param [Boolean] check if check if device already exists - # @return true if success - def ChangeDevice(type, device, newdev, check) - newdev = deep_copy(newdev) - Builtins.y2debug("ChangeDevice(%1,%2,%3,%4)", type, device, newdev, check) - Builtins.y2debug("Devices=%1", @Devices) - devmap = Ops.get(@Devices, type, {}) - dev = Builtins.sformat("%1", device) - - if check && Builtins.haskey(devmap, dev) - Builtins.y2error("Key already present: %1(%2)", dev, type) - return false - end - Ops.set(devmap, dev, newdev) - Ops.set(@Devices, type, devmap) - Builtins.y2debug("Devices=%1", @Devices) - true - end - - # Delete a device from Devices map - # @param [String] type device type - # @param [String] dev device number - # @return true if success - def DeleteDevice(type, dev) - Builtins.y2debug("Devices=%1", @Devices) - Builtins.y2debug("DeletedDevices=%1", @DeletedDevices) - - devmap = Ops.get(@Devices, type, {}) - if !Builtins.haskey(devmap, dev) - Builtins.y2error("Key not found: %1(%2)", dev, type) - return false - end - # remove(devmap, dev); - devmap = Builtins.remove(devmap, dev) - Ops.set(@Devices, type, devmap) - @DeletedDevices = Builtins.add(@DeletedDevices, dev) - - Builtins.y2debug("Devices=%1", @Devices) - Builtins.y2debug("DeletedDevices=%1", @DeletedDevices) - true - end end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-network-3.1.168/src/lib/network/network_autoconfiguration.rb new/yast2-network-3.1.169/src/lib/network/network_autoconfiguration.rb --- old/yast2-network-3.1.168/src/lib/network/network_autoconfiguration.rb 2016-08-25 16:43:51.000000000 +0200 +++ new/yast2-network-3.1.169/src/lib/network/network_autoconfiguration.rb 2016-09-06 10:01:22.000000000 +0200 @@ -19,6 +19,13 @@ Yast.import "Arch" Yast.import "Host" + # Checks if any of available interfaces is configured and active + # + # returns [Boolean] true when at least one interface is active + def any_iface_active? + network_cards.any? { |c| configured?(c) && active_config?(c) } + end + def configure_dhcp Yast.include self, "network/routines.rb" @@ -176,7 +183,7 @@ # 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 + SCR.Execute(BASH_PATH, wicked_query).zero? end # Returns list of servers used for internet reachability test diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-network-3.1.168/test/Makefile.am new/yast2-network-3.1.169/test/Makefile.am --- old/yast2-network-3.1.168/test/Makefile.am 2016-08-25 16:43:51.000000000 +0200 +++ new/yast2-network-3.1.169/test/Makefile.am 2016-09-06 10:01:23.000000000 +0200 @@ -12,6 +12,7 @@ hardware_test.rb \ host_test.rb \ ifroute_test.rb \ + inst_setup_dhcp_test.rb \ install_inf_convertor_test.rb \ lan_items_export_test.rb \ lan_items_helpers_test.rb \ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-network-3.1.168/test/inst_setup_dhcp_test.rb new/yast2-network-3.1.169/test/inst_setup_dhcp_test.rb --- old/yast2-network-3.1.168/test/inst_setup_dhcp_test.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/yast2-network-3.1.169/test/inst_setup_dhcp_test.rb 2016-09-06 10:01:23.000000000 +0200 @@ -0,0 +1,27 @@ +#!/usr/bin/env rspec + +require_relative "test_helper" + +require "yast" +require "network/network_autoconfiguration" +require_relative "../src/clients/inst_setup_dhcp" + +describe Yast::SetupDhcp do + describe "#main" do + it "returns :next when autoconfiguration is performed" do + allow(Yast::NetworkAutoconfiguration) + .to receive(:any_iface_active?) + .and_return(true) + + expect(Yast::SetupDhcp.instance.main).to eql :next + end + + it "returns :next when autoconfiguration is not performed" do + allow(Yast::NetworkAutoconfiguration) + .to receive(:any_iface_active?) + .and_return(false) + + expect(Yast::SetupDhcp.instance.main).to eql :next + end + end +end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-network-3.1.168/test/network_autoconfiguration_test.rb new/yast2-network-3.1.169/test/network_autoconfiguration_test.rb --- old/yast2-network-3.1.168/test/network_autoconfiguration_test.rb 2016-08-25 16:43:51.000000000 +0200 +++ new/yast2-network-3.1.169/test/network_autoconfiguration_test.rb 2016-09-06 10:01:23.000000000 +0200 @@ -44,110 +44,136 @@ end describe Yast::NetworkAutoconfiguration do - let(:instance) { Yast::NetworkAutoconfiguration.instance } - let(:network_interfaces) { double("NetworkInterfaces") } + describe "it sets DHCLIENT_SET_DEFAULT_ROUTE properly" do + let(:instance) { Yast::NetworkAutoconfiguration.instance } + let(:network_interfaces) { double("NetworkInterfaces") } + + before(:each) do + ifcfg_files = SectionKeyValue.new + + # network configs + allow(Yast::SCR).to receive(:Dir) do |path| + case path.to_s + when ".network.section" + ifcfg_files.sections + when /^\.network\.value\."(eth\d+)"$/ + ifcfg_files.keys(Regexp.last_match(1)) + when ".modules.options", ".etc.install_inf" + [] + else + raise "Unexpected Dir #{path}" + end + end - before(:each) do - ifcfg_files = SectionKeyValue.new + allow(Yast::SCR).to receive(:Read) do |path| + if path.to_s =~ /^\.network\.value\."(eth\d+)".(.*)/ + next ifcfg_files.get(Regexp.last_match(1), Regexp.last_match(2)) + end - # network configs - allow(Yast::SCR).to receive(:Dir) do |path| - case path.to_s - when ".network.section" - ifcfg_files.sections - when /^\.network\.value\."(eth\d+)"$/ - ifcfg_files.keys(Regexp.last_match(1)) - when ".modules.options", ".etc.install_inf" - [] - else - raise "Unexpected Dir #{path}" + raise "Unexpected Read #{path}" end - end - allow(Yast::SCR).to receive(:Read) do |path| - if path.to_s =~ /^\.network\.value\."(eth\d+)".(.*)/ - next ifcfg_files.get(Regexp.last_match(1), Regexp.last_match(2)) + allow(Yast::SCR).to receive(:Write) do |path, value| + if path.to_s =~ /^\.network\.value\."(eth\d+)".(.*)/ + ifcfg_files.set(Regexp.last_match(1), Regexp.last_match(2), value) + elsif path.to_s == ".network" && value.nil? + true + else + raise "Unexpected Write #{path}, #{value}" + end end - raise "Unexpected Read #{path}" + # stub NetworkInterfaces, apart from the ifcfgs + allow(Yast::NetworkInterfaces) + .to receive(:CleanHotplugSymlink) + allow(Yast::NetworkInterfaces) + .to receive(:GetTypeFromSysfs). with(/eth\d+/). and_return "eth" + allow(Yast::NetworkInterfaces) + .to receive(:GetType). with(/eth\d+/). and_return "eth" + allow(Yast::NetworkInterfaces) + .to receive(:GetType). with(""). and_return nil + Yast::NetworkInterfaces.instance_variable_set(:@initialized, false) + + # stub program execution + # - interfaces are up + allow(Yast::SCR) + .to receive(:Execute) + .with(path(".target.bash"), /^wicked ifstatus/) + .and_return 0 + # - reload works + allow(Yast::SCR) + .to receive(:Execute) + .with(path(".target.bash"), /^wicked ifreload/) + .and_return 0 + # - ping works + allow(Yast::SCR) + .to receive(:Execute) + .with(path(".target.bash"), /^ping/) + .and_return 0 + + # These "expect" should be "allow", but then it does not work out, + # because SCR multiplexes too much and the matchers get confused. + + # Hardware detection + expect(Yast::SCR) + .to receive(:Read) + .with(path(".probe.netcard")) + .and_return([probe_netcard_factory(0), probe_netcard_factory(1)]) + + # link status + expect(Yast::SCR) + .to receive(:Read) + .with(path(".target.string"), %r{/sys/class/net/.*/carrier}) + .twice + .and_return "1" + + # miscellaneous uninteresting but hard to avoid stuff + + allow(Yast::Arch).to receive(:architecture).and_return "x86_64" + allow(Yast::Confirm).to receive(:Detection).and_return true + expect(Yast::SCR) + .to receive(:Read) + .with(path(".etc.install_inf.BrokenModules")) + .and_return "" + expect(Yast::SCR) + .to receive(:Read) + .with(path(".udev_persistent.net")) + .and_return({}) + expect(Yast::SCR) + .to receive(:Read) + .with(path(".udev_persistent.drivers")) + .and_return({}) end - allow(Yast::SCR).to receive(:Write) do |path, value| - if path.to_s =~ /^\.network\.value\."(eth\d+)".(.*)/ - ifcfg_files.set(Regexp.last_match(1), Regexp.last_match(2), value) - elsif path.to_s == ".network" && value.nil? - true - else - raise "Unexpected Write #{path}, #{value}" - end + it "configures just one NIC to have a default route" do + expect { instance.configure_dhcp }.to_not raise_error + result = Yast::NetworkInterfaces.FilterDevices("") + expect(result["eth"]["eth0"]["DHCLIENT_SET_DEFAULT_ROUTE"]).to eq "yes" + expect(result["eth"]["eth1"]["DHCLIENT_SET_DEFAULT_ROUTE"]).to eq nil end - - # stub NetworkInterfaces, apart from the ifcfgs - allow(Yast::NetworkInterfaces) - .to receive(:CleanHotplugSymlink) - allow(Yast::NetworkInterfaces) - .to receive(:GetTypeFromSysfs). with(/eth\d+/). and_return "eth" - allow(Yast::NetworkInterfaces) - .to receive(:GetType). with(/eth\d+/). and_return "eth" - allow(Yast::NetworkInterfaces) - .to receive(:GetType). with(""). and_return nil - Yast::NetworkInterfaces.instance_variable_set(:@initialized, false) - - # stub program execution - # - interfaces are up - allow(Yast::SCR) - .to receive(:Execute) - .with(path(".target.bash"), /^wicked ifstatus/) - .and_return 0 - # - reload works - allow(Yast::SCR) - .to receive(:Execute) - .with(path(".target.bash"), /^wicked ifreload/) - .and_return 0 - # - ping works - allow(Yast::SCR) - .to receive(:Execute) - .with(path(".target.bash"), /^ping/) - .and_return 0 - - # These "expect" should be "allow", but then it does not work out, - # because SCR multiplexes too much and the matchers get confused. - - # Hardware detection - expect(Yast::SCR) - .to receive(:Read) - .with(path(".probe.netcard")) - .and_return([probe_netcard_factory(0), probe_netcard_factory(1)]) - - # link status - expect(Yast::SCR) - .to receive(:Read) - .with(path(".target.string"), %r{/sys/class/net/.*/carrier}) - .twice - .and_return "1" - - # miscellaneous uninteresting but hard to avoid stuff - - allow(Yast::Arch).to receive(:architecture).and_return "x86_64" - allow(Yast::Confirm).to receive(:Detection).and_return true - expect(Yast::SCR) - .to receive(:Read) - .with(path(".etc.install_inf.BrokenModules")) - .and_return "" - expect(Yast::SCR) - .to receive(:Read) - .with(path(".udev_persistent.net")) - .and_return({}) - expect(Yast::SCR) - .to receive(:Read) - .with(path(".udev_persistent.drivers")) - .and_return({}) end - it "configures just one NIC to have a default route" do - expect { instance.configure_dhcp }.to_not raise_error - result = Yast::NetworkInterfaces.FilterDevices("") - expect(result["eth"]["eth0"]["DHCLIENT_SET_DEFAULT_ROUTE"]).to eq "yes" - expect(result["eth"]["eth1"]["DHCLIENT_SET_DEFAULT_ROUTE"]).to eq nil + describe "#any_iface_active?" do + IFACE = "eth0".freeze + + let(:instance) { Yast::NetworkAutoconfiguration.instance } + + it "returns true if any of available interfaces has configuration and is up" do + allow(Yast::LanItems) + .to receive(:Read) + .and_return(true) + allow(Yast::LanItems) + .to receive(:GetNetcardNames) + .and_return([IFACE, "enp0s3", "br7"]) + allow(Yast::NetworkInterfaces) + .to receive(:Check) + .with(IFACE) + .and_return(true) + allow(Yast::SCR) + .to receive(:Execute) + .and_return(0) + + expect(instance.any_iface_active?).to be true + end end end