From f491be35d32dd4df041774fd03ac810d56c08e86 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vin=C3=ADcius=20Ferr=C3=A3o?= <2031761+viniciusferrao@users.noreply.github.com> Date: Fri, 21 Aug 2026 00:55:26 -0300 Subject: [PATCH] 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. --- perl-xCAT/xCAT/DHCP/Backend/Kea.pm | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/perl-xCAT/xCAT/DHCP/Backend/Kea.pm b/perl-xCAT/xCAT/DHCP/Backend/Kea.pm index 23524afaa..b6a48cc06 100644 --- a/perl-xCAT/xCAT/DHCP/Backend/Kea.pm +++ b/perl-xCAT/xCAT/DHCP/Backend/Kea.pm @@ -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 ) = @_;