Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
659 additions
and
6 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
# 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/common_widgets" | ||
|
||
module Y2Autoinstallation | ||
module Widgets | ||
module Storage | ||
# Widget to specify the bcache device which is going to be backed | ||
class BcacheBackingFor < CWM::ComboBox | ||
def initalize | ||
textdomain "autoinst" | ||
super | ||
end | ||
|
||
# @macro seeAbstractWidget | ||
def label | ||
_("Device") | ||
end | ||
|
||
# @macro seeAbstractWidget | ||
def opt | ||
[:editable] | ||
end | ||
|
||
def items=(devices) | ||
values = [["", ""]] + devices.map { |i| [i, i] } | ||
change_items(values) | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# 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/common_widgets" | ||
|
||
module Y2Autoinstallation | ||
module Widgets | ||
module Storage | ||
# Determines a bcache device | ||
class BcacheDevice < CWM::InputField | ||
def initalize | ||
textdomain "autoinst" | ||
super | ||
end | ||
|
||
# @macro seeAbstractWidget | ||
def label | ||
_("Device") | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
# 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 "autoinstall/widgets/storage/drive_page" | ||
require "autoinstall/widgets/storage/bcache_device" | ||
require "autoinstall/widgets/storage/cache_mode" | ||
|
||
module Y2Autoinstallation | ||
module Widgets | ||
module Storage | ||
# This page allows to edit a drive section representing a bcache device | ||
class BcachePage < DrivePage | ||
# @see DrivePage#initialize | ||
def initialize(*args) | ||
textdomain "autoinst" | ||
super | ||
end | ||
|
||
# @macro seeCustomWidget | ||
def contents | ||
MarginBox( | ||
0.5, | ||
0, | ||
VBox( | ||
Left(HSquash(MinWidth(15, device_widget))), | ||
VSpacing(0.5), | ||
Left(cache_mode_widget), | ||
VStretch() | ||
) | ||
) | ||
end | ||
|
||
# @macro seeAbstractWidget | ||
def init | ||
device_widget.value = section.device | ||
cache_mode_widget.value = section.bcache_options&.cache_mode | ||
end | ||
|
||
# Returns the widgets values | ||
# | ||
# @return [Hash<String,Object>] | ||
def values | ||
{ | ||
"device" => device_widget.value, | ||
"bcache_options" => { | ||
"cache_mode" => cache_mode_widget.value | ||
} | ||
} | ||
end | ||
|
||
private | ||
|
||
# Widget for setting the device | ||
def device_widget | ||
@device_widget ||= BcacheDevice.new | ||
end | ||
|
||
# Widget for setting the cache mode | ||
def cache_mode_widget | ||
@cache_mode_widget ||= CacheMode.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# 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/common_widgets" | ||
require "y2storage" | ||
|
||
module Y2Autoinstallation | ||
module Widgets | ||
module Storage | ||
# Widget to select the bcache cache mode | ||
# | ||
# It's part of the bcache_options attribute for a bcache drive section of an AutoYaST profile. | ||
class CacheMode < CWM::ComboBox | ||
# Constructor | ||
def initialize | ||
textdomain "autoinst" | ||
super() | ||
end | ||
|
||
# @macro seeAbstractWidget | ||
def label | ||
_("Cache Mode") | ||
end | ||
|
||
# @macro seeComboBox | ||
def items | ||
Y2Storage::CacheMode.all.map { |i| [i.to_s, i.to_s] } | ||
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
Oops, something went wrong.