Class: Yast::KdumpClass
- Inherits:
-
Module
- Object
- Module
- Yast::KdumpClass
- Includes:
- Logger
- Defined in:
- ../../src/modules/Kdump.rb
Constant Summary
- FADUMP_KEY =
"KDUMP_FADUMP"
- KDUMP_SERVICE_NAME =
"kdump"
- KDUMP_PACKAGES =
["kexec-tools", "kdump"]
- TEMPORARY_CONFIG_FILE =
"/var/lib/YaST2/kdump.sysconfig"
- TEMPORARY_CONFIG_PATH =
Path.new(".temporary.sysconfig.kdump")
- PROPOSE_ALLOCATED_MEMORY_MB_COMMAND =
"kdumptool --configfile #{TEMPORARY_CONFIG_FILE} calibrate"
- PROPOSE_ALLOCATED_MEMORY_MB_FALLBACK =
if the command fails
"128"
Instance Method Summary (collapse)
-
- (Boolean) Abort
Abort function.
-
- (Object) AddPackages
Adding necessary packages for installation.
-
- (Object) BuildCrashkernelValue
Build crashkernel value from allocated memory.
-
- (Object) CheckPackages
Check if user enabled kdump if no deselect packages for installing if yes add necessary packages for installation.
-
- (Boolean) checkPassword
Function check if KDUMP_SAVEDIR or KDUMP_SMTP_PASSWORD include password.
-
- (Boolean) Chmod(target, permissions)
Function set permission for file.
-
- (Object) Export
Export kdump settings to a map.
-
- (Boolean) fadump_supported?
Returns whether FADump (Firmware assisted dump) is supported by the current system.
-
- (Hash{String => String}) filterExport(settings)
bnc# 480466 - fix problem with validation autoyast profil Function filters keys for autoyast profil.
-
- (Object) getAllocatedMemory(crash_value)
get allocated memory from value of crashkernel option there can be several ranges -> take the first range @param string 64M@16M or 128M-:64M@16M [(reserved_memory*2)-:reserved_memory] @return [String] value of allocated memory (64M).
-
- (Object) GetModified
Data was modified?.
-
- (Boolean) Import(settings)
Import settings from a map.
- - (Object) log_settings_censoring_passwords(message)
- - (Object) main
-
- (Object) Propose
Propose all kdump settings.
-
- (Boolean) ProposeAllocatedMemory
Propose reserved/allocated memory Store the result as a string! to @allocated_memory.
- - (Object) ProposeCrashkernelParam
-
- (Object) ProposeGlobalVars
Propose global variables once…
-
- (Object) Read
Read all kdump settings.
-
- (Object) ReadAvailableMemory
Read available memory.
-
- (Object) ReadKdumpKernelParam
Read current kdump configuration.
-
- (Object) ReadKdumpSettings
Read current kdump configuration.
-
- (Object) SetModified
Set data was modified.
-
- (Object) Summary
Create a textual summary and a list of unconfigured cards.
-
- (Object) Update
Update crashkernel argument during update of OS.
-
- (Boolean) update_initrd
Updates initrd and reports whether it was successful.
-
- (Boolean) use_fadump(new_value)
Sets whether to use FADump (Firmware assisted dump).
-
- (Boolean) using_fadump?
Returns whether FADump (Firmware assisted dump) is currently in use.
-
- (Boolean) using_fadump_changed?
Has the using_fadump? been changed?.
-
- (Object) Write
Write all kdump settings.
- - (Object) write_temporary_config_file
-
- (Object) WriteKdumpBootParameter
Write kdump boot argument crashkernel set kdump start at boot.
-
- (Object) WriteKdumpSettings
Write current kdump configuration.
-
- (Object) WriteKdumpSettingsTo(scr_path, file_name)
Writes a file in the /etc/sysconfig/kdump format.
Instance Method Details
- (Boolean) Abort
Abort function
198 199 200 201 |
# File '../../src/modules/Kdump.rb', line 198 def Abort return @AbortFunction.call == true if @AbortFunction != nil false end |
- (Object) AddPackages
Adding necessary packages for installation
746 747 748 749 750 |
# File '../../src/modules/Kdump.rb', line 746 def AddPackages return unless Mode.installation @kdump_packages.concat KDUMP_PACKAGES end |
- (Object) BuildCrashkernelValue
Build crashkernel value from allocated memory
@return [String] value of crashkernel
321 322 323 324 325 326 327 328 329 330 331 332 |
# File '../../src/modules/Kdump.rb', line 321 def BuildCrashkernelValue # If user didn't modify or select return old value. return @crashkernel_param_value if @crashkernel_list_ranges crash_value = @allocated_memory + "M" reserved_memory = (@allocated_memory.to_i * 2).to_s crash_value = reserved_memory + "M-:" + crash_value log.info "built crashkernel value is #{crash_value}" crash_value end |
- (Object) CheckPackages
Check if user enabled kdump if no deselect packages for installing if yes add necessary packages for installation
784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 |
# File '../../src/modules/Kdump.rb', line 784 def CheckPackages # remove duplicates @kdump_packages.uniq! if !@add_crashkernel_param Builtins.y2milestone( "deselect packages for installation: %1", @kdump_packages ) @kdump_packages.each do |p| PackagesProposal.RemoveResolvables("yast2-kdump", :package, [p]) end if !@kdump_packages.empty? Builtins.y2milestone( "Deselected kdump packages for installation: %1", @kdump_packages ) end else Builtins.y2milestone( "select packages for installation: %1", @kdump_packages ) @kdump_packages.each do |p| PackagesProposal.AddResolvables("yast2-kdump", :package, [p]) end if !@kdump_packages.empty? Builtins.y2milestone( "Selected kdump packages for installation: %1", @kdump_packages ) end end nil end |
- (Boolean) checkPassword
Function check if KDUMP_SAVEDIR or KDUMP_SMTP_PASSWORD include password
255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 |
# File '../../src/modules/Kdump.rb', line 255 def checkPassword return true if Ops.get(@KDUMP_SETTINGS, "KDUMP_SMTP_PASSWORD", "") != "" if Builtins.search(Ops.get(@KDUMP_SETTINGS, "KDUMP_SAVEDIR", ""), "file") != nil || Builtins.search(Ops.get(@KDUMP_SETTINGS, "KDUMP_SAVEDIR", ""), "nfs") != nil || Ops.get(@KDUMP_SETTINGS, "KDUMP_SAVEDIR", "") == "" return false end if Builtins.search(Ops.get(@KDUMP_SETTINGS, "KDUMP_SAVEDIR", ""), "@") == nil return false end temp = Builtins.splitstring( Ops.get(@KDUMP_SETTINGS, "KDUMP_SAVEDIR", ""), "@" ) temp_1 = Ops.get(temp, 0, "") position = Builtins.findlastof(temp_1, ":") return false if position == nil # if there is 2 times ":" -> it means that password is defined # for example cifs://login:password@server.... if Ops.greater_than(position, 6) return true else return false end end |
- (Boolean) Chmod(target, permissions)
Function set permission for file.
FileUtils::Chmod (“/etc/sysconfig/kdump”, “600”) -> true FileUtils::Chmod (“/tmp/doesnt_exist”, “644”) -> false
228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 |
# File '../../src/modules/Kdump.rb', line 228 def Chmod(target, ) if !FileUtils.Exists(target) Builtins.y2error("Target %1 doesn't exist", target) return false end if !FileUtils.Exists("/bin/chmod") Builtins.y2error("tool: /bin/chmod not found") return false end cmd = Builtins.sformat("/bin/chmod %1 %2", , target) cmd_out = Convert.to_map(SCR.Execute(path(".target.bash_output"), cmd)) if Ops.get_integer(cmd_out, "exit", -1) != 0 Builtins.y2error("Command >%1< returned %2", cmd, cmd_out) return false end Builtins.y2milestone("Command: %1 finish successful.", cmd) true end |
- (Object) Export
Export kdump settings to a map
906 907 908 909 910 911 912 913 914 915 |
# File '../../src/modules/Kdump.rb', line 906 def Export out = { "crash_kernel" => BuildCrashkernelValue(), "add_crash_kernel" => @add_crashkernel_param, "general" => filterExport(@KDUMP_SETTINGS) } Builtins.y2milestone("Kdump exporting settings: %1", out) deep_copy(out) end |
- (Boolean) fadump_supported?
Returns whether FADump (Firmware assisted dump) is supported by the current system
951 952 953 |
# File '../../src/modules/Kdump.rb', line 951 def fadump_supported? Arch.ppc64 end |
- (Hash{String => String}) filterExport(settings)
bnc# 480466 - fix problem with validation autoyast profil Function filters keys for autoyast profil
889 890 891 892 893 894 895 896 897 898 899 900 901 902 |
# File '../../src/modules/Kdump.rb', line 889 def filterExport(settings) settings = deep_copy(settings) ret = {} keys = Convert.convert( Map.Keys(@DEFAULT_CONFIG), :from => "list", :to => "list <string>" ) ret = Builtins.filter(settings) do |key, value| next true if Builtins.contains(keys, key) end deep_copy(ret) end |
- (Object) getAllocatedMemory(crash_value)
get allocated memory from value of crashkernel option there can be several ranges -> take the first range @param string 64M@16M or 128M-:64M@16M [(reserved_memory*2)-:reserved_memory] @return [String] value of allocated memory (64M)
291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 |
# File '../../src/modules/Kdump.rb', line 291 def getAllocatedMemory(crash_value) result = "" allocated = "" range = "" if Builtins.search(crash_value, ",") != nil ranges = Builtins.splitstring(crash_value, ",") @crashkernel_list_ranges = true range = Ops.get(ranges, 0, "") else range = crash_value end Builtins.y2milestone("The 1st range from crashkernel is %1", range) position = Builtins.search(range, ":") if position != nil allocated = Builtins.substring(range, Ops.add(position, 1)) else allocated = range end result = Builtins.substring(allocated, 0, Builtins.search(allocated, "M")) Builtins.y2milestone("Allocated memory is %1", result) result end |
- (Object) GetModified
Data was modified?
205 206 207 208 |
# File '../../src/modules/Kdump.rb', line 205 def GetModified Builtins.y2debug("modified=%1", @modified) @modified end |
- (Boolean) Import(settings)
Import settings from a map
920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 |
# File '../../src/modules/Kdump.rb', line 920 def Import(settings) settings = deep_copy(settings) Builtins.y2milestone("Importing settings for kdump") @crashkernel_param_value = Ops.get_string(settings, "crash_kernel", "") if settings.has_key?("add_crash_kernel") @add_crashkernel_param = settings["add_crash_kernel"] else @add_crashkernel_param = ProposeCrashkernelParam() end result = true my_import_map = Ops.get_map(settings, "general", {}) Builtins.foreach(Map.Keys(@DEFAULT_CONFIG)) do |key| str_key = Builtins.tostring(key) val = Ops.get(my_import_map, str_key) Ops.set(@KDUMP_SETTINGS, str_key, val) if val != nil if val == nil Ops.set(@KDUMP_SETTINGS, str_key, Ops.get(@DEFAULT_CONFIG, str_key)) end end if Builtins.haskey(settings, "crash_kernel") || Builtins.haskey(settings, "add_crash_kernel") || Ops.greater_than(Builtins.size(my_import_map), 0) @import_called = true end result end |
- (Object) log_settings_censoring_passwords(message)
444 445 446 447 448 449 450 451 452 |
# File '../../src/modules/Kdump.rb', line 444 def log_settings_censoring_passwords() debug_KDUMP_SETTINGS = deep_copy(@KDUMP_SETTINGS) debug_KDUMP_SETTINGS["KDUMP_SAVEDIR"] = "********" debug_KDUMP_SETTINGS["KDUMP_SMTP_PASSWORD"] = "********" log.info "-------------KDUMP_SETTINGS-------------------" log.info "#{}; here with censored passwords: #{debug_KDUMP_SETTINGS}" log.info "---------------------------------------------" end |
- (Object) main
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 |
# File '../../src/modules/Kdump.rb', line 41 def main textdomain "kdump" Yast.import "Progress" Yast.import "Report" Yast.import "Summary" Yast.import "Message" Yast.import "BootCommon" #import "Storage"; Yast.import "Map" Yast.import "Bootloader" Yast.import "Service" Yast.import "Popup" Yast.import "Arch" Yast.import "Mode" Yast.import "ProductControl" Yast.import "ProductFeatures" Yast.import "PackagesProposal" Yast.import "FileUtils" Yast.import "Directory" # Data was modified? @modified = false # kdump config file @kdump_file = "/etc/sysconfig/kdump" @proposal_valid = false # List of available partiotions # with known partition # # list <string> @available_partitions = [] # true if propose was called @propose_called = false # List of available partiotions # without filesystem or with uknown # # list <string> @uknown_fs_partitions = [] # Total available memory [MB] # # # integer @total_memory = 0 # Boolean option indicates that "crashkernel" includes # several ranges # # boolean true if there are several ranges (>1) @crashkernel_list_ranges = false # list of packages for installation @kdump_packages = [] # Number of cpus # # integer @number_of_cpus = 1 # kernel version (uname -r) # # string @kernel_version = "" # Position actual boot section in BootCommon::sections list # it is relevant only if XEN boot section is used # # integer @section_pos = -1 # Boolean option indicates kernel parameter # "crashkernel" # # boolean true if kernel parameter is set @crashkernel_param = false # String option indicates value of kernel parameter # "crashkernel" # # string value of kernel parameter @crashkernel_param_value = "" # Boolean option indicates add kernel param # "crashkernel" # # boolean true if kernel parameter will be add @add_crashkernel_param = false # String option for alocate of memory for boot param # "crashkernel" # # string value number of alocate memory @allocated_memory = "0" # Boolean option indicates that Import() # was called and data was proposed # # boolean true if import was called with data @import_called = false # Write only, used during autoinstallation. # Don't run services and SuSEconfig, it's all done at one place. @write_only = false # Abort function # return boolean return true if abort @AbortFunction = nil # map of deafult values for options in UI # # global map <string, string > @DEFAULT_CONFIG = { "KDUMP_KERNELVER" => "", "KDUMP_COMMANDLINE" => "", "KDUMP_COMMANDLINE_APPEND" => "", "KEXEC_OPTIONS" => "", "KDUMP_IMMEDIATE_REBOOT" => "yes", "KDUMP_COPY_KERNEL" => "yes", "KDUMP_TRANSFER" => "", "KDUMP_SAVEDIR" => "file:///var/crash", "KDUMP_KEEP_OLD_DUMPS" => "5", "KDUMP_FREE_DISK_SIZE" => "64", "KDUMP_VERBOSE" => "3", "KDUMP_DUMPLEVEL" => "31", "KDUMP_DUMPFORMAT" => "lzo", "KDUMP_SMTP_SERVER" => "", "KDUMP_SMTP_USER" => "", "KDUMP_SMTP_PASSWORD" => "", "KDUMP_NOTIFICATION_TO" => "", "KDUMP_NOTIFICATION_CC" => "" } # map <string, string > of kdump settings # @KDUMP_SETTINGS = {} # initial kdump settings replaced in Read function @initial_kdump_settings = deep_copy(@KDUMP_SETTINGS) end |
- (Object) Propose
Propose all kdump settings
822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 |
# File '../../src/modules/Kdump.rb', line 822 def Propose Builtins.y2milestone("Proposing new settings of kdump") # read available memory ReadAvailableMemory() # set default values for global variables ProposeGlobalVars() ProposeAllocatedMemory() # add packages for installation AddPackages() # select packages for installation CheckPackages() nil end |
- (Boolean) ProposeAllocatedMemory
Propose reserved/allocated memory Store the result as a string! to @allocated_memory
386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 |
# File '../../src/modules/Kdump.rb', line 386 def ProposeAllocatedMemory # only propose once return true if @allocated_memory != "0" write_temporary_config_file out = SCR.Execute(path(".target.bash_output"), PROPOSE_ALLOCATED_MEMORY_MB_COMMAND) @allocated_memory = out["stdout"].chomp if out["exit"] != 0 or @allocated_memory.empty? # stderr has been already logged Builtins.y2error("failed to propose allocated memory") @allocated_memory = PROPOSE_ALLOCATED_MEMORY_MB_FALLBACK end Builtins.y2milestone( "[kdump] allocated memory if not set in \"crashkernel\" param: %1", @allocated_memory ) true end |
- (Object) ProposeCrashkernelParam
752 753 754 755 756 757 758 759 760 |
# File '../../src/modules/Kdump.rb', line 752 def ProposeCrashkernelParam ReadAvailableMemory() # propose disable kdump if PC has less than 1024MB RAM if @total_memory < 1024 false else true end end |
- (Object) ProposeGlobalVars
Propose global variables once… after that remember user settings
765 766 767 768 769 770 771 772 773 774 775 776 777 778 |
# File '../../src/modules/Kdump.rb', line 765 def ProposeGlobalVars if !@propose_called # Autoyast: "add_crashkernel_param" will be set by using autoinst.xml # (bnc#890719) @add_crashkernel_param = ProposeCrashkernelParam() unless Mode.autoinst @crashkernel_param = false # added defualt settings @KDUMP_SETTINGS = deep_copy(@DEFAULT_CONFIG) end @propose_called = true nil end |
- (Object) Read
Read all kdump settings
598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 |
# File '../../src/modules/Kdump.rb', line 598 def Read # Kdump read dialog caption caption = _("Initializing kdump Configuration") steps = 4 Progress.New( caption, " ", steps, [ # Progress stage 1/4 _("Reading the config file..."), # Progress stage 3/4 _("Reading kernel boot options..."), # Progress stage 4/4 _("Reading available memory...") ], [ # Progress step 1/4 _("Reading the config file..."), # Progress step 2/4 _("Reading partitions of disks..."), # Progress finished 3/4 _("Reading available memory..."), # Progress finished 4/4 Message.Finished ], "" ) # read database return false if Abort() Progress.NextStage # Error message if !ReadKdumpSettings() Report.Error(_("Cannot read config file /etc/sysconfig/kdump")) end # read another database return false if Abort() Progress.NextStep # Error message if !ReadKdumpKernelParam() Report.Error(_("Cannot read kernel boot options.")) end # read another database return false if Abort() Progress.NextStep # Error message Report.Error(_("Cannot read available memory.")) if !ReadAvailableMemory() return false if Abort() # Progress finished Progress.NextStage return false if Abort() @modified = false true end |
- (Object) ReadAvailableMemory
Read available memory
@return [Boolean] successfull
410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 |
# File '../../src/modules/Kdump.rb', line 410 def ReadAvailableMemory output = Convert.convert( SCR.Read(path(".probe.memory")), :from => "any", :to => "list <map>" ) Builtins.y2milestone( "[kdump] (ReadAvailableMemory) SCR::Read(.probe.memory): %1", output ) resor = {} temp = Builtins.maplist(output) { |mem| Ops.get(mem, "resource") } #y2milestone("[kdump] (ReadAvailableMemory) temp: %1", temp); resor = Builtins.tomap(Ops.get(temp, 0)) output = Convert.convert( Ops.get(resor, "phys_mem"), :from => "any", :to => "list <map>" ) temp = Builtins.maplist(output) { |mem| Ops.get(mem, "range") } #list <any> range = maplist(map resor["phys_mem"]:nil); #resor = (map)range; @total_memory = Ops.divide(Builtins.tointeger(Ops.get(temp, 0)), 1048576) Builtins.y2milestone( "[kdump] (ReadAvailableMemory) total phys. memory [MB]: %1", Builtins.tostring(@total_memory) ) true end |
- (Object) ReadKdumpKernelParam
Read current kdump configuration
read kernel parameter “crashkernel” @return [Boolean] successfull
339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 |
# File '../../src/modules/Kdump.rb', line 339 def ReadKdumpKernelParam result = Bootloader.kernel_param(:common, "crashkernel") result = Bootloader.kernel_param(:xen_guest, "crashkernel") if result == :missing # result could be [String,:missing,:present] # String - the value # :missing - crashkernel is missed # :present - crashkernel is defined but no value is available #Popup::Message(result); if result == :missing @crashkernel_param = false @add_crashkernel_param = false else @crashkernel_param = true @add_crashkernel_param = true end @crashkernel_param_value = result if result != :missing && result != :present # Read the current value only if crashkernel parameter is set. # (bnc#887901) @allocated_memory = getAllocatedMemory(@crashkernel_param_value) end true end |
- (Object) ReadKdumpSettings
Read current kdump configuration
@return [Boolean] successful
457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 |
# File '../../src/modules/Kdump.rb', line 457 def ReadKdumpSettings @KDUMP_SETTINGS = deep_copy(@DEFAULT_CONFIG) SCR.Dir(path(".sysconfig.kdump")).each do |key| val = Convert.to_string( SCR.Read(path(".sysconfig.kdump") + key) ) @KDUMP_SETTINGS[key] = val end log_settings_censoring_passwords("kdump configuration has been read") @initial_kdump_settings = deep_copy(@KDUMP_SETTINGS) true end |
- (Object) SetModified
Set data was modified
212 213 214 215 216 217 |
# File '../../src/modules/Kdump.rb', line 212 def SetModified @modified = true Builtins.y2debug("modified=%1", @modified) nil end |
- (Object) Summary
Create a textual summary and a list of unconfigured cards
841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 |
# File '../../src/modules/Kdump.rb', line 841 def Summary result = [] result = Builtins.add( result, Builtins.sformat( _("Kdump status: %1"), @add_crashkernel_param ? _("enabled") : _("disabled") ) ) if @add_crashkernel_param result = Builtins.add( result, Builtins.sformat( _("Value of crashkernel option: %1"), BuildCrashkernelValue() ) ) result = Builtins.add( result, Builtins.sformat( _("Dump format: %1"), Ops.get(@KDUMP_SETTINGS, "KDUMP_DUMPFORMAT", "") ) ) result = Builtins.add( result, Builtins.sformat( _("Target of dumps: %1"), Ops.get(@KDUMP_SETTINGS, "KDUMP_SAVEDIR", "") ) ) result = Builtins.add( result, Builtins.sformat( _("Number of dumps: %1"), Ops.get(@KDUMP_SETTINGS, "KDUMP_KEEP_OLD_DUMPS", "") ) ) end deep_copy(result) end |
- (Object) Update
Update crashkernel argument during update of OS
662 663 664 665 666 667 |
# File '../../src/modules/Kdump.rb', line 662 def Update Builtins.y2milestone("Update kdump settings") ReadKdumpKernelParam() WriteKdumpBootParameter() true end |
- (Boolean) update_initrd
Updates initrd and reports whether it was successful. Failed update is reported using Report library.
477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 |
# File '../../src/modules/Kdump.rb', line 477 def update_initrd # See FATE#315780 # See https://www.suse.com/support/kb/doc.php?id=7012786 # FIXME what about dracut? update_command = (using_fadump? ? "mkdumprd -f" : "mkinitrd") update_logfile = File.join(Directory.vardir, "y2logmkinitrd") run_command = update_command + " >> #{update_logfile} 2>&1" y2milestone("Running command: #{run_command}") ret = SCR.Execute(path(".target.bash"), run_command) if ret != 0 y2error("Error updating initrd, see #{update_logfile} or call {update_command} manually") Report.Error(_( "Error updating initrd while calling '%{cmd}'.\n" + "See %{log} for details." ) % { :cmd => update_command, :log => update_logfile }) return false end true end |
- (Boolean) use_fadump(new_value)
Sets whether to use FADump (Firmware assisted dump)
959 960 961 962 963 964 965 966 967 968 969 |
# File '../../src/modules/Kdump.rb', line 959 def use_fadump(new_value) # Trying to use fadump on unsupported hardware if !fadump_supported? && new_value Builtins.y2milestone("FADump is not supported on this hardware") Report.Error(_("Cannot use Firmware-assisted dump.\nIt is not supported on this hardware.")) return false end @KDUMP_SETTINGS[FADUMP_KEY] = (new_value ? "yes" : "no") true end |
- (Boolean) using_fadump?
Returns whether FADump (Firmware assisted dump) is currently in use
974 975 976 |
# File '../../src/modules/Kdump.rb', line 974 def using_fadump? @KDUMP_SETTINGS[FADUMP_KEY] == "yes" end |
- (Boolean) using_fadump_changed?
Has the using_fadump? been changed?
981 982 983 |
# File '../../src/modules/Kdump.rb', line 981 def using_fadump_changed? @initial_kdump_settings[FADUMP_KEY] != @KDUMP_SETTINGS[FADUMP_KEY] end |
- (Object) Write
Write all kdump settings
672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 |
# File '../../src/modules/Kdump.rb', line 672 def Write # Kdump read dialog caption caption = _("Saving kdump Configuration") #number of stages steps = 2 if Mode.installation write_kdump = ProductFeatures.GetBooleanFeature( "globals", "enable_kdump" ) if write_kdump == nil || !write_kdump Builtins.y2milestone("Installation doesn't support kdump.") return true end end if (Mode.installation || Mode.autoinst) && !@add_crashkernel_param Builtins.y2milestone( "Skip writing of configuration for kdump during installation" ) return true end # We do not set help text here, because it was set outside Progress.New( caption, " ", steps, [ # Progress stage 1/2 _("Write the settings"), # Progress stage 2/2 _("Update boot options") ], [ # Progress step 1/2 _("Writing the settings..."), # Progress step 2/2 _("Updating boot options..."), # Progress finished _("Finished") ], "" ) # write settings return false if Abort() Progress.NextStage # Error message if ! WriteKdumpSettings() Report.Error(_("Cannot write settings.")) return false end # write/delete bootloader option for kernel "crashkernel" return false if Abort() Progress.NextStage # Error message if !WriteKdumpBootParameter() Report.Error(_("Adding crashkernel parameter to bootloader fault.")) end return false if Abort() # Progress finished Progress.NextStage return false if Abort() true end |
- (Object) write_temporary_config_file
369 370 371 372 373 374 375 376 377 |
# File '../../src/modules/Kdump.rb', line 369 def write_temporary_config_file SCR.RegisterAgent(TEMPORARY_CONFIG_PATH, term(:ag_ini, term(:SysConfigFile, TEMPORARY_CONFIG_FILE) ) ) WriteKdumpSettingsTo(TEMPORARY_CONFIG_PATH, TEMPORARY_CONFIG_FILE) SCR.UnregisterAgent(TEMPORARY_CONFIG_PATH) end |
- (Object) WriteKdumpBootParameter
Write kdump boot argument crashkernel set kdump start at boot
@return [Boolean] successfull
533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 |
# File '../../src/modules/Kdump.rb', line 533 def WriteKdumpBootParameter result = true old_progress = false if @add_crashkernel_param crash_value = "" crash_value = BuildCrashkernelValue() if !Mode.autoinst if !@crashkernel_param || crash_value != @crashkernel_param_value crash_value = @crashkernel_param_value if Mode.autoinst if Mode.update if Builtins.search(crash_value, "@") != nil tmp_crash_value = Builtins.splitstring(crash_value, "@") crash_value = Ops.get(tmp_crash_value, 0, "") Builtins.y2milestone( "Delete offset crashkernel value: %1", crash_value ) end end Bootloader.modify_kernel_params(:common, :xen_guest, :recovery, "crashkernel" => crash_value) old_progress = Progress.set(false) Bootloader.Write Progress.set(old_progress) # Popup::Message(crash_value); Builtins.y2milestone( "[kdump] (WriteKdumpBootParameter) adding chrashkernel option with value : %1", crash_value ) if Mode.normal Popup.Message(_("To apply changes a reboot is necessary.")) end Service.Enable(KDUMP_SERVICE_NAME) return result end # start kdump at boot Service.Enable(KDUMP_SERVICE_NAME) Service.Restart(KDUMP_SERVICE_NAME) if Service.Status(KDUMP_SERVICE_NAME) == 0 else if @crashkernel_param #delete crashkernel paramter from bootloader Bootloader.modify_kernel_params(:common, :xen_guest, :recovery, "crashkernel" => :missing) old_progress = Progress.set(false) Bootloader.Write Progress.set(old_progress) if Mode.normal Popup.Message(_("To apply changes a reboot is necessary.")) end end Service.Disable(KDUMP_SERVICE_NAME) Service.Stop(KDUMP_SERVICE_NAME) if Service.Status(KDUMP_SERVICE_NAME) == 0 return result end true end |
- (Object) WriteKdumpSettings
Write current kdump configuration
@return [Boolean] successful
519 520 521 522 523 524 525 526 527 |
# File '../../src/modules/Kdump.rb', line 519 def WriteKdumpSettings WriteKdumpSettingsTo(path(".sysconfig.kdump"), @kdump_file) if using_fadump_changed? && ! update_initrd return false end true end |
- (Object) WriteKdumpSettingsTo(scr_path, file_name)
Writes a file in the /etc/sysconfig/kdump format
501 502 503 504 505 506 507 508 509 510 511 512 513 514 |
# File '../../src/modules/Kdump.rb', line 501 def WriteKdumpSettingsTo(scr_path, file_name) log_settings_censoring_passwords("kdump configuration for writing") @KDUMP_SETTINGS.each do |option_key, option_val| SCR.Write(scr_path + option_key, option_val) end SCR.Write(scr_path, nil) if checkPassword Chmod(file_name, "600") else Chmod(file_name, "644") end end |