Class: Yast::SystemSettingsClass
- Inherits:
-
Module
- Object
- Module
- Yast::SystemSettingsClass
- Includes:
- Logger
- Defined in:
- ../../src/modules/SystemSettings.rb
Instance Method Summary (collapse)
- - (Object) Activate
-
- (Object) GetIOScheduler
Kernel param 'elevator'.
- - (Object) GetPossibleElevatorValues
- - (Object) GetSysRqKeysEnabled
- - (Object) main
- - (Object) Modified
- - (Object) Read
- - (Object) SetIOScheduler(io_scheduler)
- - (Object) SetSysRqKeysEnabled(enable_sysrq)
- - (Object) Write
Instance Method Details
- (Object) Activate
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 |
# File '../../src/modules/SystemSettings.rb', line 111 def Activate if @ENABLE_SYSRQ != nil && Builtins.regexpmatch(@ENABLE_SYSRQ, "^[0-9]+$") Builtins.y2milestone("Activating SysRq config: %1", @ENABLE_SYSRQ) SCR.Execute( path(".target.bash"), Builtins.sformat("echo '%1' > /proc/sys/kernel/sysrq", @ENABLE_SYSRQ) ) else Builtins.y2warning( "Not activating invalid ENABLE_SYSRQ value: %1", @ENABLE_SYSRQ ) end if @elevator != nil Yast.import "Bootloader" new_elevator = @elevator == "" ? :missing : @elevator Builtins.y2milestone("Activating scheduler: %1", new_elevator) # set the scheduler Bootloader.modify_kernel_params("elevator" => new_elevator) # activate the scheduler for all disk devices if new_elevator != :missing Dir["/sys/block/*/queue/scheduler"].each do |f| log.info "Activating scheduler '#{new_elevator}' for device #{f}" File.write(f, new_elevator) end end end true end |
- (Object) GetIOScheduler
Kernel param 'elevator'
171 172 173 |
# File '../../src/modules/SystemSettings.rb', line 171 def GetIOScheduler @elevator end |
- (Object) GetPossibleElevatorValues
33 34 35 36 |
# File '../../src/modules/SystemSettings.rb', line 33 def GetPossibleElevatorValues # here are listed all known values of the 'elevator' variable ["cfq", "noop", "deadline"] end |
- (Object) GetSysRqKeysEnabled
193 194 195 |
# File '../../src/modules/SystemSettings.rb', line 193 def GetSysRqKeysEnabled @ENABLE_SYSRQ != nil && @ENABLE_SYSRQ != "0" end |
- (Object) main
18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File '../../src/modules/SystemSettings.rb', line 18 def main textdomain "tune" Yast.import "Service" Yast.import "Mode" # Internal Data @ENABLE_SYSRQ = nil @elevator = nil # Internal Data @modified = false end |
- (Object) Modified
38 39 40 41 |
# File '../../src/modules/SystemSettings.rb', line 38 def Modified Builtins.y2milestone("Modified: %1", @modified) @modified end |
- (Object) Read
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 |
# File '../../src/modules/SystemSettings.rb', line 43 def Read @ENABLE_SYSRQ = Convert.to_string( SCR.Read(path(".etc.sysctl_conf.\"kernel.sysrq\"")) ) Builtins.y2milestone("SysRq enabled: %1", @ENABLE_SYSRQ) current_sysrq = Convert.to_string( SCR.Read(path(".target.string"), "/proc/sys/kernel/sysrq") ) # read just the first line current_sysrq = Ops.get(Builtins.splitstring(current_sysrq, "\n"), 0, "") if @ENABLE_SYSRQ != nil && current_sysrq != @ENABLE_SYSRQ Builtins.y2warning( "SysRq mismatch: sysconfig value: '%1', current: '%2'", @ENABLE_SYSRQ, current_sysrq ) end # display the current value if it not configured @ENABLE_SYSRQ = current_sysrq if @ENABLE_SYSRQ == nil # I have to admit that this is very ugly but it is here # to avoid of the very long starting time of the yast module # because the Storage module (which is imported by the Bootloader (imported by the SystemSettings module)) # has a Read() function call in its constructor. Yast.import "Bootloader" if Mode.normal # runtime - read the settings Bootloader.Read end # get 'elevator' option from the default section elevator_parameter = Bootloader.kernel_param(:common, "elevator") Builtins.y2milestone("elevator_parameter: %1", elevator_parameter) # Variable is not set if elevator_parameter == :missing @elevator = "" # Variable is set but has not parameter elsif elevator_parameter == :present Builtins.y2warning("'elevator' variable has to have some value") @elevator = "" # Variable is set but hasn't any known value elsif !Builtins.contains( GetPossibleElevatorValues(), Convert.to_string(elevator_parameter) ) Builtins.y2warning( "'elevator' variable has to have a value from %1 instead of being set to %2", GetPossibleElevatorValues(), elevator_parameter ) @elevator = "" # Variable is OK else @elevator = Convert.to_string(elevator_parameter) end Builtins.y2milestone("Global IO scheduler: %1", @elevator) true end |
- (Object) SetIOScheduler(io_scheduler)
175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 |
# File '../../src/modules/SystemSettings.rb', line 175 def SetIOScheduler(io_scheduler) # empty string = use the default scheduler if Builtins.contains(GetPossibleElevatorValues(), io_scheduler) || io_scheduler == "" @modified = true if @elevator != io_scheduler @elevator = io_scheduler else Builtins.y2error( "unknown IO scheduler '%1', use: %2", io_scheduler, GetPossibleElevatorValues() ) end nil end |
- (Object) SetSysRqKeysEnabled(enable_sysrq)
197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 |
# File '../../src/modules/SystemSettings.rb', line 197 def SetSysRqKeysEnabled(enable_sysrq) if enable_sysrq == nil Builtins.y2warning("enable_sysrq should be 'true' or 'false'") return end enable_sysrq_string = enable_sysrq ? "1" : "0" @modified = true if @ENABLE_SYSRQ != enable_sysrq_string @ENABLE_SYSRQ = enable_sysrq_string Builtins.y2milestone("SysRq was set to %1", @ENABLE_SYSRQ) nil end |
- (Object) Write
146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 |
# File '../../src/modules/SystemSettings.rb', line 146 def Write # writing SysRq settings if @ENABLE_SYSRQ != nil && Builtins.regexpmatch(@ENABLE_SYSRQ, "^[0-9]+$") # save the SysRq setting Builtins.y2milestone("Saving ENABLE_SYSRQ: %1", @ENABLE_SYSRQ) SCR.Write(path(".etc.sysctl_conf.\"kernel.sysrq\""), @ENABLE_SYSRQ) SCR.Write(path(".etc.sysctl_conf"), nil) else Builtins.y2warning( "Not writing invalid ENABLE_SYSRQ value: %1", @ENABLE_SYSRQ ) end # the bootloader configuration is written at the end of the first stage if Mode.normal # write the elevator setting Yast.import "Bootloader" Bootloader.Write end true end |