Commit 922f246f authored by Kirk Webb's avatar Kirk Webb

Merge branch 'mobile'

parents 71514327 d85879d0
......@@ -31,13 +31,14 @@ use vars qw(@ISA @EXPORT $AUTOLOAD @EXPORT_OK);
# Configure variables
use vars qw($TB $BOSSNODE $WOL $OSSELECT $IPOD $ISUTAH $CONTROL_NETMASK
$TBOPS $JAILIPMASK $TBBASE);
$TBOPS $JAILIPMASK $TBBASE $TBADB);
$TB = "@prefix@";
$BOSSNODE = "@BOSSNODE@";
$TBOPS = "@TBOPSEMAIL@";
$WOL = "$TB/sbin/whol";
$OSSELECT = "$TB/bin/os_select";
$IPOD = "$TB/sbin/ipod";
$TBADB = "$TB/bin/tbadb";
# XXX stinky hack detection
$ISUTAH = @TBMAINSITE@;
# Need this for jail ip assignment.
......@@ -1430,6 +1431,36 @@ sub GetNodeAttributes($)
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.
#
......@@ -4123,5 +4154,70 @@ sub HaveRoutableIPs($$)
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);
if ($adb_target) {
my $tnode = $experiment->VnameToNode($adb_target);
if ($tnode) {
my $c_iface = Interface->LookupControl($tnode);
if ($c_iface && $c_iface->IP()) {
$adb_target = $c_iface->IP();
} else {
print STDERR "*** Could not find control network interface for $tnode!\n";
return -1;
}
}
if (system("$TBADB -n $node_id resvport $adb_target") != 0) {
print STDERR "*** Failed to reserve ADB port for $node_id!\n";
return -1;
}
}
# 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...
1;
......@@ -76,6 +76,7 @@ my $nodereboot = "$TB/bin/node_reboot";
my $makeconf = "$TB/sbin/dhcpd_makeconf";
my $snmpit = "$TB/bin/snmpit";
my $dynmfssetup = "$TB/sbin/nfsmfs_setup";
my $tbadb = "$TB/bin/tbadb";
my $reloadpid = "emulab-ops";
my $pendingeid = "reloadpending";
my $rppendingeid = "repositionpending";
......@@ -568,7 +569,16 @@ foreach my $node (@freed_nodes) {
}
}
}
# If it's a UE, clear any existing ADB port forwarding setup.
if ($node->class() eq "ue") {
system("$tbadb -n $node_id unforward") == 0
or warn "Could not clear ADB forwarding on $node_id!";
}
###
# Now its safe to change the reservation.
###
# If the node has a next_reserve entry, change the reservation.
my $next_reservation = $node->NextReservation();
......
......@@ -492,8 +492,13 @@ sub cmd_unforward($@) {
my $node = Node->Lookup($node_id);
die "tbadb::cmd_unforward: Invalid node name $node_id!\n"
if (!defined($node));
# Fine to unforward if we are cleaning up inside of nfree.
my $experiment = $node->Reservation();
my $isholding = (defined($experiment)
&& $experiment->pid() eq NFREELOCKED_PID
&& $experiment->eid() eq NFREELOCKED_EID);
die("tbadb::cmd_unforward: You do not have permission to modify $node\n")
if (!$isroot && !$this_user->IsAdmin() &&
if (!$isroot && !$isholding &&
!$node->AccessCheck($this_user, TB_NODEACCESS_REBOOT));
# Grab the RPC pipe.
......@@ -522,7 +527,6 @@ sub cmd_unforward($@) {
}
# Clear the virt_node_attributes entry, if there is one.
my $experiment = $node->Reservation();
if ($experiment) {
my $pid = $experiment->pid();
my $eid = $experiment->eid();
......
......@@ -55,6 +55,7 @@ my $TBOPS = "@TBOPSEMAIL@";
my $NODEREBOOT = "$TB/bin/node_reboot";
my $VNODESETUP = "$TB/sbin/vnode_setup";
my $ELABINELAB = "$TB/sbin/elabinelab";
my $TBADB = "$TB/bin/tbadb";
# Setup Operation Flags
$NOSTATE = 0x00;
......@@ -2201,5 +2202,23 @@ use English;
use Data::Dumper;
use overload ('""' => 'Stringify');
# Enable the ADB port forwarding we reserved previously via the mapper.
sub LightUpNodes($@) {
my ($self, @nodelist) = @_;
my $experiment = $self->parent()->experiment();
foreach my $node (@nodelist) {
my $node_id = $node->node_id();
my $adb_target;
$experiment->GetVirtNodeAttribute($node->vname(),"adb_target",
\$adb_target);
if (system("$TBADB -n $node_id forward") != 0) {
die_noretry("Could not setup adb forwarding for $node_id!");
}
}
return $self->SUPER::LightUpNodes(@nodelist);
}
# This needs to be the last thing in the file.
1;
......@@ -7382,6 +7382,12 @@ sub InitializePhysNode($$$)
}
$pnode->ModifyReservation(\%rsrvsets) == 0
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.
......
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