Commit a50e4d95 authored by Leigh Stoller's avatar Leigh Stoller

Another CMU tweak; send a whol to nodes in PXEWAIT since that appears to

make the laptops very sleepy.
parent 62868e1b
......@@ -17,6 +17,7 @@ use vars qw(@ISA @EXPORT);
my $TB = "@prefix@";
my $BOSSNODE = "@BOSSNODE@";
my $EVENTSYS = @EVENTSYS@;
my $WOL = "$TB/sbin/whol";
# XXX stinky hack detection
my $ISUTAH = @TBMAINSITE@;
......@@ -1433,6 +1434,58 @@ sub SetSchedReload($$;$)
return 0;
}
#
# Do a normal wakeonlan after power cycle. This is for laptops that like
# to go to sleep (especially while in PXEWAIT).
#
sub SimpleWOL($)
{
my ($self) = @_;
# Must be a real reference.
return -1
if (! ref($self));
my $node_id = $self->node_id();
# XXX Must know the outgoing interface. Using the whol flag. Ick.
my $query_result =
DBQueryFatal("select iface from interfaces ".
"where node_id='boss' and whol=1");
if ($query_result->numrows != 1) {
warn "SimpleWOL: Could not get outgoing interface for boss node.\n";
return -1;
}
my ($iface) = $query_result->fetchrow_array();
#
# Grab the control interface MAC for the node.
#
$query_result =
DBQueryFatal("select mac from interfaces ".
"where node_id='$node_id' and ".
" role='" . TBDB_IFACEROLE_CONTROL() . "'");
if ($query_result->numrows != 1) {
warn "SimpleWOL: Could not get control interface MAC for $node_id.\n";
return -1;
}
my ($mac) = $query_result->fetchrow_array();
print "Doing a plain WOL to $node_id ($mac) via interface $iface\n";
#
# Do this a few times since the packet could get lost and
# it seems to take a couple of packets to kick it.
#
for (my $i = 0; $i < 5; $i++) {
system("$WOL $iface $mac");
select(undef, undef, undef, 0.1);
}
select(undef, undef, undef, 5.0);
return 0;
}
# _Always_ make sure that this 1 is at the end of the file...
1;
#!/usr/bin/perl -wT
#
# EMULAB-COPYRIGHT
# Copyright (c) 2000-2006 University of Utah and the Flux Group.
# Copyright (c) 2000-2008 University of Utah and the Flux Group.
# All rights reserved.
#
# node reboot library. Basically the backend to the node_reboot script, but
......@@ -80,6 +80,7 @@ sub nodereboot($$)
{
my ($args, $result) = @_;
my @nodes = @{ $args->{'nodelist'}};
my %nodeobjects = (); # Not in the mood to rewrite this function.
#
# Start a new logging sub-process
......@@ -170,7 +171,8 @@ sub nodereboot($$)
foreach my $node (@nodes) {
my $nodeobject = Node->Lookup($node);
my $rebootable = $nodeobject->rebootable();
$nodeobjects{$node} = $nodeobject;
push(@temp,$node) if $rebootable;
}
@nodes = @temp;
......@@ -334,7 +336,7 @@ sub nodereboot($$)
# We need the pid so we can wait for them all before preceeding.
#
foreach my $node ( @batch ) {
$pids{$node} = RebootNode($node, $reconfig,
$pids{$node} = RebootNode($nodeobjects{$node}, $reconfig,
$killmode, $rebootmode, $prepare);
}
}
......@@ -476,8 +478,9 @@ sub nodereboot($$)
# that it can wait on all the children later.
#
sub RebootNode {
my ($pc, $reconfig, $killmode, $rebootmode, $prepare) = @_;
my ($nodeobject, $reconfig, $killmode, $rebootmode, $prepare) = @_;
my ($status, $syspid, $mypid, $didipod, $nodestate);
my $pc = $nodeobject->node_id();
#
# Start a new logging sub-process
......@@ -530,6 +533,13 @@ sub RebootNode {
return -2;
}
my $whol = 0;
if ($nodeobject->NodeAttribute("wakeonlan_afterpower", \$whol) == 0) {
if ($whol) {
$nodeobject->SimpleWOL();
}
}
#
# The aux program sends the event to stated ...
#
......
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