|
From: Jason B. <br...@us...> - 2004-11-30 19:51:15
|
Update of /cvsroot/openxcat/openxcat/bin In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15742 Added Files: rpower Log Message: Initial checkin of rpower --- NEW FILE: rpower --- #!/usr/bin/perl # rpower - Remote Power Management # # Written by Jason Brechin <br...@nc...> # Copyright 2004 The Board of Trustees of the University of Illinois. # # $Id: rpower,v 1.1 2004/11/30 19:51:06 brechin Exp $ use FindBin qw($Bin); use lib "$Bin/../lib"; use openXcat::Base; use Carp; use Switch; my $powercmds = '(on|off|stat|boot|cycle)'; if ( scalar(@ARGV) < 2 ) { usage(); } my $command = shift; my $noderange = join( ',', @ARGV ); my @nodes = noderange($noderange); $noderange = join(',', @nodes); if ( $command eq 'state' ) { $command = 'stat'; } switch( $command ) { case 'help' { usage(); } case /$powercmds/ { my $nmref = phm('power', $noderange); my @nanodes = grep { $$nmref{$_} eq 'NA' } @nodes; foreach my $hm (values %{$nmref} ) { if ( $hm eq 'NA' ) { next; } else { my @hmnodes = grep { $$nmref{$_} eq $hm } @nodes; if ( -e "$Bin/../util/rpower.$hm" ) { system("$Bin/../util/rpower.$hm $command $noderange"); } else { push( @nanodes, @hmnodes ); carp "power using $hm is not supported"; } } } print "Power function not supported on: " . join(',', @nanodes) . "\n"; } case 'reset' { my $nmref = phm('reset', $noderange); my @nanodes = grep { $$nmref{$_} eq 'NA' } @nodes; foreach my $hm (values %{$nmref} ) { if ( $hm eq 'NA' ) { next; } else { my @hmnodes = grep { $$nmref{$_} eq $hm } @nodes; if ( -e "$Bin/../util/rreset.$hm" ) { system("$Bin/../util/rreset.$hm $noderange"); } else { push( @nanodes, @hmnodes ); carp "reset using $hm is not supported"; } } } print "Reset function not supported on: " . join(',', @nanodes) . "\n"; } case 'cad' { my $nmref = phm('cad', $noderange); my @nanodes = grep { $$nmref{$_} eq 'NA' } @nodes; foreach my $hm (values %{$nmref} ) { if ( $hm eq 'NA' ) { next; } else { my @hmnodes = grep { $$nmref{$_} eq $hm } @nodes; if ( -e "$Bin/../util/rcad.$hm" ) { system("$Bin/../util/rcad.$hm $noderange"); } else { push( @nanodes, @hmnodes ); carp "cad using $hm is not supported"; } } } print "cad function not supported on: " . join(',', @nanodes) . "\n"; } else { print "Command $command not supported\n"; } } sub usage { print "$0 - Remote Power Management\n"; print version; print "Usage: $0 (on|off|stat|state|reset|cad|boot|cycle) noderange\n"; exit; } =head1 NAME rpower - Remote Power Management =head1 SYNOPSIS rpower (on|off|stat|state|reset|cad|boot|cycle) noderange =head1 DESCRIPTION rpower will attempt to use the method defined in nodehm.tab to perform the specified action on the noderange given. =head1 REVISION Revision $Revision: 1.1 $ =head1 AUTHOR Jason Brechin <br...@nc...> =head1 COPYRIGHT This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |