Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add the bcache backing partition usage
- Loading branch information
Showing
8 changed files
with
196 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
78 changes: 78 additions & 0 deletions
78
src/lib/autoinstall/widgets/storage/bcache_backing_attrs.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
# Copyright (c) [2020] 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. | ||
|
||
require "yast" | ||
require "cwm/custom_widget" | ||
require "autoinstall/widgets/storage/bcache_backing_for" | ||
|
||
module Y2Autoinstallation | ||
module Widgets | ||
module Storage | ||
# Bcache backing device attributes | ||
# | ||
# It groups those attributes that are specific for a partition being used as a bcache backing | ||
# device. | ||
# | ||
# @see PartitionUsageTab | ||
class BcacheBackingAttrs < CWM::CustomWidget | ||
# Constructor | ||
# | ||
# @param section [Presenters::Partition] presenter for the partition section | ||
def initialize(section) | ||
textdomain "autoinst" | ||
super() | ||
@section = section | ||
end | ||
|
||
# @macro seeAbstractWidget | ||
def label | ||
"" | ||
end | ||
|
||
# @macro seeCustomWidget | ||
def contents | ||
Left(HSquash(MinWidth(15, backing_for_widget))) | ||
end | ||
|
||
# @macro seeAbstractWidget | ||
def init | ||
backing_for_widget.items = section.available_bcaches | ||
backing_for_widget.value = section.bcache_backing_for | ||
end | ||
|
||
# Returns the widgets values | ||
# | ||
# @return [Hash<String,Object>] | ||
def values | ||
{ "bcache_backing_for" => backing_for_widget.value } | ||
end | ||
|
||
private | ||
|
||
# @return [Presenters::Partition] presenter for the partition section | ||
attr_reader :section | ||
|
||
# Widget for setting the bcache backing device | ||
def backing_for_widget | ||
@backing_for_widget ||= BcacheBackingFor.new | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
# Copyright (c) [2020] 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. | ||
|
||
require_relative "../../../test_helper" | ||
require "y2storage" | ||
require "autoinstall/presenters" | ||
require "autoinstall/widgets/storage/bcache_backing_attrs" | ||
require "cwm/rspec" | ||
|
||
describe Y2Autoinstallation::Widgets::Storage::BcacheBackingAttrs do | ||
subject(:widget) { described_class.new(section) } | ||
|
||
include_examples "CWM::CustomWidget" | ||
|
||
let(:drive) { Y2Autoinstallation::Presenters::Drive.new(partitioning.drives.first) } | ||
let(:section) { drive.partitions.first } | ||
|
||
let(:partitioning) do | ||
Y2Storage::AutoinstProfile::PartitioningSection.new_from_hashes( | ||
[ | ||
{ "type" => :CT_DISK, "partitions" => [{}] }, | ||
{ "type" => :CT_BCACHE, "device" => "/dev/bcache0" }, | ||
{ "type" => :CT_BCACHE, "device" => "/dev/bcache1" } | ||
] | ||
) | ||
end | ||
|
||
let(:backing_for_widget) do | ||
instance_double(Y2Autoinstallation::Widgets::Storage::BcacheBackingFor, value: "/dev/bcache") | ||
end | ||
|
||
before do | ||
allow(backing_for_widget).to receive(:items=) | ||
allow(backing_for_widget).to receive(:value=) | ||
allow(Y2Autoinstallation::Widgets::Storage::BcacheBackingFor) | ||
.to receive(:new) | ||
.and_return(backing_for_widget) | ||
end | ||
|
||
describe "#init" do | ||
it "sets the available bcache devices" do | ||
expect(backing_for_widget).to receive(:items=).with(["/dev/bcache0", "/dev/bcache1"]) | ||
widget.init | ||
end | ||
|
||
it "sets the backing device initial valaue" do | ||
expect(backing_for_widget).to receive(:value=) | ||
widget.init | ||
end | ||
end | ||
|
||
describe "#values" do | ||
it "includes bcache_backing_for" do | ||
expect(widget.values).to include("bcache_backing_for" => "/dev/bcache") | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters