• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

yast / yast-kdump / 9611059066

21 Jun 2024 09:00AM UTC coverage: 40.556% (+0.4%) from 40.11%
9611059066

Pull #138

github

schubi2
removed frozen_string_literal
Pull Request #138: kdump is currently not compatible with Systemd Boot

40 of 159 new or added lines in 8 files covered. (25.16%)

22 existing lines in 5 files now uncovered.

730 of 1800 relevant lines covered (40.56%)

4.03 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

40.0
/src/include/kdump/dialogs.rb
1
# ------------------------------------------------------------------------------
2
# Copyright (c) 2006 Novell, Inc. All Rights Reserved.
3
#
4
#
5
# This program is free software; you can redistribute it and/or modify it under
6
# the terms of version 2 of the GNU General Public License as published by the
7
# Free Software Foundation.
8
#
9
# This program is distributed in the hope that it will be useful, but WITHOUT
10
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11
# FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
12
#
13
# You should have received a copy of the GNU General Public License along with
14
# this program; if not, contact Novell, Inc.
15
#
16
# To contact Novell about this file by physical or electronic mail, you may find
17
# current contact information at www.novell.com.
18
# ------------------------------------------------------------------------------
19

20
# File:        include/kdump/wizards.ycp
21
# Package:        Configuration of kdump
22
# Summary:        Wizards definitions
23
# Authors:        Jozef Uhliarik <juhliarik@suse.com>
24
#
25
# $Id: wizards.ycp 27914 2006-02-13 14:32:08Z locilka $
26
module Yast
1✔
27
  module KdumpDialogsInclude
1✔
28
    def initialize_kdump_dialogs(include_target)
1✔
29
      textdomain "kdump"
14✔
30

31
      Yast.import "CWM"
14✔
32
      Yast.import "Label"
14✔
33
      Yast.import "Wizard"
14✔
34
      Yast.import "Kdump"
14✔
35
      Yast.import "DialogTree"
14✔
36
      Yast.import "CWMTab"
14✔
37

38
      Yast.include include_target, "kdump/helps.rb"
14✔
39
      Yast.include include_target, "kdump/uifunctions.rb"
14✔
40
    end
41

42
    def wid_handling
1✔
43
      return @wid_handling if @wid_handling
×
44

45
      @wid_handling = {
46
        "DisBackButton"          => {
×
47
          "widget"        => :custom,
48
          "custom_widget" => Empty(),
49
          "init"          => fun_ref(method(:DisBackButton), "void (string)"),
50
          "help"          => " "
51
        },
52
        #---------============ Start-up screen=============------------
53
        "EnableDisalbeKdump"     => {
54
          # TRANSLATORS: RadioButtonGroup Label
55
          "label"       => _(
56
            "Enable/Disable Kdump"
57
          ),
58
          "widget"      => :radio_buttons,
59
          "items"       => [
60
            ["enable_kdump", _("Enable Kd&ump")],
61
            ["disable_kdump", _("&Disable Kdump")]
62
          ],
63
          "orientation" => :horizontal,
64
          "init"        => fun_ref(
65
            method(:InitEnableDisalbeKdump),
66
            "void (string)"
67
          ),
68
          # "handle"                : HandleEnableDisalbeKdump,
69
          "store"       => fun_ref(
70
            method(:StoreEnableDisalbeKdump),
71
            "void (string, map)"
72
          ),
73
          "help"        => HelpKdump("StartRadioBut")
74
        },
75
        "KdumpMemory"            => {
76
          "widget"            => :custom,
77
          "custom_widget"     => HSquash(kdump_memory_widget),
78
          "init"              => fun_ref(
79
            method(:InitKdumpMemory),
80
            "void (string)"
81
          ),
82
          "handle"            => fun_ref(
83
            method(:HandleKdumpMemory),
84
            "symbol (string, map)"
85
          ),
86
          "validate_type"     => :function,
87
          "validate_function" => fun_ref(
88
            method(:ValidKdumpMemory),
89
            "boolean (string, map)"
90
          ),
91
          "store"             => fun_ref(
92
            method(:StoreKdumpMemory),
93
            "void (string, map)"
94
          ),
95
          "help"              => HelpKdump("KdumpMemory")
96
        },
97
        "FADump"                 => {
98
          "widget"        => :custom,
99
          "custom_widget" => Empty(),
100
          "init"          => fun_ref(method(:InitFADump), "void (string)"),
101
          "handle"        => fun_ref(method(:HandleFADump), "void (string, map)"),
102
          "help"          => HelpKdump("FADump")
103
        },
104
        #---------============ Dump Filtering screen=============------------
105
        "DumpLevel"              => {
106
          "widget"            => :custom,
107
          "custom_widget"     => VBox(
108
            Frame(
109
              _("Include in Dumping"),
110
              VBox(
111
                Left(
112
                  HBox(
113
                    HSpacing(1),
114
                    VBox(
115
                      Left(
116
                        CheckBox(Id("zero_page"), _("&Pages Filled with Zero"))
117
                      ), # `VStretch ()
118
                      Left(
119
                        CheckBox(
120
                          Id("cache_page"),
121
                          Opt(:notify),
122
                          _("Cach&e Pages")
123
                        )
124
                      ),
125
                      HBox(
126
                        HSpacing(2),
127
                        VBox(
128
                          Left(
129
                            CheckBox(
130
                              Id("cache_private"),
131
                              Opt(:notify),
132
                              _("Cache Priva&te Pages")
133
                            )
134
                          )
135
                        )
136
                      ),
137
                      Left(CheckBox(Id("user_data"), _("&User Data Pages"))),
138
                      Left(CheckBox(Id("free_page"), _("&Free Pages")))
139
                    )
140
                  )
141
                )
142
              )
143
            )
144
          ),
145
          "init"              => fun_ref(
146
            method(:InitDumpLevel),
147
            "void (string)"
148
          ),
149
          "handle"            => fun_ref(
150
            method(:HandleDumpLevel),
151
            "symbol (string, map)"
152
          ),
153
          "validate_type"     => :function,
154
          "validate_function" => fun_ref(
155
            method(:ValidDumpLevel),
156
            "boolean (string, map)"
157
          ),
158
          "store"             => fun_ref(
159
            method(:StoreDumpLevel),
160
            "void (string, map)"
161
          ),
162
          "help"              => HelpKdump("DumpLevel")
163
        },
164
        "DumpFormat"             => {
165
          # TRANSLATORS: TextEntry Label
166
          "label"             => _("&Dump Format"),
167
          "widget"            => :radio_buttons,
168
          "items"             => [
169
            ["none_format", _("&No Dump")],
170
            ["elf_format", _("&ELF Format")],
171
            ["compressed_format", _("C&ompressed Format")],
172
            ["lzo_format", _("&LZO Compressed Format")],
173
            ["snappy_format", _("&Snappy Compressed Format")],
174
            ["zstd_format", _("Zstandard Compressed Format")],
175
            ["raw_format", _("Raw copy of /proc/vmcore")]
176
          ],
177
          "orientation"       => :horizontal,
178
          "init"              => fun_ref(
179
            method(:InitDumpFormat),
180
            "void (string)"
181
          ),
182
          "validate_type"     => :function,
183
          "validate_function" => fun_ref(
184
            method(:ValidDumpFormat),
185
            "boolean (string, map)"
186
          ),
187
          "store"             => fun_ref(
188
            method(:StoreDumpFormat),
189
            "void (string, map)"
190
          ),
191
          "help"              => HelpKdump("DumpFormat")
192
        },
193
        #---------============ Dump Target screen=============------------
194
        "TargetKdump"            => {
195
          "label"             => _("&Select Target"),
196
          "widget"            => :combobox,
197
          "opt"               => [:notify],
198
          "items"             => [
199
            ["local_filesystem", _("Local Directory")],
200
            ["ftp", _("FTP")],
201
            ["ssh", _("SSH")],
202
            ["sftp", _("SFTP")],
203
            ["nfs", _("NFS")],
204
            ["cifs", _("CIFS (SMB)")]
205
          ],
206
          "init"              => fun_ref(
207
            method(:InitTargetKdump),
208
            "void (string)"
209
          ),
210
          # "handle_events"         : ["TargetKdump2"],
211
          "handle"            => fun_ref(
212
            method(:HandleTargetKdump),
213
            "symbol (string, map)"
214
          ),
215
          "validate_type"     => :function,
216
          "validate_function" => fun_ref(
217
            method(:ValidTargetKdump),
218
            "boolean (string, map)"
219
          ),
220
          "store"             => fun_ref(
221
            method(:StoreTargetKdump),
222
            "void (string, map)"
223
          ),
224
          "help"              => HelpKdump("TargetKdump")
225
        },
226
        #---------============ Email Notification screen=============------------
227
        "SMTPServer"             => {
228
          # TRANSLATORS: TextEntry Label
229
          "label"  => _("&SMTP Server"),
230
          "widget" => :textentry,
231
          "init"   => fun_ref(method(:InitSMTPServer), "void (string)"),
232
          # "handle"                :
233
          "store"  => fun_ref(
234
            method(:StoreSMTPServer),
235
            "void (string, map)"
236
          ),
237
          "help"   => HelpKdump("SMTPServer")
238
        },
239
        "SMTPUser"               => {
240
          # TRANSLATORS: TextEntry Label
241
          "label"  => _("&User Name"),
242
          "widget" => :textentry,
243
          "init"   => fun_ref(method(:InitSMTPUser), "void (string)"),
244
          # "handle"                :
245
          "store"  => fun_ref(
246
            method(:StoreSMTPUser),
247
            "void (string, map)"
248
          ),
249
          "help"   => HelpKdump("SMTPUser")
250
        },
251
        "SMTPPassword"           => {
252
          # TRANSLATORS: TextEntry Label
253
          "label"  => _("&Password"),
254
          "widget" => :password,
255
          "init"   => fun_ref(method(:InitSMTPPassword), "void (string)"),
256
          # "handle"                :
257
          "store"  => fun_ref(
258
            method(:StoreSMTPPassword),
259
            "void (string, map)"
260
          ),
261
          "help"   => HelpKdump("SMTPPassword")
262
        },
263
        "NotificationTo"         => {
264
          # TRANSLATORS: TextEntry Label
265
          "label"         => _("Notification &To"),
266
          "widget"        => :textentry,
267
          "init"          => fun_ref(
268
            method(:InitNotificationTo),
269
            "void (string)"
270
          ),
271
          "validate_type" => :function,
272
          # "validate_function": ValidEmail,
273
          "store"         => fun_ref(
274
            method(:StoreNotificationTo),
275
            "void (string, map)"
276
          ),
277
          "help"          => HelpKdump("NotificationTo")
278
        },
279
        "NotificationCC"         => {
280
          # TRANSLATORS: TextEntry Label
281
          "label"         => _("Notifica&tion CC"),
282
          "widget"        => :textentry,
283
          "init"          => fun_ref(
284
            method(:InitNotificationCC),
285
            "void (string)"
286
          ),
287
          "validate_type" => :function,
288
          # "validate_function": ValidEmail,
289
          "store"         => fun_ref(
290
            method(:StoreNotificationCC),
291
            "void (string, map)"
292
          ),
293
          "help"          => HelpKdump("NotificationCC")
294
        },
295
        #---------============ Expert Settings screen=============------------
296
        "InitrdKernel"           => {
297
          # TRANSLATORS: TextEntry Label
298
          "label"  => _("Custom Kdump &Kernel"),
299
          "widget" => :textentry,
300
          "init"   => fun_ref(method(:InitInitrdKernel), "void (string)"),
301
          # "handle"                :
302
          "store"  => fun_ref(
303
            method(:StoreInitrdKernel),
304
            "void (string, map)"
305
          ),
306
          "help"   => HelpKdump("InitrdKernel")
307
        },
308
        "KdumpCommandLine"       => {
309
          # TRANSLATORS: TextEntry Label
310
          "label"  => _("Kdump Co&mmand Line"),
311
          "widget" => :textentry,
312
          "init"   => fun_ref(method(:InitKdumpCommandLine), "void (string)"),
313
          # "handle"                :
314
          "store"  => fun_ref(
315
            method(:StoreKdumpCommandLine),
316
            "void (string, map)"
317
          ),
318
          "help"   => HelpKdump("KdumpCommandLine")
319
        },
320
        "KdumpCommandLineAppend" => {
321
          # TRANSLATORS: TextEntry Label
322
          "label"  => _(
323
            "Kdump Command &Line Append"
324
          ),
325
          "widget" => :textentry,
326
          "init"   => fun_ref(
327
            method(:InitKdumpCommandLineAppend),
328
            "void (string)"
329
          ),
330
          # "handle"                :
331
          "store"  => fun_ref(
332
            method(:StoreKdumpCommandLineAppend),
333
            "void (string, map)"
334
          ),
335
          "help"   => HelpKdump("KdumpCommandLineAppend")
336
        },
337
        "EnableReboot"           => {
338
          # TRANSLATORS: CheckBox Label
339
          "label"  => _(
340
            "&Enable Immediate Reboot After Saving the Core"
341
          ),
342
          "widget" => :checkbox,
343
          "init"   => fun_ref(method(:InitEnableReboot), "void (string)"),
344
          # "handle"                :
345
          "store"  => fun_ref(
346
            method(:StoreEnableReboot),
347
            "void (string, map)"
348
          ),
349
          "help"   => HelpKdump("EnableReboot")
350
        },
351
        "EnableDeleteImages"     => {
352
          # TRANSLATORS: CheckBox Label
353
          "label"  => _(
354
            "Enable &Delete Old Dump Images"
355
          ),
356
          "widget" => :checkbox,
357
          "init"   => fun_ref(method(:InitEnableDeleteImages), "void (string)"),
358
          "handle" => fun_ref(
359
            method(:HandleEnableDeleteImages),
360
            "symbol (string, map)"
361
          ),
362
          "store"  => fun_ref(
363
            method(:StoreEnableDeleteImages),
364
            "void (string, map)"
365
          ),
366
          "help"   => HelpKdump("EnableDeleteImages")
367
        },
368
        "NumberDumps"            => {
369
          # TRANSLATORS: IntField Label
370
          "label"   => _("N&umber of Old Dumps"),
371
          "widget"  => :intfield,
372
          "minimum" => 0,
373
          "maximum" => 10,
374
          "init"    => fun_ref(method(:InitNumberDumps), "void (string)"),
375
          # "handle"                :
376
          "store"   => fun_ref(
377
            method(:StoreNumberDumps),
378
            "void (string, map)"
379
          ),
380
          "help"    => HelpKdump("NumberDumps")
381
        }
382
      }
383
    end
384

385
    def tabs
1✔
386
      return @tabs if @tabs
×
387

388
      @tabs = {
389
        "start_up"           => {
×
390
          "contents"        => VBox(
391
            "EnableDisalbeKdump",
392
            VSpacing(1),
393
            Left(ReplacePoint(Id("FADump"), Empty())),
394
            Frame(
395
              _("Kdump Memory"),
396
              HBox(HSpacing(1), VBox(Left("KdumpMemory")))
397
            ),
398
            VStretch()
399
          ),
400
          "caption"         => _("Kdump Start-Up"),
401
          "tree_item_label" => _("Start-Up"),
402
          "widget_names"    => [
403
            "DisBackButton",
404
            "EnableDisalbeKdump",
405
            (Kdump.fadump_supported? ? "FADump" : ""),
×
406
            "KdumpMemory"
407
          ]
408
        },
409
        "dump_filtering"     => {
410
          "contents"        => VBox(
411
            "DumpLevel",
412
            VSpacing(1),
413
            "DumpFormat",
414
            VStretch()
415
          ),
416
          "caption"         => _("Kdump - Dump Filtering"),
417
          "tree_item_label" => _("Dump Filtering"),
418
          "widget_names"    => ["DisBackButton", "DumpLevel", "DumpFormat"]
419
        },
420
        "dump_target"        => {
421
          "contents"        => VBox(
422
            Frame(
423
              _("Saving Target for Kdump Image"),
424
              HBox(HSpacing(1), VBox(Left("TargetKdump")))
425
            ),
426
            VSpacing(1),
427
            ReplacePoint(Id("Targets"), @ftp),
428
            VStretch()
429
          ),
430
          "caption"         => _("Dump Target"),
431
          "tree_item_label" => _("Dump Target"),
432
          "widget_names"    => ["DisBackButton", "TargetKdump"]
433
        },
434
        "email_notification" => {
435
          "contents"        => VBox(
436
            Frame(
437
              _("SMTP Server"),
438
              HBox(
439
                HSpacing(1),
440
                VBox(
441
                  Left("SMTPServer"),
442
                  HBox("SMTPUser", HSpacing(1), "SMTPPassword", HStretch())
443
                )
444
              )
445
            ),
446
            Frame(
447
              _("Notification Email Addresses"),
448
              HBox(
449
                HSpacing(1),
450
                VBox(Left("NotificationTo"), Left("NotificationCC"))
451
              )
452
            ),
453
            VStretch()
454
          ),
455
          "caption"         => _("Email Notification"),
456
          "tree_item_label" => _("Email Notification"),
457
          "widget_names"    => [
458
            "DisBackButton",
459
            "SMTPServer",
460
            "SMTPUser",
461
            "SMTPPassword",
462
            "NotificationTo",
463
            "NotificationCC"
464
          ]
465
        },
466
        "exp_settings"       => {
467
          "contents"        => VBox(
468
            Frame(
469
              _("Custom Kernel for Kdump"),
470
              HBox(HSpacing(1), VBox(Left("InitrdKernel")))
471
            ),
472
            VSpacing(1),
473
            Frame(
474
              _("Command Line"),
475
              HBox(
476
                HSpacing(1),
477
                VBox(Left("KdumpCommandLine"), Left("KdumpCommandLineAppend"))
478
              )
479
            ),
480
            VSpacing(1),
481
            Frame(
482
              _("Dump Settings"),
483
              HBox(
484
                HSpacing(1),
485
                VBox(
486
                  Left("EnableDeleteImages"),
487
                  Left("NumberDumps"),
488
                  Left("EnableReboot")
489
                )
490
              )
491
            ),
492
            VStretch()
493
          ),
494
          "caption"         => _("Kdump Expert Settings"),
495
          "tree_item_label" => _("Expert Settings"),
496
          "widget_names"    => [
497
            "DisBackButton",
498
            "KdumpCommandLine",
499
            "KdumpCommandLineAppend",
500
            "EnableDeleteImages",
501
            "NumberDumps",
502
            "InitrdKernel",
503
            "SelectKernel",
504
            "EnableReboot"
505
          ]
506
        }
507
      }
508
    end
509

510
    def kdump_memory_widget
1✔
511
      high_widgets = []
×
512

513
      if Kdump.high_memory_supported?
×
514
        high_min = Kdump.memory_limits[:min_high].to_i
×
515
        high_max = Kdump.memory_limits[:max_high].to_i
×
516
        high_default = Kdump.memory_limits[:default_high].to_i
×
517
        # TRANSLATORS: %{min}, %{max}, %{default} are variable names which must not be translated.
518
        high_range = format(_("(min: %{min}; max: %{max}; suggested: %{default})"),
×
519
          min:     high_min,
520
          max:     high_max,
521
          default: high_default)
522
        high_widgets << VSpacing(1)
×
523
        high_widgets << Left(
×
524
          IntField(
525
            Id("allocated_high_memory"),
526
            Opt(:notify),
527
            _("Kdump &High Memory [MiB]"),
528
            high_min,
529
            high_max,
530
            0
531
          )
532
        )
533
        high_widgets << Left(Label(high_range))
×
534
      end
535

536
      VBox(
×
537
        Left(
538
          CheckBox(
539
            Id(:auto_resize),
540
            Opt(:notify),
541
            _("&Automatically Resize at Boot"),
542
            false
543
          )
544
        ),
545
        VSpacing(1),
546
        Left(
547
          HBox(
548
            Left(Label(_("Total System Memory [MiB]:"))),
549
            Left(Label(Id("total_memory"), "0123456789")),
550
            HStretch()
551
          )
552
        ),
553
        VBox(
554
          Id(:allocated_memory_box),
555
          Left(
556
            HBox(
557
              Left(Label(_("Usable Memory [MiB]:"))),
558
              Left(ReplacePoint(Id("usable_memory_rp"), usable_memory_widget)),
559
              HStretch()
560
            )
561
          ),
562
          VSpacing(1),
563
          Left(ReplacePoint(Id("allocated_low_memory_rp"),
564
            low_memory_widget(fadump: Kdump.using_fadump?))),
565
          *high_widgets
566
        )
567
      )
568
    end
569

570
    def DisBackButton(_key)
1✔
571
      Wizard.SetTitleIcon("yast-kdump")
×
572
      UI.ChangeWidget(Id(:back), :Enabled, false)
×
573

574
      nil
575
    end
576

577
    def RunKdumpDialogs
1✔
578
      sim_dialogs = [
579
        "start_up",
×
580
        "dump_filtering",
581
        "dump_target",
582
        "email_notification",
583
        "exp_settings"
584
      ]
585

586
      DialogTree.ShowAndRun(
×
587
        # "functions"        : " ",
588
        # return CWMTab::CreateWidget($[
589
        "ids_order"      => sim_dialogs,
590
        "initial_screen" => "start_up",
591
        "screens"        => tabs,
592
        "widget_descr"   => wid_handling,
593
        "back_button"    => "",
594
        "abort_button"   => Label.CancelButton,
595
        "next_button"    => Label.OKButton
596
      )
597
    end
598

599
  private
1✔
600

601
    # Returns the low memory widget
602
    #
603
    # @param value [Integer] Current value or default if nil passed
604
    # @fadump fadump [Boolean] whener use low mem limits or fadump one
605
    # @return [Yast::Term] Low memory widget
606
    def low_memory_widget(value: nil, fadump: false)
1✔
607
      low_label = if Kdump.high_memory_supported?
×
608
        _("Kdump &Low Memory [MiB]")
×
609
      else
610
        _("Kdump Memor&y [MiB]")
×
611
      end
612

613
      limits = Kdump.memory_limits
×
614
      min_limit = fadump ? limits[:min_fadump] : limits[:min_low]
×
615
      max_limit = fadump ? limits[:max_fadump] : limits[:max_low]
×
616
      default = fadump ? limits[:default_fadump] : limits[:default_low]
×
617
      current = (min_limit..max_limit).cover?(value) ? value : default
×
618

619
      VBox(
×
620
        IntField(
621
          Id("allocated_low_memory"),
622
          Opt(:notify),
623
          low_label,
624
          min_limit,
625
          max_limit,
626
          current
627
        ),
628
        Label(
629
          # TRANSLATORS: %{min}, %{max}, %{default} are variable names which must not be translated.
630
          format(_("(min: %{min}; max: %{max}; suggested: %{default})"),
631
            min:     min_limit,
632
            max:     max_limit,
633
            default: default)
634
        )
635
      )
636
    end
637

638
    # Returns the usable memory widget
639
    #
640
    # It is just a label, but the idea is to redraw the widget to avoid
641
    # some resizing problems.
642
    #
643
    # @param value [Integer,nil] Current value
644
    # @return [Yast::Term] Usable memory label
645
    def usable_memory_widget(value = nil)
1✔
646
      content = value ? value.to_s : "0123456789"
×
647
      Label(Id("usable_memory"), content)
×
648
    end
649
  end
650
end
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc