Commit ec1abe90 authored by Robert Ricci's avatar Robert Ricci

Change behavior to be more consistent, based on Mike's suggestions -

-s is now required to set bits, and there is a -p option so that you
can give physical node names.
parent bcc7c1ac
...@@ -24,14 +24,18 @@ use strict; ...@@ -24,14 +24,18 @@ use strict;
sub usage { sub usage {
print << "END"; print << "END";
Usage: $0 [-h] [-c] [-l] <pid> <eid> [node ...] Usage: $0 [-h] [-c | -s] [-l] <pid> <eid> [node ...]
-h This message -h This message
-c Clear, rather than set, ready bits. If no node is given, clear ready -s Set ready bits
bits for all nodes -c Clear ready bits
-p Use physical node IDs with -c or -s, rather than virtual ones. In
this case, no pid and eid should be given.
-l List ready status for each node in the experiment -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 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 nodes are given, reports just status for the listed nodes. If -s or -c is
given, sets or clears ready bits for the listed nodes, or all
them as being ready (or clears their ready bits
if -c is given) if -c is given)
END END
...@@ -42,33 +46,50 @@ END ...@@ -42,33 +46,50 @@ END
# Process command-line arguments # Process command-line arguments
# #
my %opt = (); my %opt = ();
GetOptions(\%opt,'l','h','c'); GetOptions(\%opt,'l','h','c','s','p');
if (@ARGV < 2) { if (($opt{p} && (@ARGV < 1)) || (!$opt{p} && (@ARGV < 2))) {
exit &usage; exit &usage;
} }
my ($pid, $eid) = (shift @ARGV, shift @ARGV);
my ($pid, $eid);
if (!$opt{p}) {
($pid, $eid) = (shift @ARGV, shift @ARGV);
}
my @nodes = @ARGV; my @nodes = @ARGV;
if ($opt{h}) { if ($opt{h}) {
exit &usage; exit &usage;
} }
if ($opt{l} && ($opt{c} || @nodes)) { if ($opt{l} && ($opt{c} || $opt{s})) {
exit &usage; exit &usage;
} }
# Make sure that the experiment actually exists if ($opt{s} && $opt{c}) {
if (!ExpState($pid,$eid)) { die "-s and -c are mutually exclusive\n";
die("There is no experiment '$eid' in project '$pid'.\n");
} }
# Make sure the user has the ability to modify this experiment # Make sure that the user has permission to modify the experiment, if using
if (!TBExptAccessCheck($UID, $pid, $eid, TB_EXPT_MODIFY)) { # virtual mode, or modify the nodes, if using physical names.
die("You do not have permission to modify '$eid' in project '$pid'.\n"); if ($opt{p}) {
if (!TBNodeAccessCheck($UID,TB_NODEACCESS_MODIFYINFO,@nodes)) {
die "You do not have permission to modify one or more nodes\n";
}
} else {
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;
my @pnodes; if ($opt{p}) {
@pnodes = @nodes;
} else {
if (!@nodes) { if (!@nodes) {
@pnodes = ExpNodes($pid,$eid); @pnodes = ExpNodes($pid,$eid);
} else { } else {
...@@ -81,6 +102,9 @@ if ($opt{c} || @nodes) { ...@@ -81,6 +102,9 @@ if ($opt{c} || @nodes) {
} }
} }
} }
}
if ($opt{c} || $opt{s}) {
my $newbit = 1; my $newbit = 1;
if ($opt{c}) { if ($opt{c}) {
$newbit = 0; $newbit = 0;
...@@ -89,15 +113,16 @@ if ($opt{c} || @nodes) { ...@@ -89,15 +113,16 @@ if ($opt{c} || @nodes) {
DBQueryFatal("update nodes set ready=$newbit where node_id='$pnode'"); DBQueryFatal("update nodes set ready=$newbit where node_id='$pnode'");
} }
} else { } 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 $ready = 0;
my $total = 0; my $total = 0;
while (my @row = $result->fetchrow()) { foreach my $pnode (@pnodes) {
my ($isready, $vname) = @row; my $result = DBQueryFatal("select ready, vname, nodes.node_id " .
"from nodes left join reserved on nodes.node_id=reserved.node_id ".
"where nodes.node_id='$pnode'");
my ($isready, $vname, $pname) = $result->fetchrow();
my $name = $opt{p}? $pname : $vname;
if ($opt{l}) { if ($opt{l}) {
print "$vname\t$isready\n"; print "$name\t$isready\n";
} }
if ($isready) { if ($isready) {
$ready++; $ready++;
......
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