Skip to content

Commit

Permalink
Merge pull request #727 from ancorgs/missing_drives
Browse files Browse the repository at this point in the history
AutoYaST UI: add drive types CT_NFS and CT_TMPFS
  • Loading branch information
ancorgs committed Jan 29, 2021
2 parents cda231b + e5575f6 commit b38c94a
Show file tree
Hide file tree
Showing 16 changed files with 322 additions and 44 deletions.
7 changes: 7 additions & 0 deletions package/autoyast2.changes
@@ -1,3 +1,10 @@
-------------------------------------------------------------------
Thu Jan 28 16:54:47 UTC 2021 - Ancor Gonzalez Sosa <ancor@suse.com>

- AutoYaST UI: added drive types CT_NFS and CT_TMPFS to the
partitioning section (part of jsc#SLE-11308).
- 4.3.66

-------------------------------------------------------------------
Thu Jan 14 14:38:35 UTC 2021 - Stefan Schubert <schubi@suse.de>

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

Name: autoyast2
Version: 4.3.65
Version: 4.3.66
Release: 0
Summary: YaST2 - Automated Installation
License: GPL-2.0-only
Expand Down
8 changes: 6 additions & 2 deletions src/lib/autoinstall/presenters/drive_type.rb
Expand Up @@ -45,12 +45,16 @@ def initialize(id, label)
# DriveType for CT_RAID
RAID = new(:CT_RAID, N_("RAID")).freeze
# DriveType for CT_BCACHE
BCACHE = new(:CT_BCACHE, N_("bcache")).freeze
BCACHE = new(:CT_BCACHE, N_("Bcache")).freeze
# DriveType for CT_BTRFS
BTRFS = new(:CT_BTRFS, N_("Btrfs")).freeze
# DriveType for CT_NFS
NFS = new(:CT_NFS, N_("NFS")).freeze
# DriveType for CT_TMPFS
TMPFS = new(:CT_TMPFS, N_("Tmpfs")).freeze

# All drive types
ALL = [DISK, RAID, LVM, BCACHE, BTRFS].freeze
ALL = [DISK, RAID, LVM, BCACHE, BTRFS, NFS, TMPFS].freeze

# All possible types
#
Expand Down
29 changes: 27 additions & 2 deletions src/lib/autoinstall/presenters/partition.rb
Expand Up @@ -91,6 +91,20 @@ def logical_volume?
drive_type.to_sym == :CT_LVM
end

# Whether this belongs to a drive that is only used to represent filesystems
#
# @return [Boolean]
def filesystem_drive?
[:CT_NFS, :CT_TMPFS, :CT_BTRFS].include?(drive_type.to_sym)
end

# Whether this represents a device that only exists in the system when it's mounted
#
# @return [Boolean] false if this is no backed (directly or indirectly) by block devices
def fstab_based?
[:CT_NFS, :CT_TMPFS].include?(drive_type.to_sym)
end

# Values to suggest for bcache devices fields
#
# @return [Array<String>]
Expand Down Expand Up @@ -164,6 +178,10 @@ def device_type_label
# TRANSLATORS: 'Partition' is the name of a section in the AutoYaST
# profile, so it's likely not a good idea to translate the term
_("Partition (LV)")
when :filesystem
# TRANSLATORS: 'Partition' is the name of a section in the AutoYaST
# profile, so it's likely not a good idea to translate the term
_("Partition (File System)")
else
# TRANSLATORS: 'Partition' is the name of a section in the AutoYaST
# profile, so it's likely not a good idea to translate the term
Expand Down Expand Up @@ -203,9 +221,16 @@ def usage_label
def device_type
return :lv if drive.type == :CT_LVM

return :partition unless drive.unwanted_partitions?
return device_type_no_partitions if drive.master_partition

(drive.type == :CT_TMPFS) ? :filesystem : :partition
end

# @see #device_type
def device_type_no_partitions
return :drive if drive.master_partition == section

(drive.master_partition == section) ? :drive : :none
:none
end
end
end
Expand Down
13 changes: 11 additions & 2 deletions src/lib/autoinstall/widgets/storage/bcache_page.rb
@@ -1,4 +1,4 @@
# Copyright (c) [2020] SUSE LLC
# Copyright (c) [2020-2021] SUSE LLC
#
# All Rights Reserved.
#
Expand All @@ -21,6 +21,7 @@
require "autoinstall/widgets/storage/drive_page"
require "autoinstall/widgets/storage/bcache_device"
require "autoinstall/widgets/storage/cache_mode"
require "autoinstall/widgets/storage/disklabel"

module Y2Autoinstallation
module Widgets
Expand All @@ -37,20 +38,23 @@ def initialize(*args)
def widgets
[
HSquash(MinWidth(15, device_widget)),
cache_mode_widget
cache_mode_widget,
disklabel_widget
]
end

# @see DrivePage#init_widget_values
def init_widgets_values
device_widget.value = section.device
cache_mode_widget.value = section.bcache_options&.cache_mode
disklabel_widget.value = drive.disklabel
end

# @see DrivePage#widgets_values
def widgets_values
{
"device" => device_widget.value,
"disklabel" => disklabel_widget.value,
"bcache_options" => {
"cache_mode" => cache_mode_widget.value
}
Expand All @@ -68,6 +72,11 @@ def device_widget
def cache_mode_widget
@cache_mode_widget ||= CacheMode.new
end

# Widget for setting the type of the partition table
def disklabel_widget
@disklabel_widget ||= Disklabel.new
end
end
end
end
Expand Down
66 changes: 42 additions & 24 deletions src/lib/autoinstall/widgets/storage/filesystem_attrs.rb
Expand Up @@ -53,31 +53,15 @@ def label

# @macro seeCustomWidget
def contents
VBox(
Left(
HBox(
filesystem_widget,
HSpacing(2),
HSquash(MinWidth(15, label_widget))
)
),
VSpacing(0.5),
Left(create_subvolumes_widget),
VSpacing(0.5),
Left(
HBox(
HSquash(MinWidth(15, mount_point_widget)),
HSpacing(2),
mountby_widget,
HSpacing(2),
HSquash(fstab_options_widget)
)
),
VSpacing(0.5),
Left(
HSquash(MinWidth(35, mkfs_options_widget))
if section.fstab_based?
VBox(*mount_widgets)
else
VBox(
*mount_widgets,
VSpacing(0.5),
*format_widgets
)
)
end
end

# @macro seeAbstractWidget
Expand Down Expand Up @@ -170,6 +154,40 @@ def mkfs_options_widget
def create_subvolumes_widget
@create_subvolumes_widget ||= CreateSubvolumes.new
end

# @see #contents
def format_widgets
[
Left(
HBox(
filesystem_widget,
HSpacing(2),
HSquash(MinWidth(15, label_widget))
)
),
VSpacing(0.5),
Left(
HSquash(MinWidth(35, mkfs_options_widget))
),
VSpacing(0.5),
Left(create_subvolumes_widget)
]
end

# @see #contents
def mount_widgets
[
Left(
HBox(
HSquash(MinWidth(15, mount_point_widget)),
HSpacing(2),
mountby_widget,
HSpacing(2),
HSquash(fstab_options_widget)
)
)
]
end
end
end
end
Expand Down
40 changes: 40 additions & 0 deletions src/lib/autoinstall/widgets/storage/nfs_name.rb
@@ -0,0 +1,40 @@
# 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.

require "yast"
require "cwm/common_widgets"

module Y2Autoinstallation
module Widgets
module Storage
# Determines the name of an NFS mount
class NfsName < CWM::InputField
def initalize
textdomain "autoinst"
super
end

# @macro seeAbstractWidget
def label
_("NFS Share Name")
end
end
end
end
end
66 changes: 66 additions & 0 deletions src/lib/autoinstall/widgets/storage/nfs_page.rb
@@ -0,0 +1,66 @@
# 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.

require "yast"
require "autoinstall/widgets/storage/drive_page"
require "autoinstall/widgets/storage/nfs_name"

module Y2Autoinstallation
module Widgets
module Storage
# This page allows to edit a `drive` section representing an NFS mount
class NfsPage < DrivePage
# @see DrivePage#initialize
def initialize(*args)
textdomain "autoinst"
super
end

# @macro seeCustomWidget
def contents
MarginBox(
0.5,
0,
VBox(
Left(HSquash(nfs_name_widget)),
VStretch()
)
)
end

# @see DrivePage#init
def init
nfs_name_widget.value = drive.device
end

# @see DrivePage#values
def values
{ "device" => nfs_name_widget.value }
end

private

# Widget for setting the name of the NFS mount
def nfs_name_widget
@nfs_name_widget ||= NfsName.new
end
end
end
end
end
2 changes: 2 additions & 0 deletions src/lib/autoinstall/widgets/storage/overview_tree_pager.rb
Expand Up @@ -25,6 +25,8 @@
require "autoinstall/widgets/storage/lvm_page"
require "autoinstall/widgets/storage/bcache_page"
require "autoinstall/widgets/storage/btrfs_page"
require "autoinstall/widgets/storage/nfs_page"
require "autoinstall/widgets/storage/tmpfs_page"
require "autoinstall/widgets/storage/partition_page"
require "autoinstall/widgets/storage/add_drive_button"
require "autoinstall/widgets/storage/add_partition_button"
Expand Down
18 changes: 11 additions & 7 deletions src/lib/autoinstall/widgets/storage/partition_page.rb
Expand Up @@ -65,16 +65,20 @@ def section

# Tabs to display the partition section data
#
# First tab contains common options for a partition section (including those that depend on
# the parent section type). The second one allows to choose the partition usage and its
# related options.
# Normally, the first tab contains common options for a partition section (including those
# that depend on the parent section type). The second one allows to choose the partition
# usage and its related options. In some cases, that second tab is enough.
#
# @return [CWM::Tabs]
def tabs
CWM::Tabs.new(
general_tab,
usage_tab
)
if partition.fstab_based?
CWM::Tabs.new(usage_tab)
else
CWM::Tabs.new(
general_tab,
usage_tab
)
end
end

# Tab to display common options for all partition sections
Expand Down
3 changes: 2 additions & 1 deletion src/lib/autoinstall/widgets/storage/partition_usage_tab.rb
Expand Up @@ -30,6 +30,7 @@
require "autoinstall/widgets/storage/btrfs_member_attrs"
require "autoinstall/widgets/storage/encryption_attrs"
require "autoinstall/widgets/storage/used_as"
require "autoinstall/widgets/storage/used_as_filesystem"

module Y2Autoinstallation
module Widgets
Expand Down Expand Up @@ -119,7 +120,7 @@ def encryption_widget

# Widget for choosing the partition usage
def used_as_widget
@used_as_widget ||= UsedAs.new
@used_as_widget ||= partition.filesystem_drive? ? UsedAsFilesystem.new : UsedAs.new
end

def replace_point
Expand Down

0 comments on commit b38c94a

Please sign in to comment.