Commit 86eb7647 authored by Kirk Webb's avatar Kirk Webb

tbadb: Better adb port forwarding bookkeeping.

parent de0d82f8
......@@ -383,12 +383,6 @@ sub cmd_reserveport($@) {
die("tbadb::cmd_reserveport: You do not have permission to modify $node\n")
if (!$isroot && !$this_user->IsAdmin() &&
!$node->AccessCheck($this_user, TB_NODEACCESS_REBOOT));
# Node must be in an experiment. We store the returned port number
# in the virt_node_attributes table.
my $experiment = $node->Reservation();
die "tbadb::cmd_forward: $node_id does not belong to an experiment!\n"
if (!$experiment);
# Grab the RPC pipe.
my ($rpcin, $rpcout) = GetRPCPipeHandles($node);
......@@ -423,7 +417,12 @@ sub cmd_reserveport($@) {
warn "tbadb::cmd_reserveport: Did not receive a port number from 'reserveport'!\n";
exit 1;
}
$experiment->SetVirtNodeAttribute($node->vname(), "adb_port", $portnum);
# We store the returned port number in the virt_node_attributes table if
# the node is currently allocated to an experiment.
my $experiment = $node->Reservation();
$experiment->SetVirtNodeAttribute($node->vname(), "adb_port", $portnum)
if $experiment;
# Done!
my $chost;
......@@ -532,6 +531,17 @@ sub cmd_unforward($@) {
warn "". Dumper($data);
exit 1;
}
# Clear the virt_node_attributes entry, if there is one.
my $experiment = $node->Reservation();
if ($experiment) {
my $pid = $experiment->pid();
my $eid = $experiment->eid();
my $vname = $node->vname();
DBQueryWarn("delete from virt_node_attributes".
" where pid='$pid' and eid='$eid'".
" and vname='$vname' and attrkey='adb_port'");
}
# Done!
print "tbadb::cmd_unforward: successfully removed adb fowarding for $node_id\n";
......
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