Fixes FQDN to IP wizard conversion question

This commit is contained in:
Lord Hepipud 2020-05-22 12:08:42 +02:00
parent 7961a0d0d1
commit 2ac3de5267
2 changed files with 17 additions and 10 deletions

View file

@ -285,11 +285,15 @@ function Start-IcingaAgentInstallWizard()
if ((Get-IcingaAgentInstallerAnswerInput -Prompt ([string]::Format('Do you want to convert all possible provided FQDN address for endpoint/network configuration for Icinga 2 to plain IP-Address?', $CAPort)) -Default 'y').result -eq 1) {
$InstallerArguments += "-ConvertEndpointIPConfig 1";
$ConvertEndpointIPConfig = $TRUE;
$EndpointsConversion = Convert-IcingaEndpointsToIPv4 -NetworkConfig $Endpoints;
if ($EndpointsConversion.HasErrors) {
Write-Host 'Not all of your endpoints configuration could be converted and was therefor dropped';
if ($EndpointConnections.Count -eq 0) {
$EndpointsConversion = Convert-IcingaEndpointsToIPv4 -NetworkConfig $Endpoints;
} else {
$EndpointsConversion = Convert-IcingaEndpointsToIPv4 -NetworkConfig $EndpointConnections;
}
$Endpoints = $EndpointsConversion.Network;
if ($EndpointsConversion.HasErrors) {
Write-Host ([string]::Format('Not all of your endpoint configuration could be resolved and is not reachable by this host. These endpoints were dropped: {0}', ([string]::Join(', ', $EndpointsConversion.Unresolved))));
}
$EndpointConnections = $EndpointsConversion.Network;
} else {
$InstallerArguments += "-ConvertEndpointIPConfig 0";
$ConvertEndpointIPConfig = $FALSE;

View file

@ -25,9 +25,10 @@ function Convert-IcingaEndpointsToIPv4()
[array]$NetworkConfig
);
[array]$ResolvedNetwork = @();
[bool]$HasUnresolved = $FALSE;
[string]$Domain = $ENV:UserDNSDomain;
[array]$ResolvedNetwork = @();
[array]$UnresolvedNetwork = @();
[bool]$HasUnresolved = $FALSE;
[string]$Domain = $ENV:UserDNSDomain;
foreach ($entry in $NetworkConfig) {
$Network = Get-IPConfigFromString -IPConfig $entry;
@ -48,13 +49,15 @@ function Convert-IcingaEndpointsToIPv4()
);
$ResolvedNetwork += $entry.Replace($Network.address, $ResolvedIP);
} catch {
$HasUnresolved = $TRUE;
$UnresolvedNetwork += $entry;
$HasUnresolved = $TRUE;
}
}
}
return @{
'Network' = $ResolvedNetwork;
'HasErrors' = $HasUnresolved;
'Network' = $ResolvedNetwork;
'HasErrors' = $HasUnresolved;
'Unresolved' = $UnresolvedNetwork;
};
}