From 0c4121d69384dd00a1101055f6e4f84ac42140df Mon Sep 17 00:00:00 2001 From: Christian Stein Date: Thu, 18 Jun 2020 10:14:01 +0200 Subject: [PATCH] Fixex multiple endpoint handling and IP conversion with Director Self Service Fixes #70 --- .../misc/Convert-IcingaDirectorSelfServiceArguments.psm1 | 4 ++-- .../icingaagent/misc/Start-IcingaAgentInstallWizard.psm1 | 8 +++++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/core/icingaagent/misc/Convert-IcingaDirectorSelfServiceArguments.psm1 b/lib/core/icingaagent/misc/Convert-IcingaDirectorSelfServiceArguments.psm1 index b57a4273..cac08e38 100644 --- a/lib/core/icingaagent/misc/Convert-IcingaDirectorSelfServiceArguments.psm1 +++ b/lib/core/icingaagent/misc/Convert-IcingaDirectorSelfServiceArguments.psm1 @@ -59,12 +59,12 @@ function Convert-IcingaDirectorSelfServiceArguments() $NetworkDefault += [string]::Format('[{0}]:{1},', $Endpoint, $JsonInput.agent_listen_port); } if ([string]::IsNullOrEmpty($NetworkDefault) -eq $FALSE) { - $NetworkDefault = $NetworkDefault.Substring(0, $NetworkDefault.Length - 1); + $NetworkDefault = $NetworkDefault.Substring(0, $NetworkDefault.Length - 1).Split(','); $DirectorArguments.Add( 'EndpointConnections', $NetworkDefault ); - $EndpointConnections = $NetworkDefault.Split(','); + $EndpointConnections = $NetworkDefault; $DirectorArguments.Add( 'CAEndpoint', (Get-IPConfigFromString $EndpointConnections[0]).address ); diff --git a/lib/core/icingaagent/misc/Start-IcingaAgentInstallWizard.psm1 b/lib/core/icingaagent/misc/Start-IcingaAgentInstallWizard.psm1 index 503161a2..e6ecaf09 100644 --- a/lib/core/icingaagent/misc/Start-IcingaAgentInstallWizard.psm1 +++ b/lib/core/icingaagent/misc/Start-IcingaAgentInstallWizard.psm1 @@ -310,7 +310,7 @@ function Start-IcingaAgentInstallWizard() if ($EndpointConnections.Count -eq 0) { $EndpointsConversion = Convert-IcingaEndpointsToIPv4 -NetworkConfig $Endpoints.Split(','); } else { - $EndpointsConversion = Convert-IcingaEndpointsToIPv4 -NetworkConfig $EndpointConnections.Split(','); + $EndpointsConversion = Convert-IcingaEndpointsToIPv4 -NetworkConfig $EndpointConnections; } if ($EndpointsConversion.HasErrors) { Write-IcingaConsoleWarning -Message 'Not all of your endpoint connection data could be resolved. These endpoints were dropped: {0}' -Objects ([string]::Join(', ', $EndpointsConversion.Unresolved)); @@ -340,6 +340,12 @@ function Start-IcingaAgentInstallWizard() } } $InstallerArguments += ("-EndpointConnections " + ([string]::Join(',', $EndpointConnections))); + } elseif ($EndpointConnections.Count -ne 0 -And $AcceptConnections -eq 0 -And $ConvertEndpointIPConfig) { + $EndpointsConversion = Convert-IcingaEndpointsToIPv4 -NetworkConfig $EndpointConnections; + if ($EndpointsConversion.HasErrors) { + Write-IcingaConsoleWarning -Message 'Not all of your endpoint connection data could be resolved. These endpoints were dropped: {0}' -Objects ([string]::Join(', ', $EndpointsConversion.Unresolved)); + } + $EndpointConnections = $EndpointsConversion.Network; } if ([string]::IsNullOrEmpty($ParentZone)) {