/
bcache_page.rb
83 lines (74 loc) · 2.43 KB
/
bcache_page.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# Copyright (c) [2020-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/bcache_device"
require "autoinstall/widgets/storage/cache_mode"
require "autoinstall/widgets/storage/disklabel"
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
# @see DrivePage#widgets
def widgets
[
HSquash(MinWidth(15, device_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
}
}
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
# Widget for setting the type of the partition table
def disklabel_widget
@disklabel_widget ||= Disklabel.new
end
end
end
end
end