Map Host Names
In several points in the systems, it is useful to get the host name for a checkout, for a job, for a daemon, etc. Since every machine may be known by different names, it is important to provide the expert user with the ability to map host names to some canonical form of the host name.
# Default definition of mapHostName in vovutils.tcl
proc mapHostName { host { defaultName "" } { context "" } } {
set shortHost [ string tolower [ lindex [split $host .] 0 ] ]
return $shortHost
}
mapHostNameInit <context>
where context
is an optional parameter to specify any string that
sets the context of the host mapping calls. If no context
is
provided, it defaults to an empty string.
Further, a context
can also be specified as an argument to
mapHostName procedure.
context
. However, a custom implementation specified in
hostmap.tcl may either use the context
provided in calling it, or it can access the context set in
mapHostNameInit by using the variable
vovutils(hostmap,context)
:# Example of hostmap.tcl
proc mapHostName { host { defaultName "" } { context "" } } {
global vovutils
switch -glob -- $host {
"lnxBG*" { return [string tolower $host] }
"lnx*.company.com" { return [lindex [split $host .] 0] }
"localhost" {
if { $vovutils(hostmap,context) eq "LM" } {
return $defaultName
} elseif { $context eq "NC-USA" } {
return "mynchostname"
}
}
default { return $host }
}
}
- vovlalm: Used to sample Monitor
data from Allocator. This script provides the nickname
of the Monitor instance as the
context
on mapHostNameInit, and also uses the Monitor instance's nickname as the context in the call to mapHostName. - vovlavtkncget (called by vovlanc): Used to sample Accelerator data from Allocator. This script provides the nickname of the Accelerator site as the context on mapHostNameInit, and also uses the Accelerator instance's nickname as the context in the call to mapHostName.
Also to be noted, in Monitor, is the use of the built-in procedure LMnormalizedName, which is used to eliminate non-ASCII characters from user names, host names, and feature names.