2
0
mirror of https://github.com/xcat2/xcat-core.git synced 2026-11-21 09:52:17 +00:00

fix(ipv6): format Kea Control Agent IPv6 URLs

(cherry picked from commit d93786c0734eac8d13ad0a66c774596f205d7b74)
Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
This commit is contained in:
Vinícius Ferrão
2026-10-21 18:59:05 -03:00
committed by Daniel Hilst
parent 273593cc7d
commit 5bc3f02e0e
2 changed files with 13 additions and 1 deletions
+3 -1
View File
@@ -747,7 +747,9 @@ sub control_agent_url {
my $host = $opts{host} || $self->{control_agent_host} || '127.0.0.1';
my $port = $opts{port} || $self->{control_agent_port} || 8000;
return "http://$host:$port/";
my $authority = xCAT::NetworkUtils->format_host_port($host, $port);
return unless $authority;
return "http://$authority/";
}
sub control_agent_command {
+10
View File
@@ -590,6 +590,16 @@ is( $ddns_config->{DhcpDdns}{'forward-ddns'}{'ddns-domains'}[0]{name}, 'cluster.
my $ctrl_agent_backend = xCAT::DHCP::Backend::Kea->new( kea_socket_dirs => [] );
my $ctrl_agent_config = decode_json($ctrl_agent_backend->render_ctrl_agent_config({ 'http-port' => '8000' }));
is( $ctrl_agent_config->{'Control-agent'}{'http-port'}, 8000, 'Control Agent HTTP port is numeric' );
is( $backend->control_agent_url(), 'http://127.0.0.1:8000/', 'Control Agent keeps the default IPv4 authority' );
SKIP: {
skip 'No IPv6 literal parser is available', 1
unless xCAT::NetworkUtils->isValidIPAddress('2001:db8::1');
is(
$backend->control_agent_url( host => '2001:db8::1', port => 8001 ),
'http://[2001:db8::1]:8001/',
'Control Agent brackets an IPv6 literal before appending the port'
);
}
my $runtime_socket_dir = "$unit_dir/run/kea";
my $legacy_runtime_socket_dir = "$unit_dir/var/run/kea";