1
0
mirror of https://bitbucket.org/svk28/rac-gui synced 2024-12-04 18:46:52 +00:00

Программа переведена на новый конфиг

This commit is contained in:
Sergey 2019-09-10 19:06:48 +03:00
parent 2420f0b038
commit 8a5a586a73
5 changed files with 166 additions and 100 deletions

View File

@ -45,3 +45,4 @@ localhost:1545 {
}

View File

@ -23,6 +23,33 @@ proc GetInfobasePassword {host cluster infobase} {
}
}
proc GetClusterAdmin {host cluster} {
global servers_list
if [dict exists $servers_list servers $host clusters $cluster cluster_user] {
return [dict get $servers_list servers $host clusters $cluster cluster_user]
}
}
proc GetClusterPassword {host cluster} {
global servers_list
if [dict exists $servers_list servers $host clusters $cluster cluster_pwd] {
return [dict get $servers_list servers $host clusters $cluster cluster_pwd]
}
}
proc GetAgentAdmin {host} {
global servers_list
if [dict exists $servers_list servers $host agent_user] {
return [dict get $servers_list servers $host agent_user]
}
}
proc GetAgentPassword {host} {
global servers_list
if [dict exists $servers_list servers $host agent_pwd] {
return [dict get $servers_list servers $host agent_pwd]
}
}
# Конвертация словаря в удобочитаемый формат
@ -61,6 +88,11 @@ proc dict2json {dictionary} {
}
proc SetServersConfigDict {} {
global servers_list
}
# Сохраянем конфиг
proc SaveConfig {} {
global dir servers_list
@ -70,9 +102,11 @@ proc SaveConfig {} {
#puts "\n\n[split $dict " "]\n\n"
set dict [string map {"\{" "\{\n" "\}" "\n\}"} $dict]
regsub -- {(\})} $dict "\}\n" dict
#puts $dict
#DictFormatter [dict get $servers_list servers] "-"
puts "_________"
puts $servers_list
puts "2_________"
puts $dict
#ictFormatter [dict get $servers_list servers] "-"
#DictFormatter $dict "-"
#regexp -all -indices -line -- {\}(.+?)\{} $dict m
#puts " \n $m"
@ -96,7 +130,7 @@ proc SaveConfig {} {
}
if [regexp -- {\}} $line] {
#incr open_brace -1
set indent [string range $indent 0 end-2]
set indent [string range $indent 0 end-4]
incr close_brace
}
if [regexp -nocase -all -- {(\})(.+?\{)} $line match brace phrase] {
@ -123,6 +157,15 @@ proc SaveConfig {} {
append str $indent [string trim $line] "\n"
}
puts $f $str
close $f
set file [open [file join $dir(work) 1c_srv_new.cfg] "w"]
set f [open [file join $dir(work) 1c_srv_new_.cfg] "r"]
while {[gets $f line] >=0} {
if {$line ne ""} {
puts $file $line
}
}
#file copy -force [file join $dir(work) 1c_srv_new_.cfg] [file join $dir(work) 1c_srv_new.cfg]
}
proc GetDictFromString {str indent} {
@ -178,3 +221,8 @@ proc CopyNewConfig {} {
}
}

View File

@ -32,37 +32,37 @@ proc TreePress {tree} {
}
proc SetGlobalVarFromTreeItems {tree id} {
global host server active_cluster infobase profile_name dir rac_cmd_for_host rac_cmd
global host server active_cluster infobase profile_name dir rac_cmd_for_host rac_cmd servers_list \
cluster_user cluster_pwd agent_user agent_pwd
set parent [$tree parent $id]
set values [$tree item $id -values]
set key [lindex [split $id "::"] 0]
puts "$parent $values $key"
switch -- $key {
server {
set host $values
set orig_file [open [file join $dir(work) 1c_srv.cfg] "r"]
while {[gets $orig_file line] >=0 } {
if [string match "$host*" $line] {
set path_to_rac [string trim [lindex [split $line ","] 1]]
if {$path_to_rac eq ""} {
set rac_cmd_for_host($host) "$rac_cmd"
} else {
set rac_cmd_for_host($host) $path_to_rac
set rac_cmd $path_to_rac
set rac_cmd_for_host($host) [dict get $servers_list servers $host rac_cmd]
}
work_server {
set server $values
}
}
close $orig_file
}
work_server {set server $values}
cluster {
set active_cluster $values
#dict set servers_list $host $values
#dict set servers_list servers $host clusters "$values {}"
set cluster_user [GetClusterAdmin $host $active_cluster]
set cluster_pwd [GetClusterPassword $host $active_cluster]
}
infobase {
set infobase $values
#dict set servers_list $host $active_cluster infobases $values
#dict set servers_list servers $host clusters $active_cluster infobases $values
}
profile {
set profile_name $values
}
agent_admins {
set agent_user [GetAgentAdmin $host]
set agent_pwd [GetAgentPassword $host]
}
profile {set profile_name $values}
}
if {$parent eq ""} {
@ -146,7 +146,7 @@ proc RunCommand {par} {
}
proc ErrorParcing {err opt} {
global cluster_user cluster_pwd agent_user agent_pwd
global cluster_user cluster_pwd agent_user agent_pwd servers_list
switch -regexp -- $err {
"Cluster administrator is not authenticated" {
@ -189,7 +189,7 @@ proc ErrorParcing {err opt} {
}
}
proc AuthorisationDialog {txt} {
global active_cluster agent_user agent_pwd cluster_user cluster_pwd
global active_cluster agent_user agent_pwd cluster_user cluster_pwd servers_list
.frm_work.tree_work delete [ .frm_work.tree_work children {}]
set frm [AddToplevel "$txt" administrator_grey_64 .auth_win]
@ -383,8 +383,26 @@ proc SetRacCommand {} {
if {$rac_cmd eq ""} {
return
} else {
#puts $rac_cmd
if {[file tail $rac_cmd] ne "rac" && [file tail $rac_cmd] ne "rac.exe"} {
set rac [file tail $rac_cmd]
set path_to_rac [file rootname $rac_cmd]
append msg [::msgcat::mc "Command must be"] " 'rac' " \
[::msgcat::mc "or"] " 'rac.exe'\n" \
[::msgcat::mc "You entered"] " '$rac' - " \
[::msgcat::mc "it's correct?"]
set answer [tk_messageBox -message [::msgcat::mc $msg] -icon question -type yesno]
switch -- $answer {
yes {
return $rac_cmd
}
no SetRacCommand
}
} else {
return $rac_cmd
}
}
}
@ -392,7 +410,7 @@ namespace eval Run {} {}
# Получение данных по кластерам
proc Run::server {tree host values} {
global rac_cmd_for_host rac_cmd
global rac_cmd_for_host rac_cmd servers_list
if {[info exists rac_cmd_for_host($host)] == 1 && $rac_cmd_for_host($host) ne "" } {
set rac_cmd $rac_cmd_for_host($host)
}
@ -417,10 +435,15 @@ proc Run::server {tree host values} {
}
foreach x [array names cluster] {
set id [lindex $cluster($x) 0]
set cluster_name [lindex $cluster($x) 1]
if { [$tree exists "cluster::$id"] == 0 } {
$tree insert "server::$host" end -id "cluster::$id" -text "[lindex $cluster($x) 1]" -values "$id"
$tree insert "server::$host" end -id "cluster::$id" -text "$cluster_name" -values "$id"
InsertClusterItems $tree $id
}
#dict replace servers_list [dict get servers_list servers $host clusters]
#dict set servers_list servers $host clusters $id name $cluster_name
#puts $cluster_name
#puts $servers_list
}
if { [$tree exists "agent_admins::$id"] == 0 } {
$tree insert "server::$host" end -id "agent_admins::$id" -text [::msgcat::mc "Administrators"] -values "$id"
@ -478,6 +501,7 @@ proc Run::infobases {tree host values} {
proc Run::infobase {tree host values} {
global active_cluster cluster_user cluster_pwd default servers_list
if {$cluster_user ne "" && $cluster_pwd ne ""} {
set auth "--cluster-user=$cluster_user --cluster-pwd=$cluster_pwd"
} else {
@ -937,9 +961,11 @@ proc Add::admin {tree host value} {
}
proc Add::server {} {
global default rac_cmd_for_host
global default rac_cmd_for_host servers_list
set frm [AddToplevel [::msgcat::mc "Main server"] server_grey_64]
ttk::label $frm.lbl_server_name -text [::msgcat::mc "Name"]
ttk::entry $frm.ent_server_name
ttk::label $frm.lbl_host -text [::msgcat::mc "Address"]
ttk::entry $frm.ent_host
ttk::label $frm.lbl_port -text [::msgcat::mc "Port"]
@ -948,13 +974,15 @@ proc Add::server {} {
ttk::entry $frm.ent_path_to_rac
ttk::button $frm.btn_path_to_rac -text "..." -width 3
$frm.ent_port insert end $default(port)
grid $frm.lbl_host -row 0 -column 0 -sticky nsw -padx 5 -pady 5
grid $frm.ent_host -row 0 -column 1 -columnspan 2 -sticky nsew -padx 5 -pady 5
grid $frm.lbl_port -row 1 -column 0 -sticky nsw -padx 5 -pady 5
grid $frm.ent_port -row 1 -column 1 -columnspan 2 -sticky nesw -padx 5 -pady 5
grid $frm.lbl_path_to_rac -row 2 -column 0 -sticky nsw -padx 5 -pady 5
grid $frm.ent_path_to_rac -row 2 -column 1 -sticky nsew -padx 5 -pady 5
grid $frm.btn_path_to_rac -row 2 -column 2 -sticky new -padx 5 -pady 5
grid $frm.lbl_server_name -row 0 -column 0 -sticky nsw -padx 5 -pady 5
grid $frm.ent_server_name -row 0 -column 1 -columnspan 2 -sticky nsew -padx 5 -pady 5
grid $frm.lbl_host -row 1 -column 0 -sticky nsw -padx 5 -pady 5
grid $frm.ent_host -row 1 -column 1 -columnspan 2 -sticky nsew -padx 5 -pady 5
grid $frm.lbl_port -row 2 -column 0 -sticky nsw -padx 5 -pady 5
grid $frm.ent_port -row 2 -column 1 -columnspan 2 -sticky nesw -padx 5 -pady 5
grid $frm.lbl_path_to_rac -row 3 -column 0 -sticky nsw -padx 5 -pady 5
grid $frm.ent_path_to_rac -row 3 -column 1 -sticky nsew -padx 5 -pady 5
grid $frm.btn_path_to_rac -row 3 -column 2 -sticky new -padx 5 -pady 5
grid columnconfigure $frm 0 -weight 1
grid rowconfigure $frm 0 -weight 1
@ -964,17 +992,25 @@ proc Add::server {} {
}
.add.frm_btn.btn_ok configure -command {
set host [SaveMainServer [.add.frm.ent_host get] [.add.frm.ent_port get] [.add.frm.ent_path_to_rac get]]
set server_name "[.add.frm.ent_server_name get]"
set host "[.add.frm.ent_host get]:[.add.frm.ent_port get]"
set rac_cmd_for_host($host) [.add.frm.ent_path_to_rac get]
.frm_tree.tree insert {} end -id "server::$host" -text "$host" -values "$host"
dict set servers_list servers $host "name \"$server_name\" rac_cmd $rac_cmd_for_host($host) clusters {}"
#set host [SaveMainServer [.add.frm.ent_host get] [.add.frm.ent_port get] [.add.frm.ent_path_to_rac get]]
#set rac_cmd_for_host($host) [.add.frm.ent_path_to_rac get]
#puts $servers_list
.frm_tree.tree insert {} end -id "server::$host" -text "$server_name" -values "$host"
destroy .add
SaveConfig
return $host
}
return $frm
}
proc Add::servers {tree host values} {
global default dedicate_managers using active_cluster cluster_user cluster_pwd auth \
servers_list
if {$cluster_user ne "" && $cluster_pwd ne ""} {
set auth "--cluster-user=$cluster_user --cluster-pwd=$cluster_pwd"
} else {
@ -1231,6 +1267,8 @@ proc Add::cluster {tree host values} {
set errors_count_threshold $default(errors_count_threshold)
set security_level [lindex $default(security_level) 0]
set load_balancing_mode [lindex $default(load_balancing_mode) 0]
set kill_problem_processes no
set kill_by_memory_with_dump no
set frm [AddToplevel [::msgcat::mc "Cluster"] cluster_grey_64]
@ -1303,7 +1341,7 @@ proc Add::cluster {tree host values} {
RunCommand "cluster insert \
--host=[.add.frm.ent_host get] \
--port=[.add.frm.ent_port get] \
--name=[.add.frm.ent_name get] \
--name=[regsub -all -- " " [.add.frm.ent_name get] "\\ "] \
--expiration-timeout=$expiration_timeout \
--lifetime-limit=$lifetime_limit \
--max-memory-size=$max_memory_size \
@ -1798,53 +1836,37 @@ proc Edit::managers {tree host values} {
}
proc Edit::server {tree host value} {
global dir prev_address rac_cmd rac_cmd_for_host
global dir prev_address rac_cmd rac_cmd_for_host servers_list
set frm [Add::server]
wm title .add [::msgcat::mc "Edit record"]
set lst [split $value ":"]
set prev_address $value
set orig_file [open [file join $dir(work) 1c_srv.cfg] "r"]
while {[gets $orig_file line] >=0 } {
if [string match "$prev_address*" $line] {
set path_to_rac [string trim [lindex [split $line ","] 1]]
if {$path_to_rac eq ""} {
set path_to_rac "$rac_cmd"
}
}
}
close $orig_file
.add.frm.ent_server_name delete 0 end
.add.frm.ent_host delete 0 end
.add.frm.ent_port delete 0 end
.add.frm.ent_path_to_rac delete 0 end
.add.frm.ent_server_name insert end [dict get $servers_list servers $prev_address name]
.add.frm.ent_host insert end [lindex $lst 0]
.add.frm.ent_port insert end [lindex $lst 1]
.add.frm.ent_path_to_rac insert end $path_to_rac
.add.frm.ent_path_to_rac insert end [dict get $servers_list servers $prev_address rac_cmd]
.add.frm_btn.btn_ok configure -command {
set host "[.add.frm.ent_host get]:[.add.frm.ent_port get]"
#set rac_cmd [.add.frm.ent_path_to_rac get]
set server_name [.add.frm.ent_server_name get]
set rac_cmd_for_host($host) [.add.frm.ent_path_to_rac get]
.frm_tree.tree delete "server::$prev_address"
.frm_work.tree_work delete [ .frm_work.tree_work children {}]
.frm_tree.tree insert {} end -id "server::$host" -text "$host" -values "$host"
if [file exists [file join $dir(work) 1c_srv.cfg.bak]] {
file delete [file join $dir(work) 1c_srv.cfg.bak]
}
file copy [file join $dir(work) 1c_srv.cfg] [file join $dir(work) 1c_srv.cfg.bak]
set orig_file [open [file join $dir(work) 1c_srv.cfg.bak] "r"]
set file [open [file join $dir(work) 1c_srv.cfg] "w"]
while {[gets $orig_file line] >=0 } {
if [string match "$prev_address*" $line] {
puts $file "$host,$rac_cmd_for_host($host)"
} else {
puts $file $line
}
}
close $file
close $orig_file
#return "$host:$port"
file delete [file join $dir(work) 1c_srv.cfg.bak]
.frm_tree.tree insert {} end -id "server::$host" -text "$server_name" -values "$host"
set clusters [dict get $servers_list servers $prev_address clusters]
dict unset servers_list servers $prev_address
dict set servers_list servers $host "name \"$server_name\" rac_cmd $rac_cmd_for_host($host) clusters \{$clusters\}"
unset clusters server_name
#puts $servers_list
destroy .add
SaveConfig
return $host
}
}
@ -2396,6 +2418,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 auth
if {$cluster_user ne "" && $cluster_pwd ne ""} {
@ -2420,14 +2443,20 @@ proc Del::rule {tree host values} {
no {return}
}
}
# Удаление основного сервера кластера
proc Del::server {tree host values} {
global dir
global dir servers_list
set answer [tk_messageBox -message "[::msgcat::mc "Delete server"] $values?" \
-icon question -type yesno ]
switch -- $answer {
yes {
file copy [file join $dir(work) 1c_srv.cfg] [file join $dir(work) 1c_srv.cfg.bak]
dict unset servers_list servers $values
SaveConfig
$tree delete "server::$values"
.frm_work.tree_work delete [ .frm_work.tree_work children {}]
return
# данный код не используется. УДАЛИТЬ!
file copy [file join $dir(work) 1c_srv_new.cfg] [file join $dir(work) 1c_srv.cfg.bak]
set orig_file [open [file join $dir(work) 1c_srv.cfg.bak] "r"]
set file [open [file join $dir(work) 1c_srv.cfg] "w"]
while {[gets $orig_file line] >=0 } {
@ -2437,10 +2466,10 @@ proc Del::server {tree host values} {
}
close $file
close $orig_file
#return "$host:$port"
$tree delete "server::$values"
.frm_work.tree_work delete [ .frm_work.tree_work children {}]
file delete [file join $dir(work) 1c_srv.cfg.bak]
#return "$host:$port"
########## Конец Удаления #############
}
no {return}
}
@ -2545,3 +2574,4 @@ proc Del::inet {tree host profile_name} {

View File

@ -122,10 +122,6 @@ set default(temporary_allowed_total_memory) 0
# предел превышения (секунд) допустимого объема памяти процессов <seconds>
set default(temporary_allowed_total_memory_time_limit) 300
## Раскоментировать строки и прописать свои значения если
## для Информационных Баз используются эти параметры
#set default(infobase_user) "ib_user"
@ -137,3 +133,4 @@ set default(theme) dark

View File

@ -84,31 +84,21 @@ CheckVariablesSet
# Читаем файл со списком серверов 1С
#set serversList [dict create servers]
if [file exists [file join $dir(work) 1c_srv.cfg]] {
set f [open [file join $dir(work) 1c_srv.cfg] "RDONLY"]
while {[gets $f line] >=0} {
set l [split $line ","]
set host [lindex $l 0]
if {[lindex $l 1] ne ""} {
set rac_cmd_for_host($host) [lindex $l 1]
}
.frm_tree.tree insert {} end -id "server::$host" -text "$host" -values "$host"
}
close $f
}
if [file exists [file join $dir(work) 1c_srv_new.cfg]] {
set f_new [open [file join $dir(work) 1c_srv_new.cfg] "RDONLY"]
while {[gets $f_new line] >=0} {
append str " [string trim $line]"
}
set str [string map {"\{ " "\{" " \}" "\}"} $str]
close $f
dict set servers_list servers $str
close $f_new
puts $servers_list
puts [dict get $servers_list servers]
dict for {host host_data} [dict get $servers_list servers] {
.frm_tree.tree insert {} end -id "server::$host" -text [dict get $host_data name] -values "$host"
set rac_cmd_for_host($host) [dict get $host_data rac_cmd]
}
}