Commit 08737f67 authored by Leigh Stoller's avatar Leigh Stoller

Keith Sklower's changes to support a single control network model for

ElabInElab experiments, so as not to consume an interface.

I actually modified Keith's changes so that we can dynmaically choose
the single or dual model in the NS file (Keith's changes hardwired the
system to only single control network) since the single network model
has the disadvantage of not allowing new nodes to be added to an inner
elab, which would make it impossible to test some things (like the
newnode path!).

To choose the single control network model, place this in your NS file:

	tb-elabinelab-singlenet

other it defaults to the older dual network model.
parent baab5fc2
......@@ -174,6 +174,7 @@ my %experiment_fields = ("multiplex_factor" => 1,
"elab_in_elab" => 1,
"elabinelab_eid" => 1,
"elabinelab_cvstag" => 1,
"elabinelab_singlenet" => 1,
"security_level" => 1,
"delay_capacity" => 1,
"dpdb" => 1);
......
......@@ -745,6 +745,7 @@ REPLACE INTO table_regex VALUES ('firewall_rules','rule','text','regex','^\\w[-\
REPLACE INTO table_regex VALUES ('virt_nodes','inner_elab_role','text','regex','^(boss|boss\\+router|router|ops|ops\\+fs|fs|node)$',0,0,NULL);
REPLACE INTO table_regex VALUES ('virt_nodes','plab_role','text','regex','^(plc|node|none)$',0,0,NULL);
REPLACE INTO table_regex VALUES ('experiments','elab_in_elab','int','redirect','default:boolean',0,0,NULL);
REPLACE INTO table_regex VALUES ('experiments','elabinelab_singlenet','int','redirect','default:boolean',0,0,NULL);
REPLACE INTO table_regex VALUES ('experiments','elabinelab_cvstag','text','regex','^[-\\w\\@\\/\\.]+$',0,0,NULL);
REPLACE INTO table_regex VALUES ('images','imageid','text','regex','^[a-zA-Z0-9][-\\w\\.+]+$',0,45,NULL);
REPLACE INTO table_regex VALUES ('images','imagename','text','regex','^[a-zA-Z0-9][-\\w\\.+]+$',2,30,NULL);
......
......@@ -181,9 +181,10 @@ my $firewalled = TBExptFirewall($pid, $eid, \$firewall);
# XXX NOSETUP option needs more work ...
#
$query_result =
DBQueryFatal("select elabinelab_nosetup from experiments ".
DBQueryFatal("select elabinelab_nosetup,elabinelab_singlenet ".
" from experiments ".
"where pid='$pid' and eid='$eid'");
my ($nosetup) = $query_result->fetchrow_array();
my ($nosetup,$singlenet) = $query_result->fetchrow_array();
#
# Presetup; turn off firewall.
......@@ -779,19 +780,21 @@ sub DumpDBGoo()
or die("*** $0:\n".
" Could not create temporary table temp_interfaces\n");
# First, mark the real control network as "other" to avoid it being
# thought of as the control network!.
DBQueryWarn("update temp_interfaces ".
"set role='" . TBDB_IFACEROLE_OUTER_CONTROL() . "' " .
"where role='" . TBDB_IFACEROLE_CONTROL() . "'")
or die("*** $0:\n".
" Could not delete control ifaces from temp_interfaces\n");
if (! $singlenet) {
# First, mark the real control network as "other" to avoid it being
# thought of as the control network!.
DBQueryWarn("update temp_interfaces ".
"set role='" . TBDB_IFACEROLE_OUTER_CONTROL() . "' " .
"where role='" . TBDB_IFACEROLE_CONTROL() . "'")
or die("*** $0:\n".
" Could not delete control ifaces from temp_interfaces\n");
DBQueryWarn("update temp_interfaces set ".
" role='" . TBDB_IFACEROLE_CONTROL() . "' " .
"where IP!='' and role='" . TBDB_IFACEROLE_EXPERIMENT() . "'")
or die("*** $0:\n".
" Could not update roles in temp_interfaces\n");
DBQueryWarn("update temp_interfaces set ".
" role='" . TBDB_IFACEROLE_CONTROL() . "' " .
"where IP!='' and role='" . TBDB_IFACEROLE_EXPERIMENT() . "'")
or die("*** $0:\n".
" Could not update roles in temp_interfaces\n");
}
# And rename the fs/ops nodes as above.
if (defined($fsnode)) {
......@@ -822,8 +825,8 @@ sub DumpDBGoo()
"select t.* from reserved as r ".
"left join virt_nodes as v on v.vname=r.vname and ".
" v.pid=r.pid and v.eid=r.eid ".
"left join wires as t on t.node_id1=r.node_id and ".
" t.type='Node' ".
"left join wires as t on t.node_id1=r.node_id ".
($singlenet == 0 ? " and t.type='Node' " : " ") .
"where r.pid='$pid' and r.eid='$eid' and ".
" v.inner_elab_role in ('node','ops','fs','ops+fs') ")
or die("*** $0:\n".
......@@ -841,16 +844,18 @@ sub DumpDBGoo()
or die("*** $0:\n".
" Could not ops node_id in temp_wires\n");
# But we need to take out the wires that are being used as the
# inner control network, or at least mark them as Control.
$query_result =
DBQueryWarn("select node_id,card,port from temp_interfaces ".
"where role='" . TBDB_IFACEROLE_CONTROL() . "' ");
while (my ($node_id,$card,$port) = $query_result->fetchrow_array()) {
DBQueryWarn("update temp_wires set type='Control' ".
"where node_id1='$node_id' and card1=$card and ".
" port1=$port");
if (! $singlenet) {
# But we need to take out the wires that are being used as the
# inner control network, or at least mark them as Control.
$query_result =
DBQueryWarn("select node_id,card,port from temp_interfaces ".
"where role='" . TBDB_IFACEROLE_CONTROL() . "' ");
while (my ($node_id,$card,$port) = $query_result->fetchrow_array()) {
DBQueryWarn("update temp_wires set type='Control' ".
"where node_id1='$node_id' and card1=$card and ".
" port1=$port");
}
}
# Okay, now add the "trunk" wires in without any alteration.
DBQueryWarn("insert into temp_wires ".
......
......@@ -127,14 +127,17 @@ for {set i 1} {$i <= $maxpcs} {incr i} {
tb-set-hardware [set $name] pcslow
}
}
set publiclan [$ns make-lan $lanstr 100Mb 0ms]
tb-set-ip-lan $myboss $publiclan 10.200.1.252
tb-set-ip-lan $myops $publiclan 10.200.1.253
tb-set-ip-lan $myfs $publiclan 10.200.1.251
for {set i 1} {$i <= $maxpcs} {incr i} {
if { ${::GLOBALS::elabinelab_singlenet} == 0 } {
set publiclan [$ns make-lan $lanstr 100Mb 0ms]
tb-set-ip-lan $myboss $publiclan 10.200.1.252
tb-set-ip-lan $myops $publiclan 10.200.1.253
tb-set-ip-lan $myfs $publiclan 10.200.1.251
for {set i 1} {$i <= $maxpcs} {incr i} {
set name "mypc${i}"
tb-set-ip-lan [set $name] $publiclan 10.200.1.$i
}
}
if {[info exists ::TBCOMPAT::elabinelab_nodeos("boss")]} {
......
......@@ -100,13 +100,16 @@ for {set i 1} {$i <= $maxpcs} {incr i} {
tb-set-hardware [set $name] pcslow
}
}
set publiclan [$ns make-lan $lanstr 100Mb 0ms]
tb-set-ip-lan $myboss $publiclan 10.200.1.252
tb-set-ip-lan $myops $publiclan 10.200.1.253
for {set i 1} {$i <= $maxpcs} {incr i} {
if { ${::GLOBALS::elabinelab_singlenet} == 0 } {
set publiclan [$ns make-lan $lanstr 100Mb 0ms]
tb-set-ip-lan $myboss $publiclan 10.200.1.252
tb-set-ip-lan $myops $publiclan 10.200.1.253
for {set i 1} {$i <= $maxpcs} {incr i} {
set name "mypc${i}"
tb-set-ip-lan [set $name] $publiclan 10.200.1.$i
}
}
if {[info exists ::TBCOMPAT::elabinelab_nodeos("boss")]} {
......
......@@ -77,6 +77,7 @@ proc tb-elab-in-elab {onoff} {}
proc tb-elab-in-elab-topology {topo} {}
proc tb-set-inner-elab-eid {eid} {}
proc tb-set-elabinelab-cvstag {cvstag} {}
proc tb-elabinelab-singlenet {} {}
proc tb-set-node-inner-elab-role {node role} {}
proc tb-set-node-id {vnode myid} {}
proc tb-set-link-est-bandwidth {srclink args} {}
......
......@@ -265,6 +265,7 @@ namespace eval GLOBALS {
variable elabinelab_topo ""
variable elabinelab_eid {}
variable elabinelab_cvstag {}
variable elabinelab_singlenet 0
# Does user want a per-experiment DB?
variable dpdb 0
......
......@@ -397,6 +397,7 @@ Simulator instproc run {} {
var_import ::GLOBALS::elabinelab_topo
var_import ::GLOBALS::elabinelab_eid
var_import ::GLOBALS::elabinelab_cvstag
var_import ::GLOBALS::elabinelab_singlenet
var_import ::GLOBALS::security_level
var_import ::GLOBALS::explicit_firewall
var_import ::GLOBALS::sourcefile_list
......@@ -627,6 +628,8 @@ Simulator instproc run {} {
if {$elab_in_elab} {
lappend fields "elab_in_elab"
lappend values 1
lappend fields "elabinelab_singlenet"
lappend values $elabinelab_singlenet
if { $elabinelab_eid != {} } {
lappend fields "elabinelab_eid"
......
......@@ -1575,6 +1575,11 @@ proc tb-set-elabinelab-cvstag {cvstag} {
set elabinelab_cvstag $cvstag
}
proc tb-elabinelab-singlenet {} {
var_import ::GLOBALS::elabinelab_singlenet
set elabinelab_singlenet 1
}
#
# Set the inner elab role for a node.
......
......@@ -93,6 +93,11 @@ my $hostname = `hostname`;
chomp($hostname);
my ($bossname, $outer_bossip) = tmccbossinfo();
# This is the router IP to the outside world. Needed in lots of places.
my $outer_routerip;
# And the netmask on the outer control network.
my $outer_netmask;
# Outer FS node name. See below.
my $fsname;
......@@ -109,6 +114,9 @@ my $NOSETUP = 0;
# Whether we configure a /scratch FS, turned on/off below
my $SCRATCHFS = 0;
# Single or dual control network.
my $SINGLE_CONTROLNET = 0;
# This will not change ...
my $PHP4_PKG = "php4-extensions-1.0";
......@@ -166,6 +174,7 @@ sub SetupBossNode();
sub CreateDefsFile($);
sub SetupSendMail($$);
sub GetEmulabSource($);
sub MungeMfsRoot($);
#
# Boot Action.
......@@ -219,6 +228,23 @@ sub doboot()
$emulabconfig{"WINSUPPORT"} = 0;
$emulabconfig{"NOSETUP"} = 0;
$emulabconfig{"SCRATCHFS"} = 0;
$emulabconfig{"SINGLE_CONTROLNET"} = 1;
#
# Need outer control router IP in lots of places.
#
if (! -e "$BOOTDIR/routerip") {
fatal("$BOOTDIR/routerip does not exist!");
}
$outer_routerip = `cat $BOOTDIR/routerip`;
chomp($outer_routerip);
# And the outer netmask
if (! -e "$BOOTDIR/mynetmask") {
fatal("$BOOTDIR/mynetmask does not exist!");
}
$outer_netmask = `cat $BOOTDIR/mynetmask`;
chomp($outer_netmask);
#
# Turn the tmcc results into a hash first. Then call the boss or ops
......@@ -255,6 +281,10 @@ sub doboot()
if ($emulabconfig{"SCRATCHFS"}) {
$SCRATCHFS = 1;
}
# and single vs dual control network
if ($emulabconfig{"SINGLE_CONTROLNET"}) {
$SINGLE_CONTROLNET = 0;
}
# XXX Temporary
if ($FBSD_VERSION == 5.4) {
......@@ -366,39 +396,29 @@ sub SetupFsNode()
my $outer_ip = `cat $BOOTDIR/myip`;
chomp($outer_ip);
if (! -e "$BOOTDIR/mynetmask") {
SetupFatal("$BOOTDIR/mynetmask does not exist!");
}
my $outer_netmask = `cat $BOOTDIR/mynetmask`;
chomp($outer_netmask);
if (! -e "$BOOTDIR/controlif") {
SetupFatal("$BOOTDIR/controlif does not exist!");
}
my $outer_controlif = `cat $BOOTDIR/controlif`;
chomp($outer_controlif);
#
# Need outer control router IP below too.
#
if (! -e "$BOOTDIR/routerip") {
SetupFatal("$BOOTDIR/routerip does not exist!");
}
my $outer_routerip = `cat $BOOTDIR/routerip`;
chomp($outer_routerip);
#
# We also need the hardwired config for the inner control network.
# Major kludge; should get it from tmcd data.
#
my @ifacelist;
if (getifconfig(\@ifacelist) != 0 || !@ifacelist) {
SetupFatal("Could not get ifconfig from libsetup!");
my $inner_controlif;
my $inner_ip;
my $inner_netmask;
if (! $SINGLE_CONTROLNET) {
if (getifconfig(\@ifacelist) != 0 || !@ifacelist) {
SetupFatal("Could not get ifconfig from libsetup!");
}
$inner_controlif = $ifacelist[0]->{IFACE};
$inner_ip = $ifacelist[0]->{IPADDR};
$inner_netmask = $ifacelist[0]->{IPMASK};
}
my $inner_controlif = $ifacelist[0]->{IFACE};
my $inner_ip = $ifacelist[0]->{IPADDR};
my $inner_netmask = $ifacelist[0]->{IPMASK};
#
# Run the prepare script to clear out the current accounts and such.
......@@ -516,19 +536,25 @@ sub SetupFsNode()
print RC "nfs_client_enable=\"YES\"\n";
print RC "mountd_flags=\"-r -p 900\"\n";
print RC "network_interfaces=\"$outer_controlif $inner_controlif lo0\"\n";
print RC "network_interfaces=\"$outer_controlif\"\n";
print RC "ifconfig_${outer_controlif}=".
"\"inet $outer_ip netmask $outer_netmask\"\n";
print RC "ifconfig_${inner_controlif}=".
"\"inet $inner_ip netmask $inner_netmask ".
"media 100baseTX mediaopt full-duplex\"\n";
if (! $SINGLE_CONTROLNET) {
print RC "network_interfaces=\"\$network_interfaces $inner_controlif\"\n";
print RC "ifconfig_${inner_controlif}=".
"\"inet $inner_ip netmask $inner_netmask ".
"media 100baseTX mediaopt full-duplex\"\n";
}
print RC "network_interfaces=\"\$network_interfaces lo0\"\n";
print RC "static_routes=\"outerboss vnodes\"\n";
print RC "route_outerboss=\"$outer_bossip $outer_routerip\"\n";
print RC "route_vnodes=\"-net ". $emulabconfig{"JAILIPBASE"} .
" -netmask " . $emulabconfig{"JAILIPMASK"} .
" -iface $inner_controlif\"\n";
" -iface " . ($SINGLE_CONTROLNET ?
$outer_controlif : $inner_controlif) . "\"\n";
# Leave default route pointing to control network until setup complete.
if ($NOSETUP) {
if ($NOSETUP || $SINGLE_CONTROLNET) {
print RC "defaultrouter=\"$outer_routerip\"\n";
}
else {
......@@ -686,39 +712,29 @@ sub SetupOpsNode($)
my $outer_ip = `cat $BOOTDIR/myip`;
chomp($outer_ip);
if (! -e "$BOOTDIR/mynetmask") {
SetupFatal("$BOOTDIR/mynetmask does not exist!");
}
my $outer_netmask = `cat $BOOTDIR/mynetmask`;
chomp($outer_netmask);
if (! -e "$BOOTDIR/controlif") {
SetupFatal("$BOOTDIR/controlif does not exist!");
}
my $outer_controlif = `cat $BOOTDIR/controlif`;
chomp($outer_controlif);
#
# Need outer control router IP below too.
#
if (! -e "$BOOTDIR/routerip") {
SetupFatal("$BOOTDIR/routerip does not exist!");
}
my $outer_routerip = `cat $BOOTDIR/routerip`;
chomp($outer_routerip);
#
# We also need the hardwired config for the inner control network.
# Major kludge; should get it from tmcd data.
#
my @ifacelist;
if (getifconfig(\@ifacelist) != 0 || !@ifacelist) {
SetupFatal("Could not get ifconfig from libsetup!");
my $inner_controlif;
my $inner_ip;
my $inner_netmask;
if (! $SINGLE_CONTROLNET) {
if (getifconfig(\@ifacelist) != 0 || !@ifacelist) {
SetupFatal("Could not get ifconfig from libsetup!");
}
$inner_controlif = $ifacelist[0]->{IFACE};
$inner_ip = $ifacelist[0]->{IPADDR};
$inner_netmask = $ifacelist[0]->{IPMASK};
}
my $inner_controlif = $ifacelist[0]->{IFACE};
my $inner_ip = $ifacelist[0]->{IPADDR};
my $inner_netmask = $ifacelist[0]->{IPMASK};
#
# Run the prepare script to clear out the current accounts and such.
......@@ -866,19 +882,25 @@ sub SetupOpsNode($)
print RC "syslogd_flags=\"-a $control_network\"\n";
print RC "network_interfaces=\"$outer_controlif $inner_controlif lo0\"\n";
print RC "network_interfaces=\"$outer_controlif\"\n";
print RC "ifconfig_${outer_controlif}=".
"\"inet $outer_ip netmask $outer_netmask\"\n";
print RC "ifconfig_${inner_controlif}=".
"\"inet $inner_ip netmask $inner_netmask ".
"media 100baseTX mediaopt full-duplex\"\n";
if (! $SINGLE_CONTROLNET) {
print RC "network_interfaces=\"\$network_interfaces $inner_controlif\"\n";
print RC "ifconfig_${inner_controlif}=".
"\"inet $inner_ip netmask $inner_netmask ".
"media 100baseTX mediaopt full-duplex\"\n";
}
print RC "network_interfaces=\"\$network_interfaces lo0\"\n";
print RC "static_routes=\"outerboss vnodes\"\n";
print RC "route_outerboss=\"$outer_bossip $outer_routerip\"\n";
print RC "route_vnodes=\"-net ". $emulabconfig{"JAILIPBASE"} .
" -netmask " . $emulabconfig{"JAILIPMASK"} .
" -iface $inner_controlif\"\n";
" -iface " . ($SINGLE_CONTROLNET ?
$outer_controlif : $inner_controlif) . "\"\n";
# Leave default route pointing to control network until setup complete.
if ($NOSETUP) {
if ($NOSETUP || $SINGLE_CONTROLNET) {
print RC "defaultrouter=\"$outer_routerip\"\n";
}
else {
......@@ -1050,21 +1072,6 @@ sub SetupBossNode()
my $outer_ip = `cat $BOOTDIR/myip`;
chomp($outer_ip);
if (! -e "$BOOTDIR/mynetmask") {
SetupFatal("$BOOTDIR/mynetmask does not exist!");
}
my $outer_netmask = `cat $BOOTDIR/mynetmask`;
chomp($outer_netmask);
#
# Need outer control router IP below too.
#
if (! -e "$BOOTDIR/routerip") {
SetupFatal("$BOOTDIR/routerip does not exist!");
}
my $outer_routerip = `cat $BOOTDIR/routerip`;
chomp($outer_routerip);
#
# And we need the name of the control interface for natd below.
#
......@@ -1079,13 +1086,18 @@ sub SetupBossNode()
# Major kludge; should get it from tmcd data.
#
my @ifacelist;
if (getifconfig(\@ifacelist) != 0 || !@ifacelist) {
SetupFatal("Could not get ifconfig from libsetup!");
my $inner_controlif;
my $inner_ip;
my $inner_netmask;
if (! $SINGLE_CONTROLNET) {
if (getifconfig(\@ifacelist) != 0 || !@ifacelist) {
SetupFatal("Could not get ifconfig from libsetup!");
}
$inner_controlif = $ifacelist[0]->{IFACE};
$inner_ip = $ifacelist[0]->{IPADDR};
$inner_netmask = $ifacelist[0]->{IPMASK};
}
my $inner_controlif = $ifacelist[0]->{IFACE};
my $inner_ip = $ifacelist[0]->{IPADDR};
my $inner_netmask = $ifacelist[0]->{IPMASK};
#
# Run the prepare script to clear out the current accounts and such.
......@@ -1185,17 +1197,23 @@ sub SetupBossNode()
print RC "nfs_server_flags=\"-u -t -n 8\"\n";
print RC "nfs_client_enable=\"YES\"\n";
print RC "network_interfaces=\"$outer_controlif $inner_controlif lo0\"\n";
print RC "network_interfaces=\"$outer_controlif\"\n";
print RC "ifconfig_${outer_controlif}=".
"\"inet $outer_ip netmask $outer_netmask\"\n";
print RC "ifconfig_${inner_controlif}=".
"\"inet $inner_ip netmask $inner_netmask ".
"media 100baseTX mediaopt full-duplex\"\n";
if (! $SINGLE_CONTROLNET) {
print RC "network_interfaces=\"\$network_interfaces $inner_controlif\"\n";
print RC "ifconfig_${inner_controlif}=".
"\"inet $inner_ip netmask $inner_netmask ".
"media 100baseTX mediaopt full-duplex\"\n";
}
print RC "network_interfaces=\"\$network_interfaces lo0\"\n";
print RC "static_routes=\"outerboss vnodes\"\n";
print RC "route_outerboss=\"$outer_bossip $outer_routerip\"\n";
print RC "route_vnodes=\"-net ". $emulabconfig{"JAILIPBASE"} .
" -netmask " . $emulabconfig{"JAILIPMASK"} .
" -iface $inner_controlif\"\n";
" -iface " . ($SINGLE_CONTROLNET ?
$outer_controlif : $inner_controlif) . "\"\n";
#
# Use natd so that internal control network can talk to outside world.
......@@ -1229,6 +1247,18 @@ sub SetupBossNode()
#
CreateDefsFile("${TBDIR}/testbed/src/testbed/defs-elabinelab");
if ($SINGLE_CONTROLNET) {
#
# Hack dhcpd.conf.template to ignore the rest of emulab.
# This precludes dynamic node addition
# Might think about allowing back if the experiment is firewalled.
#
mysystem("cd ${TBDIR}/testbed/src/testbed/dhcpd ; ".
" sed -E -i .orig -e " .
" 's;range .DHCPD_DYNRANGE.;ignore unknown-clients;' ".
" dhcpd.conf.template.in");
}
goto skipsetup
if ($NOSETUP);
......@@ -1334,6 +1364,16 @@ sub SetupBossNode()
#
mysystem("cp -p ${TBDIR}/testbed/stuff/emulab.pem $RPCCERT");
#
# Copy the inner ssl cert and root's public ssh keys to the mfs's
# so that imported they will talk to the inner boss properly.
# At Berkeley the frisbee mfs copies these to disk images,
# needing changes to slicefix , which always needs to be run now.
#
MungeMfsRoot("frisbee");
MungeMfsRoot("freebsd");
MungeMfsRoot("freebsd.newnode");
#
# Set up a bunch of DB stuff. This part will eventually be optional,
# resulting in a naked setup that will need to be configured the rest of
......@@ -1407,8 +1447,17 @@ sub CreateDefsFile($)
my $bossnode_ip = $emulabconfig{"BOSSIP"};
my $opsnode_ip = $emulabconfig{"OPSIP"};
my $fsnode_ip = $emulabconfig{"FSIP"};
my $control_netmask = "255.255.255.0";
#
# The control network netmask differs if using a single control network.
#
if ($SINGLE_CONTROLNET) {
$control_netmask = $outer_netmask;
}
my $control_network = inet_ntoa(inet_aton($opsnode_ip) &
inet_aton("255.255.255.0"));
inet_aton($control_netmask));
# Put dynrange at the top.
my $dynrange_low = inet_ntoa(inet_aton($control_network) |
inet_aton("0.0.0.230"));
......@@ -1489,7 +1538,7 @@ sub CreateDefsFile($)
last SWITCH;
};
/^TESTBED_NETMASK$/ && do {
print OUTDEFS "TESTBED_NETMASK=255.255.255.0\n";
print OUTDEFS "TESTBED_NETMASK=$control_netmask\n";
last SWITCH;
};
/^BOSSNODE_IP$/ && do {
......@@ -1505,7 +1554,16 @@ sub CreateDefsFile($)
last SWITCH;
};
/^CONTROL_ROUTER_IP$/ && do {
print OUTDEFS "CONTROL_ROUTER_IP=$bossnode_ip\n";
my $control_router_ip;
if ($SINGLE_CONTROLNET) {
$control_router_ip = $outer_routerip;
}
else {
$control_router_ip = $bossnode_ip;
}
print OUTDEFS "CONTROL_ROUTER_IP=$control_router_ip\n";
last SWITCH;
};
/^CONTROL_NETWORK$/ && do {
......@@ -1513,7 +1571,7 @@ sub CreateDefsFile($)
last SWITCH;
};
/^CONTROL_NETMASK$/ && do {
print OUTDEFS "CONTROL_NETMASK=255.255.255.0\n";
print OUTDEFS "CONTROL_NETMASK=$control_netmask\n";
last SWITCH;
};
/^PRIVATE_NETWORK$/ && do {
......@@ -1521,7 +1579,16 @@ sub CreateDefsFile($)
last SWITCH;
};
/^PRIVATE_ROUTER$/ && do {
print OUTDEFS "PRIVATE_ROUTER=$bossnode_ip\n";
my $private_router;
if ($SINGLE_CONTROLNET) {
$private_router = $outer_routerip;
}
else {
$private_router = $bossnode_ip;
}
print OUTDEFS "PRIVATE_ROUTER=$private_router\n";
last SWITCH;
};
/^PRIVATE_NETMASK$/ && do {
......@@ -1533,11 +1600,19 @@ sub CreateDefsFile($)
last SWITCH;
};
/^PUBLIC_ROUTER$/ && do {
print OUTDEFS "PUBLIC_ROUTER=$bossnode_ip\n";
my $public_router;
if ($SINGLE_CONTROLNET) {
$public_router = $outer_routerip;
}
else {
$public_router = $bossnode_ip;
}
print OUTDEFS "PUBLIC_ROUTER=$public_router\n";
last SWITCH;
};
/^PUBLIC_NETMASK$/ && do {
print OUTDEFS "PUBLIC_NETMASK=255.255.255.0\n";
print OUTDEFS "PUBLIC_NETMASK=$control_netmask\n";
last SWITCH;
};
/^NAMED_FORWARDERS$/ && do {
......@@ -1634,6 +1709,26 @@ sub CreateDefsFile($)
mysystem("mv -f /tmp/defs-elabinelab $defsfile");
}
sub MungeMfsRoot($)
{
my $tftpdir = shift;
my ($mount, $release);
if ($FBSD_VERSION >= 5) {
$mount = "mdconfig -a -t vnode -f mfsroot -u 2; mount /dev/md2 /mnt;";
$release = "mdconfig -d -u 2;";
}
else {
$mount = "vnconfig -c vn1 mfsroot; mount /dev/vn1 /mnt;";
$release = "vnconfig -u vn1;";
}
mysystem("cd /tftpboot/$tftpdir/boot; " . $mount . "cd /usr/testbed/etc;" .
"cat /root/.ssh/*.pub >> /mnt/root/.ssh/authorized_keys2; " .
"cp -p emulab.pem client.pem /mnt/etc/emulab ; umount /mnt ; " .
$release . " cd /tftpboot/$tftpdir/boot; " .
"gzip < mfsroot > mfsroot.gz ");
}
#
# Print error and exit.
#
......
......@@ -158,6 +158,7 @@ typedef struct {
int isplabdslice;
int isplabsvc;
int elab_in_elab;
int singlenet; /* Modifier for elab_in_elab */
int update_accounts;
char nodeid[TBDB_FLEN_NODEID];
char vnodeid[TBDB_FLEN_NODEID];
......@@ -4055,7 +4056,7 @@ iptonodeid(struct in_addr ipaddr, tmcdreq_t *reqp)
" pt.isremotenode,vt.issubnode,e.keyhash, "
" nk.sfshostid,e.eventkey,vt.isplabdslice, "
" ps.admin, "
" e.elab_in_elab "
" e.elab_in_elab,e.elabinelab_singlenet "
"from nodes as nv "
"left join nodes as np on "
" np.node_id=nv.phys_nodeid "
......@@ -4075,7 +4076,7 @@ iptonodeid(struct in_addr ipaddr, tmcdreq_t *reqp)
" nk.node_id=nv.node_id "
"where nv.node_id='%s' and "
" (i.IP='%s' and i.role='ctrl') ",
24, reqp->vnodeid, inet_ntoa(ipaddr));
25, reqp->vnodeid, inet_ntoa(ipaddr));
}
else {
res = mydb_query("select t.class,t.type,n.node_id,n.jailflag,"
......@@ -4085,7 +4086,7 @@ iptonodeid(struct in_addr ipaddr, tmcdreq_t *reqp)
" e.sync_server,t.class,t.type, "
" t.isremotenode,t.issubnode,e.keyhash, "
" nk.sfshostid,e.eventkey,0, "
" 0,e.elab_in_elab "
" 0,e.elab_in_elab,e.elabinelab_singlenet "
"from interfaces as i "
"left join nodes as n on n.node_id=i.node_id "
"left join reserved as r on "
......@@ -4097,7 +4098,7 @@ iptonodeid(struct in_addr ipaddr, tmcdreq_t *reqp)
"left join node_hostkeys as nk on "
" nk.node_id=n.node_id "
"where i.IP='%s' and i.role='ctrl'", /*XXX*/
24, inet_ntoa(ipaddr));
25, inet_ntoa(ipaddr));
}
if (!res) {
......@@ -4128,6 +4129,7 @@ iptonodeid(struct in_addr ipaddr, tmcdreq_t *reqp)
reqp->isplabdslice = (! strcasecmp(row[21], "0") ? 0 : 1);
reqp->isplabsvc = (row[22] && strcasecmp(row[22], "0")) ? 1 : 0;
reqp->elab_in_elab = (row[23] && strcasecmp(row[23], "0")) ? 1 : 0;
reqp->singlenet = (row[24] && strcasecmp(row[24], "0")) ? 1 : 0;
if (row[8])
strncpy(reqp->testdb, row[8], sizeof(reqp->testdb));
......@@ -5834,14 +5836,28 @@ COMMAND_PROTOTYPE(doemulabconfig)
* that all the nodes are on a single lan. If we get fancier about
* that, we will have to figure out how to label the specific lans
* se we know which is which.
*
* Note the single vs dual control network differences!
*/
res = mydb_query("select r.node_id,r.inner_elab_role,vl.ip,r.vname "
" from reserved as r "
"left join virt_lans as vl on vl.vnode=r.vname and "
" vl.pid=r.pid and vl.eid=r.eid "
"where r.pid='%s' and r.eid='%s' and "
" r.inner_elab_role is not null",
4, reqp->pid, reqp->eid);
if (reqp->singlenet) {
res = mydb_query("select r.node_id,r.inner_elab_role,"
" i.IP,r.vname from reserved as r "
"left join interfaces as i on "
" i.node_id=r.node_id and i.role='ctrl' "
"where r.pid='%s' and r.eid='%s' and "
" r.inner_elab_role is not null",
4, reqp->pid, reqp->eid);
}
else {
res = mydb_query("select r.node_id,r.inner_elab_role,"
" vl.ip,r.vname from reserved as r "
"left join virt_lans as vl on "
" vl.vnode=r.vname and "
" vl.pid=r.pid and vl.eid=r.eid "
"where r.pid='%s' and r.eid='%s' and "
" r.inner_elab_role is not null",
4, reqp->pid, reqp->eid);
}
if (!res) {