2007-10-26 22:44:33 +00:00
|
|
|
#!/usr/bin/env perl
|
|
|
|
# IBM(c) 2007 EPL license http://www.eclipse.org/legal/epl-v10.html
|
2009-04-14 18:27:43 +00:00
|
|
|
BEGIN { $::XCATROOT = $ENV{'XCATROOT'} ? $ENV{'XCATROOT'} : -d '/opt/xcat' ? '/opt/xcat' : '/usr'; }
|
|
|
|
use lib "$::XCATROOT/lib/perl";
|
2011-04-11 16:17:08 +00:00
|
|
|
#use Data::Dumper;
|
2009-04-14 18:27:43 +00:00
|
|
|
use xCAT::Client;
|
2011-01-18 14:19:57 +00:00
|
|
|
use Getopt::Long;
|
2009-04-14 18:27:43 +00:00
|
|
|
use strict;
|
2007-10-26 22:44:33 +00:00
|
|
|
my %output;
|
2011-01-13 19:50:50 +00:00
|
|
|
|
|
|
|
my $option;
|
|
|
|
|
|
|
|
GetOptions("n"=>\$option);
|
|
|
|
|
2007-10-26 22:44:33 +00:00
|
|
|
while (<STDIN>) {
|
|
|
|
my $node;
|
|
|
|
my $output;
|
|
|
|
if (/:/) {
|
|
|
|
($node,$output) = split /:/,$_,2;
|
|
|
|
} else {
|
|
|
|
$node= "UNKNOWN";
|
|
|
|
$output = $_;
|
|
|
|
}
|
|
|
|
$output =~ s/^ //;
|
|
|
|
$output{$node}.=$output;
|
|
|
|
}
|
|
|
|
my %collated;
|
|
|
|
foreach (keys %output) {
|
|
|
|
$collated{$output{$_}}->{$_}=1;
|
|
|
|
}
|
2009-04-14 18:27:43 +00:00
|
|
|
|
|
|
|
my $nodes;
|
|
|
|
sub fillerup {
|
|
|
|
my $response = shift;
|
|
|
|
if ($response->{data}->[0]) {
|
|
|
|
$nodes = $response->{data}->[0];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
foreach my $output (keys %collated) {
|
|
|
|
$nodes = join(',',sort (keys %{$collated{$output}}));
|
|
|
|
my $cmdref = {
|
|
|
|
noderange => [$nodes],
|
|
|
|
command => ['rnoderange'],
|
|
|
|
};
|
2011-01-13 19:50:50 +00:00
|
|
|
unless ($option) {
|
|
|
|
xCAT::Client::submit_request($cmdref,\&fillerup);
|
|
|
|
}
|
2007-10-26 22:44:33 +00:00
|
|
|
print "====================================\n";
|
|
|
|
print "$nodes\n";
|
|
|
|
print "====================================\n";
|
2009-04-14 18:27:43 +00:00
|
|
|
print $output;
|
2007-11-09 20:00:27 +00:00
|
|
|
print "\n";
|
2007-10-26 22:44:33 +00:00
|
|
|
}
|