Commit f795a1eb authored by Robert Ricci's avatar Robert Ricci

Hook support for rebooting motes attached to stargates into the

'power' command.
parent 36c84144
......@@ -1492,7 +1492,7 @@ outfiles="$outfiles Makeconf GNUmakefile \
account/addsfskey account/webaddsfskey \
account/quotamail account/mkusercert account/webmkusercert \
tbsetup/GNUmakefile tbsetup/console_setup tbsetup/spewlogfile \
tbsetup/spewrpmtar tbsetup/gentopofile \
tbsetup/spewrpmtar tbsetup/gentopofile tbsetup/power_sgmote.pm \
tbsetup/console_reset tbsetup/bwconfig tbsetup/power_rpc27.pm \
tbsetup/os_load tbsetup/os_setup tbsetup/os_select tbsetup/power \
tbsetup/node_reboot tbsetup/webnscheck tbsetup/nscheck \
......
......@@ -522,7 +522,7 @@ outfiles="$outfiles Makeconf GNUmakefile \
account/addsfskey account/webaddsfskey \
account/quotamail account/mkusercert account/webmkusercert \
tbsetup/GNUmakefile tbsetup/console_setup tbsetup/spewlogfile \
tbsetup/spewrpmtar tbsetup/gentopofile \
tbsetup/spewrpmtar tbsetup/gentopofile tbsetup/power_sgmote.pm \
tbsetup/console_reset tbsetup/bwconfig tbsetup/power_rpc27.pm \
tbsetup/os_load tbsetup/os_setup tbsetup/os_select tbsetup/power \
tbsetup/node_reboot tbsetup/webnscheck tbsetup/nscheck \
......
......@@ -46,7 +46,7 @@ LIBEXEC_STUFF = rmproj wanlinksolve wanlinkinfo \
LIB_STUFF = libtbsetup.pm exitonwarn.pm libtestbed.pm snmpit_intel.pm \
snmpit_cisco.pm snmpit_lib.pm snmpit_apc.pm power_rpc27.pm \
snmpit_cisco_stack.pm snmpit_intel_stack.pm \
snmpit_cisco_stack.pm snmpit_intel_stack.pm power_sgmote.pm \
snmpit_foundry.pm snmpit_stack.pm snmpit_remote.pm \
libaudit.pm libreboot.pm libosload.pm libtestbed.py
......
......@@ -27,6 +27,7 @@ use lib "@prefix@/lib";
use libdb;
use libxmlrpc;
use power_rpc27;
use power_sgmote;
use snmpit_apc;
use libtestbed;
use strict;
......@@ -242,8 +243,10 @@ foreach my $power_id (keys %outlets) {
#
# Find out some information about this power controller
#
my $result = DBQueryFatal("select n.type, i.IP ".
"from nodes as n left join interfaces as i on n.node_id=i.node_id " .
my $result = DBQueryFatal("select n.type, i.IP, t.class ".
"from nodes as n " .
"left join interfaces as i on n.node_id=i.node_id " .
"left join node_types as t on n.type=t.type " .
"where n.node_id='$power_id'");
if ($result->num_rows() == 0) {
warn "No entry found for power controller $power_id. Skipping " .
......@@ -251,7 +254,7 @@ foreach my $power_id (keys %outlets) {
$exitval++;
next;
}
my ($type, $IP) = $result->fetchrow();
my ($type, $IP, $class) = $result->fetchrow();
#
# Finally, we look at the controller type and construct the proper type
......@@ -275,6 +278,13 @@ foreach my $power_id (keys %outlets) {
if (rpc27ctrl($op,$power_id,@outlets)) {
print "Control of $nodestr failed.\n"; $exitval++;
}
} elsif (($class eq "sg") || ($type eq "garcia")) {
# XXX: 'garcia' is temporary until stargates are subnodes of
# garcias
if (sgmotectrl($op,@nodes)) {
print "Control of $nodestr failed.\n"; $exitval++;
$errors++;
}
} else {
print "power: Unknown power type '$type'\n";
$errors++;
......
#!/usr/bin/perl -wT
#
# EMULAB-COPYRIGHT
# Copyright (c) 2004 University of Utah and the Flux Group.
# All rights reserved.
#
# A little perl module to power cycle a mote attached to a stargate -
# basically just a wrapper for the tbsgmotepower script
package power_sgmote;
use Exporter;
@ISA = ("Exporter");
@EXPORT = qw( sgmotectrl );
#
# Commands we run
#
my $TBROOT = '@prefix@';
my $TBSGMOTEPOWER = "$TBROOT/bin/tbsgmotepower";
# Turn off line buffering on output
$| = 1;
# usage: sgmotectrl(cmd, motes)
# cmd = { "cycle" | "on" | "off" }
# motes = list of one or more physcial mote names
#
# Returns 0 on success. Non-zero on failure.
#
sub sgmotectrl($@) {
my ($cmd, @motes) = @_;
#
# All we have to do is call tbsmotepower
#
print "Running $TBSGMOTEPOWER $cmd " . join(" ",@motes) . "\n";
if (system("$TBSGMOTEPOWER $cmd " . join(" ",@motes))) {
return 1;
} else {
return 0;
}
}
1;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment