From 0d5317df7fcd5fbcb96ac4cce26222d8ecdee593 Mon Sep 17 00:00:00 2001 From: XuWei Date: Wed, 7 Mar 2018 02:10:28 -0500 Subject: [PATCH 1/3] show node name with error msg for ipmi --- xCAT-server/lib/xcat/plugins/ipmi.pm | 49 ++++++++++++++++++++++++---- 1 file changed, 42 insertions(+), 7 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/ipmi.pm b/xCAT-server/lib/xcat/plugins/ipmi.pm index a47df379a..7e38aa817 100644 --- a/xCAT-server/lib/xcat/plugins/ipmi.pm +++ b/xCAT-server/lib/xcat/plugins/ipmi.pm @@ -8264,13 +8264,20 @@ sub preprocess_request { return; } + my $all_noderange = $realnoderange; + if ($command eq "rpower") { my $subcmd = $exargs[0]; if ($subcmd eq '') { #$callback->({data=>["Please enter an action (eg: boot,off,on, etc)", $usage_string]}); #Above statement will miss error code, so replaced by the below statement - $callback->({ errorcode => [1], data => [ "Please enter an action (eg: boot,off,on, etc)", $usage_string ] }); + my $error_data = ""; + foreach (@$all_noderange) { + $error_data .= "\n" if ($error_data); + $error_data .= "$_: Please enter an action (eg: boot,off,on, etc)"; + } + $callback->({ errorcode => [1], data => [ $error_data, $usage_string ] }); $request = {}; return 0; } @@ -8284,13 +8291,23 @@ sub preprocess_request { #$callback->({data=>["Unsupported command: $command $subcmd", $usage_string]}); #Above statement will miss error code, so replaced by the below statement - $callback->({ errorcode => [1], data => [ "Unsupported command: $command $subcmd", $usage_string ] }); + my $error_data = ""; + foreach (@$all_noderange) { + $error_data .= "\n" if ($error_data); + $error_data .= "$_: Error: Unsupported command: $command $subcmd"; + } + $callback->({ errorcode => [1], data => [ $error_data, $usage_string ] }); $request = {}; return; } if (($subcmd eq 'on' or $subcmd eq 'reset' or $subcmd eq 'boot') and $::XCATSITEVALS{syspowerinterval}) { unless ($::XCATSITEVALS{syspowermaxnodes}) { - $callback->({ errorcode => [1], error => ["IPMI plugin requires syspowermaxnodes be defined if syspowerinterval is defined"] }); + my $error_data = ""; + foreach (@$all_noderange) { + $error_data .= "\n" if ($error_data); + $error_data .= "$_: IPMI plugin requires syspowermaxnodes be defined if syspowerinterval is defined"; + } + $callback->({ errorcode => [1], error => [$error_data] }); $request = {}; return 0; } @@ -8312,10 +8329,15 @@ sub preprocess_request { if ($realnoderange) { my $optset; my $option; + my $error_data = ""; foreach (@exargs) { if ($_ =~ /^(\w+)=(.*)/) { if ($optset eq 0) { - $callback->({ errorcode => [1], data => [ "Usage Error: Cannot display and change attributes on the same command."] }); + foreach (@$all_noderange) { + $error_data .= "\n" if ($error_data); + $error_data .= "$_: Usage Error: Cannot display and change attributes on the same command."; + } + $callback->({ errorcode => [1], data => [ $error_data] }); $request = {}; return; } @@ -8323,7 +8345,11 @@ sub preprocess_request { $option = $1; } else { if ($optset eq 1) { - $callback->({ errorcode => [1], data => [ "Usage Error: Cannot display and change attributes on the same command."] }); + foreach (@$all_noderange) { + $error_data .= "\n" if ($error_data); + $error_data .= "$_: Usage Error: Cannot display and change attributes on the same command."; + } + $callback->({ errorcode => [1], data => [ $error_data] }); $request = {}; return; } @@ -8331,7 +8357,11 @@ sub preprocess_request { $optset = 0; } unless ($option =~ /^USERID$|^ip$|^netmask$|^gateway$|^vlan$|^userid$|^username$|^password$|^snmpdest|^thermprofile$|^alert$|^garp$|^community$|^backupgateway$/) { - $callback->({ errorcode => [1], data => [ "Unsupported command: $command $_"] }); + foreach (@$all_noderange) { + $error_data .= "\n" if ($error_data); + $error_data .= "$_: Error: Unsupported command: $command $option"; + } + $callback->({ errorcode => [1], data => [ $error_data ] }); $request = {}; return; } @@ -8341,7 +8371,12 @@ sub preprocess_request { if ($exargs[0] eq "-t" and $#exargs == 0) { unshift @{ $request->{arg} }, 'all'; } elsif ((grep /-t/, @exargs) and !(grep /(all|vpd)/, @exargs)) { - $callback->({ errorcode => [1], error => ["option '-t' can only work with 'all' or 'vpd'"] }); + my $error_data = ""; + foreach (@$all_noderange) { + $error_data .= "\n" if ($error_data); + $error_data .= "$_: option '-t' can only work with 'all' or 'vpd"; + } + $callback->({ errorcode => [1], data => [ $error_data ] }); $request = {}; return 0; } From 3f31da435199cfb8361b27b8809e0ec06c4b9ce8 Mon Sep 17 00:00:00 2001 From: XuWei Date: Tue, 20 Mar 2018 02:17:04 -0400 Subject: [PATCH 2/3] modified depending on comments --- xCAT-server/lib/xcat/plugins/ipmi.pm | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/ipmi.pm b/xCAT-server/lib/xcat/plugins/ipmi.pm index 7e38aa817..b0edfa5df 100644 --- a/xCAT-server/lib/xcat/plugins/ipmi.pm +++ b/xCAT-server/lib/xcat/plugins/ipmi.pm @@ -8275,9 +8275,9 @@ sub preprocess_request { my $error_data = ""; foreach (@$all_noderange) { $error_data .= "\n" if ($error_data); - $error_data .= "$_: Please enter an action (eg: boot,off,on, etc)"; + $error_data .= "$_: Please enter an action (eg: boot,off,on, etc) for ipmi management method"; } - $callback->({ errorcode => [1], data => [ $error_data, $usage_string ] }); + $callback->({ errorcode => [1], data => [ $error_data ] }); $request = {}; return 0; } @@ -8294,9 +8294,9 @@ sub preprocess_request { my $error_data = ""; foreach (@$all_noderange) { $error_data .= "\n" if ($error_data); - $error_data .= "$_: Error: Unsupported command: $command $subcmd"; + $error_data .= "$_: Error: Unsupported command: $command $subcmd for ipmi management method"; } - $callback->({ errorcode => [1], data => [ $error_data, $usage_string ] }); + $callback->({ errorcode => [1], data => [ $error_data ] }); $request = {}; return; } @@ -8335,7 +8335,7 @@ sub preprocess_request { if ($optset eq 0) { foreach (@$all_noderange) { $error_data .= "\n" if ($error_data); - $error_data .= "$_: Usage Error: Cannot display and change attributes on the same command."; + $error_data .= "$_: Usage Error: Cannot display and change attributes on the same command for ipmi management method."; } $callback->({ errorcode => [1], data => [ $error_data] }); $request = {}; @@ -8347,7 +8347,7 @@ sub preprocess_request { if ($optset eq 1) { foreach (@$all_noderange) { $error_data .= "\n" if ($error_data); - $error_data .= "$_: Usage Error: Cannot display and change attributes on the same command."; + $error_data .= "$_: Usage Error: Cannot display and change attributes on the same command for ipmi management method."; } $callback->({ errorcode => [1], data => [ $error_data] }); $request = {}; @@ -8359,7 +8359,7 @@ sub preprocess_request { unless ($option =~ /^USERID$|^ip$|^netmask$|^gateway$|^vlan$|^userid$|^username$|^password$|^snmpdest|^thermprofile$|^alert$|^garp$|^community$|^backupgateway$/) { foreach (@$all_noderange) { $error_data .= "\n" if ($error_data); - $error_data .= "$_: Error: Unsupported command: $command $option"; + $error_data .= "$_: Error: Unsupported command: $command $option for ipmi management method"; } $callback->({ errorcode => [1], data => [ $error_data ] }); $request = {}; @@ -8374,7 +8374,7 @@ sub preprocess_request { my $error_data = ""; foreach (@$all_noderange) { $error_data .= "\n" if ($error_data); - $error_data .= "$_: option '-t' can only work with 'all' or 'vpd"; + $error_data .= "$_: option '-t' can only work with 'all' or 'vpd' for ipmi management method"; } $callback->({ errorcode => [1], data => [ $error_data ] }); $request = {}; From 8f2ba278972805b291bfec2524b478fa0cbff3ec Mon Sep 17 00:00:00 2001 From: XuWei Date: Thu, 22 Mar 2018 21:42:31 -0400 Subject: [PATCH 3/3] modified depending on comments --- xCAT-server/lib/xcat/plugins/ipmi.pm | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/ipmi.pm b/xCAT-server/lib/xcat/plugins/ipmi.pm index b0edfa5df..120c2830e 100644 --- a/xCAT-server/lib/xcat/plugins/ipmi.pm +++ b/xCAT-server/lib/xcat/plugins/ipmi.pm @@ -2409,7 +2409,8 @@ sub rflash { } elsif ($opt !~ /.*\.hpm$/i && $opt !~ /^-V{1,4}$|^--buffersize=|^--retry=/) { # An unexpected flag was passed, but it could be a directory name. Display error only if not -d option unless ($directory_flag) { - $callback->({ error => "The option $opt is not supported or invalid update file specified", + my $node = $sessdata->{node}; + $callback->({ data => "$node: Error: The option $opt is not supported or invalid update file specified", errorcode => 1 }); return; } @@ -8275,7 +8276,7 @@ sub preprocess_request { my $error_data = ""; foreach (@$all_noderange) { $error_data .= "\n" if ($error_data); - $error_data .= "$_: Please enter an action (eg: boot,off,on, etc) for ipmi management method"; + $error_data .= "$_: Please enter an action (eg: boot,off,on, etc) when using mgt=ipmi."; } $callback->({ errorcode => [1], data => [ $error_data ] }); $request = {}; @@ -8294,7 +8295,7 @@ sub preprocess_request { my $error_data = ""; foreach (@$all_noderange) { $error_data .= "\n" if ($error_data); - $error_data .= "$_: Error: Unsupported command: $command $subcmd for ipmi management method"; + $error_data .= "$_: Error: Unsupported command: $command $subcmd when using mgt=ipmi."; } $callback->({ errorcode => [1], data => [ $error_data ] }); $request = {}; @@ -8305,7 +8306,7 @@ sub preprocess_request { my $error_data = ""; foreach (@$all_noderange) { $error_data .= "\n" if ($error_data); - $error_data .= "$_: IPMI plugin requires syspowermaxnodes be defined if syspowerinterval is defined"; + $error_data .= "$_: 'syspowermaxnodes` is required if 'syspowerinterval' is configured in the site table."; } $callback->({ errorcode => [1], error => [$error_data] }); $request = {}; @@ -8335,7 +8336,7 @@ sub preprocess_request { if ($optset eq 0) { foreach (@$all_noderange) { $error_data .= "\n" if ($error_data); - $error_data .= "$_: Usage Error: Cannot display and change attributes on the same command for ipmi management method."; + $error_data .= "$_: Usage Error: Cannot display and change attributes on the same command when using mgt=ipmi.."; } $callback->({ errorcode => [1], data => [ $error_data] }); $request = {}; @@ -8347,7 +8348,7 @@ sub preprocess_request { if ($optset eq 1) { foreach (@$all_noderange) { $error_data .= "\n" if ($error_data); - $error_data .= "$_: Usage Error: Cannot display and change attributes on the same command for ipmi management method."; + $error_data .= "$_: Usage Error: Cannot display and change attributes on the same command when using mgt=ipmi."; } $callback->({ errorcode => [1], data => [ $error_data] }); $request = {}; @@ -8359,7 +8360,7 @@ sub preprocess_request { unless ($option =~ /^USERID$|^ip$|^netmask$|^gateway$|^vlan$|^userid$|^username$|^password$|^snmpdest|^thermprofile$|^alert$|^garp$|^community$|^backupgateway$/) { foreach (@$all_noderange) { $error_data .= "\n" if ($error_data); - $error_data .= "$_: Error: Unsupported command: $command $option for ipmi management method"; + $error_data .= "$_: Error: Unsupported command: $command $option when using mgt=ipmi."; } $callback->({ errorcode => [1], data => [ $error_data ] }); $request = {}; @@ -8374,7 +8375,7 @@ sub preprocess_request { my $error_data = ""; foreach (@$all_noderange) { $error_data .= "\n" if ($error_data); - $error_data .= "$_: option '-t' can only work with 'all' or 'vpd' for ipmi management method"; + $error_data .= "$_: option '-t' can only work with 'all' or 'vpd' when using mgt=ipmi."; } $callback->({ errorcode => [1], data => [ $error_data ] }); $request = {};