Skip to content

Commit fa04e92

Browse files
committed
re-write of qhost_F_parse function
// BelongsTo: CS-1612
1 parent 8d95b30 commit fa04e92

File tree

2 files changed

+47
-91
lines changed

2 files changed

+47
-91
lines changed

src/tcl_files/control_procedures.tcl

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2439,12 +2439,20 @@ proc resolve_build_arch_installed_libs {host {raise_error 1}} {
24392439
# SEE ALSO
24402440
# ???/???
24412441
#*******************************
2442+
# clear cache on re-source of tcl-files (menu 33)
2443+
global resolve_host_cache
2444+
unset -nocomplain resolve_host_cache
24422445
proc resolve_host {name {long 0}} {
2443-
global resolve_host_cache CHECK_USER
2444-
24452446
get_current_cluster_config_array ts_config
2447+
global CHECK_USER
2448+
global resolve_host_cache
24462449

24472450
set name [string trim $name]
2451+
if {$name eq ""} {
2452+
ts_log_severe "empty host name given to resolve_host"
2453+
return ""
2454+
}
2455+
24482456
# we cannot resolve hostgroups.
24492457
if {[string range $name 0 0] == "@"} {
24502458
ts_log_fine "hostgroups ($name) cannot be resolved"
@@ -2464,7 +2472,7 @@ proc resolve_host {name {long 0}} {
24642472
set result [start_sge_utilbin "gethostbyname" "-aname $name" $ts_config(master_host) $CHECK_USER]
24652473

24662474
if {$prg_exit_state != 0} {
2467-
ts_log_fine "proc resolve_host - gethostbyname failed: \n$result"
2475+
ts_log_fine "proc resolve_host - gethostbyname -aname $name failed: \n$result"
24682476
return $name
24692477
}
24702478

src/tcl_files/parser.tcl

Lines changed: 36 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -3102,7 +3102,7 @@ proc qstat_F_plain_parse {result_array_var {params ""} {user ""} {add_args ""} {
31023102
# matches dom:name=value (in_use)
31033103
set qstat_output($queue_name,${dom}:$name) $value
31043104
set qstat_output($queue_name,${dom}:${name}_in_use) $in_use
3105-
} elseif {[regexp {([a-zA-Z]{2}):([a-zA-Z_]+)=([a-zA-Z._0-9/]+)} $id all dom name value]} {
3105+
} elseif {[regexp {([a-zA-Z]{2}):([a-zA-Z_]+)=([a-zA-Z._0-9/-]+)} $id all dom name value]} {
31063106
# matches dom:name=value
31073107
set qstat_output($queue_name,${dom}:$name) $value
31083108
} elseif { [regexp "\[a-zA-Z\]" $id] } { ; # queue listing
@@ -3805,105 +3805,53 @@ proc qhost_q_parse { output_var jobCount } {
38053805
#
38063806
#
38073807
#*******************************
3808-
proc qhost_F_parse {output_var job_count_var {params "" }} {
3809-
upvar $output_var plain
3810-
upvar $job_count_var job
3808+
proc qhost_F_parse {output_var host_count_var {params "" }} {
3809+
upvar $output_var output
3810+
upvar $host_count_var host_count
38113811

38123812
# capture plain output
3813-
set plainoutput [start_sge_bin "qhost" "$params"]
3813+
set plainoutput [start_sge_bin "qhost" $params]
38143814

38153815
# split plain output on each new line
38163816
set plain_split [split $plainoutput "\n"]
3817-
set has_binding [ge_has_feature "binding-in-execd"]
3818-
set has_binding_scheduler [ge_has_feature "binding-in-scheduler"]
38193817

3820-
set inc 0
3821-
set job 0
3822-
set count 1
3823-
set line -1
3824-
foreach elem $plain_split {
3825-
#ts_log_fine "$line: $elem"
3826-
if {$count > 2} {
3827-
switch -- $line {
3828-
"1" {
3829-
qhost_add_plain plain $elem $job
3830-
}
3831-
2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - 15 - 16 - 17 - 18 - 19 - 20 - 21 {
3832-
set attr [ split $elem "="]
3833-
lassign $attr heading value
3834-
set val [ split $heading ":"]
3835-
lassign $val dom nam
3836-
set plain(host$job,$nam) $value
3837-
}
3818+
set job_count 0
3819+
set line_no 0
3820+
set host_count 0
3821+
foreach line $plain_split {
3822+
# skip header
3823+
if {$line_no > 1} {
3824+
set single_white_space_string [qstat_special_parse [string trim $line]]
3825+
if {$single_white_space_string eq ""} {
3826+
continue
38383827
}
3839-
if {$has_binding} {
3840-
if {[is_version_in_range "9.1.0"]} {
3841-
# if core binding is present then there are more lines for m_topology, m_core, m_socket, m_thread
3842-
switch -- $line {
3843-
22 - 23 - 24 - 25 {
3844-
set attr [ split $elem "="]
3845-
lassign $attr heading value
3846-
set val [ split $heading ":"]
3847-
lassign $val dom nam
3848-
set plain(host$job,$nam) $value
3849-
3850-
}
3851-
}
3852-
# switch to next job, increment counter
3853-
if {$line == 25} {
3854-
incr job 1
3855-
set line 0
3856-
}
3857-
} else {
3858-
# if core binding is present then there are more lines for m_topology, m_core, m_socket, m_thread, m_topology_inuse
3859-
switch -- $line {
3860-
22 - 23 - 24 - 25 - 26 {
3861-
set attr [ split $elem "="]
3862-
lassign $attr heading value
3863-
set val [ split $heading ":"]
3864-
lassign $val dom nam
3865-
set plain(host$job,$nam) $value
38663828

3867-
}
3868-
}
3869-
# switch to next job, increment counter
3870-
if {$line == 26} {
3871-
incr job 1
3872-
set line 0
3873-
}
3874-
}
3875-
} elseif {$has_binding_scheduler} {
3876-
# if core binding is present then there are more lines for m_topology, m_core, m_socket, m_thread, slots
3877-
switch -- $line {
3878-
22 - 23 - 24 - 25 - 26 {
3879-
set attr [ split $elem "="]
3880-
lassign $attr heading value
3881-
set val [ split $heading ":"]
3882-
lassign $val dom nam
3883-
set plain(host$job,$nam) $value
3884-
}
3885-
}
3886-
# switch to next job, increment counter
3887-
if { $line == 26} {
3888-
incr job 1
3889-
set line 0
3890-
}
3829+
ts_log_fine $single_white_space_string
3830+
set id [lindex $single_white_space_string 0]
3831+
set two_ids [lrange $single_white_space_string 0 1]
3832+
3833+
if {[regexp {([a-zA-Z]{2}):([a-zA-Z_]+)=([a-zA-Z]+) \(([a-zA-Z]+)\)} $two_ids all dom name value in_use]} {
3834+
# matches dom:name=value (in_use)
3835+
# new output in 9.1.0
3836+
set output($hostid,$name) $value
3837+
#set output($hostid,${dom}:${name}_in_use) $in_use
3838+
} elseif {[regexp {([a-zA-Z]{2}):([a-zA-Z_]+)=([a-zA-Z._0-9/-]+)} $id all dom name value]} {
3839+
# matches dom:name=value
3840+
# usual -F output
3841+
# hl:arch=lx-amd64
3842+
set output($hostid,$name) $value
3843+
} elseif {[regexp "\[a-zA-Z\]" $id]} {
3844+
# host line
3845+
# ubuntu-24-amd64-1 lx-amd64 8 2 8 8 1.00 7.8G 493.6M 2.3G 0.0
3846+
set hostid "host$host_count"
3847+
qhost_add_plain output $single_white_space_string $host_count
3848+
incr host_count
38913849
} else {
3892-
# switch to next job, increment counter
3893-
if { $line == 21} {
3894-
incr job 1
3895-
set line 0
3896-
}
3897-
}
3898-
if { $count == 3 } {
3899-
incr job 1
3900-
set line 0
3850+
# we could parse additional info, e.g. from qhost -j here
39013851
}
39023852
}
3903-
incr line 1
3904-
incr count 1
3853+
incr line_no
39053854
}
3906-
incr job -1
39073855
}
39083856

39093857
#****** parser/plain_gdr_parse() ******

0 commit comments

Comments
 (0)