Using ProLiant Essentials Rapid Deployment Pack for scripted blade based switch configuration
SwitchInfo.txt
SwitchInfo.txt is an example text based database file containing the interconnect switch address and
access information.
# The following record represents switch login information.
# Lines not beginning with the switch location are ignored
# including blank lines.
# Each line is of the following form:
# EnclosureName-RackName-switchAorB:SwitchType:NameOrIP:User:Password.
# Rack name is rack1, enclosure name is enclosure0.
# IP address is 192.168.10.15. User name is root, password is admin.
enc0-rack1-switchA:p-GbE2:192.168.10.15:root:admin
# IP address is 192.168.10.16. There is no user name, password is admin.
enc0-rack1-switchB:p-GbE2:192.168.10.16::admin
GetSwitchInfo.pm
GetSwitchInfo.pm is a Perl module loaded by the interconnect switch configuration program.
sub GetSwitchInfo
{
# Set switch location from passed in parameters.
local($enc) = @_[0];
local($rack) = @_[1];
local($side) = @_[2]; # A or B
# Define local variables for the return values and the line buffer.
local($line);
# Define the search key which is the rack location and
# the switch side separated by `-`.
local($key) = $enc . "-$rack-" . $side;
local(%switch_params);
# Set the length of the search key.
local($keylen) = length($key);
# Open the switch information file and read each line until
# there are no more lines to read.
open(filehandle, "<SwitchInfo.txt")
or die "error opening SwitchInfo.txt\n";
while(1){
$line = <filehandle>;
if(!$line){
last;
}
# Remove the newline from the end of the line
# and check for a search match.
chomp($line);
if(substr($line, 0, $keylen) eq $key){ #found the line matching the key
# Split the line on colons, the first entry will be the key
@tmp = split(/:/, substr($line, $keylen + 1), -1);
$switch_params{'switch-type'} = $tmp[0];
$switch_params{'host'} = $tmp[1];
$switch_params{'user'} = $tmp[2];
$switch_params{'password'} = $tmp[3];
$switch_params{'side'} = $side;
return %switch_params;
}
}
# Return the values.
return %switch_params;
}
1;
18