2
0
mirror of https://github.com/xcat2/xcat-core.git synced 2026-09-04 20:17:55 +00:00

fix(dhcp): render the Kea option flags as booleans

The option flags of a client class -- always-send and its siblings -- were
passed through as whatever the caller set, so a plain Perl 1 reached the
configuration as the number 1 and Kea refuses to parse that. The class
flag next to it is already normalised; do the same for the option data, so
callers can stay free of JSON.
This commit is contained in:
Vinícius Ferrão
2026-08-21 00:55:26 -03:00
parent 609f6febef
commit f491be35d3
+25
View File
@@ -809,10 +809,35 @@ sub _render_client_class {
delete $rendered{'only-if-required'};
$rendered{ $self->_additional_class_flag_field() } = _json_bool($additional_only)
if defined $additional_only;
$rendered{'option-data'} = _render_option_data( $rendered{'option-data'} )
if $rendered{'option-data'};
return \%rendered;
}
# Kea reads the option flags as booleans, so the callers can set them the plain
# Perl way and still produce a configuration the server parses.
sub _render_option_data {
my ($option_data) = @_;
return $option_data unless ref($option_data) eq 'ARRAY';
my @rendered;
foreach my $option (@$option_data) {
if ( ref($option) ne 'HASH' ) {
push @rendered, $option;
next;
}
my %copy = %$option;
foreach my $flag (qw/always-send csv-format never-send/) {
$copy{$flag} = _json_bool( $copy{$flag} ) if defined $copy{$flag};
}
push @rendered, \%copy;
}
return \@rendered;
}
sub _render_subnet6 {
my ( $self, $subnet ) = @_;