-Implement log, ntp, dns server list processing for dhcp

git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@3004 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
This commit is contained in:
jbjohnso 2009-03-26 20:08:18 +00:00
parent a7d16674b3
commit a09d1db241
2 changed files with 63 additions and 8 deletions

View File

@ -255,13 +255,15 @@ networks => {
netname => 'Name used to identify this network definition.',
net => 'The network address.',
mask => 'The network mask.',
mgtifname => 'The interface name the dhcp server should listen on.',
mgtifname => 'The interface name of the management/service node facing this network. !remote! indicates a non-local network for relay DHCP.',
gateway => 'The network gateway.',
dhcpserver => 'The DHCP server that is servicing this network.',
tftpserver => 'The TFTP server that is servicing this network.',
dhcpserver => 'The DHCP server that is servicing this network. Required to be explicitly set for pooled service node operation.',
tftpserver => 'The TFTP server that is servicing this network. If not set, the DHCP server is assumed.',
nameservers => 'The nameservers for this network. Used in creating the DHCP network definition, and DNS configuration.',
ntpservers => 'The ntp servers for this network. Used in creating the DHCP network definition. Assumed to be the DHCP server if not set.',
logservers => 'The log servers for this network. Used in creating the DHCP network definition. Assumed to be the DHCP server if not set.',
dynamicrange => 'The IP address range used by DHCP to assign dynamic IP addresses for requests on this network.',
nodehostname => 'Not Used??',
nodehostname => 'A regular expression used to specify node name to network-specific hostname. i.e. "/\z/-secondary/" would mean that the hostname of "n1" would be n1-secondary on this network. By default, the nodename is assumed to equal the hostname, followed by nodename-interfacename.',
comments => 'Any user-written notes.',
disable => "Set to 'yes' or '1' to comment out this row.",
},

View File

@ -20,6 +20,9 @@ my $omshell;
my $statements; #Hold custom statements to be slipped into host declarations
my $callback;
my $restartdhcp;
my $sitenameservers;
my $sitentpservers;
my $sitelogservers;
my $nrhash;
my $machash;
my $iscsients;
@ -376,6 +379,19 @@ sub process_request
}
}
}
($href) = $sitetab->getAttribs({key => 'nameservers'}, 'value');
if ($href and $href->{value}) {
$sitenameservers = $href->{value};
}
($href) = $sitetab->getAttribs({key => 'ntpservers'}, 'value');
if ($href and $href->{value}) {
$sitentpservers = $href->{value};
}
($href) = $sitetab->getAttribs({key => 'logservers'}, 'value');
if ($href and $href->{value}) {
$sitelogservers = $href->{value};
}
($href) = $sitetab->getAttribs({key => 'domain'}, 'value');
($href) = $sitetab->getAttribs({key => 'domain'}, 'value');
unless ($href and $href->{value})
{
@ -598,6 +614,22 @@ sub process_request
}
}
sub putmyselffirst {
my $srvlist = shift;
if ($srvlist =~ /,/) { #TODO: only reshuffle when requested, or allow opt out of reshuffle?
my @dnsrvs = split /,/,$srvlist;
my @reordered;
foreach (@dnsrvs) {
if (xCAT::Utils->thishostisnot($_)) {
push @reordered,$_;
} else {
unshift @reordered,$_;
}
}
$srvlist = join(', ',@reordered);
}
return $srvlist;
}
sub addnet
{
my $net = shift;
@ -643,6 +675,8 @@ sub addnet
# if here, means we found the idx before which to insert
my $nettab = xCAT::Table->new("networks");
my $nameservers;
my $ntpservers;
my $logservers;
my $gateway;
my $tftp;
my $range;
@ -652,21 +686,40 @@ sub addnet
{
my ($ent) =
$nettab->getAttribs({net => $net, mask => $mask},
qw(tftpserver nameservers gateway dynamicrange dhcpserver));
qw(tftpserver nameservers ntpservers logservers gateway dynamicrange dhcpserver));
if ($ent and $ent->{ntpservers}) {
$ntpservers = $ent->{ntpservers};
} elsif ($sitentpservers) {
$ntpservers = $sitentpservers;
}
if ($ent and $ent->{logservers}) {
$logservers = $ent->{logservers};
} elsif ($sitelogservers) {
$logservers = $sitelogservers;
}
if ($ent and $ent->{nameservers})
{
$nameservers = $ent->{nameservers};
}
else
{
if ($sitenameservers) {
$nameservers = $sitenameservers;
} else {
$callback->(
{
warning => [
"No $net specific entry for nameservers, and dhcp plugin not sourcing from site yet (TODO)"
"No $net specific entry for nameservers, and no nameservers defined in site table."
]
}
);
}
}
$nameservers=putmyselffirst($nameservers);
$ntpservers=putmyselffirst($nameservers);
$logservers=putmyselffirst($nameservers);
if ($ent and $ent->{tftpserver})
{
$tftp = $ent->{tftpserver};
@ -743,10 +796,10 @@ sub addnet
{
push @netent, " next-server $tftp;\n";
}
if ($myip){
if ($myip){
push @netent, " option log-servers $myip;\n";
push @netent, " option ntp-servers $myip;\n";
}
}
push @netent, " option domain-name \"$domain\";\n";
if ($nameservers)
{