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

yast / yast-kdump / 3624339857

pending completion
3624339857

Pull #132

github

Unknown Committer
Unknown Commit Message
Pull Request #132: add support for fadump keys in kdumptool calibrate

12 of 12 new or added lines in 1 file covered. (100.0%)

749 of 1831 relevant lines covered (40.91%)

4.54 hits per line

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

42.55
/src/include/kdump/dialogs.rb
1
# encoding: utf-8
2

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

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

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

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

44
    def wid_handling
1✔
45
      return @wid_handling if @wid_handling
×
46

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

398
    def tabs
1✔
399
      return @tabs if @tabs
×
400

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

525
    def kdump_memory_widget
1✔
526
      high_widgets = []
×
527

528
      if Kdump.high_memory_supported?
×
529
        high_min = Kdump.memory_limits[:min_high].to_i
×
530
        high_max = Kdump.memory_limits[:max_high].to_i
×
531
        high_default = Kdump.memory_limits[:default_high].to_i
×
532
        # TRANSLATORS: %{min}, %{max}, %{default} are variable names which must not be translated.
533
        high_range = format(_("(min: %{min}; max: %{max}; suggested: %{default})"),
×
534
          min:     high_min,
535
          max:     high_max,
536
          default: high_default)
537
        high_widgets << VSpacing(1)
×
538
        high_widgets << Left(
×
539
          IntField(
540
            Id("allocated_high_memory"),
541
            Opt(:notify),
542
            _("Kdump &High Memory [MiB]"),
543
            high_min,
544
            high_max,
545
            0
546
          )
547
        )
548
        high_widgets << Left(Label(high_range))
×
549
      end
550

551
      VBox(
×
552
        Left(
553
          CheckBox(
554
            Id(:auto_resize),
555
            Opt(:notify),
556
            _("&Automatically Resize at Boot"),
557
            false
558
          )
559
        ),
560
        VSpacing(1),
561
        Left(
562
          HBox(
563
            Left(Label(_("Total System Memory [MiB]:"))),
564
            Left(Label(Id("total_memory"), "0123456789")),
565
            HStretch()
566
          )
567
        ),
568
        VBox(
569
          Id(:allocated_memory_box),
570
          Left(
571
            HBox(
572
              Left(Label(_("Usable Memory [MiB]:"))),
573
              Left(ReplacePoint(Id("usable_memory_rp"), usable_memory_widget)),
574
              HStretch()
575
            )
576
          ),
577
          VSpacing(1),
578
          Left(ReplacePoint(Id("allocated_low_memory_rp"), low_memory_widget)),
579
          *high_widgets
580
        )
581
      )
582
    end
583

584
    def DisBackButton(_key)
1✔
585
      Wizard.SetTitleIcon("yast-kdump")
×
586
      UI.ChangeWidget(Id(:back), :Enabled, false)
×
587

588
      nil
589
    end
590

591
    def RunKdumpDialogs
1✔
592
      sim_dialogs = [
593
        "start_up",
×
594
        "dump_filtering",
595
        "dump_target",
596
        "email_notification",
597
        "exp_settings"
598
      ]
599

600
      DialogTree.ShowAndRun(
×
601
        # "functions"        : " ",
602
        # return CWMTab::CreateWidget($[
603
        "ids_order"      => sim_dialogs,
604
        "initial_screen" => "start_up",
605
        "screens"        => tabs,
606
        "widget_descr"   => wid_handling,
607
        "back_button"    => "",
608
        "abort_button"   => Label.CancelButton,
609
        "next_button"    => Label.OKButton
610
      )
611
    end
612

613
  private
1✔
614

615
    # Returns the low memory widget
616
    #
617
    # @param value [Integer] Current value
618
    # @return [Yast::Term] Low memory widget
619
    def low_memory_widget(value = nil)
1✔
620
      low_label = if Kdump.high_memory_supported?
×
621
        _("Kdump &Low Memory [MiB]")
×
622
      else
623
        _("Kdump Memor&y [MiB]")
×
624
      end
625

626
      limits = Kdump.memory_limits
×
627
      current = (limits[:min_low]..limits[:max_low]).cover?(value) ? value : limits[:default_low]
×
628

629
      VBox(
×
630
        IntField(
631
          Id("allocated_low_memory"),
632
          Opt(:notify),
633
          low_label,
634
          limits[:min_low],
635
          limits[:max_low],
636
          current
637
        ),
638
        Label(
639
          # TRANSLATORS: %{min}, %{max}, %{default} are variable names which must not be translated.
640
          format(_("(min: %{min}; max: %{max}; suggested: %{default})"),
641
            min:     limits[:min_low],
642
            max:     limits[:max_low],
643
            default: limits[:default_low])
644
        )
645
      )
646
    end
647

648
    # Returns the usable memory widget
649
    #
650
    # It is just a label, but the idea is to redraw the widget to avoid
651
    # some resizing problems.
652
    #
653
    # @param value [Integer,nil] Current value
654
    # @return [Yast::Term] Usable memory label
655
    def usable_memory_widget(value = nil)
1✔
656
      content = value ? value.to_s : "0123456789"
×
657
      Label(Id("usable_memory"), content)
×
658
    end
659
  end
660
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

© 2025 Coveralls, Inc