diff --git a/xCAT-server/lib/xcat/plugins/blade.pm b/xCAT-server/lib/xcat/plugins/blade.pm index c202c331b..c621b8f5a 100644 --- a/xCAT-server/lib/xcat/plugins/blade.pm +++ b/xCAT-server/lib/xcat/plugins/blade.pm @@ -4579,6 +4579,10 @@ sub process_request { $req->{noderange} = [$node]; $req->{discoverymethod} = ['blade']; $doreq->($req); + if (defined($req->{error})) { + $request->{error}->[0] = '1'; + $request->{error_msg}->[0] = $req->{error_msg}->[0]; + } %{$req} = (); #Clear request. it is done return 0; } diff --git a/xCAT-server/lib/xcat/plugins/hpblade.pm b/xCAT-server/lib/xcat/plugins/hpblade.pm index 364627ba7..e3c9f0477 100755 --- a/xCAT-server/lib/xcat/plugins/hpblade.pm +++ b/xCAT-server/lib/xcat/plugins/hpblade.pm @@ -771,6 +771,10 @@ sub process_request { my $req = {%$request}; $req->{command} = ['discovered']; $req->{noderange} = [ $macmap{$mac} ]; + if (defined($req->{error})) { + $request->{error}->[0] = '1'; + $request->{error_msg}->[0] = $req->{error_msg}->[0]; + } $doreq->($req); %{$req} = (); #Clear request. it is done #undef $mactab; diff --git a/xCAT-server/lib/xcat/plugins/nodediscover.pm b/xCAT-server/lib/xcat/plugins/nodediscover.pm index 0e48b3924..c357000eb 100644 --- a/xCAT-server/lib/xcat/plugins/nodediscover.pm +++ b/xCAT-server/lib/xcat/plugins/nodediscover.pm @@ -265,6 +265,12 @@ sub process_request { my $macstring = ""; if (defined($request->{mac})) { + if (!inet_aton($node)) { + xCAT::MsgUtils->message("S", "xcat.discovery.nodediscover: Can not resolve IP for the matching node:$node. Make sure \"makehosts\" and \"makedns\" have been run for $node."); + $request->{error} = [0]; + $request->{error_msg} = ["Can not resolve IP for the matching node:$node."]; + return; + } my $mactab = xCAT::Table->new("mac", -create => 1); my @ifinfo; my %usednames; @@ -272,6 +278,7 @@ sub process_request { my @hostnames_to_update = (); my %bydriverindex; my $forcenic = 0; #-1 is force skip, 0 is use default behavior, 1 is force to be declared even if hosttag is skipped to do so + my $localnic = 0; foreach (@{ $request->{mac} }) { @ifinfo = split /\|/; @@ -318,9 +325,6 @@ sub process_request { $hosttag = "$node-$ifinfo[1]"; push @hostnames_to_update, $hosttag; } - elsif (!inet_aton($node)) { - xCAT::MsgUtils->message("S", "xcat.discovery.nodediscover: Can not resolve IP for the matching node:$node. Make sure \"makehosts\" and \"makedns\" have been run for $node."); - } } #print Dumper($hosttag) . "\n"; if ($hosttag) { @@ -330,6 +334,7 @@ sub process_request { } if ($hosttag eq $node) { $macstring .= $currmac . "|"; + $localnic = 1; } else { $macstring .= $currmac . "!" . $hosttag . "|"; } @@ -347,6 +352,11 @@ sub process_request { if ($forcenic == 1) { $macstring .= $currmac . "|"; } } } + unless ($localnic) { + $request->{error} = [1]; + $request->{error_msg} = ["No nic found in deploy network for $node"]; + return; + } $macstring =~ s/\|\z//; $mactab->setNodeAttribs($node, { mac => $macstring }); if (scalar @hostnames_to_update) { diff --git a/xCAT-server/lib/xcat/plugins/seqdiscovery.pm b/xCAT-server/lib/xcat/plugins/seqdiscovery.pm index 7b8858156..c8aad37e2 100755 --- a/xCAT-server/lib/xcat/plugins/seqdiscovery.pm +++ b/xCAT-server/lib/xcat/plugins/seqdiscovery.pm @@ -398,10 +398,15 @@ sub findme { my $req = {%$request}; $req->{command} = ['discovered']; $req->{noderange} = [$node]; - $request->{bmc_node} = [$bmc_node]; + $req->{bmc_node} = [$bmc_node]; $req->{updateswitch} = ['yes']; $subreq->($req); + if (defined($req->{error})) { + $request->{error}->[0] = '1'; + $request->{error_msg}->[0] = $req->{error_msg}->[0]; + } + %{$req} = (); #Clear req structure, it's done.. undef $mactab; } else { diff --git a/xCAT-server/lib/xcat/plugins/switch.pm b/xCAT-server/lib/xcat/plugins/switch.pm index 024070b67..1ace2fffb 100644 --- a/xCAT-server/lib/xcat/plugins/switch.pm +++ b/xCAT-server/lib/xcat/plugins/switch.pm @@ -373,6 +373,10 @@ sub process_request { $request->{noderange} = [$node]; $request->{bmc_node} = [$bmc_node]; $doreq->($request); + if (defined($request->{error})) { + $req->{error}->[0] = '1'; + $req->{error_msg}->[0] = $request->{error_msg}->[0]; + } %{$request} = (); #Clear req structure, it's done.. undef $mactab; } else { diff --git a/xCAT-server/lib/xcat/plugins/typemtms.pm b/xCAT-server/lib/xcat/plugins/typemtms.pm index 33e4e6d0f..5911cdcd2 100644 --- a/xCAT-server/lib/xcat/plugins/typemtms.pm +++ b/xCAT-server/lib/xcat/plugins/typemtms.pm @@ -61,6 +61,10 @@ sub findme { $req->{bmc_node} = [$bmc_node]; $req->{updateswitch} = ['yes']; $subreq->($req); + if (defined($req->{error})) { + $request->{error}->[0] = '1'; + $request->{error_msg}->[0] = $req->{error_msg}->[0]; + } %{$req} = (); } } diff --git a/xCAT-server/lib/xcat/plugins/zzzdiscovery.pm b/xCAT-server/lib/xcat/plugins/zzzdiscovery.pm index f76338081..fb11381ff 100644 --- a/xCAT-server/lib/xcat/plugins/zzzdiscovery.pm +++ b/xCAT-server/lib/xcat/plugins/zzzdiscovery.pm @@ -22,11 +22,15 @@ sub process_request { my $doreq = shift; if ($req->{command}->[0] eq 'findme') { - if (!defined($req->{discoverymethod}) or !defined($req->{discoverymethod}->[0]) or ($req->{discoverymethod}->[0] eq 'undef')) { + if (!defined($req->{discoverymethod}) or !defined($req->{discoverymethod}->[0]) or ($req->{discoverymethod}->[0] eq 'undef') or defined($req->{error})) { + my $error_msg = "."; + if (defined($req->{error_msg}) and defined($req->{error_msg}->[0])) { + $error_msg = ": ". $req->{error_msg}->[0]; + } my $rsp = {}; - $rsp->{error}->[0] = "The discovery request can not be processed"; + $rsp->{error}->[0] = "The discovery request can not be processed".$error_msg; $cb->($rsp); - xCAT::MsgUtils->message("S", "xcat.discovery.zzzdiscovery: ($req->{_xcat_clientmac}->[0]) Failed to discover the node."); + xCAT::MsgUtils->message("S", "xcat.discovery.zzzdiscovery: ($req->{_xcat_clientmac}->[0]) Failed for node discovery".$error_msg); #now, notify the node that its findme request has been processed my $client_ip = $req->{'_xcat_clientip'};