Class: Yast::GeoClusterClass
- Inherits:
-
Module
- Object
- Module
- Yast::GeoClusterClass
- Defined in:
- ../../src/modules/GeoCluster.rb
Instance Method Summary (collapse)
-
- (Boolean) Abort
Abort function.
- - (Object) add_list_quote(stringlist)
- - (Object) add_quote(str)
-
- (Hash) AutoPackages
Return packages needed to be installed and removed during Autoinstallation to insure module has all needed software installed.
- - (Object) empty_ticket(ticket)
-
- (Hash) Export
Dump the geo-cluster settings to a single map (For use by autoinstallation.).
- - (Object) get_a_conf(confname)
-
- (Boolean) Import(settings)
Get all geo-cluster 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
- - (Object) remove_list_quote(stringlist)
- - (Object) remove_quote(str)
- - (Object) save_a_conf(confname)
- - (Object) SetAbortFunction(function)
-
- (Object) SetModified(value)
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 geo-cluster settings.
-
- (Object) WriteOnly
True if module is marked as “write only” (don't start services etc…).
Instance Method Details
- (Boolean) Abort
Abort function
86 87 88 89 |
# File '../../src/modules/GeoCluster.rb', line 86 def Abort return @AbortFunction.call == true if @AbortFunction != nil false end |
- (Object) add_list_quote(stringlist)
157 158 159 160 161 162 163 164 165 166 |
# File '../../src/modules/GeoCluster.rb', line 157 def add_list_quote(stringlist) stringlist = deep_copy(stringlist) temp = remove_list_quote(stringlist) i = 0 while Ops.less_than(i, Builtins.size(stringlist)) Ops.set(stringlist, i, add_quote(Ops.get(temp, i, ""))) i = Ops.add(i, 1) end deep_copy(stringlist) end |
- (Object) add_quote(str)
153 154 155 |
# File '../../src/modules/GeoCluster.rb', line 153 def add_quote(str) Ops.add(Ops.add("\"", str), "\"") end |
- (Hash) AutoPackages
Return packages needed to be installed and removed during Autoinstallation to insure module has all needed software installed.
465 466 467 468 |
# File '../../src/modules/GeoCluster.rb', line 465 def AutoPackages # TODO FIXME: your code here... { "install" => [], "remove" => [] } end |
- (Object) empty_ticket(ticket)
168 169 170 171 172 173 174 |
# File '../../src/modules/GeoCluster.rb', line 168 def empty_ticket(ticket) empty = true @global_conf_ticket.each_key do |key| empty = false if ticket[key] != "" end empty end |
- (Hash) Export
Dump the geo-cluster settings to a single map (For use by autoinstallation.)
441 442 443 444 |
# File '../../src/modules/GeoCluster.rb', line 441 def Export # TODO FIXME: your code here (return the above mentioned variables)... {} end |
- (Object) get_a_conf(confname)
176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 |
# File '../../src/modules/GeoCluster.rb', line 176 def get_a_conf(confname) conf_hash = {} temp_path = path(".booth")+Builtins.topath(confname) @global_conf_single.each do |key, value| temp_value = SCR.Read(temp_path+Builtins.topath(key)) if !temp_value && value temp_value = value end conf_hash[key] = temp_value end @global_conf_list.each do |key| conf_hash[key] = SCR.Read(temp_path+Builtins.topath(key)) end tickets_info = {} temp_ticket_path = temp_path+Builtins.topath("ticket") tickets_list = SCR.Dir(temp_ticket_path) if tickets_list tickets_list.each do |tname| temp_t = {} @global_conf_ticket.each_key do |key| # Not necessary to use remove_list_quote? temp_t[key] = SCR.Read(temp_ticket_path+Builtins.topath(tname)+Builtins.topath(key)) end tickets_info[tname] = temp_t end end conf_hash["ticket"] = tickets_info Builtins.y2debug("Get a conf: %1 = %2", confname, conf_hash) conf_hash end |
- (Boolean) Import(settings)
Get all geo-cluster settings from the first parameter (For use by autoinstallation.)
432 433 434 435 436 |
# File '../../src/modules/GeoCluster.rb', line 432 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 80 81 82 |
# File '../../src/modules/GeoCluster.rb', line 35 def main textdomain "geo-cluster" Yast.import "Progress" Yast.import "Report" Yast.import "Summary" Yast.import "Message" Yast.import "SuSEFirewall" Yast.import "SuSEFirewallServices" # 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 ()") # Settings: Define all variables needed for configuration of geo-cluster # TODO FIXME: Define all the variables necessary to hold # TODO FIXME: the configuration here (with the appropriate # TODO FIXME: description) # TODO FIXME: For example: # /** # * List of the configured cards. # */ # list cards = []; # # /** # * Some additional parameter needed for the configuration. # */ # boolean additional_parameter = true; # Read all geo-cluster settings # @return true on success @global_files = {} # Empty "authfile" means disable authentification @global_conf_single = { "transport" => "UDP", "port" => "9929", "authfile" => "" } @global_conf_list = [ "arbitrator", "site" ] @global_conf_ticket = { "expire" => "", "acquire-after" => "", "timeout" => "", "retries" => "", "weights" => "", "before-acquire-handler" => ""} @global_del_confs = [] end |
- (Object) Modified
Data was modified?
93 94 95 96 |
# File '../../src/modules/GeoCluster.rb', line 93 def Modified Builtins.y2debug("modified=%1", @modified) @modified end |
- (Object) Overview
Create an overview table with all configured cards
456 457 458 459 |
# File '../../src/modules/GeoCluster.rb', line 456 def Overview # TODO FIXME: your code here... [] end |
- (Object) ProposalValid
105 106 107 |
# File '../../src/modules/GeoCluster.rb', line 105 def ProposalValid @proposal_valid end |
- (Object) Read
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 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 |
# File '../../src/modules/GeoCluster.rb', line 282 def Read # GeoCluster read dialog caption caption = _("Initializing Geo Cluster Configuration") # TODO FIXME Set the right number of stages steps = 2 sl = 500 # TODO FIXME Names of real stages # We do not set help text here, because it was set outside Progress.New( caption, " ", steps, [_("Read the previous settings"), _("Read SuSEFirewall Settings")], [ _("Reading the previous settings..."), _("Read SuSEFirewall Settings"), _("Finished") ], "" ) file_list = SCR.Dir(path(".booth.allconfs")) if file_list # Read all confs into a hash file_list.each do |filename| temp_conf = get_a_conf(filename) @global_files[filename] = temp_conf end end Builtins.y2debug("Global files = %1", @global_files) # read return false if Abort() Progress.NextStage # Error message Report.Error(Message.CannotReadCurrentSettings) if false Builtins.sleep(sl) # read the SuSEfirewall2 SuSEFirewall.Read return false if Abort() # Progress finished Progress.NextStage Builtins.sleep(sl) return false if Abort() Progress.Finish @modified = false true end |
- (Object) remove_list_quote(stringlist)
143 144 145 146 147 148 149 150 151 |
# File '../../src/modules/GeoCluster.rb', line 143 def remove_list_quote(stringlist) stringlist = deep_copy(stringlist) i = 0 while Ops.less_than(i, Builtins.size(stringlist)) Ops.set(stringlist, i, remove_quote(Ops.get(stringlist, i, ""))) i = Ops.add(i, 1) end deep_copy(stringlist) end |
- (Object) remove_quote(str)
135 136 137 138 139 140 141 |
# File '../../src/modules/GeoCluster.rb', line 135 def remove_quote(str) str = Builtins.regexpsub(str, "^\"?(.*)", "\\1") if Builtins.regexpmatch(str, ".*\"$") str = Builtins.regexpsub(str, "^(.*)\"$", "\\1") end str end |
- (Object) save_a_conf(confname)
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 |
# File '../../src/modules/GeoCluster.rb', line 215 def save_a_conf(confname) Builtins.y2milestone("Writing configure file %1\n", confname) error_flag = false temp_path = path(".booth")+Builtins.topath(confname) conf = @global_files[confname] @global_conf_single.each_key do |key| Builtins.y2milestone("Writing global_conf %1 = %2\n", key, conf[key]) if key == "authfile" # SCR won't write authfile when empty("") # Convert relative path to absolute path if conf[key] != "" && !conf[key].include?("/") conf[key]="/etc/booth/"+conf[key] end end ret = SCR.Write((temp_path+Builtins.topath(key)), conf[key]) error_flag = true if !ret end (error_flag = false && Report.Error(_("Cannot write global conf settings."))) if error_flag # List like site @global_conf_list.each do |key| item_str = "" if conf[key] conf[key].each do |item| if item_str == "" item_str += item else item_str = item_str + ";" + item end end end Builtins.y2milestone("Writing global %1 settings. %2\n", key, item_str) ret = SCR.Write((temp_path+Builtins.topath(key)), item_str) error_flag = true if !ret end (error_flag = false && Report.Error(_("Cannot write global settings."))) if error_flag temp_ticket_path = temp_path + Builtins.topath("ticket") # Empty all tickets from ag_booth memory SCR.Write((temp_ticket_path + Builtins.topath("emptyallticket")), "") conf["ticket"].each do |tname, value| Builtins.y2milestone("Writing global ticket settings - %1\n", tname) # Empty (all Int) ticket will be ignore by ag_booth # Create a ticket item if empty_ticket(value) ret = SCR.Write((temp_ticket_path+Builtins.topath(tname)+Builtins.topath("ticket")), "") Builtins.y2milestone("Writing empty ticket - %1 \n", tname) error_flag = true if !ret else @global_conf_ticket.each_key do |key| ret = SCR.Write((temp_ticket_path+Builtins.topath(tname)+Builtins.topath(key)), value[key]) Builtins.y2milestone("Writing ticket settings: %1 = %2\n", key, value[key]) error_flag = true if !ret end end end (error_flag = false && Report.Error(_("Cannot write global ticket settings."))) if error_flag true end |
- (Object) SetAbortFunction(function)
128 129 130 131 132 133 |
# File '../../src/modules/GeoCluster.rb', line 128 def SetAbortFunction(function) function = deep_copy(function) @AbortFunction = deep_copy(function) nil end |
- (Object) SetModified(value)
Mark as modified, for Autoyast.
99 100 101 102 103 |
# File '../../src/modules/GeoCluster.rb', line 99 def SetModified(value) @modified = true nil end |
- (Object) SetProposalValid(value)
109 110 111 112 113 |
# File '../../src/modules/GeoCluster.rb', line 109 def SetProposalValid(value) @proposal_valid = value nil end |
- (Object) SetWriteOnly(value)
Set write_only flag (for autoinstalation).
121 122 123 124 125 |
# File '../../src/modules/GeoCluster.rb', line 121 def SetWriteOnly(value) @write_only = value nil end |
- (Object) Summary
Create a textual summary and a list of unconfigured cards
448 449 450 451 452 |
# File '../../src/modules/GeoCluster.rb', line 448 def Summary # TODO FIXME: your code here... # Configuration summary text for autoyast [_("Configuration summary..."), []] end |
- (Object) Write
Write all geo-cluster settings
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 417 418 419 420 421 422 423 424 425 426 |
# File '../../src/modules/GeoCluster.rb', line 341 def Write # GeoCluster write dialog caption caption = _("Saving Geo Cluster Configuration") ret = false # TODO FIXME And set the right number of stages steps = 2 sl = 500 # TODO FIXME Names of real stages # 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 _("Write the SuSEfirewall settings") ], [ # Progress step 1/2 _("Writing the settings..."), # Progress step 2/2 _("Writing the SuSEFirewall settings"), # Progress finished _("Finished") ], "" ) # Remove delete confs from memory # Do not empty all memory in case future extend @global_del_confs.each do |delconf| SCR.Write(path(".booth")+Builtins.topath(delconf),"") end # Not necessary to add_(list)_quote @global_files.each_key do |key| save_a_conf(key) end SCR.Write(path(".booth"),"") return false if Abort() Progress.NextStage # Error message Report.Error(_("Cannot write settings.")) if false Builtins.sleep(sl) # run SuSEconfig return false if Abort() # Open all needed port of all confs open_ports = [] @global_files.each_key do |file| temp_port = @global_files[file]["port"] if !open_ports.include?(temp_port) open_ports.push(temp_port) end end SuSEFirewallServices.SetNeededPortsAndProtocols( "service:booth", # Use the same udp port for tcp. { "tcp_ports" => open_ports, "udp_ports" => open_ports } ) SuSEFirewall.Write # Error message Report.Error(Message.SuSEConfigFailed) if false Builtins.sleep(sl) return false if Abort() # Progress finished Progress.NextStage Builtins.sleep(sl) return false if Abort() Progress.Finish true end |
- (Object) WriteOnly
Returns true if module is marked as “write only” (don't start services etc…)
116 117 118 |
# File '../../src/modules/GeoCluster.rb', line 116 def WriteOnly @write_only end |