Module: Yast::GeoClusterDialogsInclude
- Defined in:
- ../../src/include/geo-cluster/dialogs.rb
Instance Method Summary (collapse)
-
- (Object) ChooseConfigureDialog
Dialog for geo-cluster Choose config file dialog.
- - (Object) cluster_configure_layout(conf)
-
- (Object) ConfigureDialog(conf)
Dialog for geo-cluster Configure2 dialog.
-
- (Object) fill_arbitrators_entries(arbitrators)
fill arbitrator_box with global_arbitrators.
-
- (Object) fill_conf_entries
fill confs with global_files.
-
- (Object) fill_sites_entries(sites)
fill site_box with global_site.
-
- (Object) fill_ticket_entries(tickets)
fill ticket_box with global_ticket.
- - (Object) initialize_geo_cluster_dialogs(include_target)
-
- (Object) ip_address_input_dialog(title, value)
return `cacel or a string.
- - (Object) ServiceDialog
- - (Object) ticket_input_dialog(ticket_hash)
Instance Method Details
- (Object) ChooseConfigureDialog
Dialog for geo-cluster Choose config file dialog
668 669 670 671 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 742 743 744 745 746 747 748 749 750 |
# File '../../src/include/geo-cluster/dialogs.rb', line 668 def ChooseConfigureDialog # GeoCluster choose configure dialog caption caption = _("GeoCluster Configuration Select") # Wizard::SetContentsButtons(caption, contents, HELPS["c2"]:"", # Label::BackButton(), Label::NextButton()); config_box = VBox( SelectionBox(Id(:conf_box), _("Choose configuration file:")), Right( HBox( PushButton(Id(:conf_add), _("Add")), PushButton(Id(:conf_edit), _("Edit")), PushButton(Id(:conf_del), _("Delete")) ) ) ) ret = nil current = 0 conf_list = [] caption = _("Geo Cluster Configuration") while true Wizard.SelectTreeItem("choose_conf") # FIXME ugly work. Better use alias and function, see yast2 drbd. Wizard.SetContents( caption, config_box, Ops.get_string(@HELPS, "confs", ""), true, true ) conf_list = fill_conf_entries ret = UI.UserInput if ret == :conf_add ret = ConfigureDialog("") next if ret == :cancel next end if ret == :conf_edit current = UI.QueryWidget(:conf_box, :CurrentItem).to_i ret = ConfigureDialog(conf_list[current]) next if ret == :cancel next end if ret == :conf_del current = UI.QueryWidget(:conf_box, :CurrentItem).to_i GeoCluster.global_del_confs.push(conf_list[current]) GeoCluster.global_files.delete(conf_list[current]) next end if ret == :wizardTree ret = Convert.to_string(UI.QueryWidget(Id(:wizardTree), :CurrentItem)) end # abort? if ret == :abort || ret == :cancel || ret == :back if ReallyAbort() break else next end elsif ret == :next break elsif Builtins.contains(@DIALOG, Convert.to_string(ret)) ret = Builtins.symbolof(Builtins.toterm(ret)) break else Builtins.y2error("unexpected retcode: %1", ret) next end end deep_copy(ret) end |
- (Object) cluster_configure_layout(conf)
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 |
# File '../../src/include/geo-cluster/dialogs.rb', line 45 def cluster_configure_layout(conf) VBox( HBox( InputField( Id(:confname), Opt(:hstretch), _("configuration file"), conf ), HSpacing(1), ComboBox( Id(:transport), Opt(:hstretch, :notify), _("transport"), [Ops.get(GeoCluster.global_files[conf], "transport", "UDP")] ), HSpacing(1), InputField( Id(:port), Opt(:hstretch), _("port"), Ops.get(GeoCluster.global_files[conf], "port", "") ) ), HBox( VBox( SelectionBox(Id(:arbitrator_box), _("arbitrator")), Left( HBox( PushButton(Id(:arbitrator_add), _("Add")), PushButton(Id(:arbitrator_edit), _("Edit")), PushButton(Id(:arbitrator_del), _("Delete")) ) ) ), VSpacing(1), VBox( SelectionBox(Id(:site_box), _("site")), Right( HBox( PushButton(Id(:site_add), _("Add")), PushButton(Id(:site_edit), _("Edit")), PushButton(Id(:site_del), _("Delete")) ) ) ), ), HSpacing(2), VBox( Left(Label(_("ticket"))), Table(Id(:ticket_box), Header("ticket", "timeout", "retries", "weights", "expire", "acquire-after", "before-acquire-handler"), []), Left( HBox( PushButton(Id(:ticket_add), "Add"), PushButton(Id(:ticket_edit), "Edit"), PushButton(Id(:ticket_del), "Delete")) ) ), VBox( Right( HBox( PushButton(Id(:ok), _("OK")), PushButton(Id(:cancel_inner), _("Cancel")) ) ) ) ) end |
- (Object) ConfigureDialog(conf)
Dialog for geo-cluster Configure2 dialog
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 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 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 593 594 595 596 597 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 658 659 660 661 662 663 |
# File '../../src/include/geo-cluster/dialogs.rb', line 414 def ConfigureDialog(conf) # GeoCluster configure2 dialog caption caption = _("Geo Cluster Configuration") # Wizard::SetContentsButtons(caption, contents, HELPS["c2"]:"", # Label::BackButton(), Label::NextButton()); ret = nil add_new_conf = false Wizard.SetContents( caption, cluster_configure_layout(conf), Ops.get_string(@HELPS, "booth", ""), false, false ) current = 0 temp_site = [] temp_arbitrator = [] temp_ticket = [] if conf != "" if GeoCluster.global_files[conf]["arbitrator"] temp_arbitrator = deep_copy(GeoCluster.global_files[conf]["arbitrator"]) end if GeoCluster.global_files[conf]["site"] temp_site = deep_copy(GeoCluster.global_files[conf]["site"]) end if GeoCluster.global_files[conf]["ticket"] GeoCluster.global_files[conf]["ticket"].each do |tname, value| temp_ticket.push({tname => deep_copy(value)}) end end else add_new_conf = true end while true fill_arbitrators_entries(temp_arbitrator) fill_sites_entries(temp_site) fill_ticket_entries(temp_ticket) if conf != "" UI.ChangeWidget(Id(:confname), :Enabled, false) elsif conf == "" && GeoCluster.global_files.empty? UI.ChangeWidget(Id(:confname), :Value, "booth") end if temp_arbitrator.size == 0 UI.ChangeWidget(Id(:arbitrator_edit), :Enabled, false) UI.ChangeWidget(Id(:arbitrator_del), :Enabled, false) else UI.ChangeWidget(Id(:arbitrator_edit), :Enabled, true) UI.ChangeWidget(Id(:arbitrator_del), :Enabled, true) end if temp_site.size == 0 UI.ChangeWidget(Id(:site_edit), :Enabled, false) UI.ChangeWidget(Id(:site_del), :Enabled, false) else UI.ChangeWidget(Id(:site_edit), :Enabled, true) UI.ChangeWidget(Id(:site_del), :Enabled, true) end if temp_ticket.size == 0 UI.ChangeWidget(Id(:ticket_edit), :Enabled, false) UI.ChangeWidget(Id(:ticket_del), :Enabled, false) else UI.ChangeWidget(Id(:ticket_edit), :Enabled, true) UI.ChangeWidget(Id(:ticket_del), :Enabled, true) end ret = UI.UserInput if ret == :arbitrator_add ret = ip_address_input_dialog( _("Enter an IP address of your arbitrator"), "" ) next if ret == :cancel temp_arbitrator.push(ret.to_s) next end if ret == :arbitrator_edit current = UI.QueryWidget(:arbitrator_box, :CurrentItem).to_i ret = ip_address_input_dialog( _("Edit IP address of your arbitrator"), temp_arbitrator[current] ) next if ret == :cancel temp_arbitrator[current] = ret.to_s next end if ret == :arbitrator_del current = UI.QueryWidget(:arbitrator_box, :CurrentItem).to_i temp_arbitrator.delete_at(current) next end if ret == :site_add ret = ip_address_input_dialog( _("Enter an IP address of your site"), "" ) next if ret == :cancel temp_site.push(ret.to_s) next end if ret == :site_edit current = UI.QueryWidget(:site_box, :CurrentItem).to_i ret = ip_address_input_dialog( _("Edit IP address of your site"), temp_site[current] ) next if ret == :cancel temp_site[current] = ret.to_s next end if ret == :site_del current = UI.QueryWidget(:site_box, :CurrentItem).to_i temp_site.delete_at(current) next end if ret == :ticket_add ret = ticket_input_dialog({}) next if ret == :cancel dup_name = false ret.each_key do |tname| temp_ticket.each do |ticket| if ticket.include?(tname) Popup.Message(_("Ticket name already exist!")) dup_name = true break end end end next if dup_name temp_ticket.push(ret) next end if ret == :ticket_edit current = UI.QueryWidget(:ticket_box, :CurrentItem).to_i ret = ticket_input_dialog(temp_ticket[current]) next if ret == :cancel temp_ticket[current] = ret next end if ret == :ticket_del current = UI.QueryWidget(:ticket_box, :CurrentItem).to_i temp_ticket.delete_at(current) next end if ret == :wizardTree Wizard.SelectTreeItem("choose_conf") next #ret = Convert.to_string(UI.QueryWidget(Id(:wizardTree), :CurrentItem)) end next if Builtins.contains(@DIALOG, Convert.to_string(ret)) # abort? if ret == :abort || ret == :back if ReallyAbort() break else next end elsif ret == :ok conf = UI.QueryWidget(:confname, :Value).to_s if conf == "" Popup.Message(_("Configuration name can not be empty.")) next elsif add_new_conf && GeoCluster.global_files.include?(conf) Popup.Message(_("Configuration name can not be duplicated.")) next end port = UI.QueryWidget(:port, :Value).to_s num_port = Builtins.tointeger(port) if num_port == nil || num_port <= 0 || num_port > 65535 Popup.Message(_("port is invalid!")) next end transport = UI.QueryWidget(:transport, :Value).to_s if transport == "" Popup.Message(_("transport have to be filled!")) next end if temp_arbitrator.size == 0 Popup.Message(_("arbitrator have to be filled!")) next end if temp_site.size == 0 Popup.Message(_("site have to be filled!")) next end if temp_ticket.size == 0 Popup.Message(_("ticket have to be filled!")) next end GeoCluster.global_files[conf] = {} GeoCluster.global_files[conf]["port"] = port GeoCluster.global_files[conf]["transport"] = transport GeoCluster.global_files[conf]["arbitrator"] = temp_arbitrator GeoCluster.global_files[conf]["site"] = temp_site GeoCluster.global_files[conf]["ticket"] = {} temp_ticket.each do |ticket| GeoCluster.global_files[conf]["ticket"] = GeoCluster.global_files[conf]["ticket"].merge(ticket) end if add_new_conf && GeoCluster.global_del_confs.include?(conf) GeoCluster.global_del_confs.delete(conf) end break elsif ret == :cancel_inner break else Builtins.y2error("unexpected retcode: %1", ret) next end end deep_copy(ret) end |
- (Object) fill_arbitrators_entries(arbitrators)
fill arbitrator_box with global_arbitrators
270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 |
# File '../../src/include/geo-cluster/dialogs.rb', line 270 def fill_arbitrators_entries(arbitrators) i = 0 ret = 0 current = 0 items = [] arbitrators.each do |arbitrator| items = items.push(Item(Id(i), arbitrator)) i += 1 end current = UI.QueryWidget(:arbitrator_box, :CurrentItem).to_i current = i-1 if current >= i UI.ChangeWidget(:arbitrator_box, :Items, items) UI.ChangeWidget(:arbitrator_box, :CurrentItem, current) nil end |
- (Object) fill_conf_entries
fill confs with global_files
335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 |
# File '../../src/include/geo-cluster/dialogs.rb', line 335 def fill_conf_entries i = 0 ret = 0 current = 0 items = [] conf_list = [] GeoCluster.global_files.each_key do |conf| conf_list.push(conf) items = items.push(Item(Id(i), conf)) i += 1 end current = UI.QueryWidget(:conf_box, :CurrentItem).to_i current = i-1 if current >= i UI.ChangeWidget(:conf_box, :Items, items) UI.ChangeWidget(:conf_box, :CurrentItem, current) deep_copy(conf_list) end |
- (Object) fill_sites_entries(sites)
fill site_box with global_site
288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 |
# File '../../src/include/geo-cluster/dialogs.rb', line 288 def fill_sites_entries(sites) i = 0 ret = 0 current = 0 items = [] sites.each do |site| items = items.push(Item(Id(i), site)) i += 1 end current = UI.QueryWidget(:site_box, :CurrentItem).to_i current = i-1 if current >= i UI.ChangeWidget(:site_box, :Items, items) UI.ChangeWidget(:site_box, :CurrentItem, current) nil end |
- (Object) fill_ticket_entries(tickets)
fill ticket_box with global_ticket
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 |
# File '../../src/include/geo-cluster/dialogs.rb', line 306 def fill_ticket_entries(tickets) i = 0 ret = 0 current = 0 items = [] tickets.each do |ticket_hash| ticket_hash.each do |tname, value| acquireafter = Ops.get_string(value,"acquire-after","") timeout = Ops.get_string(value,"timeout","") retries = Ops.get_string(value,"retries","") weights = Ops.get_string(value,"weights","") expire = Ops.get_string(value,"expire","") beforeah = Ops.get_string(value,"before-acquire-handler","") items = items.push(Item(Id(i), tname, timeout, retries, weights, expire, acquireafter, beforeah)) i += 1 end end current = UI.QueryWidget(:ticket_box, :CurrentItem).to_i current = i-1 if current >= i UI.ChangeWidget(:ticket_box, :Items, items) UI.ChangeWidget(:ticket_box, :CurrentItem, current) nil end |
- (Object) initialize_geo_cluster_dialogs(include_target)
30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File '../../src/include/geo-cluster/dialogs.rb', line 30 def initialize_geo_cluster_dialogs(include_target) Yast.import "UI" textdomain "geo-cluster" Yast.import "Label" Yast.import "Wizard" Yast.import "GeoCluster" Yast.import "Popup" Yast.import "IP" Yast.import "CWMFirewallInterfaces" Yast.include include_target, "geo-cluster/helps.rb" end |
- (Object) ip_address_input_dialog(title, value)
return `cacel or a string
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 |
# File '../../src/include/geo-cluster/dialogs.rb', line 116 def ip_address_input_dialog(title, value) ret = nil UI.OpenDialog( MarginBox( 1, 1, VBox( MinWidth(100, InputField(Id(:text), Opt(:hstretch), title, value)), VSpacing(1), Right( HBox( PushButton(Id(:ok), _("OK")), PushButton(Id(:cancel), _("Cancel")) ) ) ) ) ) while true ret = UI.UserInput if ret == :ok val = Convert.to_string(UI.QueryWidget(:text, :Value)) if IP.Check(val) == true ret = val break else Popup.Message(_("Please enter a valid ip address")) end end break if ret == :cancel end UI.CloseDialog deep_copy(ret) end |
- (Object) ServiceDialog
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 |
# File '../../src/include/geo-cluster/dialogs.rb', line 355 def ServiceDialog ret = nil event = {} caption = _("Firewall Configuration") = CWMFirewallInterfaces.CreateOpenFirewallWidget( { #servie:geo-cluster is the name of /etc/sysconfig/SuSEfirewall2.d/services/geo-cluster "services" => [ "service:booth" ], "display_details" => true } ) firewall_layout = Ops.get_term(, "custom_widget", VBox()) contents = VBox( VSpacing(1), Frame("firewall settings", firewall_layout), VStretch() ) Wizard.SetContents( caption, firewall_layout, Ops.get_string(@HELPS, "geo-cluster", ""), true, true ) CWMFirewallInterfaces.OpenFirewallInit(, "") while true event = UI.WaitForEvent ret = Ops.get(event, "ID") if ret == :next CWMFirewallInterfaces.OpenFirewallStore(, "", event) break end if ret == :wizardTree ret = Convert.to_string(UI.QueryWidget(Id(:wizardTree), :CurrentItem)) end if Builtins.contains(@DIALOG, Convert.to_string(ret)) ret = Builtins.symbolof(Builtins.toterm(ret)) break end if ret == :abort || ret == :cancel if ReallyAbort() return deep_copy(ret) else next end end break if ret == :back CWMFirewallInterfaces.OpenFirewallHandle(, "", event) end deep_copy(ret) end |
- (Object) ticket_input_dialog(ticket_hash)
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 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 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 |
# File '../../src/include/geo-cluster/dialogs.rb', line 152 def ticket_input_dialog(ticket_hash) ret = nil ticket = "" acquireafter = "" timeout = "" retries = "" weights = "" expire = "" beforeah = "" if ticket_hash != {} if ticket_hash.size != 1 return {} end ticket_hash.each do |tname, value| ticket = tname acquireafter = Ops.get_string(value,"acquire-after","") timeout = Ops.get_string(value,"timeout","") retries = Ops.get_string(value,"retries","") weights = Ops.get_string(value,"weights","") expire = Ops.get_string(value,"expire","") beforeah = Ops.get_string(value,"before-acquire-handler","") end end UI.OpenDialog( MarginBox( 1, 1, VBox( Label(_("Enter ticket and timeout")), HBox( InputField(Id(:ticket), Opt(:hstretch), _("ticket"), ticket), ), VSpacing(1), HBox( InputField(Id(:timeout), Opt(:hstretch), _("timeout"), timeout), HSpacing(2), InputField(Id(:retries), Opt(:hstretch), _("retries"), retries), HSpacing(2), InputField(Id(:weights), Opt(:hstretch), _("weights"), weights), HSpacing(2), InputField(Id(:expire), Opt(:hstretch), _("expire"), expire), HSpacing(2), InputField(Id(:acquireafter), Opt(:hstretch), _("acquire-after"), acquireafter), HSpacing(2), InputField(Id(:beforeah), Opt(:hstretch), _("before-acquire-handler"), beforeah) ), VSpacing(1), Right( HBox( PushButton(Id(:ok), _("OK")), PushButton(Id(:cancel), _("Cancel")) ) ) ) ) ) while true if ticket != "" UI.ChangeWidget(Id(:ticket), :Enabled, false) end ret = UI.UserInput if ret == :ok ticket = UI.QueryWidget(:ticket, :Value).to_s timeout = UI.QueryWidget(:timeout, :Value).to_s expire = UI.QueryWidget(:expire, :Value).to_s acquireafter = UI.QueryWidget(:acquireafter, :Value).to_s retries = UI.QueryWidget(:retries, :Value).to_s weights = UI.QueryWidget(:weights, :Value).to_s beforeah = UI.QueryWidget(:beforeah, :Value).to_s num_timeout = Builtins.tointeger(timeout) num_expire = Builtins.tointeger(expire) num_acquireafter = Builtins.tointeger(acquireafter) num_retries = Builtins.tointeger(retries) num_weights = Builtins.tointeger(weights) if num_timeout == nil && timeout != "" Popup.Message(_("timeout is invalid")) elsif num_expire == nil && expire != "" Popup.Message(_("expire is invalid")) elsif num_acquireafter == nil && acquireafter != "" Popup.Message(_("acquireafter is invalid")) elsif num_retries == nil && retries != "" Popup.Message(_("retries is invalid")) elsif retries != "" && num_retries < 3 Popup.Message(_("retries values lower than 3 is illegal")) elsif num_weights == nil && weights != "" Popup.Message(_("weights is invalid")) elsif ticket == "" Popup.Message(_("ticket can not be empty")) else temp_ticket = {} temp_ticket["timeout"] = timeout temp_ticket["expire"] = expire temp_ticket["acquire-after"] = acquireafter temp_ticket["retries"] = retries temp_ticket["weights"] = weights temp_ticket["before-acquire-handler"] = beforeah ret = {ticket => deep_copy(temp_ticket)} break end end break if ret == :cancel end UI.CloseDialog deep_copy(ret) end |