Skip to content

Commit

Permalink
Merge pull request #432 from yast/ay-avoid-nodisk-warn
Browse files Browse the repository at this point in the history
Do not warn too soon about missing disks
  • Loading branch information
imobachgs committed May 2, 2018
2 parents 14feb7e + 8e41463 commit 93c373f
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 2 deletions.
7 changes: 7 additions & 0 deletions 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

Expand Down
2 changes: 1 addition & 1 deletion package/autoyast2.spec
Expand Up @@ -22,7 +22,7 @@
%endif

Name: autoyast2
Version: 4.0.49
Version: 4.0.50
Release: 0

BuildRoot: %{_tmppath}/%{name}-%{version}-build
Expand Down
16 changes: 16 additions & 0 deletions src/modules/AutoinstStorage.rb
Expand Up @@ -7,6 +7,7 @@
#
# $Id$
require "yast"
require "y2storage"
require "autoinstall/storage_proposal"
require "autoinstall/dialogs/question"
require "autoinstall/storage_proposal_issues_presenter"
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down
41 changes: 40 additions & 1 deletion test/autoinst_storage_test.rb
Expand Up @@ -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)
Expand All @@ -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|
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 93c373f

Please sign in to comment.