All new accounts created on Gitlab now require administrator approval. If you invite any collaborators, please let Flux staff know so they can approve the accounts.

Commit d6a221ec authored by Kirk Webb's avatar Kirk Webb

tbadb: Load/store adb target host/port info in db.

parent 555263e1
......@@ -333,8 +333,14 @@ sub cmd_forward($@) {
my $node = Node->Lookup($node_id);
die "tbadb::cmd_forward: Invalid node name $node_id!\n"
if (!defined($node));
die("tbadb::cmd_forward: You do not have permission to access $node\n")
die "tbadb::cmd_forward: You do not have permission to access $node\n"
if (!$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);
......@@ -363,15 +369,18 @@ sub cmd_forward($@) {
exit 1;
}
# Grab the returned port number and store it.
my $portnum = $data->{RESULT}->{PORT};
if (!$portnum) {
warn "tbadb::cmd_forward: Did not receive a port number from 'forward'!\n";
exit 1;
}
$experiment->SetVirtNodeAttribute($node->vname(), "adb_port", $portnum);
# Done!
print "tbadb::cmd_forward: successfully setup adb port: $portnum\n";
# XXX: insert into DB somewhere, along with console host.
my $chost;
$node->TipServer(\$rhost);
print "tbadb::cmd_forward: successfully setup adb port: $chost:$portnum\n";
return 0;
}
......
......@@ -1274,7 +1274,8 @@ sub SetupReloadUISP($)
sub SetupReloadUE($)
{
my $reload_info = $_[0];
my $node = $reload_info->{'node'};
my $nodeobject = $reload_info->{'nodeobj'};
my $node_id = $reload_info->{'node'};
my $image = (@{$reload_info->{'images'}})[0];
my $osid = $reload_info->{'osid'};
......@@ -1284,33 +1285,47 @@ sub SetupReloadUE($)
my $imgpid = $image->pid();
my $imgname = $image->imagename();
#
# Grab the target adb host if specified by the user. Adjust the
# tbadb command as appropriate.
#
my $thost;
my $experiment = $nodeobject->Reservation();
if ($experiment) {
$experiment->GetVirtNodeAttribute($nodeobject->vname(),
"adb_target", \$thost);
}
my $adbcmd =
$thost ? "setup $imgpid $imgname $thost" :
"loadimage $imgpid $imgname";
#
# Tell stated that we're about to start reloading
#
TBSetNodeNextOpMode($node,TBDB_NODEOPMODE_RELOADUE);
TBSetNodeNextOpMode($node_id,TBDB_NODEOPMODE_RELOADUE);
#
# The mote goes 'down', then starts to reload
#
TBSetNodeEventState($node,TBDB_NODESTATE_SHUTDOWN);
TBSetNodeEventState($node,TBDB_NODESTATE_RELOADING);
TBSetNodeEventState($node_id,TBDB_NODESTATE_SHUTDOWN);
TBSetNodeEventState($node_id,TBDB_NODESTATE_RELOADING);
#
# Invoke local script that calls the remote end that
# actually does the work.
#
my $rv = system("$TBADB -n $node loadimage $imgpid $imgname");
my $rv = system("$TBADB -n $node_id $adbcmd");
if ($rv) {
tberror "$node: tbadb loadimage failed!";
tberror "$node_id: tbadb failed!";
return -1;
}
#
# Tell stated that we've finished reloading the node
#
TBSetNodeEventState($node,TBDB_NODESTATE_RELOADDONE);
TBSetNodeEventState($node_id,TBDB_NODESTATE_RELOADDONE);
system("$osselect $osid $node");
system("$osselect $osid $node_id");
if ($?) {
tberror "os_select $osid failed!";
return -1;
......@@ -1320,7 +1335,7 @@ sub SetupReloadUE($)
# 'Reboot' the node (from stated's perspective, anyway)
# has been shutdown, so that the os_select will take effect
#
TBSetNodeEventState($node,TBDB_NODESTATE_SHUTDOWN);
TBSetNodeEventState($node_id,TBDB_NODESTATE_SHUTDOWN);
return 0;
}
......
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