2
0
mirror of https://github.com/xcat2/xcat-core.git synced 2025-05-21 19:22:05 +00:00

Forwarding to MN if the request is accepted by SN

This commit is contained in:
Bin Xu 2017-07-27 15:55:30 +08:00
parent 53d3b1bced
commit 31ba541657
4 changed files with 65 additions and 27 deletions

View File

@ -1,8 +1,8 @@
package xCAT::Scope;
#use Data::Dumper;
use xCAT::Utils;
use xCAT::Table;
use xCAT::TableUtils;
use xCAT::ServiceNodeUtils qw(getSNList);
@ -148,22 +148,31 @@ sub get_broadcast_scope_with_parallel {
if ($req->{_xcatpreprocessed}->[0] == 1) { return [$req]; }
my $snlist = shift;
my @reqs = ();
$req->{_xcatpreprocessed}->[0] = 1;
my $isMN = xCAT::Utils->isMN();
#Handle the one for current management/service node
my $reqs = get_parallel_scope($req);
if ( $isMN ) {
$reqs = get_parallel_scope($req);
} else {
# get site.master and broadcast to it as MN will not be in SN list or defined in noderes.servicenode.
my @entries = xCAT::TableUtils->get_site_attribute("master");
my $master = $entries[0];
my $reqcopy = {%$req};
$reqcopy->{'_xcatdest'} = $master;
$reqs = get_parallel_scope($reqcopy);
}
my @requests = @$reqs;
#Broadcast the request to other management/service nodes
foreach (@$snlist) {
my $xcatdest = $_;
if (xCAT::NetworkUtils->thishostisnot($xcatdest)) {
my $reqcopy = {%$req};
$reqcopy->{'_xcatdest'} = $xcatdest;
$reqcopy->{_xcatpreprocessed}->[0] = 1;
my $reqcopy = {%$req};
$reqcopy->{'_xcatdest'} = $xcatdest;
$reqs = get_parallel_scope($reqcopy);
foreach (@$reqs) {
push @requests, {%$_};
}
$reqs = get_parallel_scope($reqcopy);
foreach (@$reqs) {
push @requests, {%$_};
}
}
return \@requests;
@ -197,12 +206,22 @@ sub get_broadcast_disjoint_scope_with_parallel {
my $sn_hash = shift;
my @reqs = ();
$req->{_xcatpreprocessed}->[0] = 1;
my $isMN = xCAT::Utils->isMN();
#Handle the one for current management/service node
if ( xCAT::Utils->isMN() ) {
$reqs = get_parallel_scope($req);
if ( $isMN ) {
$reqs = get_parallel_scope($req);
} else {
# get site.master and broadcast to it as MN will not be in SN list or defined in noderes.servicenode.
my @entries = xCAT::TableUtils->get_site_attribute("master");
my $master = $entries[0];
my $reqcopy = {%$req};
$reqcopy->{'_xcatdest'} = $master;
$reqs = get_parallel_scope($reqcopy);
}
my @requests = @$reqs;
my $handled4me = 0;
#Broadcast the request to other management/service nodes
foreach (keys %$sn_hash) {
my $xcatdest = $_;
@ -210,15 +229,26 @@ sub get_broadcast_disjoint_scope_with_parallel {
my $reqcopy = {%$req};
$reqcopy->{'_xcatdest'} = $xcatdest;
$reqcopy->{'node'} = $sn_hash->{$xcatdest};
$reqcopy->{_xcatpreprocessed}->[0] = 1;
$reqs = get_parallel_scope($reqcopy);
foreach (@$reqs) {
push @requests, {%$_};
}
} elsif ($isMN == 0) {
# avoid handle myself multiple times when different IP address used in `noderes.servicenode`.
next if $handled4me;
my $reqcopy = {%$req};
$reqcopy->{'_xcatdest'} = $xcatdest;
$reqcopy->{'node'} = $sn_hash->{$xcatdest};
$reqs = get_parallel_scope($reqcopy);
foreach (@$reqs) {
push @requests, {%$_};
}
$handled4me = 1;
}
}
#print Dumper(\@requests);
return \@requests;
}

View File

@ -573,7 +573,7 @@ sub process_request {
my $errormsg = $ipret->{'error'};
my $nodeip = $ipret->{'ip'};
if ($errormsg) {# Add the node to failure set
xCAT::MsgUtils->trace(0, "E", "grub2: IP address of $_ is $nodeip. $errormsg");
xCAT::MsgUtils->trace(0, "E", "grub2: Defined IP address of $_ is $nodeip. $errormsg");
unless ($nodeip) {
$failurenodes{$_} = 1;
}
@ -606,7 +606,10 @@ sub process_request {
unless (@nodes) {
xCAT::MsgUtils->message("S", "xCAT: grub2 netboot: no valid nodes. Stop the operation on this server.");
# It must be an error if my managed nodes are not handled.
# We need special hanlding to see if the plugin needs report error.
# - For MN, it is designed to handle all nodes, any error is required to be reqport. (All nodes are handled on MN if sharedtftp=1)
# - For SN, if disjointdhcps=1 AND sharedtftp=0, all nodes in the request are the nodes managed by this SN, so we need report error
# if disjointdhcps=1 AND sharedtftp=0, report error only if there are nodes are managed by me.
if (xCAT::Utils->isMN() != 1 && $request->{'_disparatetftp'}->[0] && $request->{'_disjointmode'}->[0] != 1) {
# Find out which nodes are really mine only when not sharedtftp and not disjoint mode.
# For other case, all passing node range are required to be handled.
@ -634,7 +637,7 @@ sub process_request {
}
my $rsp;
$rsp->{errorcode}->[0] = 1;
$rsp->{error}->[0] = "Failed to generate grub2 configurations for some node(s) on $::myxcatname. Check xCAT log file for more details.\n";
$rsp->{error}->[0] = "Failed to generate grub2 configurations for some node(s) on $::myxcatname. Check xCAT log file for more details.";
$callback->($rsp);
return;
}
@ -878,7 +881,7 @@ sub process_request {
if (%failurenodes) {
my $rsp;
$rsp->{errorcode}->[0] = 1;
$rsp->{error}->[0] = "Failed to generate grub2 configurations for some node(s) on $::myxcatname. Check xCAT log file for more details.\n";
$rsp->{error}->[0] = "Failed to generate grub2 configurations for some node(s) on $::myxcatname. Check xCAT log file for more details.";
$callback->($rsp);
return;
}

View File

@ -1,7 +1,6 @@
# IBM(c) 2014 EPL license http://www.eclipse.org/legal/epl-v10.html
package xCAT_plugin::petitboot;
#use Data::Dumper;
use File::Path;
use Getopt::Long;
use xCAT::Table;
@ -464,7 +463,7 @@ sub process_request {
my $errormsg = $ipret->{'error'};
my $nodeip = $ipret->{'ip'};
if ($errormsg) {# Add the node to failure set
xCAT::MsgUtils->trace(0, "E", "petitboot: IP address of $_ is $nodeip. $errormsg");
xCAT::MsgUtils->trace(0, "E", "petitboot: Defined IP address of $_ is $nodeip. $errormsg");
unless ($nodeip) {
$failurenodes{$_} = 1;
}
@ -497,7 +496,10 @@ sub process_request {
unless (@nodes) {
xCAT::MsgUtils->message("S", "xCAT: petitboot netboot: no valid nodes. Stop the operation on this server.");
# It must be an error if my managed nodes are not handled.
# We need special hanlding to see if the plugin needs report error.
# - For MN, it is designed to handle all nodes, any error is required to be reqport. (All nodes are handled on MN if sharedtftp=1)
# - For SN, if disjointdhcps=1 AND sharedtftp=0, all nodes in the request are the nodes managed by this SN, so we need report error
# if disjointdhcps=1 AND sharedtftp=0, report error only if there are nodes are managed by me.
if (xCAT::Utils->isMN() != 1 && $request->{'_disparatetftp'}->[0] && $request->{'_disjointmode'}->[0] != 1) {
# Find out which nodes are really mine only when not sharedtftp and not disjoint mode.
# For other case, all passing node range are required to be handled.
@ -525,7 +527,7 @@ sub process_request {
}
my $rsp;
$rsp->{errorcode}->[0] = 1;
$rsp->{error}->[0] = "Failed to generate petitboot configurations for some node(s) on $::myxcatname. Check xCAT log file for more details.\n";
$rsp->{error}->[0] = "Failed to generate petitboot configurations for some node(s) on $::myxcatname. Check xCAT log file for more details.";
$callback->($rsp);
return;
}
@ -696,7 +698,7 @@ sub process_request {
if (%failurenodes) {
my $rsp;
$rsp->{errorcode}->[0] = 1;
$rsp->{error}->[0] = "Failed to generate petitboot configurations for some node(s) on $::myxcatname. Check xCAT log file for more details.\n";
$rsp->{error}->[0] = "Failed to generate petitboot configurations for some node(s) on $::myxcatname. Check xCAT log file for more details.";
$callback->($rsp);
return;
}

View File

@ -509,7 +509,7 @@ sub process_request {
my $errormsg = $ipret->{'error'};
my $nodeip = $ipret->{'ip'};
if ($errormsg) {# Add the node to failure set
xCAT::MsgUtils->trace(0, "E", "xnba: IP address of $_ is $nodeip. $errormsg");
xCAT::MsgUtils->trace(0, "E", "xnba: Defined IP address of $_ is $nodeip. $errormsg");
unless ($nodeip) {
$failurenodes{$_} = 1;
}
@ -542,7 +542,10 @@ sub process_request {
unless (@nodes) {
xCAT::MsgUtils->message("S", "xCAT: xnba netboot: no valid nodes. Stop the operation on this server.");
# It must be an error if my managed nodes are not handled.
# We need special hanlding to see if the plugin needs report error.
# - For MN, it is designed to handle all nodes, any error is required to be reqport. (All nodes are handled on MN if sharedtftp=1)
# - For SN, if disjointdhcps=1 AND sharedtftp=0, all nodes in the request are the nodes managed by this SN, so we need report error
# if disjointdhcps=1 AND sharedtftp=0, report error only if there are nodes are managed by me.
if (xCAT::Utils->isMN() != 1 && $::XNBA_request->{'_disparatetftp'}->[0] && $::XNBA_request->{'_disjointmode'}->[0] != 1) {
# Find out which nodes are really mine only when not sharedtftp and not disjoint mode.
# For other case, all passing node range are required to be handled.
@ -570,7 +573,7 @@ sub process_request {
}
my $rsp;
$rsp->{errorcode}->[0] = 1;
$rsp->{error}->[0] = "Failed to generate xnba configurations for some node(s) on $::myxcatname. Check xCAT log file for more details.\n";
$rsp->{error}->[0] = "Failed to generate xnba configurations for some node(s) on $::myxcatname. Check xCAT log file for more details.";
$::XNBA_callback->($rsp);
return;
}
@ -742,7 +745,7 @@ sub process_request {
if (%failurenodes) {
my $rsp;
$rsp->{errorcode}->[0] = 1;
$rsp->{error}->[0] = "Failed to generate xnba configurations for some node(s) on $::myxcatname. Check xCAT log file for more details.\n";
$rsp->{error}->[0] = "Failed to generate xnba configurations for some node(s) on $::myxcatname. Check xCAT log file for more details.";
$::XNBA_callback->($rsp);
return;
}