Commit 7eb2adb6 authored by Leigh B. Stoller's avatar Leigh B. Stoller

Add -a option to reboot all free pcs.

parent 17a431e7
...@@ -25,12 +25,13 @@ sub usage() ...@@ -25,12 +25,13 @@ sub usage()
"Use the -n option to not wait for nodes to go down\n" . "Use the -n option to not wait for nodes to go down\n" .
"Use the -w option to to wait for nodes is come back up\n" . "Use the -w option to to wait for nodes is come back up\n" .
"Use the -k option to power cycle nodes in PXEWAIT mode\n" . "Use the -k option to power cycle nodes in PXEWAIT mode\n" .
"Use the -a option to reboot all free nodes\n".
"Use the -f option to power cycle (and not wait for nodes to die)\n"; "Use the -f option to power cycle (and not wait for nodes to die)\n";
exit(-1); exit(-1);
} }
# The hidden -r option runs this in "realmode", ie don't send an event, but # The hidden -r option runs this in "realmode", ie don't send an event, but
# really do the work instead. # really do the work instead.
my $optlist = "dfe:nwrk"; my $optlist = "dfe:nwrka";
# #
# Configure variables # Configure variables
...@@ -66,6 +67,7 @@ my $nowait = 0; ...@@ -66,6 +67,7 @@ my $nowait = 0;
my $failed = 0; my $failed = 0;
my $eidmode = 0; my $eidmode = 0;
my $killmode = 0; my $killmode = 0;
my $freemode = 0;
my $pid; my $pid;
my $eid; my $eid;
...@@ -106,6 +108,9 @@ if (defined($options{"w"})) { ...@@ -106,6 +108,9 @@ if (defined($options{"w"})) {
if (defined($options{"r"})) { if (defined($options{"r"})) {
$realmode = 1; $realmode = 1;
} }
if (defined($options{"a"})) {
$freemode = 1;
}
if (defined($options{"n"}) && !defined($options{"w"})) { if (defined($options{"n"}) && !defined($options{"w"})) {
$nowait = 1; $nowait = 1;
} }
...@@ -131,11 +136,35 @@ $realmode=1; ...@@ -131,11 +136,35 @@ $realmode=1;
# die("*** You cannot use real mode!\n"); # die("*** You cannot use real mode!\n");
#} #}
# if ($freemode) {
# If eidmode, then get the node list out of the DB instead of the command #
# line. A proper check is made later, so need to be fancy about the query. # Reboot all free nodes
# #
if ($eidmode) { if ($UID && !TBAdmin($UID)) {
die("*** You not have permission to reboot all free nodes!\n");
}
my $query_result =
DBQueryFatal("select n.node_id from nodes as n ".
"left join reserved as r on r.node_id=n.node_id ".
"left join node_types as nt on nt.type=n.type ".
"where nt.class='pc' and n.role='testnode' and ".
" r.pid is NULL");
if ($query_result->numrows == 0) {
print STDOUT "There are no free nodes to reboot\n";
usage();
}
while (@row = $query_result->fetchrow_array()) {
push(@nodes, $row[0]);
}
}
elsif ($eidmode) {
#
# If eidmode, then get the node list out of the DB instead of the command
# line. A proper check is made later, so need to be fancy about the query.
#
my @row; my @row;
# #
......
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