From e80509c0ae4a2eb697987f4a06c2611930d2a69f Mon Sep 17 00:00:00 2001 From: chenglch Date: Wed, 21 Mar 2018 16:24:00 +0800 Subject: [PATCH] use msgsource directly --- perl-xCAT/xCAT/Client.pm | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/perl-xCAT/xCAT/Client.pm b/perl-xCAT/xCAT/Client.pm index ba52dcfbc..455c3524e 100644 --- a/perl-xCAT/xCAT/Client.pm +++ b/perl-xCAT/xCAT/Client.pm @@ -1129,12 +1129,15 @@ sub handle_response { return; } - my $msgsource; + my $msgsource = ""; if ($ENV{'XCATSHOWSVR'}) { unless ($rsp->{NoSvrPrefix}) { # some plugins could disable the prefix forcely by seting the flag in response. $msgsource = $rsp->{xcatdsource}->[0] if ($rsp->{xcatdsource}); } } + if ($rsp->{host}) { + $msgsource = $rsp->{xcatdsource}->[0] if ($rsp->{xcatdsource}); + } #print "in handle_response\n"; # Handle errors @@ -1148,10 +1151,6 @@ sub handle_response { $xCAT::Client::EXITCODE |= $rsp->{errorcode}; } # assume it is a non-reference scalar } - my $host = ""; - if ($rsp->{host}) { - $host = "[".$rsp->{host}->[0]."]" if !$msgsource; - } if ($rsp->{error}) { @@ -1160,14 +1159,14 @@ sub handle_response { foreach my $text (@{ $rsp->{error} }) { my $desc = "$text"; $desc = "[$msgsource]: $desc" if ($msgsource && $desc); - $desc = "Error$host: $desc" unless ($rsp->{NoErrorPrefix}); + $desc = "Error: $desc" unless ($rsp->{NoErrorPrefix}); print STDERR "$desc\n"; } } else { my $desc = $rsp->{error}; $desc = "[$msgsource]: $desc" if ($msgsource && $desc); - $desc = "Error$host: $desc" unless ($rsp->{NoErrorPrefix}); + $desc = "Error: $desc" unless ($rsp->{NoErrorPrefix}); print STDERR "$desc\n"; } } @@ -1178,14 +1177,14 @@ sub handle_response { foreach my $text (@{ $rsp->{warning} }) { my $desc = "$text"; $desc = "[$msgsource]: $desc" if ($msgsource && $desc); - $desc = "Warning$host: $desc" unless ($rsp->{NoWarnPrefix}); + $desc = "Warning: $desc" unless ($rsp->{NoWarnPrefix}); print STDERR "$desc\n"; } } else { my $desc = $rsp->{warning}; $desc = "[$msgsource]: $desc" if ($msgsource && $desc); - $desc = "Warning$host: $desc" unless ($rsp->{NoWarnPrefix}); + $desc = "Warning: $desc" unless ($rsp->{NoWarnPrefix}); print STDERR "$desc\n"; } } @@ -1193,7 +1192,7 @@ sub handle_response { #print "printing info\n"; if (ref($rsp->{info}) eq 'ARRAY') { foreach my $text (@{ $rsp->{info} }) { - my $desc = "$host$text"; + my $desc = "$text"; $desc = "[$msgsource]: $desc" if ($msgsource && $desc); print "$desc\n"; }