Skip to content

Commit

Permalink
Adjust qdevice setting codes
Browse files Browse the repository at this point in the history
  • Loading branch information
liangxin1300 committed Jul 7, 2023
1 parent 3afc5c6 commit 50a5f3b
Showing 1 changed file with 69 additions and 58 deletions.
127 changes: 69 additions & 58 deletions src/include/cluster/dialogs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1225,9 +1225,9 @@ def heuristics_executables_input_dialog(name="", script="")
1,
VBox(
HBox(
MinWidth(40, InputField(Id(:exec_name), _("Execute Name"), name)),
MinWidth(20, InputField(Id(:exec_name), _("Execute Name"), name)),
HSpacing(1),
MinWidth(100, InputField(Id(:exec_script), _("Execute Script"), script))
MinWidth(55, InputField(Id(:exec_script), _("Execute Script"), script))
),
VSpacing(1),
Right(
Expand Down Expand Up @@ -1331,46 +1331,47 @@ def SaveCorosyncQdevice
end

def CorosyncQdeviceLayout
qdevice_section = VBox(
Left(ComboBox(
Id(:qdevice_model),
Opt(:hstretch),
_("Qdevice model:"),
["net"]
))
)
ask_config = CheckBox(Id(:configure_qdevice), Opt(:notify), "Qnetd Server Host:", false)

qdevice_net_section = VBox(
HBox(
Left(InputField(Id(:qdevice_host),Opt(:hstretch), _("Qnetd server host:"),"")),
HSpacing(1),
Left(InputField(Id(:qdevice_port),Opt(:hstretch), _("Qnetd server TCP port:"),"5403"))
),
qdevice_config_base =
HBox(
Left(ComboBox(
Id(:qdevice_tls), Opt(:hstretch), _("TLS:"),
["off", "on", "required"]
)),
Left(ComboBox(Id(:qdevice_algorithm),Opt(:hstretch, :notify), _("Algorithm:"),["ffsplit"])),
VBox(
Left(ask_config),
Left(InputField(Id(:qdevice_host),Opt(:hstretch), _(""),"")),
),
HSpacing(1),
Left(InputField(Id(:qdevice_tie_breaker),Opt(:hstretch), _("Tie breaker:"),"lowest"))
Left(InputField(Id(:qdevice_port),Opt(:hstretch), _("Qnetd Server TCP port:"),"5403")),
)
)

qdevice_heuristics_section = VBox(
HBox(
Left(ComboBox(
Id(:heuristics_mode), Opt(:hstretch, :notify), _("Heuristics Mode:"),
["off", "on", "sync"]
))
),
qdevice_config_advance =
HBox(
Left(InputField(Id(:heuristics_timeout),Opt(:hstretch), _("Heuristics Timeout(milliseconds):"),"5000")),
Left(ComboBox(Id(:qdevice_model),Opt(:hstretch),_("Qdevice Model:"),["net"])),
HSpacing(1),
Left(InputField(Id(:heuristics_sync_timeout),Opt(:hstretch), _("Heuristics Sync_timeout(milliseconds):"),"15000")),
Left(ComboBox(Id(:qdevice_tls), Opt(:hstretch), _("TLS:"),["off", "on", "required"])),
HSpacing(1),
Left(InputField(Id(:heuristics_interval),Opt(:hstretch), _("Heuristics Interval(milliseconds):"),"30000")),
),
Left(ComboBox(Id(:qdevice_algorithm),Opt(:hstretch, :notify), _("Algorithm:"),["ffsplit"])),
HSpacing(1),
Left(InputField(Id(:qdevice_tie_breaker),Opt(:hstretch), _("Tie Breaker:"),"lowest"))
)

heuristics_conifg =
VBox(
HBox(
Left(ComboBox(
Id(:heuristics_mode), Opt(:hstretch, :notify), _("Heuristics Mode:"),
["off", "on", "sync"]
)),
HSpacing(1),
Left(InputField(Id(:heuristics_timeout),Opt(:hstretch), _("Heuristics Timeout(ms):"),"5000")),
),
HBox(
Left(InputField(Id(:heuristics_sync_timeout),Opt(:hstretch), _("Heuristics Sync Timeout(ms):"),"15000")),
HSpacing(1),
Left(InputField(Id(:heuristics_interval),Opt(:hstretch), _("Heuristics Interval(ms):"),"30000")),
)
)

heuristics_table =
VBox(
Left(Label(_("Heuristics Executables:"))),
Table(Id(:heuristics_executables), Header(_("Name"), _("Value")), []),
Expand All @@ -1380,30 +1381,21 @@ def CorosyncQdeviceLayout
PushButton(Id(:executable_edit), "Edit"))
)
)
)

contents = VBox(
VSpacing(1),
CheckBoxFrame(
Id(:corosync_qdevice),
Opt(:hstretch, :notify),
_("En&able Corosync Qdevice"),
false,
contents =
Frame(
_(""),
VBox(
qdevice_section,
qdevice_net_section,
qdevice_heuristics_section,
qdevice_config_base,
qdevice_config_advance,
heuristics_conifg,
heuristics_table
)
),
VStretch()
)
)

my_SetContents("corosyncqdevice", contents)

UI.ChangeWidget(Id(:corosync_qdevice), :Value, Cluster.corosync_qdevice)

UI.ChangeWidget(Id(:qdevice_model), :Value, Cluster.qdevice_model)

UI.ChangeWidget(Id(:qdevice_host), :Value, Cluster.qdevice_host)
UI.ChangeWidget(Id(:qdevice_port), :Value, Cluster.qdevice_port)
UI.ChangeWidget(Id(:qdevice_tls), :Value, Cluster.qdevice_tls)
Expand Down Expand Up @@ -1434,14 +1426,34 @@ def UpdateQdeviceVotes
nil
end

def qdevice_switch
enable_widgets(UI.QueryWidget(Id(:configure_qdevice), :Value),
:qdevice_host,
:qdevice_port,
:qdevice_model,
:qdevice_tls,
:qdevice_tie_breaker,
:qdevice_algorithm,
:heuristics_mode)
nil
end

def heuristics_switch
if !UI.QueryWidget(Id(:heuristics_mode), :Value) ||
UI.QueryWidget(Id(:heuristics_mode), :Value) == "off"
UI.QueryWidget(Id(:heuristics_mode), :Value) == "off" ||
!UI.QueryWidget(Id(:configure_qdevice), :Value)
disable = false
else
disable = true
end
enable_widgets(disable, :heuristics_timeout, :heuristics_sync_timeout, :heuristics_interval, :heuristics_executables)
enable_widgets(disable,
:heuristics_timeout,
:heuristics_sync_timeout,
:heuristics_interval,
:heuristics_executables,
:executable_add,
:executable_edit,
:executable_del)

nil
end
Expand All @@ -1466,13 +1478,12 @@ def CorosyncQdeviceDialog
while true
fill_qdevice_heuristics_executables
heuristics_switch
qdevice_switch

ret = UI.UserInput

if ret == :corosync_qdevice
if UI.QueryWidget(Id(:corosync_qdevice), :Value) == false
next
end

if ret == :configure_qdevice
next
end

if ret == :heuristics_mode
Expand Down

0 comments on commit 50a5f3b

Please sign in to comment.