All new accounts created on Gitlab now require administrator approval. If you invite any collaborators, please let Flux staff know so they can approve the accounts.

Commit 1d2fa1a9 authored by Ryan Jackson's avatar Ryan Jackson

Add support for subbosses to dhcpd_makeconf

Make sure we correctly handle subbosses by:
A) ignoring nodes which are assigned to other dhcp servers
B) correctly specifying the next-server and bootinfo options
   if boss is still the dhcp server and other subbosses are to
   handle those duties.
parent 236f7d79
......@@ -41,7 +41,7 @@ delete @ENV{'IFS', 'CDPATH', 'ENV', 'BASH_ENV'};
# Turn off line buffering on output
$| = 1;
use lib "@prefix@/lib";
use lib "/usr/testbed/lib";
use libdb;
use libtestbed;
use NodeType;
......@@ -50,6 +50,9 @@ my $CRTLTAG = TBDB_IFACEROLE_CONTROL();
my $DHCPD_CONF = "/usr/local/etc/dhcpd.conf";
my $DHCPD_TEMPLATE = "/usr/local/etc/dhcpd.conf.template";
my %servernodes = ();
my %dhcp_subbosses = ();
my %tftp_subbosses = ();
my %bootinfo_subbosses = ();
my %singlectlnet = ();
my $template = $DHCPD_TEMPLATE;
my $outfile = "/tmp/dhcpd_makeconf.$$";
......@@ -155,6 +158,28 @@ while (my %row = $query_result->fetchhash()) {
}
}
# Slurp in all of the subboss data to know A) if we should serve the DHCP
# lease to a given node, or if the next-server field should be something
# other than the IP for boss.
$query_result =
DBQueryWarn("select s.node_id, s.service, s.subboss_id, i.IP ".
"from subbosses as s left join interfaces as i on ".
"s.subboss_id=i.node_id where i.role='$CRTLTAG'");
if (! $query_result) {
fatal("Could not dhcpd data from DB!");
}
while (my %row = $query_result->fetchhash()) {
my $node_id = $row{"node_id"};
if ($row{"service"} eq 'tftp') {
$tftp_subbosses{$node_id} = $row{"IP"};
} elsif ($row{"service"} eq 'dhcp') {
$dhcp_subbosses{$node_id} = $row{"IP"};
} elsif ($row{"service"} eq 'bootinfo') {
$bootinfo_subbosses{$node_id} = $row{"IP"};
}
}
open(IF,"<$template") or
fatal("Unable to open $template for reading");
while (<IF>) {
......@@ -239,47 +264,25 @@ while (<IF>) {
}
}
}
elsif (defined $dhcp_subbosses{$node_id}) {
$hostname =
"${spaces}\toption host-name \"$node_id\";\n";
$booting = "${spaces}\tignore booting;\n";
}
else {
$hostname =
"${spaces}\toption host-name \"$node_id\";\n";
my $query_result =
DBQueryWarn( "(select attrvalue from " .
"node_attributes where node_id = '$node_id' " .
" and attrkey = 'tftp_server' ) union " .
"(select attrvalue from " .
"node_type_attributes where type = " .
"'$nodetype' " .
" and attrkey = 'tftp_server') limit 1" );
if (! $query_result) {
fatal("Could not get tftp_server data from DB!");
}
if (my %row = $query_result->fetchhash()) {
my $tftp_server = $row{'attrvalue'};
$next_server = "${spaces}\tnext-server " .
$tftp_server . ";\n";
}
if (defined $tftp_subbosses{$node_id}) {
$next_server = "${spaces}\tnext-server " .
$tftp_subbosses{$node_id} . ";\n";
}
$query_result =
DBQueryWarn( "(select attrvalue from " .
"node_attributes where node_id = '$node_id' " .
" and attrkey = 'bootinfo_server' ) union " .
"(select attrvalue from " .
"node_type_attributes where type = " .
"'$nodetype' " .
" and attrkey = 'bootinfo_server') limit 1" );
if (! $query_result) {
fatal("Could not get bootinfo_server data from DB!");
}
if (defined $bootinfo_subbosses{$node_id}) {
$bootinfo_server = "${spaces}\toption PXE.emulab-bootinfo " .
$bootinfo_subbosses{$node_id} . ";\n";
}
if (my %row = $query_result->fetchhash()) {
$bootinfo_server = "${spaces}\toption " .
"PXE.emulab-bootinfo " .
$row{'attrvalue'} . ";\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