From 323758433e7b72847cea17e274a494ddf5b4fd7f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Imobach=20Gonz=C3=A1lez=20Sosa?= Date: Fri, 27 Apr 2018 16:42:57 +0100 Subject: [PATCH 1/2] Do not parse import the partitioning section when no disks are found --- src/modules/AutoinstStorage.rb | 16 +++++++++++++ test/autoinst_storage_test.rb | 41 +++++++++++++++++++++++++++++++++- 2 files changed, 56 insertions(+), 1 deletion(-) diff --git a/src/modules/AutoinstStorage.rb b/src/modules/AutoinstStorage.rb index 356706886..eb8463a34 100644 --- a/src/modules/AutoinstStorage.rb +++ b/src/modules/AutoinstStorage.rb @@ -7,6 +7,7 @@ # # $Id$ require "yast" +require "y2storage" require "autoinstall/storage_proposal" require "autoinstall/dialogs/question" require "autoinstall/storage_proposal_issues_presenter" @@ -56,6 +57,7 @@ def main # @return [Boolean] success def Import(settings) log.info "entering Import with #{settings.inspect}" + return false unless available_storage? partitioning = preprocessed_settings(settings) return false unless partitioning @@ -325,6 +327,20 @@ def preprocessed_settings(settings) preprocessor = Y2Autoinstallation::PartitioningPreprocessor.new preprocessor.run(settings) end + + # Determine (and warn the user) no storage is available for installation + # + # @return [Boolean] true if there are devices for installation; false otherwise. + def available_storage? + probed = Y2Storage::StorageManager.instance.probed + return true if probed && !probed.empty? + Yast::Popup.Error( + _("No storage devices were found for the installation.\n" \ + "Please, check your hardware or your AutoYaST profile.") + ) + false + end + end AutoinstStorage = AutoinstStorageClass.new diff --git a/test/autoinst_storage_test.rb b/test/autoinst_storage_test.rb index 4a0297f76..94f68e4db 100755 --- a/test/autoinst_storage_test.rb +++ b/test/autoinst_storage_test.rb @@ -22,7 +22,15 @@ let(:warnings_settings) { { "show" => true, "timeout" => 5 } } let(:settings) { [{ "device" => "/dev/sda" }] } let(:ask_settings) { [{ "device" => "ask" }] } - let(:preprocessor) { instance_double(Y2Autoinstallation::PartitioningPreprocessor, run: settings) } + let(:preprocessor) do + instance_double(Y2Autoinstallation::PartitioningPreprocessor, run: settings) + end + let(:probed_devicegraph) do + instance_double(Y2Storage::Devicegraph, :empty? => false) + end + let(:storage_manager) do + instance_double(Y2Storage::StorageManager, probed: probed_devicegraph) + end before do allow(Y2Autoinstallation::StorageProposal).to receive(:new) @@ -32,6 +40,7 @@ allow(storage_proposal).to receive(:save) allow(Y2Autoinstallation::PartitioningPreprocessor).to receive(:new) .and_return(preprocessor) + allow(Y2Storage::StorageManager).to receive(:instance).and_return(storage_manager) end around do |example| @@ -184,6 +193,36 @@ end end + + context "when there are no available storage for installation" do + before do + allow(probed_devicegraph).to receive(:empty?).and_return(true) + end + + it "displays an error" do + expect(Yast::Popup).to receive(:Error).with(/No storage devices/) + subject.Import({}) + end + + it "returns false" do + expect(subject.Import({})).to eq(false) + end + end + + context "when the probed devicegraph is nil" do + before do + allow(storage_manager).to receive(:probed).and_return(nil) + end + + it "displays an error" do + expect(Yast::Popup).to receive(:Error).with(/No storage devices/) + subject.Import({}) + end + + it "returns false" do + expect(subject.Import({})).to eq(false) + end + end end describe "#import_general_settings" do From 8e414637d8157462bee5e1ee29c5d2e747754670 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Imobach=20Gonz=C3=A1lez=20Sosa?= Date: Fri, 27 Apr 2018 16:46:12 +0100 Subject: [PATCH 2/2] Bump version and update changes file --- package/autoyast2.changes | 7 +++++++ package/autoyast2.spec | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/package/autoyast2.changes b/package/autoyast2.changes index 68eb3d9c4..b8dd13df4 100644 --- a/package/autoyast2.changes +++ b/package/autoyast2.changes @@ -1,3 +1,10 @@ +------------------------------------------------------------------- +Fri Apr 27 15:43:05 UTC 2018 - igonzalezsosa@suse.com + +- Display an error and abort the installation when no storage + devices are available for installation (bsc#1091033). +- 4.0.50 + ------------------------------------------------------------------- Fri Apr 20 20:58:54 UTC 2018 - igonzalezsosa@suse.com diff --git a/package/autoyast2.spec b/package/autoyast2.spec index 454d2c76b..145a136a1 100644 --- a/package/autoyast2.spec +++ b/package/autoyast2.spec @@ -22,7 +22,7 @@ %endif Name: autoyast2 -Version: 4.0.49 +Version: 4.0.50 Release: 0 BuildRoot: %{_tmppath}/%{name}-%{version}-build