hierarchy support in commands handled by ipmi.pm, blade.pm and nodestat.pm

git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@1059 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
This commit is contained in:
linggao 2008-04-15 14:37:26 +00:00
parent 0a71595fd4
commit ed718151f9
5 changed files with 134 additions and 46 deletions

View File

@ -1836,7 +1836,7 @@ sub get_site_Master
Will get the Service node ( name or ipaddress) as known by the Management
Server or NOde for the input nodename or ipadress of the node
input: list of nodenames and/or node ipaddresses
input: list of nodenames and/or node ipaddresses (array ref)
service name
"MN" or "Node" determines if you want the Service node as known
by the Management Node or by the node.
@ -1850,7 +1850,7 @@ sub get_site_Master
Todo: Handle dhcpserver and nameserver from the networks table
output: A hash of arrays, the key is the service node pointing to
output: A hash ref of of arrays, the key is the service node pointing to
an array of nodes that are serviced by that service node
Globals:
@ -1858,7 +1858,7 @@ sub get_site_Master
Error:
$::ERROR_RC=0 no error $::ERROR_RC=1 error
example: $sn =xCAT::Utils->get_ServiceNode(@nodes,$service,"MN");
example: $sn =xCAT::Utils->get_ServiceNode(\@nodes,$service,"MN");
=cut

View File

@ -1191,6 +1191,83 @@ sub build_depend {
}
sub preprocess_request {
my $request = shift;
if ($request->{_xcatdest}) { return [$request]; } #exit if preprocessed
my $callback=shift;
my @requests;
#display usage statement if -h is present or no noderage is specified
my $noderange = $request->{node}; #Should be arrayref
my $command = $request->{command}->[0];
my $extrargs = $request->{arg};
my @exargs=($request->{arg});
if (ref($extrargs)) {
@exargs=@$extrargs;
}
my $usage_string=xCAT::Usage->parseCommand($command, @exargs);
if ($usage_string) {
$callback->({data=>$usage_string});
$request = {};
return;
}
if (!$noderange) {
$usage_string=xCAT::Usage->getUsage($command);
$callback->({data=>$usage_string});
$request = {};
return;
}
#print "noderange=@$noderange\n";
#get the MMs for the nodes for the nodes in order to figure out which service nodes to send the requests to
my $mptab = xCAT::Table->new("mp");
unless ($mptab) { return 2; }
my @all = $mptab->getAllNodeAttribs([qw(node, mpa)]);
my %mpa_hash=();
my %input_hash=();
foreach (@$noderange) { $input_hash{$_}=1;}
foreach (@all) {
if ($input_hash{$_->{node}}) {
push @{$mpa_hash{$_->{mpa}}}, $_->{node};
$input_hash{$_->{node}}=0;
next;
}
if ($input_hash{$_->{mpa}}) {
push @{$mpa_hash{$_->{mpa}}}, $_->{mpa};
$input_hash{$_->{mpa}}=0;
next;
}
}
# find service nodes for the MMs
# build an individual request for each service node
my $service = "xcat";
my @mms=keys(%mpa_hash);
my $sn = xCAT::Utils->get_ServiceNode(\@mms, $service, "MN");
# build each request for each service node
foreach my $snkey (keys %$sn)
{
#print "snkey=$snkey\n";
my $reqcopy = {%$request};
$reqcopy->{'_xcatdest'} = $snkey;
my $mms1=$sn->{$snkey};
my @nodes=();
foreach (@$mms1) { push @nodes, @{$mpa_hash{$_}};}
$reqcopy->{node} = \@nodes;
#print "nodes=@nodes\n";
push @requests, $reqcopy;
}
return \@requests;
}
sub process_request {
my $request = shift;
my $callback = shift;
@ -1209,22 +1286,6 @@ sub process_request {
@exargs = ($request->{arg});
}
if ($command ne "findme") {
my $usage_string=xCAT::Usage->parseCommand($command, @exargs);
if ($usage_string) {
$callback->({data=>$usage_string});
$request = {};
return;
}
if (!$noderange) {
$usage_string=xCAT::Usage->getUsage($command);
$callback->({data=>$usage_string});
$request = {};
return;
}
}
if ($command eq "rpower" and grep(/^on|off|boot|reset|cycle$/, @exargs)) {
if (!grep /^--nodeps$/, @exargs) {
# handles 1 level of dependencies only

View File

@ -4535,10 +4535,9 @@ sub loadsdrcache {
sub preprocess_request {
my $request = shift;
if ($request->{_xcatdest}) { return [$request]; } #exit if preprocessed
my $callback=shift;
my @requests;
my %servicenodehash;
my %noservicenodehash;
my $noderange = $request->{node}; #Should be arrayref
my $command = $request->{command}->[0];
@ -4562,28 +4561,24 @@ sub preprocess_request {
return;
}
#print "noderange=@$noderange\n";
my $nrtab = xCAT::Table->new('noderes');
foreach my $node (@{$request->{node}}) {
my $tent = $nrtab->getNodeAttribs($node,['servicenode']);
if ($tent and $tent->{servicenode}) {
$servicenodehash{$tent->{servicenode}}->{$node} = 1;
} else {
$noservicenodehash{$node} = 1;
}
}
foreach my $smaster (keys %servicenodehash) {
my $reqcopy = {%$request};
$reqcopy->{'_xcatdest'} = $smaster;
$reqcopy->{node} = [ keys %{$servicenodehash{$smaster}} ];
push @requests,$reqcopy;
}
my $reqcopy = {%$request};
$reqcopy->{node} = [ keys %noservicenodehash ];
if ($reqcopy->{node}) {
push @requests,$reqcopy;
}
return \@requests;
# find service nodes for requested nodes
# build an individual request for each service node
my $service = "xcat";
my $sn = xCAT::Utils->get_ServiceNode($noderange, $service, "MN");
# build each request for each service node
foreach my $snkey (keys %$sn)
{
#print "snkey=$snkey\n";
my $reqcopy = {%$request};
$reqcopy->{node} = $sn->{$snkey};
$reqcopy->{'_xcatdest'} = $snkey;
push @requests, $reqcopy;
}
return \@requests;
}
@ -4599,7 +4594,6 @@ sub process_request {
if (ref($extrargs)) {
@exargs=@$extrargs;
}
my $ipmiuser = 'USERID';
my $ipmipass = 'PASSW0RD';
my $ipmitrys = 3;

View File

@ -58,6 +58,40 @@ sub getstat {
$stat = $response->{node}->[0]->{data}->[0];
}
#-------------------------------------------------------
=head3 preprocess_request
Check and setup for hierarchy
=cut
#-------------------------------------------------------
sub preprocess_request
{
my $req = shift;
my $cb = shift;
my %sn;
if ($req->{_xcatdest}) { return [$req]; } #exit if preprocessed
my $nodes = $req->{node};
my $service = "xcat";
# find service nodes for requested nodes
# build an individual request for each service node
$sn = xCAT::Utils->get_ServiceNode($nodes, $service, "MN");
# build each request for each service node
foreach my $snkey (keys %$sn)
{
my $reqcopy = {%$req};
$reqcopy->{node} = $sn->{$snkey};
$reqcopy->{'_xcatdest'} = $snkey;
push @requests, $reqcopy;
}
return \@requests;
}
sub process_request {
my $request = shift;

View File

@ -54,18 +54,17 @@ sub preprocess_request
my $cb = shift;
my %sn;
if ($req->{_xcatdest}) { return [$req]; } #exit if preprocessed
my @nodes = $req->{node};
my $nodes = $req->{node};
my $service = "xcat";
# find service nodes for requested nodes
# build an individual request for each service node
$sn = xCAT::Utils->get_ServiceNode(@nodes, $service, "MN");
$sn = xCAT::Utils->get_ServiceNode($nodes, $service, "MN");
# build each request for each service node
foreach my $snkey (keys %$sn)
{
my $reqcopy = {%$req};
$reqcopy->{node} = $sn->{$snkey};
$reqcopy->{'_xcatdest'} = $snkey;