Commit 1a52760a authored by Leigh B Stoller's avatar Leigh B Stoller

Deprecate the use of jailip in the nodes table, for local dynamic

virtual nodes. We now create an interfaces table entry so that we do
not special code to find the control network interface. This entry is
delated along with the node entries when the experiment is swapped
out.

Of course, we still have existing nodes with jailip entries, so not
much code was removed, but this saves me from having to add more
special cases for XEN elabinelab, and at some point we can remove the
deprecated code.
parent 40573936
/*
* EMULAB-COPYRIGHT
* Copyright (c) 2000-2011 University of Utah and the Flux Group.
* Copyright (c) 2000-2012 University of Utah and the Flux Group.
* All rights reserved.
*/
......@@ -16,6 +16,7 @@
#define TBDB_FLEN_NODECLASS (10 + 1)
#define TBDB_FLEN_NODETYPE (30 + 1)
#define TBDB_FLEN_IP (16 + 1)
#define TBDB_FLEN_IPMASK (16 + 1)
#define TBDB_FLEN_EVOBJTYPE 128
#define TBDB_FLEN_EVOBJNAME 128
#define TBDB_FLEN_EVEVENTTYPE 128
......
......@@ -1898,6 +1898,8 @@ sub CreateVnodes($$$)
{
my ($class, $rptr, $options) = @_;
my @created = ();
my @ifaceargs = ();
my @interfaces= ();
my @tocreate = ();
my @vlist = ();
require Interface;
......@@ -2196,7 +2198,9 @@ sub CreateVnodes($$$)
"def_boot_osid" => $osid,
"update_accounts" => 1,
"jailflag" => $isjailed);
if ($isjailed && !$isremote) {
# This is deprecated and will be removed. We now create real
# interfaces, see below.
if (0 && $isjailed && !$isremote) {
$nodesets{"jailip"} = $jailip;
$nodesets{"jailipmask"} = $JAILIPMASK;
}
......@@ -2266,15 +2270,63 @@ sub CreateVnodes($$$)
Node->MakeFake($vnodeid, \%nodesets, \%rsrvsets)
if ($impotent);
push(@created, $vnodeid);
#
# Save up interfaces we need to create after table unlock.
#
if ($isjailed && !$isremote) {
my $ifaceargs = {
"node_id" => $vnodeid,
"card" => 0,
"port" => 1,
"iface" => "eth0",
"role" => TBDB_IFACEROLE_CONTROL(),
"MAC" => "000000000000",
"IP" => $jailip,
"mask" => $JAILIPMASK,
"type" => "generic",
"logical" => 1,
};
push(@ifaceargs, $ifaceargs);
}
}
DBQueryFatal("unlock tables");
#
# Now create a control network interface for local jailed nodes.
# Now that tables are unlocked.
#
foreach my $ifaceargs (@ifaceargs) {
my $vnodeid = $ifaceargs->{'node_id'};
my $node = Node->Lookup($vnodeid);
if (!defined($node)) {
print STDERR
"*** CreateVnodes: Could not lookup node object for $vnodeid\n";
goto bad;
}
my $interface = ($impotent ?
Interface->MakeFake($node, $ifaceargs) :
Interface->Create($node, $ifaceargs));
if (!defined($interface)) {
print STDERR
"*** CreateVnodes: Could not create interface for $vnodeid\n";
goto bad;
}
print STDERR Dumper($interface)
if ($debug);
push(@interfaces, $interface);
}
@$rptr = @created;
return 0;
bad:
if (!$impotent) {
foreach my $interface (@interfaces) {
$interface->Delete();
}
foreach my $vnodeid (@created) {
DBQueryWarn("delete from reserved where node_id='$vnodeid'");
DBQueryWarn("delete from nodes where node_id='$vnodeid'");
......@@ -2301,6 +2353,10 @@ sub DeleteVnodes(@)
DBQueryFatal("unlock tables");
foreach my $vnodeid (@vnodes) {
my $interface = Interface->LookupControl($vnodeid);
$interface->Delete()
if (defined($interface));
DBQueryWarn("delete from node_hostkeys where node_id='$vnodeid'");
DBQueryWarn("delete from node_status where node_id='$vnodeid'");
DBQueryWarn("delete from node_rusage where node_id='$vnodeid'");
......@@ -3076,8 +3132,24 @@ sub SetJailIPFromVnode($$$)
"*** $vnode_id has a jailip attribute but no jailipmask.\n";
return -1;
}
return $self->Update({"jailip" => $jailip,
"jailipmask" => $jailipmask});
#
# We now create interface entries for local jailed nodes, so have
# to update the entry. We still use jailip under some circumstances.
#
if (!$self->isremotenode() && !defined($self->jailip())) {
my $interface = Interface->LookupControl($self);
if (!defined($interface)) {
print STDERR "*** $vnode_id does not have a control interface\n";
return -1;
}
$interface->Update({"IP" => $jailip,
"mask" => $jailipmask})
== 0 or return -1;
}
else {
return $self->Update({"jailip" => $jailip,
"jailipmask" => $jailipmask});
}
}
return 0;
}
......
#!/usr/bin/perl -w
#
# EMULAB-COPYRIGHT
# Copyright (c) 2000-2011 University of Utah and the Flux Group.
# Copyright (c) 2000-2012 University of Utah and the Flux Group.
# All rights reserved.
#
use English;
......@@ -49,8 +49,6 @@ my $dbg = 0;
my $domx = 0;
my @row;
use strict;
# If we are disabled, just quietly exit
if ($DISABLED) {
exit 0;
......@@ -97,18 +95,17 @@ if ((my $locked = TBScriptLock("named", 1)) != TBSCRIPTLOCK_OKAY()) {
}
#
# Grab the list of all nodes, including virtual and widearea nodes
# Grab the list of all nodes with proper control network interfaces.
#
my $db_result =
DBQueryFatal("select n.node_id, n.role, n.jailip, i.IP, i.role, ".
DBQueryFatal("select n.node_id, n.role, null, i.IP, i.role, ".
" r.inner_elab_role ".
" from nodes as n join interfaces as i ".
"left join reserved as r on r.node_id=n.node_id ".
"where (n.node_id=i.node_id and n.role='testnode' or ".
" n.phys_nodeid=i.node_id and n.role='virtnode') ".
" and (i.IP is not null or n.jailip is not null) ".
" and (i.card is null or ".
" i.role='" . TBDB_IFACEROLE_CONTROL() . "')");
"where (n.node_id=i.node_id and ".
" (n.role='testnode' or n.role='virtnode')) ".
" and i.IP is not null ".
" and i.role='" . TBDB_IFACEROLE_CONTROL() . "'");
my %routable;
my %unroutable;
......@@ -116,6 +113,24 @@ my %reverse;
process_nodes($db_result);
#
# Now get the static virtnodes and older dynamic virtnodes that used
# jailip. The i2 join is to weed out the dynamic virtnodes we got in
# the above query (nodes with a dynamic control network interface).
#
$db_result =
DBQueryFatal("select n.node_id, n.role, n.jailip, i.IP, i.role, ".
" r.inner_elab_role ".
" from nodes as n ".
"left join interfaces as i on i.node_id=n.phys_nodeid ".
"left join interfaces as i2 on i2.node_id=n.node_id ".
"left join reserved as r on r.node_id=n.node_id ".
"where n.role='virtnode' and i2.card is null and ".
" (i.IP is not null or n.jailip is not null) and ".
" i.role='" . TBDB_IFACEROLE_CONTROL() . "'");
process_nodes($db_result);
#
# For IXPs we also need their gateway addresses as well
#
......
......@@ -3506,33 +3506,6 @@ COMMAND_PROTOTYPE(dohosts)
hostcount += 2;
}
#if 0
/*
* List of control net addresses for jailed nodes.
* Temporary.
*/
res = mydb_query("select r.node_id,r.vname,n.jailip "
" from reserved as r "
"left join nodes as n on n.node_id=r.node_id "
"where r.pid='%s' and r.eid='%s' "
" and jailflag=1 and jailip is not null",
3, reqp->pid, reqp->eid);
if (res) {
if ((nrows = mysql_num_rows(res))) {
while (nrows--) {
row = mysql_fetch_row(res);
OUTPUT(buf, sizeof(buf),
"NAME=%s IP=%s ALIASES='%s.%s.%s.%s'\n",
row[0], row[2], row[1], reqp->eid, reqp->pid,
OURDOMAIN);
client_writeback(sock, buf, strlen(buf), tcp);
hostcount++;
}
}
mysql_free_result(res);
}
#endif
info("HOSTNAMES: %d hosts in list\n", hostcount);
host = hosts;
while (host) {
......@@ -6716,6 +6689,7 @@ COMMAND_PROTOTYPE(dojailconfig)
MYSQL_RES *res;
MYSQL_ROW row;
char buf[MYBUFSIZE];
char jailip[TBDB_FLEN_IP], jailipmask[TBDB_FLEN_IPMASK];
char *bufp = buf, *ebufp = &buf[sizeof(buf)];
int low, high;
......@@ -6764,11 +6738,17 @@ COMMAND_PROTOTYPE(dojailconfig)
mysql_free_result(res);
/*
* Now need the sshdport and jailip for this node.
* Now need the sshdport and jailip for this node. The jailip
* slot is not deprecated, but there might still exists nodes
* created before we switched to creating real interface entries
* for jailed nodes.
*/
res = mydb_query("select sshdport,jailip,jailipmask from nodes "
"where node_id='%s'",
3, reqp->nodeid);
res = mydb_query("select n.sshdport,n.jailip,n.jailipmask,i.IP,i.mask "
" from nodes as n "
"left join interfaces as i on "
" i.node_id=n.node_id and i.role='ctrl' "
"where n.node_id='%s'",
5, reqp->nodeid);
if (!res) {
error("JAILCONFIG: %s: DB Error getting config!\n",
......@@ -6781,12 +6761,19 @@ COMMAND_PROTOTYPE(dojailconfig)
return 0;
}
row = mysql_fetch_row(res);
if (row[3]) {
strcpy(jailip, row[3]);
strcpy(jailipmask, row[4]);
}
else if (row[1]) {
strcpy(jailip, row[1]);
strcpy(jailipmask, (row[2] ? row[2] : JAILIPMASK));
}
bzero(buf, sizeof(buf));
if (row[1]) {
if (jailip[0]) {
bufp += OUTPUT(bufp, ebufp - bufp,
"JAILIP=\"%s,%s\"\n",
row[1], (row[2] ? row[2] : JAILIPMASK));
"JAILIP=\"%s,%s\"\n", jailip, jailipmask);
}
bufp += OUTPUT(bufp, ebufp - bufp,
"PORTRANGE=\"%d,%d\"\n"
......@@ -8059,9 +8046,12 @@ COMMAND_PROTOTYPE(doemulabconfig)
*/
if (reqp->isvnode && reqp->singlenet) {
res = mydb_query("select r.node_id,r.inner_elab_role,"
" n.jailip,r.vname from reserved as r "
" IFNULL(i.IP,n.jailip),r.vname "
" from reserved as r "
"left join nodes as n on "
" n.node_id=r.node_id "
"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);
......
......@@ -2,7 +2,7 @@
#
# EMULAB-COPYRIGHT
# Copyright (c) 2000-2011 University of Utah and the Flux Group.
# Copyright (c) 2000-2012 University of Utah and the Flux Group.
# All rights reserved.
#
......@@ -48,6 +48,7 @@ use lib "@prefix@/lib";
use libdb;
use libtestbed;
use Node;
use Interface;
#
# Turn off line buffering on output
......@@ -105,7 +106,16 @@ else {
exit(1);
}
}
$hostname = $node->phys_nodeid();
else {
#
# jailip is deprecated, but nodes might still exist.
# Now we create interface table entries.
#
my $interface = Interface->LookupControl($node);
if (! (defined($interface) || defined($node->jailip()))) {
$hostname = $node->phys_nodeid();
}
}
}
elsif ($node->isremotenode() && !$node->isdedicatedremote()) {
$user = "emulabman";
......
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