Commit 616601b5 authored by Robert Ricci's avatar Robert Ricci

New script: readycount

Simple command-line interface to the ready bits. Its primary
purposes are:

* Manually report ready for nodes that can't do it themselves
* Get a list of which nodes are ready, so that you can figure out
  which one(s) aren't reporting in
* Clear ready bits so you can use them again without restarting the
  experiment
* Make it possible to poll ready bits on boss/ops
parent 85d30cce
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -312,7 +312,7 @@ outfiles="$outfiles Makeconf GNUmakefile \
db/libdb.pm db/inuse db/avail db/nodeip db/showgraph \
db/dhcpd_makeconf db/nodelog db/webnodelog db/unixgroups \
db/dbcheck db/interswitch db/dbboot db/schemacheck \
db/grabron db/idlecheck db/webnfree db/stategraph \
db/grabron db/idlecheck db/webnfree db/stategraph db/readycount \
discvr/GNUmakefile \
ipod/GNUmakefile \
lib/GNUmakefile lib/libtb/GNUmakefile \
......
......@@ -11,7 +11,7 @@ UNIFIED = @UNIFIED_BOSS_AND_OPS@
include $(OBJDIR)/Makeconf
BIN_SCRIPTS = nalloc nfree nodeip idlecheck
BIN_SCRIPTS = nalloc nfree nodeip idlecheck readycount
SBIN_SCRIPTS = avail inuse showgraph if2port backup webcontrol node_status \
genelists genelists.proxy dhcpd_makeconf nodelog unixgroups \
dbcheck interswitch dbboot grabron stategraph newwanode
......
#!/usr/bin/perl -w
#
# EMULAB-COPYRIGHT
# Copyright (c) 2000-2003 University of Utah and the Flux Group.
# All rights reserved.
#
#
# readycount - Command-line tool to get at the ready bits in the database
#
#
# Configure variables
#
use lib '@prefix@/lib';
use libdb;
use English;
use Getopt::Long;
use strict;
sub usage {
print << "END";
Usage: $0 [-h] [-c] [-l] <pid> <eid> [node ...]
-h This message
-c Clear, rather than set, ready bits. If no node is given, clear ready
bits for all nodes
-l List ready status for each node in the experiment
If no nodes are given, gives a summary of the nodes that have reported ready.
If nodes are given, reports them as being ready (or clears their ready bits
if -c is given)
END
return 1;
}
#
# Process command-line arguments
#
my %opt = ();
GetOptions(\%opt,'l','h','c');
if (@ARGV < 2) {
exit &usage;
}
my ($pid, $eid) = (shift @ARGV, shift @ARGV);
my @nodes = @ARGV;
if ($opt{h}) {
exit &usage;
}
if ($opt{l} && ($opt{c} || @nodes)) {
exit &usage;
}
# Make sure that the experiment actually exists
if (!ExpState($pid,$eid)) {
die("There is no experiment '$eid' in project '$pid'.\n");
}
# Make sure the user has the ability to modify this experiment
if (!TBExptAccessCheck($UID, $pid, $eid, TB_EXPT_MODIFY)) {
die("You do not have permission to modify '$eid' in project '$pid'.\n");
}
if ($opt{c} || @nodes) {
my @pnodes;
if (!@nodes) {
@pnodes = ExpNodes($pid,$eid);
} else {
foreach my $vnode (@nodes) {
my $pnode;
if (VnameToNodeid($pid, $eid, $vnode, \$pnode)) {
push @pnodes, $pnode;
} else {
die "No such node $vnode in $pid/$eid!\n";
}
}
}
my $newbit = 1;
if ($opt{c}) {
$newbit = 0;
}
foreach my $pnode (@pnodes) {
DBQueryFatal("update nodes set ready=$newbit where node_id='$pnode'");
}
} else {
my $result = DBQueryFatal("select ready, vname " .
"from reserved left join nodes on nodes.node_id=reserved.node_id " .
"where reserved.eid='$eid' and reserved.pid='$pid'");
my $ready = 0;
my $total = 0;
while (my @row = $result->fetchrow()) {
my ($isready, $vname) = @row;
if ($opt{l}) {
print "$vname\t$isready\n";
}
if ($isready) {
$ready++;
}
$total++;
}
print "READY=$ready TOTAL=$total\n";
}
exit(0);
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