From 040ab4c0cbf2332cedcc50807292bafea95c25a5 Mon Sep 17 00:00:00 2001 From: Casandra Qiu Date: Thu, 2 Mar 2017 10:50:19 -0500 Subject: [PATCH] Remove Error message for rpower command when node has pdu attributes --- xCAT-server/lib/xcat/plugins/pdu.pm | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/pdu.pm b/xCAT-server/lib/xcat/plugins/pdu.pm index 7e107d529..b24adf3eb 100644 --- a/xCAT-server/lib/xcat/plugins/pdu.pm +++ b/xCAT-server/lib/xcat/plugins/pdu.pm @@ -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++) {