mirror of
https://github.com/xcat2/xcat-core.git
synced 2025-05-30 17:46:38 +00:00
Merge pull request #1481 from zet809/fix_issue_1371
Fix issue 1371: xcatprobe switch-macmap - could not get valid informa…
This commit is contained in:
commit
06f3f28c67
@ -570,10 +570,14 @@ sub getsnmpsession {
|
||||
my $snmpver='1';
|
||||
my $swent = $self->{switchparmhash}->{$switch};
|
||||
|
||||
if ($swent) {
|
||||
$snmpver=$swent->{snmpversion};
|
||||
$community=$swent->{password};
|
||||
}
|
||||
if ($swent) {
|
||||
if ($swent->{snmpversion}) {
|
||||
$snmpver=$swent->{snmpversion};
|
||||
}
|
||||
if ($swent->{password}) {
|
||||
$community=$swent->{password};
|
||||
}
|
||||
}
|
||||
my $switch_ip = xCAT::NetworkUtils->getipaddr($switch);
|
||||
unless ($switch_ip) {
|
||||
return ({"ErrorStr"=>"Can not resolve IP address for $switch"});
|
||||
|
@ -53,13 +53,15 @@ if ($help) {
|
||||
probe_utils->send_msg("$output", "d", $::USAGE);
|
||||
exit 0;
|
||||
}
|
||||
|
||||
if (! -d "$currdir/bin") {
|
||||
mkpath("$currdir/bin/");
|
||||
}
|
||||
if (! -e "$currdir/bin/switchprobe") {
|
||||
link("$::XCATROOT/bin/xcatclient", "$currdir/bin/switchprobe");
|
||||
}
|
||||
|
||||
if ($test) {
|
||||
if (! -d "$currdir/bin") {
|
||||
mkpath("$currdir/bin/");
|
||||
}
|
||||
if (! -e "$currdir/bin/switchprobe") {
|
||||
link("$::XCATROOT/bin/xcatclient", "$currdir/bin/switchprobe");
|
||||
}
|
||||
`$currdir/bin/switchprobe -h`;
|
||||
if ($?) {
|
||||
probe_utils->send_msg("$output", "f", "No switchprobe tool is available at $currdir/bin/");
|
||||
@ -92,21 +94,25 @@ if (-f $error_file) {
|
||||
}
|
||||
my $fd;
|
||||
open($fd, "<", "$normal_file");
|
||||
my %fails = ();
|
||||
my @fails = ();
|
||||
# There is 2 kinds of error message:
|
||||
# 1. Error: The nodetype is not 'switch' for nodes: switch1
|
||||
# Error: No switch configuration info find for switch-10-5-23-1
|
||||
# 2. switch-10-5-23-1: Error: Timeout
|
||||
foreach (<$fd>) {
|
||||
chomp($_);
|
||||
if (/^(\S*):\s*(.*)/) {
|
||||
my $switch = $1;
|
||||
my $info = $2;
|
||||
if (/PASS/) {
|
||||
probe_utils->send_msg("$output", "o", "$switch");
|
||||
} elsif (/Error:/) {
|
||||
$info =~ s/Error://;
|
||||
$fails{$switch} = $info;
|
||||
if (/Error:/) {
|
||||
if (/^(\S*):\s*Error:\s*(.*)/) {
|
||||
push @fails, "$1 - $2";
|
||||
} elsif (/^Error:\s*(.*)/) {
|
||||
push @fails, $1;
|
||||
} else {
|
||||
probe_utils->send_msg("$output", "d", "$_");
|
||||
push @fails, $_;
|
||||
}
|
||||
}
|
||||
elsif (/^(\S*):\s*PASS/) {
|
||||
probe_utils->send_msg("$output", "o", "$1");
|
||||
}
|
||||
else {
|
||||
probe_utils->send_msg("$output", "d", $_);
|
||||
}
|
||||
@ -118,7 +124,7 @@ if (-f $normal_file) {
|
||||
if (-f $error_file) {
|
||||
unlink($error_file);
|
||||
}
|
||||
foreach (keys %fails) {
|
||||
probe_utils->send_msg("$output", "f", "$_ - $fails{$_}");
|
||||
foreach (@fails) {
|
||||
probe_utils->send_msg("$output", "f", "$_");
|
||||
}
|
||||
exit 0;
|
||||
|
@ -130,9 +130,21 @@ sub preprocess_request {
|
||||
if (defined($check)) {
|
||||
$request->{opt}->{check} = $check;
|
||||
}
|
||||
my $switchestab = xCAT::Table->new('switches', -create=>0);
|
||||
my $swhash = undef;
|
||||
if ($switchestab) {
|
||||
$swhash = $switchestab->getAllNodeAttribs(['switch'], 1);
|
||||
if (!defined($swhash)) {
|
||||
$callback->({error=>["Get attributes from table 'switches' failed"],errorcode=>1});
|
||||
return;
|
||||
}
|
||||
}
|
||||
else {
|
||||
$callback->({error=>["Open table 'switches' failed"],errorcode=>1});
|
||||
return;
|
||||
}
|
||||
if (defined($noderange)) {
|
||||
my $nthash = undef;
|
||||
my $swhash = undef;
|
||||
my $nodetypetab=xCAT::Table->new('nodetype',-create=>0);
|
||||
if ($nodetypetab) {
|
||||
$nthash = $nodetypetab->getNodesAttribs($noderange, ['nodetype']);
|
||||
@ -145,19 +157,6 @@ sub preprocess_request {
|
||||
$callback->({error=>["Open table 'nodetype' failed"],errorcode=>1});
|
||||
return;
|
||||
}
|
||||
my $switchestab = xCAT::Table->new('switches', -create=>0);
|
||||
if ($switchestab) {
|
||||
$swhash = $switchestab->getNodesAttribs($noderange, ['switch']);
|
||||
if (!defined($swhash)) {
|
||||
$callback->({error=>["Get attributes from table 'switches' failed"],errorcode=>1});
|
||||
return;
|
||||
}
|
||||
}
|
||||
else {
|
||||
$callback->({error=>["Open table 'switches' failed"],errorcode=>1});
|
||||
return;
|
||||
|
||||
}
|
||||
my @switchnode = ();
|
||||
my @errswnode = ();
|
||||
my @errornode = ();
|
||||
@ -165,7 +164,7 @@ sub preprocess_request {
|
||||
if (!defined($nthash->{$node}) or $nthash->{$node}->[0]->{nodetype} ne 'switch') {
|
||||
push @errornode, $node;
|
||||
}
|
||||
elsif (!defined($swhash->{$node})) {
|
||||
elsif (!defined($swhash->{$node}) or !defined($swhash->{$node}->[0])) {
|
||||
push @errswnode, $node;
|
||||
}
|
||||
else {
|
||||
@ -183,6 +182,12 @@ sub preprocess_request {
|
||||
return [$request];
|
||||
}
|
||||
return;
|
||||
}
|
||||
else {
|
||||
if (!scalar(keys %$swhash)) {
|
||||
$callback->({error=>["No switch configuration info get from 'switches' table"],errorcode=>1});
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
return [$request];
|
||||
|
Loading…
x
Reference in New Issue
Block a user