mirror of
https://github.com/Icinga/icinga-powershell-framework.git
synced 2025-12-20 23:00:35 -05:00
Merge pull request #384 from Icinga:fix/removes_module_loaded_testing
Fix: Module not loaded exception Fixes an exception, telling the user a module is not loaded or installed, while the check itself returned a false value. However, this check in general is useless and should be removed, as we can only check for components being loaded already, making it impossible to verify that a command is not available and loading the corresponding module, as we are unable to detect which module belongs to the command. Therefor the entire test for this just causes CPU overhead and loading time for nothing.
This commit is contained in:
commit
22b493b24a
3 changed files with 3 additions and 20 deletions
|
|
@ -15,6 +15,7 @@ Released closed milestones can be found on [GitHub](https://github.com/Icinga/ic
|
|||
|
||||
* [#375](https://github.com/Icinga/icinga-powershell-framework/pull/375) Fixes exception on last message printed during `Uninstall-IcingaForWindows`, because the prior used function is no longer present at this point
|
||||
* [#376](https://github.com/Icinga/icinga-powershell-framework/pull/376) Fixes IMC error handling on invalid JSON for installation command/file
|
||||
* [#377](https://github.com/Icinga/icinga-powershell-framework/issues/377) Fixes overhead for testing of modules being loaded, which returned invalid path values and wrong exceptions, which was unnecessary in first place
|
||||
* [#381](https://github.com/Icinga/icinga-powershell-framework/issues/381) Fixes Repository Hash generator for new repositories, which always returned the same hash regardless of the files inside
|
||||
|
||||
### Enhancements
|
||||
|
|
|
|||
|
|
@ -27,24 +27,6 @@ function Exit-IcingaPluginNotInstalled()
|
|||
[string]$Command
|
||||
);
|
||||
|
||||
$PowerShellModule = Get-Module 'icinga-powershell-*' -ListAvailable |
|
||||
ForEach-Object {
|
||||
foreach ($cmd in $_.ExportedCommands.Values) {
|
||||
if ($Command.ToLower() -eq $cmd.Name.ToLower()) {
|
||||
return $cmd.Path;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ([string]::IsNullOrEmpty($PowerShellModule) -eq $FALSE) {
|
||||
try {
|
||||
Import-Module $PowerShellModule -ErrorAction Stop;
|
||||
} catch {
|
||||
$ExMsg = $_.Exception.Message;
|
||||
Exit-IcingaThrowException -CustomMessage 'Module not loaded' -ExceptionType 'Configuration' -ExceptionThrown $ExMsg -Force;
|
||||
}
|
||||
}
|
||||
|
||||
if ([string]::IsNullOrEmpty($Command)) {
|
||||
Exit-IcingaThrowException -CustomMessage 'Null-Command' -ExceptionType 'Configuration' -ExceptionThrown $IcingaExceptions.Configuration.PluginNotAssigned -Force;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,9 +34,9 @@
|
|||
};
|
||||
|
||||
[hashtable]$Configuration = @{
|
||||
PluginArgumentConflict = 'Your plugin argument configuration is causing a conflict. Mostly this error is caused by missmatching configurations by enabling multiple switch arguments which are resulting in a conflicting configuration for the plugin.';
|
||||
PluginArgumentConflict = 'Your plugin argument configuration is causing a conflict. Mostly this error is caused by mismatching configurations by enabling multiple switch arguments which are resulting in a conflicting configuration for the plugin.';
|
||||
PluginArgumentMissing = 'Your plugin argument configuration is missing mandatory arguments. This error is caused when mandatory or required arguments are missing from a plugin call and the operation is unable to process without them.';
|
||||
PluginNotInstalled = 'The plugin assigned to this service check seems not to be installed on this machine. Please review your service check configuration for spelling errors and check if the plugin is installed and executable on this machine by PowerShell.';
|
||||
PluginNotInstalled = 'The plugin assigned to this service check seems not to be installed on this machine. Please review your service check configuration for spelling errors and check if the plugin is installed and executable on this machine by PowerShell. You can ensure modules are available by manually importing them by their name with the following commands: Import-Module -Name "module name" -Force; Import-Module -Name "module name" -Global -Force;';
|
||||
PluginNotAssigned = 'Your check for this service could not be processed because it seems like no valid Cmdlet was assigned to the check command. Please review your check command to ensure that a valid Cmdlet is assigned and executed by a PowerShell call.';
|
||||
EventLogNotInstalled = 'Your Icinga PowerShell Framework has been executed by an unprivileged user before it was properly installed. The Windows EventLog application could not be registered because the current user has insufficient permissions. Please log into the machine and run "Use-Icinga" once from an administrative shell to complete the setup process. Once done this error should vanish.';
|
||||
PerfCounterCategoryMissing = 'The specified Performance Counter category was not found on this system. This could either be a configuration error on your local Windows machine or a wrong usage of the plugin. Please check on different Windows machines if this issue persis. In case it only occurs on certain machines it is likely that the counter is simply not present and the plugin can not be processed.';
|
||||
|
|
|
|||
Loading…
Reference in a new issue