Commit 86564e95 authored by Leigh B Stoller's avatar Leigh B Stoller

Allow override of the default jail ip/mask to make it easier to bring

up a container using a routable IP.
parent 49a9940e
#!/usr/bin/perl -wT #!/usr/bin/perl -wT
# #
# EMULAB-COPYRIGHT # EMULAB-COPYRIGHT
# Copyright (c) 2005-2011 University of Utah and the Flux Group. # Copyright (c) 2005-2012 University of Utah and the Flux Group.
# All rights reserved. # All rights reserved.
# #
package Node; package Node;
...@@ -13,7 +13,8 @@ use vars qw(@ISA @EXPORT $AUTOLOAD @EXPORT_OK); ...@@ -13,7 +13,8 @@ use vars qw(@ISA @EXPORT $AUTOLOAD @EXPORT_OK);
@EXPORT = qw(); @EXPORT = qw();
# Configure variables # Configure variables
use vars qw($TB $BOSSNODE $WOL $OSSELECT $ISUTAH $CONTROL_NETMASK $TBOPS); use vars qw($TB $BOSSNODE $WOL $OSSELECT $ISUTAH $CONTROL_NETMASK
$TBOPS $JAILIPMASK);
$TB = "@prefix@"; $TB = "@prefix@";
$BOSSNODE = "@BOSSNODE@"; $BOSSNODE = "@BOSSNODE@";
$TBOPS = "@TBOPSEMAIL@"; $TBOPS = "@TBOPSEMAIL@";
...@@ -23,6 +24,7 @@ $OSSELECT = "$TB/bin/os_select"; ...@@ -23,6 +24,7 @@ $OSSELECT = "$TB/bin/os_select";
$ISUTAH = @TBMAINSITE@; $ISUTAH = @TBMAINSITE@;
# Need this for jail ip assignment. # Need this for jail ip assignment.
$CONTROL_NETMASK = "@CONTROL_NETMASK@"; $CONTROL_NETMASK = "@CONTROL_NETMASK@";
$JAILIPMASK = "@JAILIPMASK@";
use libdb; use libdb;
use libtestbed; use libtestbed;
...@@ -1897,6 +1899,7 @@ sub CreateVnodes($$$) ...@@ -1897,6 +1899,7 @@ sub CreateVnodes($$$)
my ($class, $rptr, $options) = @_; my ($class, $rptr, $options) = @_;
my @created = (); my @created = ();
my @tocreate = (); my @tocreate = ();
my @vlist = ();
require Interface; require Interface;
require NodeType; require NodeType;
...@@ -2193,9 +2196,10 @@ sub CreateVnodes($$$) ...@@ -2193,9 +2196,10 @@ sub CreateVnodes($$$)
"def_boot_osid" => $osid, "def_boot_osid" => $osid,
"update_accounts" => 1, "update_accounts" => 1,
"jailflag" => $isjailed); "jailflag" => $isjailed);
$nodesets{"jailip"} = $jailip if ($isjailed && !$isremote) {
if ($isjailed && !$isremote); $nodesets{"jailip"} = $jailip;
$nodesets{"jailipmask"} = $JAILIPMASK;
}
my $statement = "insert into nodes set ". my $statement = "insert into nodes set ".
join(",", map("$_='" . $nodesets{$_} . "'", keys(%nodesets))); join(",", map("$_='" . $nodesets{$_} . "'", keys(%nodesets)));
...@@ -3048,7 +3052,32 @@ sub GetJailIP($;$) ...@@ -3048,7 +3052,32 @@ sub GetJailIP($;$)
$pnet++; $pnet++;
$pnode2 -= $nodenumlimit; $pnode2 -= $nodenumlimit;
} }
return "${IPBASE1}.${pnet}.${pnode2}.${num}"; return ("${IPBASE1}.${pnet}.${pnode2}.${num}", $JAILIPMASK);
}
#
# Another variant of above, this one looks in the virt_node_attributes
# table of the vnode assigned to the pnode.
#
sub SetJailIPFromVnode($$$)
{
my ($self, $experiment, $vnode_id) = @_;
my ($jailip, $jailipmask);
return -1
if ($experiment->GetVirtNodeAttribute($vnode_id, \$jailip) < 0 ||
$experiment->GetVirtNodeAttribute($vnode_id, \$jailipmask) < 0);
if (defined($jailip)) {
if (!defined($jailipmask)) {
print STDERR
"*** $vnode_id has a jailip attribute but no jailipmask.\n";
return -1;
}
return $self->Update({"jailip" => $jailip,
"jailipmask" => $jailipmask});
}
return 0;
} }
# #
...@@ -3136,5 +3165,6 @@ sub CheckPreReserve($$) ...@@ -3136,5 +3165,6 @@ sub CheckPreReserve($$)
return $result; return $result;
} }
# _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;
...@@ -5117,6 +5117,11 @@ sub AllocVirtNodes($) ...@@ -5117,6 +5117,11 @@ sub AllocVirtNodes($)
# #
$pnode->ModifyReservation({"vname" => $virtual}) == 0 $pnode->ModifyReservation({"vname" => $virtual}) == 0
or return -1 if (!$self->impotent()); or return -1 if (!$self->impotent());
#
# Not sure where to put this.
#
$pnode->SetJailIPFromVnode($experiment, $virtual);
} }
# Since we have some extra physical vnodes reserved on this pnode, # Since we have some extra physical vnodes reserved on this pnode,
......
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