|
From: Jason B. <br...@us...> - 2004-11-30 19:50:26
|
Update of /cvsroot/openxcat/openxcat/lib/openXcat In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15511 Modified Files: Base.pm Log Message: Add phm function Index: Base.pm =================================================================== RCS file: /cvsroot/openxcat/openxcat/lib/openXcat/Base.pm,v retrieving revision 1.24 retrieving revision 1.25 diff -u -d -r1.24 -r1.25 --- Base.pm 16 Nov 2004 19:02:05 -0000 1.24 +++ Base.pm 30 Nov 2004 19:50:16 -0000 1.25 @@ -46,6 +46,7 @@ pbsjobnodes ping nodehash + phm ); my $D = 0; @@ -336,21 +337,21 @@ if ( $beg =~ /(\S*\D)(\d+)/ ) { if ($D) { print "Numeric range\n"; } my $pre = $1; - print "pre=$pre\n"; + #print "pre=$pre\n"; my $bnum = $2; - print "bnum=$bnum\n"; + #print "bnum=$bnum\n"; my $padding; if ( $bnum =~ /^(0+)/ ) { $padding = length($bnum); } - print "pad=$padding\n"; + #print "pad=$padding\n"; my $enum; if ( $end =~ /$pre(\d+)/ ) { $enum = $1; } else { carp "Cannot find end of range in $end (prefix $pre)"; } - print "enum=$enum\n"; + #print "enum=$enum\n"; my @nums; for ( $bnum .. $enum ) { push @nums, sprintf("%0*d", $padding, $_); @@ -390,17 +391,16 @@ if ( $file =~ /^(\/.*?):(\d.*)$/ ) { $file = $1; $range = $2; + print "Getting $range from $file\n"; } - print "Getting $range from $file\n"; if ( ! -r "$file" ) { - return undef; + carp "File $file doesn't exist"; } else { open( NRFILE, "<$file" ) or carp "Couldn't open $file: $!"; my @nrs = <NRFILE>; foreach my $nr (@nrs) { chomp $nr; - $nr =~ /(\S*?)/; - $nr = $1; + $nr =~ /^(\S*?)/; } close NRFILE; my @ranges; @@ -409,27 +409,28 @@ my $beg = $1 - 1; my $end = $1; if ( $2 ) { - if ( $3 ) { - $end = $3 - 1; - } else { - $end = $#nrs; - } + if ( $3 ) { + $end = $3 - 1; + } else { + $end = $#nrs; + } } foreach my $line ( $beg .. $end ) { - push( @ranges, $nrs[$line] ); + push( @ranges, $nrs[$line] ); } } else { @ranges = @nrs; } my @retranges; + foreach my $range (@ranges) { if ( $range !~ /^#/ && $range ne '' ) { - push( @retranges, $range ); + push( @retranges, $range ); } } - print "Returning @retranges\n"; + #print "Returning @retranges\n"; return @retranges; } } @@ -626,6 +627,53 @@ $pinger->close(); return @reachable; } + +sub phm { + unless ( scalar(@_) > 1 ) { + return undef; + } + my $function = shift; + my @nodes = noderange(@_); + if ( ! scalar(@nodes) ) { + return undef; + } + + my %funcs = ( 'power' => 0, + 'reset' => 1, + 'cad' => 2, + 'vitals' => 3, + 'inv' => 4, + 'cons' => 5, + 'bioscons' => 6, + 'eventlogs' => 7, + 'getmacs' => 8, + 'netboot' => 9, + 'eth0' => 10, + 'gcons' => 11, + 'sb' => 12, + 'beacon' => 13, + 'bootseq' => 14, + 'serialbps' => 15, + ); + + unless( defined($funcs{$function}) ) { + return undef; + } + + my %hmtab = openXcat::Config::getconfigfile($TABS{'NODEHM'}); + + my %nodemethod; + + foreach my $node (@nodes) { + if ( ! defined($hmtab{$node}) ) { + $nodemethod{$node} = 'NA'; + } else { + $nodemethod{$node} = (@{$hmtab{$node}})[$funcs{$function}]; + } + } + + return \%nodemethod; +} 1; @@ -752,6 +800,11 @@ Returns two references to hashes, one with node keys, one with group keys +=item C<phm> + +Pass in a function name and a noderange, it returns an array with the method +by which that node supports that function (e.g. node1 uses ipmi for power) + =back =head1 SEE ALSO |