Skip to content
Snippets Groups Projects
Commit 0cda6daf authored by Morris Jette's avatar Morris Jette
Browse files

Harden test for node names without numeric suffix

parent af7a6fd3
No related branches found
No related tags found
No related merge requests found
...@@ -2414,13 +2414,19 @@ proc make_bash_script { script_name script_contents } { ...@@ -2414,13 +2414,19 @@ proc make_bash_script { script_name script_contents } {
# #
# Purpose: Given a hostname, return it's numeric suffix # Purpose: Given a hostname, return it's numeric suffix
# #
# Returns: numerical suffix for input 'hostname' # Returns: numerical suffix for input 'hostname' or -1 if not a number
# #
# Input: hostname -- hostname for which to return suffix # Input: hostname -- hostname for which to return suffix
# #
################################################################ ################################################################
proc get_suffix { hostname } { proc get_suffix { hostname } {
set host_len [string length $hostname] set host_len [string length $hostname]
set host_inx [expr $host_len-1]
set host_char [string index $hostname $host_inx]
if {[string compare $host_char "0"] < 0 || [string compare $host_char "9"] > 0} {
return -1
}
for {set host_inx [expr $host_len-1]} {$host_inx >= 0} {incr host_inx -1} { for {set host_inx [expr $host_len-1]} {$host_inx >= 0} {incr host_inx -1} {
set host_char [string index $hostname $host_inx] set host_char [string index $hostname $host_inx]
if {[string compare $host_char "0"] < 0} { break } if {[string compare $host_char "0"] < 0} { break }
......
...@@ -143,6 +143,11 @@ set host_0_num [get_suffix $host_0_name] ...@@ -143,6 +143,11 @@ set host_0_num [get_suffix $host_0_name]
set host_1_num [get_suffix $host_1_name] set host_1_num [get_suffix $host_1_name]
set host_2_num [get_suffix $host_2_name] set host_2_num [get_suffix $host_2_name]
if {$host_0_num == -1 || $host_1_num == -1 || $host_2_num == -1} {
send_user "\nWARNING: node names lack numeric suffix\n"
exit $exit_code
}
if {$host_1_num != [expr $host_0_num + 1]} { if {$host_1_num != [expr $host_0_num + 1]} {
send_user "\nFAILURE: node sequence number not contiguous\n" send_user "\nFAILURE: node sequence number not contiguous\n"
set exit_code 1 set exit_code 1
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment