...
 
Commits (2)
......@@ -241,6 +241,8 @@ AC_SUBST(OPSVM_MOUNTPOINT)
AC_SUBST(PORTAL_ENABLE)
AC_SUBST(PORTAL_ISPRIMARY)
AC_SUBST(LINUX_FSNODE)
AC_SUBST(VPUBADDR_BASE)
AC_SUBST(VPUBADDR_BITLEN)
#
# Offer both versions of the email addresses that have the @ escaped
......@@ -351,6 +353,8 @@ PORTAL_ENABLE=0
PORTAL_ISPRIMARY=0
LINUX_FSNODE=0
DHCPD_EXTRAIFS=""
VPUBADDR_BASE="none"
VPUBADDR_BITLEN="none"
#
# XXX You really don't want to change these!
......
......@@ -2099,7 +2099,8 @@ sub CreateVnodes($$$)
# those. Must do this with tables locked, of course.
#
DBQueryFatal("lock tables nodes write, reserved write, ".
"node_status write, node_hostkeys write");
"node_status write, node_hostkeys write, ".
"virt_node_public_addr write, virt_node_attributes read");
#
# Reload the reservation status now that tables are locked and confirm
......@@ -2170,7 +2171,7 @@ sub CreateVnodes($$$)
foreach my $n (@tocreate) {
my $vpriority = 10000000 + ($ipbase * 1000) + $n;
my $vnodeid = $nodeprefix . "vm" . $nodenum . "-" . $n;
my $jailip;
my ( $jailip, $jailmask );
if ($isjailed) {
#
......@@ -2183,14 +2184,41 @@ sub CreateVnodes($$$)
# nodenum=201 and I would like our vnode IPs to align
# at that boundary, so 254 becomes 200.
#
my $nodenumlimit = $ISUTAH ? 200 : 254;
my $pnet = $IPBASE2;
my $pnode2 = int($ipbase);
while ($pnode2 > $nodenumlimit) {
$pnet++;
$pnode2 -= $nodenumlimit;
my $vname = $options->{'vlist'}->[ $n - 1 ];
$query_result =
DBQueryWarn( "SELECT attrvalue FROM virt_node_attributes " .
"WHERE pid='$pid' AND eid='$eid' AND " .
"vname='$vname' AND " .
"attrkey='routable_control_ip'" );
if( $query_result && $query_result->numrows &&
( $query_result->fetchrow_array() )[ 0 ] eq "true" ) {
$query_result =
DBQueryWarn( "SELECT IP, mask FROM virt_node_public_addr ".
"WHERE node_id IS NULL" );
if (!$query_result || !$query_result->numrows ) {
print STDERR "*** CreateVnodes: no free public address\n";
goto bad;
}
( $jailip, $jailmask ) = $query_result->fetchrow_array();
DBQueryFatal( "UPDATE virt_node_public_addr SET " .
"node_id='$vnodeid', card='0', port='1' " .
"WHERE IP='$jailip'" );
} else {
my $nodenumlimit = $ISUTAH ? 200 : 254;
my $pnet = $IPBASE2;
my $pnode2 = int($ipbase);
while ($pnode2 > $nodenumlimit) {
$pnet++;
$pnode2 -= $nodenumlimit;
}
$jailip = "${IPBASE1}.${pnet}.${pnode2}.${n}";
$jailmask = $JAILIPMASK;
}
$jailip = "${IPBASE1}.${pnet}.${pnode2}.${n}";
}
# Need to keep the UUIDs consistent across regression mode.
......@@ -2318,7 +2346,7 @@ sub CreateVnodes($$$)
"role" => TBDB_IFACEROLE_CONTROL(),
"MAC" => "000000000000",
"IP" => $jailip,
"mask" => $JAILIPMASK,
"mask" => $jailmask,
"type" => "generic",
"logical" => 1,
};
......@@ -2402,9 +2430,13 @@ sub DeleteVnodes(@)
foreach my $vnodeid (@vnodes) {
my $interface = Interface->LookupControl($vnodeid);
$interface->Delete()
if (defined($interface));
if( defined( $interface ) ) {
my $addr = $interface->IP();
DBQueryWarn( "UPDATE virt_node_public_addr SET node_id=NULL, " .
"card='0', port='0' WHERE IP='$addr'" );
$interface->Delete();
}
DBQueryWarn("delete from node_bootlogs where node_id='$vnodeid'");
DBQueryWarn("delete from node_hostkeys where node_id='$vnodeid'");
DBQueryWarn("delete from node_status where node_id='$vnodeid'");
......@@ -3190,13 +3222,23 @@ sub GetJailIP($;$)
print STDERR "*** GetJailIP: Bad ipbase '$ipbase' for $interface\n";
return undef;
}
my $nodenumlimit = $ISUTAH ? 200 : 254;
my $pnet = $IPBASE2;
my $pnode2 = int($ipbase);
while ($pnode2 > $nodenumlimit) {
$pnet++;
$pnode2 -= $nodenumlimit;
my $node_id = $self->node_id();
my $query_result =
DBQueryWarn( "SELECT IP, mask FROM virt_node_public_addr WHERE " .
"node_id='$node_id' AND card='0' AND port='1'" );
if( $query_result && $query_result->numrows ) {
# we've assigned a public address to this one
return $query_result->fetchrow_array();
} else {
my $nodenumlimit = $ISUTAH ? 200 : 254;
my $pnet = $IPBASE2;
my $pnode2 = int($ipbase);
while ($pnode2 > $nodenumlimit) {
$pnet++;
$pnode2 -= $nodenumlimit;
}
}
return ("${IPBASE1}.${pnet}.${pnode2}.${num}", $JAILIPMASK);
}
......
......@@ -127,6 +127,8 @@ PUBLIC_ROUTER=155.98.33.1
PUBLIC_NETMASK=255.255.255.0
DHCPD_DYNRANGE="155.98.36.200 155.98.36.249"
NAMED_FORWARDERS=""
VPUBADDR_BASE=none
VPUBADDR_BITLEN=none
#
# Google Maps API key, for user map
......
......@@ -280,6 +280,14 @@ VIRTNODE_NETMASK=255.240.0.0
JAILIPBASE=$VIRTNODE_NETWORK
JAILIPMASK=$VIRTNODE_NETMASK
# Dynamic public addresses for virtual nodes. Leave as "none" if you don't
# have public IP addresses to spare, otherwise define to an otherwise
# unused block of addresses that will be given out to virtual nodes asking
# for routable control net interfaces (instead of the VIRTNODE_NETWORK
# block they'd otherwise get).
VPUBADDR_BASE=none
VPUBADDR_BITLEN=none
#
# Selective disable of a couple of features.
#
......
#
# Add a table of public IP addresses to assign to vnodes
#
use strict;
use libdb;
sub DoUpdate($$$)
{
my ($dbhandle, $dbname, $version) = @_;
if( !DBTableExists( "virt_node_public_addr" ) ) {
DBQueryFatal( "CREATE TABLE `virt_node_public_addr` ( " .
" `IP` varchar(15) default NULL, " .
" `mask` varchar(15) default NULL, " .
" `node_id` varchar(32) default NULL, " .
" `card` tinyint(3) unsigned default '0', " .
" `port` tinyint(3) unsigned default '0', " .
" PRIMARY KEY (`IP`) " .
") ENGINE=MyISAM DEFAULT CHARSET=latin1" );
}
return 0;
}
1;
# Local Variables:
# mode:perl
# End:
......@@ -1720,7 +1720,8 @@ foreach my $pnode (sort(keys(%virtnodes))) {
"nodeid" => $pnode,
"verbose" => $verbose,
"regression" => $regression,
"impotent" => $impotent}) < 0) {
"impotent" => $impotent,
"vlist" => \@vlist }) < 0) {
fatal("Could not allocate vnodes on $pnode");
}
}
......
......@@ -5022,6 +5022,7 @@ sub AllocVirtNodes($)
"sharedokay" => $sharedokay,
"regression" => $self->regression(),
"user" => $self->user(),
"vlist" => \@vlist
})
< 0) {
tberror("Could not allocate vnodes on $physical\n");
......
......@@ -5097,6 +5097,7 @@ sub AllocVirtNodes($)
"sharedokay" => $sharedokay,
"regression" => $self->regression(),
"user" => $self->user(),
"vlist" => \@vlist
})
< 0) {
tberror("Could not allocate vnodes on $physical\n");
......
......@@ -29,7 +29,8 @@ SBIN_SCRIPTS = vlandiff vlansync withadminprivs export_tables cvsupd.pl \
archive-expinfo grantfeature emulabfeature addblob readblob \
prereserve grantimage getimages localize_mfs \
management_iface sharevlan check-shared-bw \
addspecialdevice addspecialiface imagehash clone_image
addspecialdevice addspecialiface imagehash clone_image \
addvpubaddr
WEB_SBIN_SCRIPTS= webnewnode webdeletenode webspewconlog webarchive_list \
webwanodecheckin webspewimage
......
#!/usr/bin/perl -w
#
# EMULAB-COPYRIGHT
# Copyright (c) 2012 University of Utah and the Flux Group.
# All rights reserved.
#
use English;
use strict;
use Socket;
#
# Configure variables
#
my $TB = "@prefix@";
#
# Turn off line buffering on output
#
$| = 1;
#
# Untaint the path
#
$ENV{'PATH'} = "$TB/bin:$TB/sbin:/bin:/usr/bin:/sbin:/usr/sbin";
delete @ENV{'IFS', 'CDPATH', 'ENV', 'BASH_ENV'};
#
# Testbed Support libraries
#
use lib "@prefix@/lib";
use libdb;
use libtestbed;
#
# Handle command-line options.
#
sub usage() {
print STDERR "Usage: $0 aaa.bbb.ccc.ddd/ee [mmm.nnn.ooo.ppp]\n" .
" where aaa.bbb.ccc.ddd is the prefix of the addresses to add,\n" .
" ee is the bit-length of the prefix,\n" .
" and mmm.nnn.ooo.ppp is the optional netmask to apply\n" .
" (default is derived from prefix length).\n";
exit( 1 );
}
usage() unless @ARGV == 1 || @ARGV == 2;
my $pattern = $ARGV[ 0 ];
my ( $mask, $base, $masklen );
if( $pattern =~ /^([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)\/([0-9]+)$/ ) {
$base = $1;
$masklen = $2;
} else {
usage();
}
if( @ARGV == 1 ) {
my $derived_mask = 0xFFFFFFFF - ( 0xFFFFFFFF >> $masklen );
my $mask_addr = pack( "N", $derived_mask );
$mask = inet_ntoa( $mask_addr );
} else {
$mask = $ARGV[ 1 ];
}
my $first = unpack( "N", inet_aton( $base ) );
my $last = $first | ( 0xFFFFFFFF >> ( $masklen ) );
my $i;
for( $i = $first; $i <= $last; $i++ ) {
my $addr = inet_ntoa( pack( "N", $i ) );
DBQueryWarn( "INSERT INTO virt_node_public_addr SET " .
"IP='$addr', mask='$mask'" );
}
exit( 0 );