Commit 5b7f0a09 authored by Kirk Webb's avatar Kirk Webb

Merge branch 'external-management'

parents 58f426d2 bf929ce1
......@@ -69,6 +69,12 @@ use lib "@prefix@/lib";
use libdb;
use libtestbed;
use Node;
use Experiment;
use EmulabFeatures;
use EmulabConstants;
# Tell EmulabFeatures to take it down a notch.
$EmulabFeatures::verbose = 0;
#
# PXE boot constants
......@@ -92,6 +98,7 @@ my %dhcp_subbosses = ();
my %tftp_subbosses = ();
my %bootinfo_subbosses = ();
my %singlectlnet = ();
my %extman_cache = ();
my $template = $DHCPD_TEMPLATE;
my $outfile = "/tmp/dhcpd_makeconf.$$";
my $OUT = *STDOUT;
......@@ -278,6 +285,8 @@ while (<IF>) {
my $dns = "";
my $booting = "";
my $filename = "";
my $tag;
my $extman = 0;
if ($vnames && defined($row{"vname"})) {
$node_id = $row{"vname"};
......@@ -285,7 +294,37 @@ while (<IF>) {
else {
$node_id = $row{"node_id"};
}
#
# Grab some information for nodes that are
# currently reserved to an experiment. In
# addition to setting a simple tag for further
# lookups below, check to see if a node's current
# experiment is swapping in AND is marked for
# external management. This state is used below in
# determining whether or not to disable a node in
# the dhcp config file. Keep a cache of this
# experiment-level info so that we don't have to
# hit the DB for each and every node.
#
if (defined($row{"pid"})) {
$tag = $row{"pid"} . ":" . $row{"eid"};
if (!exists($extmanaged{$tag})) {
my $experiment = Experiment->Lookup($row{"pid"},
$row{"eid"});
$extman = $extman_cache{$tag} =
defined($experiment) &&
EmulabFeatures->FeatureEnabled(
"ExternalNodeManagement", undef, undef,
$experiment) &&
$experiment->state() eq EXPTSTATE_ACTIVATING();
}
else {
$extman = $extman_cache{$tag};
}
}
# Management ports, nothing special to do.
if ($role eq TBDB_IFACEROLE_MANAGEMENT()) {
my $network = inet_ntoa(inet_aton($ip) &
......@@ -305,11 +344,22 @@ while (<IF>) {
goto spit;
}
my $tag;
if (defined($row{"pid"})) {
$tag = $row{"pid"} . ":" . $row{"eid"};
#
# Neuter dhcp nodes reserved to experiments which
# are marked for external node management. Some
# other entity will be responsible for
# bootstrapping them in this case.
#
if ($extman) {
$hostname = "${spaces}\toption host-name ".
"\"$node_id\";\n";
$booting = "${spaces}\tignore booting;\n";
goto spit;
}
#
# Do different stuff for elabinelab / plab nodes.
#
if (defined($tag) && defined($servernodes{$tag}) &&
(($row{"inner_elab_boot"} == 1 &&
defined($row{"inner_elab_role"}) &&
......@@ -341,6 +391,9 @@ while (<IF>) {
}
}
}
#
# Defer to subbosses for dhcp and/or tftp if delegated.
#
elsif (defined $dhcp_subbosses{$node_id}) {
$hostname =
"${spaces}\toption host-name \"$node_id\";\n";
......@@ -350,6 +403,9 @@ while (<IF>) {
$tftp_subbosses{$node_id} . ";\n";
}
}
#
# The default case: just a plain old TB node.
#
else {
$hostname =
"${spaces}\toption host-name \"$node_id\";\n";
......
......@@ -49,6 +49,7 @@ my $partial = 0;
my $TB = "@prefix@";
my $consetup = "$TB/libexec/console_setup";
my $exportsetup = "$TB/sbin/exports_setup";
my $makeconf = "$TB/sbin/dhcpd_makeconf";
#
# Testbed Support libraries
......@@ -60,6 +61,7 @@ use Experiment;
use Project;
use User;
use Node;
use EmulabFeatures;
#
# Turn off line buffering on output
......@@ -294,6 +296,18 @@ if ($need_consetup && !$error && @nodes) {
TBDebugTimeStamp("nalloc finished console setup");
}
$EmulabFeatures::verbose = 0;
if (EmulabFeatures->FeatureEnabled("ExternalNodeManagement",
undef, undef,
$experiment)) {
print "ExternalNodeManagement feature is set: Disabling Emulab ".
"management of nodes in $experiment ...\n";
# Shut off dhcp response for nodes in this experiment.
if (system("$makeconf -i -r")) {
print STDERR "WARNING: Failed to reconfigure dhcp!\n";
}
}
#
# Exit with -1 if an error, else the number of nodes that could not
# be allocated.
......
......@@ -67,6 +67,7 @@ use Experiment;
use Node;
use OSinfo;
use Lan;
use EmulabFeatures;
# Local stuff
my $consetup = "$TB/libexec/console_setup";
......@@ -206,6 +207,17 @@ else {
}
}
#
# Trigger a remake of the dhcpd.conf file for any experiment marked
# with the ExternalNodeManagement feature.
#
$EmulabFeatures::verbose = 0;
if (EmulabFeatures->FeatureEnabled("ExternalNodeManagement",
undef, undef,
$experiment)) {
$mustmakeconf = 1;
}
#
# Sanity check. Do not want to release nodes if they have ports that
# are trunked or disabled. Means something went wrong elsewhere and
......
......@@ -79,6 +79,9 @@ use User;
use Node;
use EmulabFeatures;
# Simmer down EmulabFeatures!
$EmulabFeatures::verbose = 0;
# Is this needed any longer?
my $dolastload = 0;
......@@ -398,6 +401,15 @@ while (1) {
$count++;
}
# XXX: Poke at stated to move along nodes that are going to be
# externally managed. This feels kind of kludgy.
if (EmulabFeatures->FeatureEnabled("ExternalNodeManagement",
undef, undef, $experiment)) {
foreach my $node (@nodes) {
$node->SetEventState(TBDB_NODESTATE_BOOTING());
}
}
# And wait.
print STDERR "Waiting for nodes ...\n";
$MyStruct->WaitForNodes(@nodes);
......
......@@ -1024,6 +1024,21 @@ sub doSwapin($) {
return 1;
}
}
#
# Check for feature to back off and let something else manage the
# nodes in the experiment. Unconditionally mark the experiment since
# this feature is most likely to come from the swapper or project.
# Need to do this before nalloc is called by the mapper.
#
if (EmulabFeatures->FeatureEnabled("ExternalNodeManagement",
$this_user,
$group,
$experiment)) {
TBDebugTimeStamp("ExternalNodeManagement feature is set.");
EmulabFeatures->Lookup("ExternalNodeManagement")->
Enable($experiment);
}
print "Mapping to physical reality ...\n";
TBDebugTimeStamp("mapper wrapper started");
......
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