Skip to content

Commit

Permalink
Merge branch 'SLE-15-SP2' into bsc-1182818-master
Browse files Browse the repository at this point in the history
  • Loading branch information
imobachgs committed Mar 5, 2021
2 parents 474ec98 + 5a72777 commit caaaa76
Show file tree
Hide file tree
Showing 16 changed files with 117 additions and 5 deletions.
7 changes: 7 additions & 0 deletions package/yast2-network.changes
@@ -1,3 +1,10 @@
-------------------------------------------------------------------
Thu Mar 4 15:41:04 UTC 2021 - Imobach Gonzalez Sosa <igonzalezsosa@suse.com>

- Do not consider proposing 'nfsroot' as startmode when running on
installation (bsc#1182818).
- 4.3.53

-------------------------------------------------------------------
Wed Mar 3 12:11:39 UTC 2021 - Knut Anderssen <kanderssen@suse.com>

Expand Down
2 changes: 1 addition & 1 deletion package/yast2-network.spec
Expand Up @@ -17,7 +17,7 @@


Name: yast2-network
Version: 4.3.52
Version: 4.3.53
Release: 0
Summary: YaST2 - Network Configuration
License: GPL-2.0-only
Expand Down
17 changes: 13 additions & 4 deletions src/lib/y2network/connection_config/base.rb
Expand Up @@ -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
Expand Down Expand Up @@ -121,11 +123,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

Expand Down Expand Up @@ -245,6 +246,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
59 changes: 59 additions & 0 deletions 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
1 change: 1 addition & 0 deletions test/y2network/connection_config/bonding_test.rb
Expand Up @@ -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"

Expand Down
3 changes: 3 additions & 0 deletions test/y2network/connection_config/ctc_test.rb
Expand Up @@ -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)
Expand Down
3 changes: 3 additions & 0 deletions test/y2network/connection_config/dummy_test.rb
Expand Up @@ -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)
Expand Down
3 changes: 3 additions & 0 deletions test/y2network/connection_config/ethernet_test.rb
Expand Up @@ -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)
Expand Down
4 changes: 4 additions & 0 deletions test/y2network/connection_config/hsi_test.rb
Expand Up @@ -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)
Expand Down
4 changes: 4 additions & 0 deletions test/y2network/connection_config/lcs_test.rb
Expand Up @@ -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)
Expand Down
4 changes: 4 additions & 0 deletions test/y2network/connection_config/qeth_test.rb
Expand Up @@ -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)
Expand Down
3 changes: 3 additions & 0 deletions test/y2network/connection_config/tap_test.rb
Expand Up @@ -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)
Expand Down
3 changes: 3 additions & 0 deletions test/y2network/connection_config/tun_test.rb
Expand Up @@ -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)
Expand Down
3 changes: 3 additions & 0 deletions test/y2network/connection_config/usb_test.rb
Expand Up @@ -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)
Expand Down
3 changes: 3 additions & 0 deletions test/y2network/connection_config/vlan_test.rb
Expand Up @@ -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)
Expand Down
3 changes: 3 additions & 0 deletions test/y2network/connection_config/wireless_test.rb
Expand Up @@ -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)
Expand Down

0 comments on commit caaaa76

Please sign in to comment.