Commit 848d3e5c authored by Mac Newbold's avatar Mac Newbold

Now returns error code if any non-fatal errors occured.

parent ab488519
......@@ -5,6 +5,7 @@ my $dbh = Mysql->connect("localhost","tbdb","script","none");
if ($#ARGV < 1) {die("Usage: nalloc <pid> <eid> <node> <node> <...>\n");}
my $error = 0;
my $pid = shift;
my $eid = shift;
my @node_names=@ARGV;
......@@ -28,19 +29,25 @@ foreach my $n (@node_names) {
$sth = $dbh->query($cmd);
if ($sth->numrows > 0) {
print "You have already reserved node '$n'.\n";
$error++;
} else {
print "Someone else has already reserved node '$n'.\n";
$error++;
}
next;
} else {
$sth = $dbh->query("select * from nodes where node_id='$n'");
if ($sth->numrows < 1) {
print "Node '$n' does not exist.\n";
$error++;
next;
}
}
print "Reserving node '$n'...";
$cmd = "insert into reserved (node_id,pid,eid) values ('$n','$pid','$eid')";
$sth = $dbh->query($cmd) && print "Succeeded.\n"
|| print "Failed Command:\n$cmd\nError string is:".$dbh->errstr."\n";
|| (print "Failed Command:\n$cmd\nError string is:".$dbh->errstr."\n"
&& $error++);
}
exit($error);
......@@ -9,6 +9,7 @@ if ($#ARGV < 1) {
"nfree releases only the listed nodes.\n");
}
my $error = 0;
my $pid = shift;
my $eid = shift;
my @node_names=@ARGV;
......@@ -40,11 +41,14 @@ foreach my $n (@node_names) {
"and eid='$eid'");
if ($sth->numrows == 0) {
print "Node '$n' is not reserved by your experiment.\n";
$error++;
next;
}
print "Releasing node '$n'...";
$cmd = "delete from reserved where node_id='$n' and eid='$eid'";
$sth = $dbh->query($cmd) && print "Succeeded.\n"
|| print "Failed Command:\n$cmd\nError string is:".$dbh->errstr."\n";
|| (print "Failed Command:\n$cmd\nError string is:".$dbh->errstr."\n"
&& $error++);
}
exit($error);
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