From 7db5cbaabcc80351cb9762630a891a8cd2ca9f0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Imobach=20Gonz=C3=A1lez=20Sosa?= Date: Thu, 4 Mar 2021 15:33:18 +0000 Subject: [PATCH 1/2] Do not propose 'nfsroot' when running in installation --- src/lib/y2network/connection_config/base.rb | 17 ++++-- test/support/connection_config_examples.rb | 59 +++++++++++++++++++ .../connection_config/bonding_test.rb | 1 + test/y2network/connection_config/ctc_test.rb | 3 + .../y2network/connection_config/dummy_test.rb | 3 + .../connection_config/ethernet_test.rb | 3 + test/y2network/connection_config/hsi_test.rb | 4 ++ test/y2network/connection_config/lcs_test.rb | 4 ++ test/y2network/connection_config/qeth_test.rb | 4 ++ test/y2network/connection_config/tap_test.rb | 3 + test/y2network/connection_config/tun_test.rb | 3 + test/y2network/connection_config/usb_test.rb | 3 + test/y2network/connection_config/vlan_test.rb | 3 + .../connection_config/wireless_test.rb | 3 + 14 files changed, 109 insertions(+), 4 deletions(-) create mode 100644 test/support/connection_config_examples.rb diff --git a/src/lib/y2network/connection_config/base.rb b/src/lib/y2network/connection_config/base.rb index 7ef4bd5f4..0916a8a67 100644 --- a/src/lib/y2network/connection_config/base.rb +++ b/src/lib/y2network/connection_config/base.rb @@ -25,6 +25,8 @@ require "y2network/startmode" require "y2network/connection_config/ip_config" +Yast.import "Mode" + module Y2Network module ConnectionConfig # This class is reponsible of a connection configuration @@ -120,11 +122,10 @@ def propose def propose_startmode Yast.import "ProductFeatures" - # see bsc#176804 - devicegraph = Y2Storage::StorageManager.instance.staging - if devicegraph.filesystem_in_network?("/") - @startmode = Startmode.create("nfsroot") + + if root_filesystem_in_network? log.info "startmode nfsroot" + @startmode = Startmode.create("nfsroot") return end @@ -225,6 +226,14 @@ def hotplug_interface? false # TODO: interface is just string so interface.hardware.hotplug does not work end + + def root_filesystem_in_network? + return false unless Yast::Mode.normal + + # see bsc#176804 + devicegraph = Y2Storage::StorageManager.instance.staging + devicegraph.filesystem_in_network?("/") + end end end end diff --git a/test/support/connection_config_examples.rb b/test/support/connection_config_examples.rb new file mode 100644 index 000000000..45463e260 --- /dev/null +++ b/test/support/connection_config_examples.rb @@ -0,0 +1,59 @@ +# Copyright (c) [2021] SUSE LLC +# +# All Rights Reserved. +# +# This program is free software; you can redistribute it and/or modify it +# under the terms of version 2 of the GNU General Public License as published +# by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +# more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, contact SUSE LLC. +# +# To contact SUSE LLC about this file by physical or electronic mail, you may +# find current contact information at www.suse.com. + +RSpec.shared_examples "connection configuration" do + describe "#propose" do + context "startmode" do + let(:normal?) { true } + let(:root_in_network?) { false } + + let(:storage_manager) do + instance_double(Y2Storage::StorageManager, staging: devicegraph) + end + + let(:devicegraph) { instance_double(Y2Storage::Devicegraph) } + + before do + allow(Yast::Mode).to receive(:normal).and_return(normal?) + allow(Y2Storage::StorageManager).to receive(:instance) + .and_return(storage_manager) + allow(devicegraph).to receive(:filesystem_in_network?).with("/") + .and_return(root_in_network?) + end + + context "when root filesystem is on a network device" do + let(:root_in_network?) { true } + + it "is set to 'nfsroot'" do + subject.propose + expect(subject.startmode.to_s).to eq("nfsroot") + end + end + + context "when running on installation" do + let(:normal?) { false } + + it "does not check whether the root filesystem is on a network device" do + expect(storage_manager).to_not receive(:staging) + subject.propose + end + end + end + end +end diff --git a/test/y2network/connection_config/bonding_test.rb b/test/y2network/connection_config/bonding_test.rb index 3ee5e4d08..84baee2d7 100644 --- a/test/y2network/connection_config/bonding_test.rb +++ b/test/y2network/connection_config/bonding_test.rb @@ -18,6 +18,7 @@ # find current contact information at www.suse.com. require_relative "../../test_helper" +require_relative "../../support/connection_config_examples" require "y2network/connection_config/bonding" require "y2network/interface_type" diff --git a/test/y2network/connection_config/ctc_test.rb b/test/y2network/connection_config/ctc_test.rb index 67bac2757..dce214fb5 100644 --- a/test/y2network/connection_config/ctc_test.rb +++ b/test/y2network/connection_config/ctc_test.rb @@ -18,10 +18,13 @@ # find current contact information at www.suse.com. require_relative "../../test_helper" +require_relative "../../support/connection_config_examples" require "y2network/connection_config/ctc" require "y2network/interface_type" describe Y2Network::ConnectionConfig::Ctc do + include_examples "connection configuration" + describe "#type" do it "returns 'ctc'" do expect(subject.type).to eq(Y2Network::InterfaceType::CTC) diff --git a/test/y2network/connection_config/dummy_test.rb b/test/y2network/connection_config/dummy_test.rb index 211c1689f..c111bef8a 100644 --- a/test/y2network/connection_config/dummy_test.rb +++ b/test/y2network/connection_config/dummy_test.rb @@ -18,12 +18,15 @@ # find current contact information at www.suse.com. require_relative "../../test_helper" +require_relative "../../support/connection_config_examples" require "y2network/connection_config/dummy" require "y2network/interface_type" describe Y2Network::ConnectionConfig::Dummy do subject(:config) { described_class.new } + include_examples "connection configuration" + describe "#type" do it "returns 'dummy'" do expect(config.type).to eq(Y2Network::InterfaceType::DUMMY) diff --git a/test/y2network/connection_config/ethernet_test.rb b/test/y2network/connection_config/ethernet_test.rb index a66aedfef..6b90e07b0 100644 --- a/test/y2network/connection_config/ethernet_test.rb +++ b/test/y2network/connection_config/ethernet_test.rb @@ -18,12 +18,15 @@ # find current contact information at www.suse.com. require_relative "../../test_helper" +require_relative "../../support/connection_config_examples" require "y2network/connection_config/ethernet" require "y2network/interface_type" describe Y2Network::ConnectionConfig::Ethernet do subject(:config) { described_class.new } + include_examples "connection configuration" + describe "#type" do it "returns 'ethernet'" do expect(config.type).to eq(Y2Network::InterfaceType::ETHERNET) diff --git a/test/y2network/connection_config/hsi_test.rb b/test/y2network/connection_config/hsi_test.rb index bee5b6a7d..0ccba8e3d 100644 --- a/test/y2network/connection_config/hsi_test.rb +++ b/test/y2network/connection_config/hsi_test.rb @@ -18,10 +18,14 @@ # find current contact information at www.suse.com. require_relative "../../test_helper" +require_relative "../../support/connection_config_examples" require "y2network/connection_config/hsi" require "y2network/interface_type" describe Y2Network::ConnectionConfig::Hsi do + + include_examples "connection configuration" + describe "#type" do it "returns 'hsi'" do expect(subject.type).to eq(Y2Network::InterfaceType::HSI) diff --git a/test/y2network/connection_config/lcs_test.rb b/test/y2network/connection_config/lcs_test.rb index b72d94210..05d50fe3d 100644 --- a/test/y2network/connection_config/lcs_test.rb +++ b/test/y2network/connection_config/lcs_test.rb @@ -18,10 +18,14 @@ # find current contact information at www.suse.com. require_relative "../../test_helper" +require_relative "../../support/connection_config_examples" require "y2network/connection_config/lcs" require "y2network/interface_type" describe Y2Network::ConnectionConfig::Lcs do + + include_examples "connection configuration" + describe "#type" do it "returns 'lcs'" do expect(subject.type).to eq(Y2Network::InterfaceType::LCS) diff --git a/test/y2network/connection_config/qeth_test.rb b/test/y2network/connection_config/qeth_test.rb index ff60b2572..ebb70be6a 100644 --- a/test/y2network/connection_config/qeth_test.rb +++ b/test/y2network/connection_config/qeth_test.rb @@ -18,10 +18,14 @@ # find current contact information at www.suse.com. require_relative "../../test_helper" +require_relative "../../support/connection_config_examples" require "y2network/connection_config/qeth" require "y2network/interface_type" describe Y2Network::ConnectionConfig::Qeth do + + include_examples "connection configuration" + describe "#type" do it "returns 'qeth'" do expect(subject.type).to eq(Y2Network::InterfaceType::QETH) diff --git a/test/y2network/connection_config/tap_test.rb b/test/y2network/connection_config/tap_test.rb index a74906d1a..fc519210f 100644 --- a/test/y2network/connection_config/tap_test.rb +++ b/test/y2network/connection_config/tap_test.rb @@ -18,12 +18,15 @@ # find current contact information at www.suse.com. require_relative "../../test_helper" +require_relative "../../support/connection_config_examples" require "y2network/connection_config/tap" require "y2network/interface_type" describe Y2Network::ConnectionConfig::Tap do subject(:config) { described_class.new } + include_examples "connection configuration" + describe "#type" do it "returns 'tap'" do expect(config.type).to eq(Y2Network::InterfaceType::TAP) diff --git a/test/y2network/connection_config/tun_test.rb b/test/y2network/connection_config/tun_test.rb index cae6a49e1..1e3f180fe 100644 --- a/test/y2network/connection_config/tun_test.rb +++ b/test/y2network/connection_config/tun_test.rb @@ -18,12 +18,15 @@ # find current contact information at www.suse.com. require_relative "../../test_helper" +require_relative "../../support/connection_config_examples" require "y2network/connection_config/tun" require "y2network/interface_type" describe Y2Network::ConnectionConfig::Tun do subject(:config) { described_class.new } + include_examples "connection configuration" + describe "#type" do it "returns 'tun'" do expect(config.type).to eq(Y2Network::InterfaceType::TUN) diff --git a/test/y2network/connection_config/usb_test.rb b/test/y2network/connection_config/usb_test.rb index b095e6755..b9b9dbbfc 100644 --- a/test/y2network/connection_config/usb_test.rb +++ b/test/y2network/connection_config/usb_test.rb @@ -18,12 +18,15 @@ # find current contact information at www.suse.com. require_relative "../../test_helper" +require_relative "../../support/connection_config_examples" require "y2network/connection_config/usb" require "y2network/interface_type" describe Y2Network::ConnectionConfig::Usb do subject(:config) { described_class.new } + include_examples "connection configuration" + describe "#type" do it "returns 'usb'" do expect(config.type).to eq(Y2Network::InterfaceType::USB) diff --git a/test/y2network/connection_config/vlan_test.rb b/test/y2network/connection_config/vlan_test.rb index 41b9db857..ba04e917e 100644 --- a/test/y2network/connection_config/vlan_test.rb +++ b/test/y2network/connection_config/vlan_test.rb @@ -18,12 +18,15 @@ # find current contact information at www.suse.com. require_relative "../../test_helper" +require_relative "../../support/connection_config_examples" require "y2network/connection_config/vlan" require "y2network/interface_type" describe Y2Network::ConnectionConfig::Vlan do subject(:config) { described_class.new } + include_examples "connection configuration" + describe "#type" do it "returns 'vlan'" do expect(config.type).to eq(Y2Network::InterfaceType::VLAN) diff --git a/test/y2network/connection_config/wireless_test.rb b/test/y2network/connection_config/wireless_test.rb index 8f18c7f4f..d69976b42 100644 --- a/test/y2network/connection_config/wireless_test.rb +++ b/test/y2network/connection_config/wireless_test.rb @@ -18,12 +18,15 @@ # find current contact information at www.suse.com. require_relative "../../test_helper" +require_relative "../../support/connection_config_examples" require "y2network/connection_config/wireless" require "y2network/interface_type" describe Y2Network::ConnectionConfig::Wireless do subject(:config) { described_class.new } + include_examples "connection configuration" + describe "#type" do it "returns 'wireless'" do expect(config.type).to eq(Y2Network::InterfaceType::WIRELESS) From 59be34bbaa630704c04fd0c8688f8e65200dec03 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Imobach=20Gonz=C3=A1lez=20Sosa?= Date: Thu, 4 Mar 2021 15:45:53 +0000 Subject: [PATCH 2/2] Bump version and update changes file --- package/yast2-network.changes | 7 +++++++ package/yast2-network.spec | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/package/yast2-network.changes b/package/yast2-network.changes index cbba952c1..2305f4680 100644 --- a/package/yast2-network.changes +++ b/package/yast2-network.changes @@ -1,3 +1,10 @@ +------------------------------------------------------------------- +Thu Mar 4 15:41:04 UTC 2021 - Imobach Gonzalez Sosa + +- Do not consider proposing 'nfsroot' as startmode when running on + installation (bsc#1182818). +- 4.2.96 + ------------------------------------------------------------------- Wed Mar 3 12:11:39 UTC 2021 - Knut Anderssen diff --git a/package/yast2-network.spec b/package/yast2-network.spec index a0d0e21d2..fc58d0f6d 100644 --- a/package/yast2-network.spec +++ b/package/yast2-network.spec @@ -17,7 +17,7 @@ Name: yast2-network -Version: 4.2.95 +Version: 4.2.96 Release: 0 Summary: YaST2 - Network Configuration License: GPL-2.0-only