Commit 27d1d683 authored by Kirk Webb's avatar Kirk Webb

UE devices: Add code to do some early resource alloc/setup.

parent 2ae2c685
...@@ -31,13 +31,14 @@ use vars qw(@ISA @EXPORT $AUTOLOAD @EXPORT_OK); ...@@ -31,13 +31,14 @@ use vars qw(@ISA @EXPORT $AUTOLOAD @EXPORT_OK);
# Configure variables # Configure variables
use vars qw($TB $BOSSNODE $WOL $OSSELECT $IPOD $ISUTAH $CONTROL_NETMASK use vars qw($TB $BOSSNODE $WOL $OSSELECT $IPOD $ISUTAH $CONTROL_NETMASK
$TBOPS $JAILIPMASK $TBBASE); $TBOPS $JAILIPMASK $TBBASE $TBADB);
$TB = "@prefix@"; $TB = "@prefix@";
$BOSSNODE = "@BOSSNODE@"; $BOSSNODE = "@BOSSNODE@";
$TBOPS = "@TBOPSEMAIL@"; $TBOPS = "@TBOPSEMAIL@";
$WOL = "$TB/sbin/whol"; $WOL = "$TB/sbin/whol";
$OSSELECT = "$TB/bin/os_select"; $OSSELECT = "$TB/bin/os_select";
$IPOD = "$TB/sbin/ipod"; $IPOD = "$TB/sbin/ipod";
$TBADB = "$TB/bin/tbadb";
# XXX stinky hack detection # XXX stinky hack detection
$ISUTAH = @TBMAINSITE@; $ISUTAH = @TBMAINSITE@;
# Need this for jail ip assignment. # Need this for jail ip assignment.
...@@ -1430,6 +1431,36 @@ sub GetNodeAttributes($) ...@@ -1430,6 +1431,36 @@ sub GetNodeAttributes($)
return $self->{"ATTRS"}; return $self->{"ATTRS"};
} }
#
# Set an attribute for a node, overwriting the same attribute if it
# already exists.
#
sub SetNodeAttribute($$$) {
my ($self, $attrkey, $attrval) = @_;
my $node_id = $self->node_id();
return -1
if (!$attrkey || !$attrval);
$attrkey = DBQuoteSpecial($attrkey);
$attrval = DBQuoteSpecial($attrval);
return -1
if (!DBQueryWarn("replace into node_attributes set".
" node_id='$node_id',".
" attrkey=$attrkey,".
" attrvalue=$attrval"));
if (!defined($self->{"ATTRS"})) {
if ($self->LoadNodeAttributes()) {
return -1;
}
}
$self->{"ATTRS"}->{$attrkey} = $attrval;
return 0;
}
# #
# Return a hash of the node features for this node. # Return a hash of the node features for this node.
# #
...@@ -4123,5 +4154,56 @@ sub HaveRoutableIPs($$) ...@@ -4123,5 +4154,56 @@ sub HaveRoutableIPs($$)
return 1; return 1;
} }
#
# For performing a bit of early UE (mobile) device configuration
#
sub UEConfig($) {
my ($self) = @_;
my $node_id = $self->node_id();
my $experiment = $self->Reservation();
if (!$experiment) {
print STDERR "*** Cannot call UEConfig() unless node is in an ".
"experiment!\n";
return -1;
}
if ($self->class() ne "ue") {
print STDERR "*** DO NOT call UEConfig() for nodes that are not of class 'ue'!\n";
return -1;
}
# Request forwarding port if adb_host virt_node_attribute is set.
my $adb_target;
$self->FlushReserved();
$experiment->GetVirtNodeAttribute($self->vname(), "adb_target",
\$adb_target);
system("$TBADB -n $node_id resvport $adb_target")
if ($adb_target);
# Get current USIM sequence number, increment and save, and add
# as virt_node_attribute to be picked up and put in manifest.
my $seqdef;
my $seqincr;
TBGetSiteVar("ue/sim_sequence_default", \$seqdef);
TBGetSiteVar("ue/sim_sequence_increment", \$seqincr);
if (!$seqdef || !$seqincr) {
print STDERR "*** Could not get UE sequence number site variables!\n";
} else {
my $seqnum;
$self->NodeAttribute("sim_sequence_number", \$seqnum);
if (!$seqnum) {
print STDERR "Warning: No sequence number for UE $node_id. Setting to sitevar default: $seqdef\n";
$self->SetNodeAttribute("sim_sequence_number", $seqdef);
} else {
$seqnum += int($seqincr);
$self->SetNodeAttribute("sim_sequence_number", $seqnum);
}
}
return 0;
}
# _Always_ make sure that this 1 is at the end of the file... # _Always_ make sure that this 1 is at the end of the file...
1; 1;
...@@ -1315,7 +1315,8 @@ sub SetupReloadUE($) ...@@ -1315,7 +1315,8 @@ sub SetupReloadUE($)
# Invoke local script that calls the remote end that # Invoke local script that calls the remote end that
# actually does the work. This will go into the background. # actually does the work. This will go into the background.
# #
my $rv = system("$TBADB -n $node loadimage $imgpid $imgname nowait"); my $rv = system("$TBADB -n $node loadimage $imgpid $imgname ".
"nowait doforward");
if ($rv) { if ($rv) {
tberror "$node: tbadb failed!"; tberror "$node: tbadb failed!";
return -1; return -1;
......
...@@ -7382,6 +7382,12 @@ sub InitializePhysNode($$$) ...@@ -7382,6 +7382,12 @@ sub InitializePhysNode($$$)
} }
$pnode->ModifyReservation(\%rsrvsets) == 0 $pnode->ModifyReservation(\%rsrvsets) == 0
or return -1 if (! ($self->impotent() || $self->alloconly())); or return -1 if (! ($self->impotent() || $self->alloconly()));
# Do some limited early setup for UE class nodes to get necessary
# information into the PG manifest.
if ($pnode->class eq "ue") {
$pnode->UEConfig();
}
# #
# Now call os_select. # Now call os_select.
......
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