/
ui.rb
242 lines (223 loc) · 7.28 KB
/
ui.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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
# encoding: utf-8
# Copyright (c) 2012 Novell, Inc.
#
# 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 Novell, Inc.
#
# To contact Novell about this file by physical or electronic mail, you may
# find current contact information at www.novell.com.
# File: include/s390/dump/ui.ycp
# Package: Creation of s390 dump devices
# Summary: Dialogs definitions
# Authors: Tim Hardeck <thardeck@suse.de>
#
module Yast
module S390DumpUiInclude
def initialize_s390_dump_ui(_include_target)
Yast.import "UI"
textdomain "s390"
Yast.import "Dump"
Yast.import "Label"
Yast.import "Popup"
Yast.import "Wizard"
# Defines the default active device selection (`dasd, `zfcp)
@type = :zfcp
end
# Run the dialog for Dump
# @param what symbol a
# @return [Symbol] EditDumpDialog that was edited
def DumpDialog
caption = _("Create Dump Device")
help =
# Dump dialog help 1/8
_(
"<p><b>Prepare one or more volumes for use as S/390 dump device.</b></p>"
) +
# Dump dialog help 2/8
_(
"<p>Supported devices are ECKD DASD and ZFCP disks, while multi-volumes are limited to DASD.<br>"
) +
# Dump dialog help 3/8
_(
"Only whole disks can be used, no partitions. If the device is incompatibly\n" \
"formatted or partitioned, activate the checkbox <b>Force overwrite of disk</b>.</p>"
) +
# Dump dialog help 4/8
_(
"<p>To use DASD and ZFCP devices activate them in the respective YaST DASD or ZFCP dialog.<br>"
) +
# Dump dialog help 5/8
_(
"Devices which are in use or have mounted partitions will not be shown.</p>"
) +
# Dump dialog help 6/8
_(
"<p><b>dumpdevice</b> after a disk indicates that it is a usable dump\ndevice. " \
"Multi-volume dump devices are indicated by a list of DASD IDs.</p>"
) +
# Dump dialog help 7/8
_("<p>ZFCP columns: Device, Size, ID, WWPN, LUN, Dump<br>") +
# Dump dialog help 8/8
_("DASD columns: Device, Size, ID, Dump</p>")
dasd_disks = deep_copy(Dump.dasd_disks)
zfcp_disks = deep_copy(Dump.zfcp_disks)
# Dialog content
content = HBox(
VBox(
RadioButtonGroup(
Id(:disk),
VBox(
Frame(
"",
VBox(
Left(
RadioButton(
Id(:zfcp),
Opt(:notify),
_("&ZFCP"),
@type == :zfcp
)
),
ComboBox(Id(:zfcp_disks), Opt(:hstretch), "", zfcp_disks)
)
),
VSpacing(0.3),
Frame(
"",
VBox(
Left(
RadioButton(
Id(:dasd),
Opt(:notify),
_("&DASD"),
@type == :dasd
)
),
MultiSelectionBox(Id(:dasd_disks), "", dasd_disks)
)
)
)
),
VSpacing(0.3),
Left(
CheckBox(Id(:force), Opt(:notify), _("&Force overwrite of disk"))
)
)
)
# Apply the settings
Wizard.SetContentsButtons(
caption,
content,
help,
Label.BackButton,
Label.CreateButton
)
Wizard.HideBackButton
Wizard.SetAbortButton(:cancel, Label.CancelButton)
UI.ChangeWidget(Id(:dasd_disks), :Enabled, @type == :dasd)
UI.ChangeWidget(Id(:zfcp_disks), :Enabled, @type == :zfcp)
force = false
ret = nil
begin
ret = Convert.to_symbol(UI.UserInput)
if ret == :force
force = Convert.to_boolean(UI.QueryWidget(Id(:force), :Value))
end
# disable inactive area
if ret == :dasd || ret == :zfcp
UI.ChangeWidget(Id(:dasd_disks), :Enabled, ret == :dasd)
UI.ChangeWidget(Id(:zfcp_disks), :Enabled, ret == :zfcp)
end
if Builtins.contains([:create, :ok, :next, :finish], ret)
device = ""
@type = Convert.to_symbol(UI.QueryWidget(Id(:disk), :CurrentButton))
# gather selected device[s]
entries = []
if @type == :zfcp
dev_line = Convert.to_string(
UI.QueryWidget(Id(:zfcp_disks), :Value)
)
entries = Builtins.splitstring(dev_line, "\t")
device = Ops.get(entries, 0, "") # dasd
else
selected_items = Convert.convert(
UI.QueryWidget(Id(:dasd_disks), :SelectedItems),
from: "any",
to: "list <string>"
)
Builtins.foreach(selected_items) do |dev_line|
entries = Builtins.splitstring(dev_line, "\t")
# prevent leading space
device = if device != ""
Ops.add(Ops.add(device, " "), Ops.get(entries, 0, ""))
else
Ops.get(entries, 0, "")
end
end
end
if Builtins.size(device) == 0
Popup.Notify(_("You haven't selected any device."))
else
# warn only in case of force
if !force ||
Popup.YesNo(
Builtins.sformat(
_(
"The disk %1 will be formatted as a dump device. All data on " \
"this device will be lost! Continue?"
),
device
)
)
success = Dump.FormatDisk(device, force)
# don't quit in case of failures, error messages are reported by FormatDisk()
ret = if success &&
!Popup.YesNo(
_("Operation successful. Initialize another dump device?")
)
:cancel
else
# reinitialize devices
:again
end
# reset screen after dump progress bar
Wizard.SetContentsButtons(
caption,
VBox(),
help,
Label.BackButton,
Label.CreateButton
)
end
end
end
end while !Builtins.contains([:abort, :cancel, :again], ret)
ret
end
# The whole squence
# @return sequence result
def DumpSequence
ret = nil
# reset dialog if required
Wizard.CreateDialog
Wizard.SetDesktopIcon("dump")
begin
Dump.Read
ret = DumpDialog()
end while ret == :again
UI.CloseDialog
ret
end
end
end