Commit 70ce5b04 authored by Leigh B. Stoller's avatar Leigh B. Stoller
Browse files

Fixes to how we name and assign IPs to dynamic virtual nodes; not

everyone names their nodes pcXXX ...
parent 979442f3
...@@ -22,6 +22,9 @@ my $OSSELECT = "$TB/bin/os_select"; ...@@ -22,6 +22,9 @@ my $OSSELECT = "$TB/bin/os_select";
# XXX stinky hack detection # XXX stinky hack detection
my $ISUTAH = @TBMAINSITE@; my $ISUTAH = @TBMAINSITE@;
# Need this for jail ip assignment.
my $CONTROL_NETMASK = "@CONTROL_NETMASK@";
# Must come after package declaration! # Must come after package declaration!
use lib '@prefix@/lib'; use lib '@prefix@/lib';
use libdb; use libdb;
...@@ -31,6 +34,7 @@ require Interface; ...@@ -31,6 +34,7 @@ require Interface;
require Experiment; require Experiment;
require OSinfo; require OSinfo;
use English; use English;
use Socket;
use Data::Dumper; use Data::Dumper;
use overload ('""' => 'Stringify'); use overload ('""' => 'Stringify');
if ($EVENTSYS) { if ($EVENTSYS) {
...@@ -1282,6 +1286,12 @@ sub CreateVnodes($$) ...@@ -1282,6 +1286,12 @@ sub CreateVnodes($$)
my $vtype = $options->{'vtype'}; my $vtype = $options->{'vtype'};
my $pnode = $options->{'nodeid'}; my $pnode = $options->{'nodeid'};
my $node = Node->Lookup($pnode);
if (!defined($node)) {
print STDERR "*** CreateVnodes: No such node $pnode!\n";
return -1;
}
my $experiment = Experiment->Lookup($pid, $eid); my $experiment = Experiment->Lookup($pid, $eid);
if (!defined($experiment)) { if (!defined($experiment)) {
print STDERR "*** CreateVnodes: No such experiment $pid/$eid!\n"; print STDERR "*** CreateVnodes: No such experiment $pid/$eid!\n";
...@@ -1310,14 +1320,37 @@ sub CreateVnodes($$) ...@@ -1310,14 +1320,37 @@ sub CreateVnodes($$)
# #
my $nodeprefix; my $nodeprefix;
my $nodenum; my $nodenum;
my $ipbase;
if ($pnode =~ /^(.*\D)(\d+)$/) { if ($pnode =~ /^(.*\D)(\d+)$/) {
$nodeprefix = $1; $nodeprefix = $1;
$nodenum = $2; $nodenum = $2;
$ipbase = $nodenum;
} }
else { else {
print STDERR "*** CreateVnodes: Unexpected nodeid '$pnode'\n"; $nodeprefix = $pnode;
$nodenum = "";
#
# Determine ipbase from the control IP.
#
my $interface = Interface->LookupControl($node);
if (!defined($interface)) {
print STDERR "*** CreateVnodes: No control interface for $node\n";
return -1;
}
my $ctrlip = $interface->IP();
if (!defined($ctrlip) || $ctrlip eq "") {
print STDERR "*** CreateVnodes: No control IP for $interface\n";
return -1; return -1;
} }
my $tmp = ~inet_aton($CONTROL_NETMASK) & inet_aton($ctrlip);
$ipbase = unpack("N", $tmp);
if ($ipbase == 0 || $ipbase < 0 || $ipbase > 0x3fff) {
print STDERR
"*** CreateVnodes: Bad ipbase '$ipbase' for $interface\n";
return -1;
}
}
# #
# Need the opmode, which comes from the OSID, which is in the node_types # Need the opmode, which comes from the OSID, which is in the node_types
...@@ -1408,7 +1441,7 @@ sub CreateVnodes($$) ...@@ -1408,7 +1441,7 @@ sub CreateVnodes($$)
# Create a bunch. # Create a bunch.
# #
foreach my $i (@tocreate) { foreach my $i (@tocreate) {
my $vpriority = 10000000 + ($nodenum * 1000) + $i; my $vpriority = 10000000 + ($ipbase * 1000) + $i;
my $vnodeid = $nodeprefix . "vm" . $nodenum . "-" . $i; my $vnodeid = $nodeprefix . "vm" . $nodenum . "-" . $i;
# #
...@@ -1423,7 +1456,7 @@ sub CreateVnodes($$) ...@@ -1423,7 +1456,7 @@ sub CreateVnodes($$)
# #
my $nodenumlimit = $ISUTAH ? 200 : 254; my $nodenumlimit = $ISUTAH ? 200 : 254;
my $pnet = $IPBASE2; my $pnet = $IPBASE2;
my $pnode2 = int($nodenum); my $pnode2 = int($ipbase);
while ($pnode2 > $nodenumlimit) { while ($pnode2 > $nodenumlimit) {
$pnet++; $pnet++;
$pnode2 -= $nodenumlimit; $pnode2 -= $nodenumlimit;
...@@ -1431,6 +1464,7 @@ sub CreateVnodes($$) ...@@ -1431,6 +1464,7 @@ sub CreateVnodes($$)
my $jailip = "${IPBASE1}.${pnet}.${pnode2}.${i}"; my $jailip = "${IPBASE1}.${pnet}.${pnode2}.${i}";
if ($verbose) { if ($verbose) {
print "Jail IP for $vnodeid is $jailip\n";
if ($impotent) { if ($impotent) {
print "Would allocate $vnodeid on $pnode ($vtype, $osid)\n"; print "Would allocate $vnodeid on $pnode ($vtype, $osid)\n";
} }
......
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