Commit f37afcf0 authored by Austin Clements's avatar Austin Clements

Glued the Plab manager to experiment setup. Slices are created and

destroyed if necessary, and nodes are allocated into the slice when
needed.  This should be optimized a bit better so that the Plab
manager can obtain as many tickets as possible in one operation,
instead of per node.
parent 38facc58
......@@ -542,6 +542,39 @@ sub doSwapout($) {
}
}
if (! $TESTMODE) {
#
# If the experiment has no Plab dslice nodes left, but still has
# a Plab slice, destroy the slice
#
# Does the slice exist?
$db_result =
DBQueryFatal("select slicename from plab_slices ".
"where pid='$pid' and eid='$eid'");
if ($db_result->numrows) {
# Are there any dslice nodes left?
$db_result =
DBQueryFatal("select n.node_id from nodes as n ".
"left join node_types as nt on n.type = nt.type ".
"left join reserved as r ".
" on r.node_id = n.node_id ".
"where r.pid='$pid' and r.eid='$eid' ".
" and nt.isplabdslice = 1");
if (!$db_result->numrows) {
print "Destroying Planetlab slice.\n";
TBDebugTimeStamp("plabslice destroy started");
if (system("plabslice -v destroy $pid $eid")) {
print STDERR "*** Failed to destroy Plab dslice\n";
$swapout_errors = 1;
}
TBDebugTimeStamp("plabslice destroy finished");
}
}
}
if (! $TESTMODE) {
#
# All of these errors are non-fatal on swapout. We find out about them
......@@ -715,6 +748,43 @@ sub doSwapin($) {
return 0;
}
#
# If there are any Plab dslice nodes in the experiment, create the
# dslice now
#
if ($type > UPDATE_RECOVER) {
# Are there any Plab nodes?
$db_result =
DBQueryFatal("select n.node_id from nodes as n ".
"left join node_types as nt on n.type = nt.type ".
"left join reserved as r on r.node_id = n.node_id ".
"where r.pid='$pid' and r.eid='$eid' ".
" and nt.isplabdslice = 1");
if ($db_result->numrows) {
# Does slice already exist?
$db_result =
DBQueryFatal("select slicename from plab_slices ".
"where pid='$pid' and eid='$eid'");
if (! $db_result->numrows) {
my @plabnodes = ();
while (my ($node) = $db_result->fetchrow_array()) {
push(@plabnodes, $node);
}
print "Creating Planetlab slice.\n";
TBDebugTimeStamp("plabslice create started");
if (system("plabslice -v create $pid $eid")) {
print STDERR "*** Failed to create Plab dslice\n";
return 3;
}
TBDebugTimeStamp("plabslice alloc finished");
}
}
}
#
# These things need to get started before the nodes come up, so we'll
# do them before the os_setup. Everything else can done in parallel with
......
......@@ -153,9 +153,10 @@ my $exptstate = ExpState($pid, $eid);
foreach my $node (@nodes) {
my $pnode;
my $jailed;
my $plab;
my $allocstate;
if (! TBIsNodeVirtual($node, \$jailed)) {
if (! TBIsNodeVirtual($node, \$jailed, \$plab)) {
next;
}
if (! TBPhysNodeID($node, \$pnode)) {
......@@ -280,14 +281,29 @@ foreach my $node (@nodes) {
else {
my $args = ($killmode ? "-k " : " ");
$args .= ($jailed ? "-j " : " ");
$args .= ($plab ? "-p " : " ");
$args .= "$node ";
# Must change our real UID to root so that ssh will work.
$UID = 0;
exec("$ssh -host $pnode $CLIENT_BIN/vnodesetup $args");
if ($plab && !$killmode) {
if (system("$TB/sbin/plabnode -v -d alloc $pid $eid $node")) {
die("*** $0:\n".
" Plab node allocation failed");
}
}
exec("$ssh -host $node $CLIENT_BIN/vnodesetup $args");
die("*** $0:\n".
" exec failed!\n");
if ($plab && $killmode) {
if (system("$TB/sbin/plabnode -v -d free $pid $eid $node")) {
warn("*** $0:\n".
" Plab node free failed");
}
}
}
}
......
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