Class: Yast::IplbClass
- Inherits:
-
Module
- Object
- Module
- Yast::IplbClass
- Defined in:
- ../../src/modules/Iplb.rb
Instance Method Summary (collapse)
-
- (Boolean) Abort
Abort function.
- - (Object) add_global_conf_quote
- - (Object) add_vserver_conf_quote
-
- (Hash) AutoPackages
Return packages needed to be installed and removed during Autoinstallation to insure module has all needed software installed.
-
- (Hash) Export
Dump the iplb settings to a single map (For use by autoinstallation.).
-
- (Boolean) Import(settings)
Get all iplb settings from the first parameter (For use by autoinstallation.).
- - (Object) main
-
- (Object) Modified
Data was modified?.
-
- (Object) Overview
Create an overview table with all configured cards.
- - (Object) ProposalValid
-
- (Object) Read
Read all iplb settings.
- - (Object) remove_global_conf_quote
- - (Object) remove_quote(str)
- - (Object) remove_vserver_conf_quote
- - (Object) SetAbortFunction(function)
-
- (Object) SetModified
Mark as modified, for Autoyast.
- - (Object) SetProposalValid(value)
-
- (Object) SetWriteOnly(value)
Set write_only flag (for autoinstalation).
-
- (Object) Summary
Create a textual summary and a list of unconfigured cards.
-
- (Object) Write
Write all iplb settings.
-
- (Object) WriteOnly
True if module is marked as “write only” (don't start services etc…).
Instance Method Details
- (Boolean) Abort
Abort function
83 84 85 86 |
# File '../../src/modules/Iplb.rb', line 83 def Abort return @AbortFunction.call == true if @AbortFunction != nil false end |
- (Object) add_global_conf_quote
157 158 159 160 161 162 163 164 165 166 167 168 169 170 |
# File '../../src/modules/Iplb.rb', line 157 def add_global_conf_quote remove_global_conf_quote Builtins.foreach(@global_conf) do |key, val| if Builtins.contains(@quote_list, key) Ops.set( @global_conf, key, Ops.add(Ops.add("\"", Ops.get(@global_conf, key, "")), "\"") ) end end nil end |
- (Object) add_vserver_conf_quote
189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 |
# File '../../src/modules/Iplb.rb', line 189 def add_vserver_conf_quote remove_vserver_conf_quote Builtins.foreach(@vserver_conf) do |key1, val1| Builtins.foreach( Convert.convert(val1, :from => "map", :to => "map <string, list>") ) do |key2, val2| if Builtins.contains(@quote_list, key2) Ops.set( val2, 0, Ops.add(Ops.add("\"", Ops.get_string(val2, 0, "")), "\"") ) Ops.set(@vserver_conf, [key1, key2], val2) end end end nil end |
- (Hash) AutoPackages
Return packages needed to be installed and removed during Autoinstallation to insure module has all needed software installed.
455 456 457 458 |
# File '../../src/modules/Iplb.rb', line 455 def AutoPackages # TODO FIXME: your code here... { "install" => [], "remove" => [] } end |
- (Hash) Export
Dump the iplb settings to a single map (For use by autoinstallation.)
431 432 433 434 |
# File '../../src/modules/Iplb.rb', line 431 def Export # TODO FIXME: your code here (return the above mentioned variables)... {} end |
- (Boolean) Import(settings)
Get all iplb settings from the first parameter (For use by autoinstallation.)
422 423 424 425 426 |
# File '../../src/modules/Iplb.rb', line 422 def Import(settings) settings = deep_copy(settings) # TODO FIXME: your code here (fill the above mentioned variables)... true end |
- (Object) main
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 |
# File '../../src/modules/Iplb.rb', line 35 def main textdomain "iplb" Yast.import "Progress" Yast.import "Report" Yast.import "Summary" Yast.import "Message" Yast.import "IP" # the global configure @global_conf = {} # the virtual servers configure @vserver_conf = {} # Data was modified? @modified = false @proposal_valid = 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 = fun_ref(method(:Modified), "boolean ()") @quote_list = [ "callback", "logfile", "emailalert", "execute", "checkcommand", "request", "receive", "virtualhost", "login", "passwd", "database", "secret" ] end |
- (Object) Modified
Data was modified?
90 91 92 93 |
# File '../../src/modules/Iplb.rb', line 90 def Modified Builtins.y2debug("modified=%1", @modified) @modified end |
- (Object) Overview
Create an overview table with all configured cards
446 447 448 449 |
# File '../../src/modules/Iplb.rb', line 446 def Overview # TODO FIXME: your code here... [] end |
- (Object) ProposalValid
102 103 104 |
# File '../../src/modules/Iplb.rb', line 102 def ProposalValid @proposal_valid end |
- (Object) Read
Read all iplb settings
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 243 244 245 246 247 248 249 250 251 252 253 254 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 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 |
# File '../../src/modules/Iplb.rb', line 212 def Read pair_names = [] caption = _("Initializing IPLB Configuration") # Names of real stages Progress.New( caption, " ", 3, [_("Read the global settings"), _("Read the virtual host settings")], [ _("Reading the global settings..."), _("Reading the virtual host settings..."), _("Finished") ], "" ) #/////////////////////////////// # read global configure #/////////////////////////////// # dir all global configure names pair_names = SCR.Dir(path(".iplb.value")) # read global configure values @global_conf = {} Builtins.foreach(pair_names) do |key| vals = Convert.convert( SCR.Read(Ops.add(path(".iplb.value"), Builtins.topath(key))), :from => "any", :to => "list <string>" ) Ops.set(@global_conf, key, Ops.get(vals, 0, "")) end remove_global_conf_quote Builtins.y2debug("___iplbdebug___ read global_conf = %1", @global_conf) Progress.NextStage #/////////////////////////////// # read vservers configure #/////////////////////////////// # dir all vserver names vserver_names = SCR.Dir(path(".iplb.section")) # iterate all vserver names Builtins.foreach(vserver_names) do |vs_name| Ops.set(@vserver_conf, vs_name, {}) # vserver name contains ".", so quote it vs_name_path = Builtins.topath(Ops.add(Ops.add("\"", vs_name), "\"")) # dir all pair name of given vserver name pair_names = SCR.Dir(Ops.add(path(".iplb.value"), vs_name_path)) # iterate pair names to read the pair value Builtins.foreach(pair_names) do |key| Ops.set( @vserver_conf, [vs_name, key], SCR.Read( Ops.add( Ops.add(path(".iplb.value"), vs_name_path), Builtins.topath(key) ) ) ) end #check for IPv6 address is_ipv6 = false sect_path = Builtins.topath("") ipv6_address = Builtins.regexpsub(vs_name, "\\[(.+)\\]", "\\1") is_ipv6 = IP.Check6(ipv6_address) if ipv6_address != nil if is_ipv6 if Ops.get_list(@vserver_conf, [vs_name, "real6"], []) != [] Ops.set( @vserver_conf, [vs_name, "real"], Ops.get_list(@vserver_conf, [vs_name, "real6"], []) ) Ops.set(@vserver_conf, [vs_name, "real6"], []) end if Ops.get_list(@vserver_conf, [vs_name, "fallback6"], []) != [] Ops.set( @vserver_conf, [vs_name, "fallback"], Ops.get_list(@vserver_conf, [vs_name, "fallback6"], []) ) Ops.set(@vserver_conf, [vs_name, "fallback6"], []) end end end remove_vserver_conf_quote Builtins.y2debug("___iplbdebug___ read vserver_conf = %1", @vserver_conf) Progress.NextStage # Progress finished Progress.NextStage @modified = false true end |
- (Object) remove_global_conf_quote
142 143 144 145 146 147 148 149 150 151 152 153 154 |
# File '../../src/modules/Iplb.rb', line 142 def remove_global_conf_quote Builtins.foreach(@global_conf) do |key, val| if Builtins.contains(@quote_list, key) Ops.set( @global_conf, key, remove_quote(Ops.get(@global_conf, key, "")) ) end end nil end |
- (Object) remove_quote(str)
133 134 135 136 137 138 139 |
# File '../../src/modules/Iplb.rb', line 133 def remove_quote(str) str = Builtins.regexpsub(str, "^\"?(.*)", "\\1") if Builtins.regexpmatch(str, ".*\"$") str = Builtins.regexpsub(str, "^(.*)\"$", "\\1") end str end |
- (Object) remove_vserver_conf_quote
173 174 175 176 177 178 179 180 181 182 183 184 185 186 |
# File '../../src/modules/Iplb.rb', line 173 def remove_vserver_conf_quote Builtins.foreach(@vserver_conf) do |key1, val1| Builtins.foreach( Convert.convert(val1, :from => "map", :to => "map <string, list>") ) do |key2, val2| if Builtins.contains(@quote_list, key2) Ops.set(val2, 0, remove_quote(Ops.get_string(val2, 0, ""))) Ops.set(@vserver_conf, [key1, key2], val2) end end end nil end |
- (Object) SetAbortFunction(function)
125 126 127 128 129 130 |
# File '../../src/modules/Iplb.rb', line 125 def SetAbortFunction(function) function = deep_copy(function) @AbortFunction = deep_copy(function) nil end |
- (Object) SetModified
Mark as modified, for Autoyast.
96 97 98 99 100 |
# File '../../src/modules/Iplb.rb', line 96 def SetModified @modified = true nil end |
- (Object) SetProposalValid(value)
106 107 108 109 110 |
# File '../../src/modules/Iplb.rb', line 106 def SetProposalValid(value) @proposal_valid = value nil end |
- (Object) SetWriteOnly(value)
Set write_only flag (for autoinstalation).
118 119 120 121 122 |
# File '../../src/modules/Iplb.rb', line 118 def SetWriteOnly(value) @write_only = value nil end |
- (Object) Summary
Create a textual summary and a list of unconfigured cards
438 439 440 441 442 |
# File '../../src/modules/Iplb.rb', line 438 def Summary # TODO FIXME: your code here... # Configuration summary text for autoyast [_("Configuration summary..."), []] end |
- (Object) Write
Write all iplb settings
318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 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 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 |
# File '../../src/modules/Iplb.rb', line 318 def Write ret = false caption = _("Saving IPLB Configuration") Progress.New( caption, " ", 2, [_("Write the settings"), _("Run SuSEconfig")], [ _("Writing the settings..."), _("Running SuSEconfig..."), _("Finished") ], "" ) # remove all sections, as ini agent will write new global conf # entry at the end of the conf file. (global conf after sections # will be read as vserver conf, not as global conf. it's a bug) Builtins.foreach(@vserver_conf) do |key, val| sect_path = Builtins.topath(Ops.add(Ops.add("\"", key), "\"")) ret = SCR.Write(Ops.add(path(".iplb.section"), sect_path), nil) end saved_global_conf = deep_copy(@global_conf) add_global_conf_quote # write global conf Builtins.y2debug("___iplbdebug___ write global_conf=%1", @global_conf) Builtins.foreach(@global_conf) do |key, val| write_val = nil write_val = [val] if val != nil ret = SCR.Write( Ops.add(path(".iplb.value"), Builtins.topath(key)), write_val ) Report.Error(_("Cannot write settings.")) if !ret end Progress.NextStage @global_conf = deep_copy(saved_global_conf) saved_vserver_conf = deep_copy(@vserver_conf) add_vserver_conf_quote # write vserver conf Builtins.y2debug("___iplbdebug___ write vserver_conf=%1", @vserver_conf) Builtins.foreach(@vserver_conf) do |key, val| #check for ipv6 address to decide whether to add "6=" or "=" # string key's format # 192.168.6.241:89 or [2001:db8::5]:119 # only extract the 2001:db8::5 part from the key string # to check whether it is an ipv6 address; is_ipv6 = false sect_path = Builtins.topath("") ipv6_address = Builtins.regexpsub(key, "\\[(.+)\\]", "\\1") is_ipv6 = IP.Check6(ipv6_address) if ipv6_address != nil if is_ipv6 sect_path = Builtins.topath(Ops.add(Ops.add("\"6 = ", key), "\"")) if Ops.get_list(val, "fallback", []) != [] Ops.set(val, "fallback6", Ops.get_list(val, "fallback", [])) Ops.set(val, "fallback", []) end if Ops.get_list(val, "real", []) != [] Ops.set(val, "real6", Ops.get_list(val, "real", [])) Ops.set(val, "real", []) end else sect_path = Builtins.topath(Ops.add(Ops.add("\" = ", key), "\"")) end if val == nil ret = SCR.Write(Ops.add(path(".iplb.section"), sect_path), nil) Report.Error(_("Cannot write settings.")) if !ret next end Builtins.foreach( Convert.convert(val, :from => "map", :to => "map <string, list>") ) do |key1, val1| ret = SCR.Write( Ops.add( Ops.add(path(".iplb.value"), sect_path), Builtins.topath(key1) ), val1 ) Report.Error(_("Cannot write settings.")) if !ret end end Progress.NextStage @vserver_conf = deep_copy(saved_vserver_conf) # Progress finished Progress.NextStage true end |
- (Object) WriteOnly
Returns true if module is marked as “write only” (don't start services etc…)
113 114 115 |
# File '../../src/modules/Iplb.rb', line 113 def WriteOnly @write_only end |