Некоторые изменения в коде - понаставил заглушек. Сделана обработка ошибок и вывод сообщений. Поотловлены некоторые ошибки.

This commit is contained in:
Sergey Kalinin 2018-06-23 15:00:39 +03:00
parent ad8ed8617b
commit 7b78146d81
3 changed files with 90 additions and 50 deletions

View File

@ -21,7 +21,6 @@ proc TreePress {tree} {
SetGlobalVarFromTreeItems $tree $id
set values [$tree item $id -values]
set key [lindex [split $id "::"] 0]
puts $key
Run::$key $tree $host $values
}
@ -90,6 +89,7 @@ proc RunCommand {root par} {
} on error {result options} {
puts "Handle >$result< "
ErrorParcing $result $options
return ""
#RunCommand $root $par
}
@ -111,7 +111,6 @@ proc ErrorParcing {err opt} {
#RunCommand $root $par
}
"Central server administrator is not authenticated" {
#tk_messageBox -type ok -message "Логиницоооооооооооооо!"
AuthorisationDialog "Администратор агента кластера"
.auth_win.frm_btn.btn_ok configure -command {
set agent_user [.auth_win.frm.ent_name get]
@ -119,6 +118,26 @@ proc ErrorParcing {err opt} {
destroy .auth_win
}
}
"Администратор кластера не аутентифицирован" {
AuthorisationDialog "Администратор кластера"
.auth_win.frm_btn.btn_ok configure -command {
set cluster_user [.auth_win.frm.ent_name get]
set cluster_pwd [.auth_win.frm.ent_pwd get]
destroy .auth_win
}
#RunCommand $root $par
}
"Администратор центрального сервера не аутентифицирован" {
AuthorisationDialog "Администратор агента кластера"
.auth_win.frm_btn.btn_ok configure -command {
set agent_user [.auth_win.frm.ent_name get]
set agent_pwd [.auth_win.frm.ent_pwd get]
destroy .auth_win
}
}
(.+) {
tk_messageBox -type ok -icon error -message "$err"
}
}
}
proc AuthorisationDialog {txt} {
@ -185,7 +204,13 @@ proc InsertWorkServerItems {tree id} {
}
proc GetInfobases {cluster host} {
set lst [RunCommand "" "infobase summary --cluster=$cluster list $host"]
global active_cluster cluster_user cluster_pwd auth
if {$cluster_user ne "" && $cluster_pwd ne ""} {
set auth "--cluster-user=$cluster_user --cluster-pwd=$cluster_pwd"
} else {
set auth ""
}
set lst [RunCommand "" "infobase summary --cluster=$cluster $auth list $host"]
set return_list ""
foreach info_bases_list $lst {
foreach i $info_bases_list {
@ -207,6 +232,7 @@ proc FormFieldsDataInsert {frm lst} {
$frm.ent_$entry_name insert end [string trim $value "\""]
}
if [winfo exists $frm.cb_$entry_name] {
global $entry_name
set $entry_name [string trim $value "\""]
}
if [winfo exists $frm.check_$entry_name] {
@ -236,6 +262,7 @@ namespace eval Run {} {}
proc Run::server {tree host values} {
set lst [RunCommand server::$host "cluster list $host"]
if {$lst eq ""} {return}
set l [lindex $lst 0]
#puts $lst
.frm_work.tree_work delete [ .frm_work.tree_work children {}]
@ -261,7 +288,6 @@ proc Run::server {tree host values} {
}
}
if { [$tree exists "agent_admins::$id"] == 0 } {
$tree insert "server::$host" end -id "agent_admins::$id" -text "Администраторы" -values "$id"
#InsertClusterItems $tree $id
}
@ -380,6 +406,8 @@ proc Run::servers {tree host values} {
}
set lst [RunCommand infobase::$values "server list --cluster=$active_cluster $auth $host"]
puts ">>>>>>>$lst<<<<"
if {$lst eq ""} {return}
foreach l $lst {
foreach i $l {
set server_list [split $i ":"]
@ -571,33 +599,12 @@ proc Add {} {
Add::$key .frm_tree.tree $host $values
}
proc AddToplevel_ {lbl img} {
if [winfo exists .add] {destroy .add}
toplevel .add
wm title .add $lbl
#wm iconphoto .add server_grey_64
ttk::label .add.lbl -image $img
set frm [ttk::labelframe .add.frm -text $lbl -labelanchor nw]
grid columnconfigure $frm 0 -weight 1
grid rowconfigure $frm 0 -weight 1
set frm_btn [frame .add.frm_btn -border 0]
ttk::button $frm_btn.btn_ok -image ok_grey_24 -command { }
ttk::button $frm_btn.btn_cancel -command {destroy .add} -image quit_grey_24
grid .add.lbl -row 0 -column 0 -sticky nw -padx 5 -pady 10
grid $frm -row 0 -column 1 -sticky nw -padx 5 -pady 5
grid $frm_btn -row 1 -column 1 -sticky se -padx 5 -pady 5
pack $frm_btn.btn_cancel -side right
pack $frm_btn.btn_ok -side right -padx 10
return $frm
}
proc AddToplevel {lbl img {win_name .add}} {
set cmd "destroy $win_name"
if [winfo exists $win_name] {destroy $win_name}
toplevel $win_name
wm title $win_name $lbl
wm iconphoto $win_name tcl
#wm iconphoto $win_name server_grey_64
ttk::label $win_name.lbl -image $img
@ -717,7 +724,7 @@ proc Add::server {} {
return $frm
}
proc Add::servers {tree host values} {
global default dedicate_managers using active_cluster cluster_user cluster_pwd
global default dedicate_managers using active_cluster cluster_user cluster_pwd auth
if {$cluster_user ne "" && $cluster_pwd ne ""} {
set auth "--cluster-user=$cluster_user --cluster-pwd=$cluster_pwd"
} else {
@ -810,11 +817,19 @@ proc Add::servers {tree host values} {
proc Add::work_server {tree host values} {
return [Add::servers $tree $host $values]
}
proc Add::manager {tree host values} {
return
}
proc Add::managers {tree host values} {
return
}
proc Add::infobase {tree host values} {
return [Add::infobases $tree $host $values]
}
proc Add::infobases {tree host values} {
global default active_cluster agent_user agent_pwd cluster_user cluster_pwd
global default active_cluster agent_user agent_pwd cluster_user cluster_pwd auth
global security_level dbms scheduled_jobs_deny create_db license_distribution date_offset db_create
if {$cluster_user ne "" && $cluster_pwd ne ""} {
set auth "--cluster-user=$cluster_user --cluster-pwd=$cluster_pwd"
@ -824,7 +839,7 @@ proc Add::infobases {tree host values} {
#set active_cluster $values
# установка значений по умолчанию
set license_distribution deny
set secure_level [lindex $default(secure_level) 0]
set security_level [lindex $default(security_level) 0]
set date_offset [lindex $default(date_offset) 0]
set dbms [lindex $default(dbms) 0]
set block_shedule on
@ -836,7 +851,7 @@ proc Add::infobases {tree host values} {
label $frm.lbl_descr -text "Описание"
entry $frm.ent_descr
label $frm.lbl_security_level -text "Защищённое соединение"
ttk::combobox $frm.cb_security_level -textvariable security_level -values $default(secure_level)
ttk::combobox $frm.cb_security_level -textvariable security_level -values $default(security_level)
label $frm.lbl_db_server -text "Адрес сервера баз данных"
entry $frm.ent_db_server
label $frm.lbl_dbms -text "Тип СУБД"
@ -934,7 +949,7 @@ proc Add::cluster {tree host values} {
set max_memory_size $default(max_memory_size)
set max_memory_time_limit $default(max_memory_time_limit)
set errors_count_threshold $default(errors_count_threshold)
set secure_level [lindex $default(secure_level) 0]
set security_level [lindex $default(security_level) 0]
set load_balancing_mode [lindex $default(load_balancing_mode) 0]
set frm [AddToplevel "Добавление кластера" cluster_grey_64]
@ -947,7 +962,7 @@ proc Add::cluster {tree host values} {
label $frm.lbl_name -text "Название кластера"
entry $frm.ent_name
label $frm.lbl_secure_connect -text "Защищённое соединение"
ttk::combobox $frm.cb_security_level -textvariable security_level -values $default(secure_level)
ttk::combobox $frm.cb_security_level -textvariable security_level -values $default(security_level)
label $frm.lbl_expiration_timeout -text "Останавливать выключенные процессы через:"
entry $frm.ent_expiration_timeout -textvariable expiration_timeout
label $frm.lbl_session_fault_tolerance_level -text "Уровень отказоустойчивости"
@ -1017,7 +1032,7 @@ proc Add::cluster {tree host values} {
proc Add::rule {tree host values} {
global default active_cluster infobase object_type server infobase_name rule_type \
agent_user agent_pwd cluster_user cluster_pwd
agent_user agent_pwd cluster_user cluster_pwd auth
if {$cluster_user ne "" && $cluster_pwd ne ""} {
set auth "--cluster-user=$cluster_user --cluster-pwd=$cluster_pwd"
} else {
@ -1087,6 +1102,13 @@ namespace eval Edit {} {}
proc Edit::admins {tree host value} {
return
}
proc Edit::manager {tree host values} {
return
}
proc Edit::managers {tree host values} {
return
}
proc Edit::server {tree host value} {
global dir prev_address
@ -1126,7 +1148,7 @@ proc Edit::cluster {tree host values} {
global default lifetime_limit expiration_timeout session_fault_tolerance_level
global max_memory_size max_memory_time_limit errors_count_threshold security_level
global load_balancing_mode kill_problem_processes active_cluster \
agent_user agent_pwd cluster_user cluster_pwd
agent_user agent_pwd cluster_user cluster_pwd auth
if {$cluster_user ne "" && $cluster_pwd ne ""} {
set auth "--cluster-user=$cluster_user --cluster-pwd=$cluster_pwd"
} else {
@ -1137,7 +1159,7 @@ proc Edit::cluster {tree host values} {
$frm configure -text "Редактирование кластера"
set active_cluster $values
set lst [RunCommand cluster::$values "cluster info --cluster=$active_cluster $auth $host"]
set lst [RunCommand cluster::$values "cluster info --cluster=$active_cluster $host"]
FormFieldsDataInsert $frm $lst
@ -1157,7 +1179,7 @@ proc Edit::cluster {tree host values} {
--load-balancing-mode=$load_balancing_mode \
--errors-count-threshold=$errors_count_threshold \
--kill-problem-processes=$kill_problem_processes \
$host"
$auth $host"
$tree delete "cluster::$active_cluster"
Run::server $tree $host ""
destroy .add
@ -1186,7 +1208,7 @@ proc Edit::infobases {tree host values} {
proc Edit::infobase {tree host values} {
global default active_cluster infobase agent_user agent_pwd cluster_user cluster_pwd
global security_level dbms scheduled_jobs_deny license_distribution date_offset
global sessions_deny
global sessions_deny auth
if {$cluster_user ne "" && $cluster_pwd ne ""} {
set auth "--cluster-user=$cluster_user --cluster-pwd=$cluster_pwd"
} else {
@ -1254,7 +1276,7 @@ proc Edit::infobase {tree host values} {
grid $frm.lbl_external_session_manager_required -row 9 -column 2 -sticky nw -padx 5 -pady 5
grid $frm.check_external_session_manager_required -row 9 -column 3 -sticky nw -padx 5 -pady 5
set lst [RunCommand infobase::$values "infobase info --cluster=$active_cluster --infobase=$values $host"]
set lst [RunCommand infobase::$values "infobase info --cluster=$active_cluster --infobase=$values $auth $host"]
FormFieldsDataInsert $frm $lst
.add.frm_btn.btn_ok configure -command {
@ -1308,7 +1330,7 @@ proc Edit::servers {tree host values} {
proc Edit::work_server {tree host values} {
global default active_cluster agent_user agent_pwd cluster_user cluster_pwd
global default dedicate_managers using
global default dedicate_managers using auth
if {$cluster_user ne "" && $cluster_pwd ne ""} {
set auth "--cluster-user=$cluster_user --cluster-pwd=$cluster_pwd"
} else {
@ -1348,7 +1370,7 @@ proc Edit::work_server {tree host values} {
}
proc Edit::rule {tree host values} {
global default active_cluster object_type infobase_name object_type server infobase_name rule_type rule \
agent_user agent_pwd cluster_user cluster_pwd
agent_user agent_pwd cluster_user cluster_pwd auth
if {$cluster_user ne "" && $cluster_pwd ne ""} {
set auth "--cluster-user=$cluster_user --cluster-pwd=$cluster_pwd"
} else {
@ -1408,9 +1430,21 @@ proc Del {} {
}
namespace eval Del {} {}
proc Del::manager {tree host values} {
return
}
proc Del::managers {tree host values} {
return
}
proc Del::locks {tree host values} {
return
}
proc Del::processes {tree host values} {
return
}
proc Del::admin {tree host values} {
global active_cluster agent_user agent_pwd cluster_user cluster_pwd
global active_cluster agent_user agent_pwd cluster_user cluster_pwd auth
if {$cluster_user ne "" && $cluster_pwd ne ""} {
set auth "--cluster-user=$cluster_user --cluster-pwd=$cluster_pwd"
} else {
@ -1456,7 +1490,7 @@ proc Del::admins {tree host values} {
}
proc Del::agent_admin {tree host values} {
global agent_user agent_pwd
global agent_user agent_pwd auth
if {$agent_user ne "" && $agent_pwd ne ""} {
set agent_auth "--agent-user=$agent_user --agent-pwd=$agent_pwd"
@ -1500,7 +1534,7 @@ proc Del::agent_admins {tree host values} {
proc Del::work_server {tree host values} {
global active_cluster agent_user agent_pwd cluster_user cluster_pwd
global active_cluster agent_user agent_pwd cluster_user cluster_pwd auth
if {$cluster_user ne "" && $cluster_pwd ne ""} {
set auth "--cluster-user=$cluster_user --cluster-pwd=$cluster_pwd"
} else {
@ -1539,7 +1573,7 @@ proc Del::servers {tree host values} {
Del::work_server $tree $host $work_server_id
}
proc Del::cluster {tree host values} {
global agent_user agent_pwd cluster_user cluster_pwd
global agent_user agent_pwd cluster_user cluster_pwd auth
if {$cluster_user ne "" && $cluster_pwd ne ""} {
set auth "--cluster-user=$cluster_user --cluster-pwd=$cluster_pwd"
} else {
@ -1558,7 +1592,7 @@ proc Del::cluster {tree host values} {
}
}
proc Del::infobase {tree host values} {
global active_cluster agent_user agent_pwd cluster_user cluster_pwd
global active_cluster agent_user agent_pwd cluster_user cluster_pwd auth
if {$cluster_user ne "" && $cluster_pwd ne ""} {
set auth "--cluster-user=$cluster_user --cluster-pwd=$cluster_pwd"
} else {
@ -1598,7 +1632,7 @@ proc Del::infobases {tree host values} {
Del::infobase $tree $host $values
}
proc Del::connections {tree host values} {
global active_cluster agent_user agent_pwd cluster_user cluster_pwd
global active_cluster agent_user agent_pwd cluster_user cluster_pwd auth
if {$cluster_user ne "" && $cluster_pwd ne ""} {
set auth "--cluster-user=$cluster_user --cluster-pwd=$cluster_pwd"
} else {
@ -1639,7 +1673,7 @@ proc Del::connections {tree host values} {
}
proc Del::sessions {tree host values} {
global active_cluster agent_user agent_pwd cluster_user cluster_pwd
global active_cluster agent_user agent_pwd cluster_user cluster_pwd auth
if {$cluster_user ne "" && $cluster_pwd ne ""} {
set auth "--cluster-user=$cluster_user --cluster-pwd=$cluster_pwd"
} else {
@ -1674,7 +1708,7 @@ proc Del::sessions {tree host values} {
proc Del::rule {tree host values} {
global active_cluster server agent_user agent_pwd cluster_user cluster_pwd
global active_cluster server agent_user agent_pwd cluster_user cluster_pwd auth
if {$cluster_user ne "" && $cluster_pwd ne ""} {
set auth "--cluster-user=$cluster_user --cluster-pwd=$cluster_pwd"
} else {
@ -1737,3 +1771,4 @@ proc Del::server {tree host values} {
no {return}
}
}

View File

@ -11,7 +11,7 @@
if {[info exists topLevelGeometry]} {
wm geometry . $topLevelGeometry
} else {
wm geometry . 1024x768+0+0
wm geometry . 1024x768
}
wm title . "1C Rac GUI"
@ -95,3 +95,4 @@ pack $frm_tree $frm_work -side left -expand true -fill both
.panel add $frm_tree -weight 1
.panel add $frm_work -weight 1

View File

@ -37,7 +37,11 @@ set default(dbms) {
# 0 - выключено
# 1 - только соединение
# 2 - постоянно
set default(secure_level) [list 0 1 2]
set default(security_level) {
0
1
2
}
set default(date_offset) [list 0 2000]
# Объект требования
set default(object_type) {