add check for servicenodes and computenodes in noderange for nodeset. Also remove very old commented out code defect 3750

This commit is contained in:
lissav 2013-08-27 12:48:37 -04:00
parent c0fbda2ee2
commit edabe5dc6c

View File

@ -10,6 +10,7 @@ use File::Path;
use Getopt::Long;
require xCAT::Utils;
require xCAT::TableUtils;
use xCAT::ServiceNodeUtils;
my $addkcmdlinehandled;
my $request;
my $callback;
@ -279,6 +280,7 @@ sub preprocess_request {
my $callback1 = shift;
my $command = $req->{command}->[0];
my $sub_req = shift;
my $nodes = $req->{node};
my @args=();
if (ref($req->{arg})) {
@args=@{$req->{arg}};
@ -286,6 +288,7 @@ sub preprocess_request {
@args=($req->{arg});
}
@ARGV = @args;
Getopt::Long::Configure("bundling");
Getopt::Long::Configure("pass_through");
if (!GetOptions('h|?|help' => \$HELP, 'v|version' => \$VERSION) ) {
@ -323,10 +326,22 @@ sub preprocess_request {
return;
}
#my $sent = $stab->getAttribs({key=>'sharedtftp'},'value');
my @entries = xCAT::TableUtils->get_site_attribute("sharedtftp");
my $t_entry = $entries[0];
if ( defined($t_entry) and ($t_entry == 0 or $t_entry =~ /no/i)) {
# check for computenodes and servicenodes from the noderange, if so error out
my @SN;
my @CN;
xCAT::ServiceNodeUtils->getSNandCPnodes(\@$nodes, \@SN, \@CN);
if ((@SN > 0) && (@CN >0 )) { # there are both SN and CN
my $rsp;
$rsp->{data}->[0] =
"Nodeset was run with a noderange containing both service nodes and compute nodes. This is not valid. You must submit with either compute nodes in the noderange or service nodes. \n";
xCAT::MsgUtils->message("E", $rsp, $callback1);
return;
}
$req->{'_disparatetftp'}=[1];
if ($req->{inittime}->[0]) {
return [$req];
@ -335,58 +350,6 @@ sub preprocess_request {
}
return [$req];
}
#sub preprocess_request {
# my $req = shift;
# $callback = shift;
# if ($req->{_xcatdest}) { return [$req]; } #Exit if the packet has been preprocessed in its history
# my @requests = ({%$req}); #Start with a straight copy to reflect local instance
# my $sitetab = xCAT::Table->new('site');
# (my $ent) = $sitetab->getAttribs({key=>'xcatservers'},'value');
# $sitetab->close;
# if ($ent and $ent->{value}) {
# foreach (split /,/,$ent->{value}) {
# if (xCAT::NetworkUtils->thishostisnot($_)) {
# my $reqcopy = {%$req};
# $reqcopy->{'_xcatdest'} = $_;
# push @requests,$reqcopy;
# }
# }
# }
# return \@requests;
#}
#sub preprocess_request {
# my $req = shift;
# my $callback = shift;
# my %localnodehash;
# my %dispatchhash;
# my $nrtab = xCAT::Table->new('noderes');
# foreach my $node (@{$req->{node}}) {
# my $nodeserver;
# my $tent = $nrtab->getNodeAttribs($node,['tftpserver']);
# if ($tent) { $nodeserver = $tent->{tftpserver} }
# unless ($tent and $tent->{tftpserver}) {
# $tent = $nrtab->getNodeAttribs($node,['servicenode']);
# if ($tent) { $nodeserver = $tent->{servicenode} }
# }
# if ($nodeserver) {
# $dispatchhash{$nodeserver}->{$node} = 1;
# } else {
# $localnodehash{$node} = 1;
# }
# }
# my @requests;
# my $reqc = {%$req};
# $reqc->{node} = [ keys %localnodehash ];
# if (scalar(@{$reqc->{node}})) { push @requests,$reqc }
#
# foreach my $dtarg (keys %dispatchhash) { #iterate dispatch targets
# my $reqcopy = {%$req}; #deep copy
# $reqcopy->{'_xcatdest'} = $dtarg;
# $reqcopy->{node} = [ keys %{$dispatchhash{$dtarg}}];
# push @requests,$reqcopy;
# }
# return \@requests;
#}
sub process_request {
$request = shift;