mirror of
https://github.com/xcat2/xcat-core.git
synced 2026-10-22 07:38:08 +00:00
128e7fe197
The global Kea classes give the upstream loader to an x86 client that cannot fetch its script, and the Etherboot class gives it the BIOS loader. The network classes and the ISC x86 lines give the Genesis script under xcat/ipxe/nets to a client with the iPXE features of its path, and the Kea subnet lists those classes. Without an upstream loader file on the server, neither backend names it or the second stage that it would fetch, and the ISC lines stop such a client before the fallback. The xNBA files name no global class. An xnba node gets xNBA from its own first-stage classes when the server has the xNBA BIOS file, and still xcat/xnba.efi without the local UEFI file. Without the xNBA BIOS file it has no first-stage classes, as it has no ISC host statements. An ipxe node without a SAN disk carries the upstream loader in its own first-stage classes. The ISC configuration test also checks these lines in configurations that makedhcp upgraded, one of them with indented declarations. The DHCP wire cases now expect the upstream loader for an x86 client with no reservation, and its network script for a second stage that reports the features in option 175. A second stage without them gets the loader again, and an xnba node still gets xNBA.
71 lines
2.6 KiB
Perl
71 lines
2.6 KiB
Perl
#!/usr/bin/env perl
|
|
use strict;
|
|
use warnings;
|
|
|
|
use FindBin;
|
|
use lib "$FindBin::Bin/../../perl-xCAT";
|
|
|
|
use File::Spec;
|
|
use File::Temp qw(tempdir);
|
|
use Test::More;
|
|
use xCAT::DHCP::BootPolicy;
|
|
|
|
my ($dhcpd) = grep { -x $_ } qw(/usr/sbin/dhcpd /usr/local/sbin/dhcpd);
|
|
plan skip_all => 'dhcpd is required for ISC configuration validation' unless $dhcpd;
|
|
plan skip_all => 'root is required to validate from the ISC configuration directory'
|
|
unless $> == 0;
|
|
|
|
my @header = (
|
|
"#xCAT generated dhcp configuration\n",
|
|
"\n",
|
|
"option conf-file code 209 = text;\n",
|
|
"option space gpxe;\n",
|
|
"option gpxe-encap-opts code 175 = encapsulate gpxe;\n",
|
|
"option gpxe.bus-id code 177 = string;\n",
|
|
@{ xCAT::DHCP::BootPolicy->isc_ipxe_feature_option_lines() },
|
|
"option user-class-identifier code 77 = string;\n",
|
|
"option client-architecture code 93 = unsigned integer 16;\n",
|
|
"option www-server code 114 = string;\n",
|
|
"default-lease-time 600;\n",
|
|
"max-lease-time 600;\n",
|
|
);
|
|
|
|
# makedhcp without -n adds the iPXE feature options to the header that an older makedhcp -n wrote.
|
|
my %feature = map { $_ => 1 } @{ xCAT::DHCP::BootPolicy->isc_ipxe_feature_option_lines() };
|
|
my @upgraded = grep { !$feature{$_} } @header;
|
|
my @indented = map { /^option / ? " $_" : $_ } @upgraded;
|
|
xCAT::DHCP::BootPolicy->isc_declare_ipxe_features($_) for \@upgraded, \@indented;
|
|
|
|
my @subnet = (
|
|
"subnet 192.0.2.0 netmask 255.255.255.0 {\n",
|
|
" range 192.0.2.100 192.0.2.110;\n",
|
|
@{ xCAT::DHCP::BootPolicy->isc_client_architecture_lines(
|
|
next_server => '192.0.2.1',
|
|
portsuffix => '',
|
|
net => '192.0.2.0',
|
|
prefix => 24,
|
|
) },
|
|
"}\n",
|
|
);
|
|
|
|
# The PXE class names all three lease bounds rather than a maximum alone.
|
|
# dhcpd is the only thing that can say whether it accepts them in class scope.
|
|
push @subnet, @{ xCAT::DHCP::BootPolicy->isc_pxe_lease_class_lines() };
|
|
|
|
my $configuration_root = -d '/etc/dhcp' ? '/etc/dhcp' : '/etc';
|
|
my $directory = tempdir(DIR => $configuration_root, CLEANUP => 1);
|
|
for my $case ( [ 'a new configuration', \@header ], [ 'an upgraded configuration', \@upgraded ],
|
|
[ 'an upgraded configuration with indented declarations', \@indented ] )
|
|
{
|
|
my ( $label, $lines ) = @$case;
|
|
my $path = File::Spec->catfile($directory, 'dhcpd.conf');
|
|
open(my $config_file, '>', $path) or die "Cannot create $path: $!";
|
|
print {$config_file} @$lines, @subnet;
|
|
close($config_file) or die "Cannot close $path: $!";
|
|
|
|
my $status = system($dhcpd, '-t', '-cf', $path);
|
|
is($status, 0, "ISC accepts the boot policy and the PXE lease class in $label");
|
|
}
|
|
|
|
done_testing();
|