Class WqlDetectionHelper
java.lang.Object
org.sentrysoftware.metricshub.engine.strategy.utils.WqlDetectionHelper
Helper class for WBEM/WMI namespace detection using WQL queries.
This class provides methods to find possible namespaces, detect suitable namespaces,
and perform WQL detection tests.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classData class representing the result for a specific namespace.static classData class representing the result of querying for possible namespaces. -
Constructor Summary
ConstructorsConstructorDescriptionWqlDetectionHelper(ClientsExecutor clientsExecutor) Constructs a new instance ofWqlDetectionHelperwith the provided ClientsExecutor. -
Method Summary
Modifier and TypeMethodDescriptiondetectNamespace(String hostname, IConfiguration configuration, WqlCriterion criterion, Set<String> possibleNamespaces) Detect the WBEM/WMI namespace applicable to the specified WBEM/WMI criterion.findPossibleNamespaces(String hostname, IWinConfiguration configuration) Find the possible WMI namespaces on specified hostname with specified credentials.findPossibleNamespaces(String hostname, WbemConfiguration configuration) Find the possible WBEM namespaces using the configuredWbemConfiguration.static booleanAssess whether an exception (or any of its causes) is simply an error saying that the requested namespace of class doesn't exist, which is considered okay.performDetectionTest(String hostname, @NonNull IConfiguration configuration, @NonNull WqlCriterion criterion) Perform the specified WQL detection test, on the specified WBEM/WMI protocol configuration.
-
Constructor Details
-
WqlDetectionHelper
Constructs a new instance ofWqlDetectionHelperwith the provided ClientsExecutor.- Parameters:
clientsExecutor- The ClientsExecutor to be used for WQL queries.
-
-
Method Details
-
findPossibleNamespaces
public WqlDetectionHelper.PossibleNamespacesResult findPossibleNamespaces(String hostname, WbemConfiguration configuration) Find the possible WBEM namespaces using the configuredWbemConfiguration.- Parameters:
hostname- The hostname of the host device.configuration- The user's configuredWbemConfiguration.- Returns:
- A
WqlDetectionHelper.PossibleNamespacesResultwrapping the success state, the message in case of errors and the possibleWmiNamespacesSet.
-
findPossibleNamespaces
public WqlDetectionHelper.PossibleNamespacesResult findPossibleNamespaces(String hostname, IWinConfiguration configuration) Find the possible WMI namespaces on specified hostname with specified credentials.- Parameters:
hostname- The hostname of the device.configuration- Win configuration (credentials, timeout)- Returns:
- A
WqlDetectionHelper.PossibleNamespacesResultwrapping the success state, the message in case of errors and the possibleWmiNamespacesSet.
-
detectNamespace
public WqlDetectionHelper.NamespaceResult detectNamespace(String hostname, IConfiguration configuration, WqlCriterion criterion, Set<String> possibleNamespaces) Detect the WBEM/WMI namespace applicable to the specified WBEM/WMI criterion.
The namespace in the criterion must be "Automatic".- Parameters:
hostname- The host nameconfiguration- WBEM/WMI configuration (credentials, timeout)criterion- WQL detection properties (WQL, expected result, namespace must be "Automatic")possibleNamespaces- The possible namespaces to execute the WQL on- Returns:
- A
WqlDetectionHelper.NamespaceResultwrapping the detected namespace and the error message if the detection fails.
-
performDetectionTest
public CriterionTestResult performDetectionTest(String hostname, @NonNull @NonNull IConfiguration configuration, @NonNull @NonNull WqlCriterion criterion) Perform the specified WQL detection test, on the specified WBEM/WMI protocol configuration.
Note: "Automatic" namespace is not supported in this method.- Parameters:
hostname- Host nameconfiguration- WBEM/WMI configuration (credentials, timeout)criterion- WQL detection properties (WQL, namespace, expected result)- Returns:
CriterionTestResultwhich indicates if the check has succeeded or not.
-
isAcceptableException
Assess whether an exception (or any of its causes) is simply an error saying that the requested namespace of class doesn't exist, which is considered okay.- Parameters:
t- Exception to verify- Returns:
- whether specified exception is acceptable while performing namespace detection
-