Commit 41a1fdfd authored by Leigh B. Stoller's avatar Leigh B. Stoller

Minor addition of -p option, which is just a helper to schedule a

reload that will get picked up by the reload daemon instead of being
fired off immediately. The node is reserved to reloadpending EID,
which the reload daemon looks for. This is useful since until Frisbee
is fully operational, we cannot do mass reloads, so this approach
results in all the nodes getting reserved away and slowy reloaded and
freeed up later.
parent 353e407c
......@@ -8,15 +8,16 @@ use Getopt::Std;
# testbed:reloading. Otherwise, put the right info into the database, and
# nfree will do it when the node gets freed.
#
# usage: sched_reload [-f] <imageid> <node> [node ...]
# usage: sched_reload [-f | -p] <imageid> <node> [node ...]
#
sub usage()
{
print STDOUT "Usage: sched_reload [-f] <imageid> <node> [node ...]\n".
"Use the -f to force reload. Fail if node cannot be reserved.\n";
print STDOUT "Usage: sched_reload [-f | -p] <imageid> <node> [node ...]\n".
"Use the -f to force reload. Fail if node cannot be reserved.\n".
"Use the -p to pend reload for the reload daemon.\n";
exit(-1);
}
my $optlist = "f";
my $optlist = "fp";
#
# Configure variables
......@@ -30,10 +31,12 @@ use lib "@prefix@/lib";
use libdb;
#
# This stuff should not be hardwired in.
# XXX This stuff should not be hardwired in. If you change these, be sure
# to update the test in doreboot() in tmcd/tmcd.c.
#
my $RELOADPID = "emulab-ops";
my $RELOADEID = "reloading";
my $PENDINGEID = "reloadpending";
my $osload = "$TB/bin/os_load";
my $nalloc = "$TB/bin/nalloc";
......@@ -41,6 +44,7 @@ my $name = "";
my $error = 0;
my $debug = 0;
my $force = 0;
my $pend = 0;
my @nodes = ();
my @row;
......@@ -64,6 +68,12 @@ if (@ARGV < 2) {
if (defined($options{"f"})) {
$force = $options{"f"};
}
if (defined($options{"p"})) {
$pend = $options{"p"};
}
if ($pend and $force) {
usage();
}
my $imageid = shift;
#
......@@ -114,11 +124,15 @@ foreach my $node (@nodes) {
if ( ($sth->num_rows()) < 1) {
print STDERR "Available.\nReserving and adding to list.\n";
#
# XXX If you change testbed/reloading, be sure to update the
# test in doreboot() in tmcd/tmcd.c.
#
my $cmd = "$nalloc $RELOADPID $RELOADEID $pc";
my $eid;
if ($pend) {
$eid = $PENDINGEID;
}
else {
$eid = $RELOADEID;
}
my $cmd = "$nalloc $RELOADPID $eid $pc";
if ( system($cmd) != 0 ) {
print STDERR "WARNING: Could not reserve $pc!\n";
} else {
......@@ -148,6 +162,11 @@ foreach my $node (@nodes) {
"(node_id, image_id) values ('$pc', '$imageid')");
}
if ($pend) {
print STDOUT "Reload Scheduling Done!\n";
exit $error;
}
if (@load_list > 0) {
print STDERR "Running os_load on ",join(", ",@load_list),":\n";
$cmd = "$osload $imageid @load_list";
......
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