2
0
mirror of https://github.com/xcat2/xcat-core.git synced 2025-05-30 01:26:38 +00:00

Remove Error message for rpower command when node has pdu attributes

This commit is contained in:
Casandra Qiu 2017-03-02 10:50:19 -05:00
parent 47f3b6c039
commit 040ab4c0cb

View File

@ -131,9 +131,12 @@ sub process_request
return powerstat($noderange, $callback);
}elsif ($command eq "rpower") {
my $subcmd = $exargs[0];
if(($subcmd eq 'on') || ($subcmd eq 'off') || ($subcmd eq 'stat')){
if (($subcmd eq 'pduoff') || ($subcmd eq 'pduon') || ($subcmd eq 'pdustat')){
#if one day, pdu node have pdu attribute, handle in this section too
return powerpduoutlet($noderange, $subcmd, $callback);
} else {
#-------------------------------------------
#there are 2 cases will enter this black
#there are 2 cases will enter this block
#one is if node's mgt is pdu
#another is if node has pdu attribute but mgt isn't pdu
#if the node has pdu attribute but mgt isn't pdu,
@ -144,15 +147,14 @@ sub process_request
my $nodehmhash = $nodehm->getNodesAttribs($noderange, ['mgt']);
foreach my $node (@$noderange) {
if($nodehmhash->{$node}->[0]->{mgt} eq 'pdu'){
push @allpdunodes, $node;
if(($subcmd eq 'on') || ($subcmd eq 'off') || ($subcmd eq 'stat')){
push @allpdunodes, $node;
} else {
$callback->({ errorcode => [1],error => "The input $command is not support for pdu"});
}
}
}
return powerpdu(\@allpdunodes, $subcmd, $callback);
}elsif(($subcmd eq 'pduoff') || ($subcmd eq 'pduon') || ($subcmd eq 'pdustat')){
#if one day, pdu node have pdu attribute, handle in this section too
return powerpduoutlet($noderange, $subcmd, $callback);
}else{
$callback->({ errorcode => [1],error => "The input command $subcmd is not support for pdu"});
}
}elsif($command eq "nodeset") {
$callback->({ errorcode => [1],error => "The input $command is not support for pdu"});
@ -185,6 +187,9 @@ sub powerpdu {
foreach my $node (@$noderange) {
my $session = connectTopdu($node,$callback);
if (!$session) {
next;
}
my $count = $session->get("$outletnum");
my $value;
my $statstr;
@ -244,6 +249,9 @@ sub powerpduoutlet {
foreach my $pdu_outlet (@pdus) {
my ($pdu, $outlet) = split /:/, $pdu_outlet;
my $session = connectTopdu($pdu,$callback);
if (!$session) {
next;
}
my $cmd;
if ($subcmd eq "pdustat") {
$statstr=outletstat($session, $outlet);
@ -307,6 +315,9 @@ sub powerstat {
my $outletnum = ".1.3.6.1.4.1.2.6.223.8.2.1.0";
foreach my $pdu (@$noderange) {
my $session = connectTopdu($pdu,$callback);
if (!$session) {
next;
}
my $count = $session->get("$outletnum");
for (my $outlet =1; $outlet <= $count; $outlet++)
{