Skip to content

Commit

Permalink
Fixes the framework migration error on multi framework installation
Browse files Browse the repository at this point in the history
  • Loading branch information
LordHepipud committed May 26, 2023
1 parent d91500f commit cb6aee0
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
2 changes: 2 additions & 0 deletions doc/100-General/10-Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@ Released closed milestones can be found on [GitHub](https://github.com/Icinga/ic

* [#603](https://github.com/Icinga/icinga-powershell-framework/issues/603) Fixes service filter to handle exclude with wildcards instead of requiring the full service name (*not* applying to the display name)
* [#609](https://github.com/Icinga/icinga-powershell-framework/issues/609) Fixes config generator to never use `set_if = true` on Icinga 2/Icinga Director configuration
* [#615](https://github.com/Icinga/icinga-powershell-framework/issues/615) Fixes the framework migration tasks which fails in case multiple versions of the framework are installed, printing warnings in case there is
* [#617](https://github.com/Icinga/icinga-powershell-framework/issues/617) Fixes failing calls for plugins which use a switch argument like `-NoPerfData`, which is followed directly by the `-ThresholdInterval` argument
* [#621](https://github.com/Icinga/icinga-powershell-framework/pull/621) Fixes `-ThresholdInterval` key detection on newer systems


### Enhancements

* [#619](https://github.com/Icinga/icinga-powershell-framework/pull/619) Adds feature to securely read enum provider values with new function `Get-IcingaProviderEnumData`
Expand Down
18 changes: 17 additions & 1 deletion lib/core/framework/Test-IcingaForWindowsMigration.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,26 @@ function Test-IcingaForWindowsMigration()
return $FALSE;
}

[Version]$CurrentFrameworkVersion = (Get-Module -ListAvailable -Name icinga-powershell-framework).Version;
[string]$CurrentFrameworkRoot = Get-IcingaFrameworkRootPath;
[array]$ListOfFrameworks = (Get-Module -ListAvailable -Name icinga-powershell-framework);
[Version]$CurrentFrameworkVersion = $ListOfFrameworks[0].Version;
[string]$MigrationConfigPath = [string]::Format('Framework.Migrations.{0}', $MigrationVersion.ToString().Replace('.', ''));
$VersionMigrationApplied = Get-IcingaPowerShellConfig -Path $MigrationConfigPath;

if ($ListOfFrameworks.Count -gt 1) {
Write-IcingaConsoleWarning -Message 'Found multiple installations of the module "icinga-powershell-framework". Please check the list below and cleanup your installation to ensure system integrity'
foreach ($entry in $ListOfFrameworks) {
Write-Host ([string]::Format(' => Path "{0}" with version "{1}"', $entry.ModuleBase, $entry.Version));

# Ensure we use the correct version of the framework loaded within this session
if ($CurrentFrameworkRoot -eq $entry.ModuleBase) {
$CurrentFrameworkVersion = $entry.Version;
}
}

Write-IcingaConsoleWarning -Message 'This instance of Icinga for Windows will run with Framework version "{0}"' -Objects $CurrentFrameworkVersion.ToString();
}

# Migration for this version is already applied
if ($VersionMigrationApplied) {
return $FALSE;
Expand Down

0 comments on commit cb6aee0

Please sign in to comment.