private IProbeCapabilities GetProbeCapability(string ovalObject, FamilyEnumeration plataform) { return(new ProbeCapabilities() { OvalObject = ovalObject, PlataformName = plataform }); }
private void SetPlatform() { if (CustomFileProvider != null) { var fileProviderTypeName = CustomFileProvider.GetType().Name.ToLower(); Platform = fileProviderTypeName.Contains("unix") ? FamilyEnumeration.unix : FamilyEnumeration.windows; } }
private IProbeCapabilities CreateProbeCapability(String capabilityName, FamilyEnumeration plataform) { ProbeCapabilities probeCapability = new ProbeCapabilities(); probeCapability.OvalObject = capabilityName; probeCapability.PlataformName = plataform; return(probeCapability); }
/// <summary> /// Gets the system information service by the plataform name. /// </summary> /// <param name="plataformName">Name of the plataform.</param> /// <returns></returns> public ISystemInformationService GetSystemInformationService(FamilyEnumeration plataformName) { var systemInformationService = this.systemInformationServices.SingleOrDefault(systemInfo => systemInfo.Metadata.PlataformName == plataformName); if (systemInformationService != null) { return(systemInformationService.Value); } return(null); }
/// <summary> /// This method is responsible to start of collect process. /// </summary> /// <param name="objectTypes">The object types.</param> public void ExecuteCollect(IDocumentSession session, CollectRequest collectRequest, FamilyEnumeration plataform) { ExecutionLogBuilder executionLog = new ExecutionLogBuilder(); this.SetStatusToExecuting(collectRequest); CollectExecution collectExecution = this.CreateCollectExecution(session, collectRequest); try { collectExecution.SetDateStartCollect(); this.StartCollect(session, collectRequest, collectExecution, plataform, executionLog); this.EndCollect(session, collectRequest, collectExecution); } catch (Exception ex) { var logMessage = String.Format(EXECUTION_ERROR_MESSAGE, ex.Message, ex.StackTrace); Logger.Error(logMessage); this.EndsACollectRequestBecauseThisErrorIsUnrecoverable(collectRequest, "Collect Manager", collectExecution, ex, executionLog); } session.SaveChanges(); }
private void CloseExecutionIfIncomplete(IDocumentSession session, CollectRequest collectRequest, CollectExecution collectExecution, FamilyEnumeration plataform, IEnumerable<ObjectType> objectTypes) { IEnumerable<SelectedProbe> objectsNotSupported = ProbeManager.GetNotSupportedObjects(objectTypes, plataform); var objectNotSupported = this.GetObjectTypesFromSelectedProbes(objectsNotSupported); var objectSupportedNotCollect = objectTypes.Except(objectNotSupported); this.CreateCollectedObjectsForNotSupportedObjects(session, objectsNotSupported, collectRequest, collectExecution); if (objectSupportedNotCollect.Count() > 0) { IEnumerable<SelectedProbe> objectsSupportedNotCollected = ProbeManager.GetProbesFor(objectSupportedNotCollect, plataform); this.CreateCollectedObjectsForNotSupportedObjects(session, objectsSupportedNotCollected, collectRequest, collectExecution); } collectRequest.SetResultComplete(session); collectRequest.Close(); session.SaveChanges(); }
public FileItemTypeFactory(FamilyEnumeration platform) { this.Platform = platform; }
public PathOperatorEvaluator(IFileProvider fileProvider, FamilyEnumeration platform) { this.FileProvider = fileProvider; this.Platform = platform; }
private void CloseExecutionIfIncomplete(IDocumentSession session, CollectRequest collectRequest, CollectExecution collectExecution, FamilyEnumeration plataform, IEnumerable <ObjectType> objectTypes) { IEnumerable <SelectedProbe> objectsNotSupported = ProbeManager.GetNotSupportedObjects(objectTypes, plataform); var objectNotSupported = this.GetObjectTypesFromSelectedProbes(objectsNotSupported); var objectSupportedNotCollect = objectTypes.Except(objectNotSupported); this.CreateCollectedObjectsForNotSupportedObjects(session, objectsNotSupported, collectRequest, collectExecution); if (objectSupportedNotCollect.Count() > 0) { IEnumerable <SelectedProbe> objectsSupportedNotCollected = ProbeManager.GetProbesFor(objectSupportedNotCollect, plataform); this.CreateCollectedObjectsForNotSupportedObjects(session, objectsSupportedNotCollected, collectRequest, collectExecution); } collectRequest.SetResultComplete(session); collectRequest.Close(); session.SaveChanges(); }
public TextFileContentEntityOperationEvaluator(BaseObjectCollector systemDataSource, IFileProvider fileDataSource, FamilyEnumeration platform) { this.TextFileContentDataSource = systemDataSource; this.PathOperatorEvaluator = new PathOperatorEvaluator(fileDataSource, platform); }
public IEnumerable <SelectedProbe> GetNotSupportedObjects(IEnumerable <ObjectType> objectTypes, FamilyEnumeration plataform) { List <SelectedProbe> selectedProbes = new List <SelectedProbe>(); var objectTypesByComponentString = from t in objectTypes group t by t.ComponentString into types select new { Capability = types.Key, objectsTypes = types }; foreach (var type in objectTypesByComponentString) { IProbeCapabilities capability = this.CreateProbeCapability(type.Capability, plataform); IProbe probe = this.GetProbe(capability); if (probe == null) { probe = this.probes.First().Value; SelectedProbe selectedProbe = new SelectedProbe(probe, type.objectsTypes, (ProbeCapabilities)capability); selectedProbes.Add(selectedProbe); } } return(selectedProbes); }
private SelectedProbe CreateSelectedProbe <T>(IProbe probe, string capability, FamilyEnumeration plataform, CollectRequest collectRequest) where T : ObjectType { SelectedProbe selectedProbe = new SelectedProbe(probe, collectRequest.GetObjectTypes(session).OfType <T>(), new ProbeCapabilities() { OvalObject = capability, PlataformName = plataform }); return(selectedProbe); }
public FileEntityOperationEvaluator(IFileProvider fileProvider, FamilyEnumeration platform) { this.FileProvider = fileProvider; this.pathOperatorEvaluator = new PathOperatorEvaluator(FileProvider, platform); }
private void UpdateSystemInformationOfTarget(IDocumentSession session, CollectRequest collectRequest, FamilyEnumeration plataform, ExecutionLogBuilder executionLog) { if (!collectRequest.Target.IsSystemInformationDefined()) { executionLog.CollectSystemInformation(); ISystemInformationService systemInformationService = ProbeManager.GetSystemInformationService(plataform); if (systemInformationService != null) { try { this.GetSystemInformationFromTarget(collectRequest, systemInformationService); session.SaveChanges(); } catch (RecoverableProbeException ex) { CollectExecution collectExecution = this.CreateCollectExecution(session, collectRequest); collectExecution.SetDateStartCollect(); this.ConfigureTheCollectRequestWithAnErrorProbeExecute(collectRequest, "SystemInformation", collectExecution, ex, executionLog); session.SaveChanges(); throw new SystemInformationException(ex.Message, ex); } catch (Exception ex) { CreateCollectionExcutionWithError(session, collectRequest, "SystemInformation", ex, executionLog); session.SaveChanges(); throw new SystemInformationException(ex.Message, ex); } } } }
private void StartCollect(IDocumentSession session, CollectRequest collectRequest, CollectExecution collectExecution, FamilyEnumeration plataform, ExecutionLogBuilder executionLog) { int attemptsOfEvaluateVariables = 1; bool anErrorOccured = false; bool allObjectWasCollect = false; IEnumerable<ObjectType> objectTypes = collectRequest.GetObjectTypesWasNotCollected(session); session.SaveChanges(); while (!collectTimeOut.IsExceededTheMaxAttemptsOfEvaluateVariables(attemptsOfEvaluateVariables) && !allObjectWasCollect && !anErrorOccured && !Interrupted) { IEnumerable<StateType> states = collectRequest.GetStates(session); IEnumerable<SelectedProbe> selectedProbes = ProbeManager.GetProbesFor(objectTypes, plataform); VariablesEvaluated variables = variableEvaluatorService.Evaluate(collectRequest, session); session.SaveChanges(); try { this.UpdateSystemInformationOfTarget(session, collectRequest, plataform, executionLog); this.ExecuteCollectWithProbes(session, selectedProbes, collectRequest, variables, states, collectExecution, executionLog); session.SaveChanges(); } catch (SystemInformationException ex) { string logMessage; if (ex.InnerException == null) { logMessage = String.Format(EXECUTION_ERROR_MESSAGE, ex.Message, ex.StackTrace); } else { logMessage = String.Format(EXECUTION_ERROR_MESSAGE_WITH_INNER_EXCEPTION, ex.Message, ex.InnerException.StackTrace, ex.StackTrace); } Logger.Error(logMessage); collectRequest.SetResultError(); collectRequest.Close(); anErrorOccured = true; session.SaveChanges(); break; } catch { // only ends the loop. The error already was treated anErrorOccured = true; } objectTypes = collectRequest.GetObjectTypesWasNotCollected(session); allObjectWasCollect = objectTypes.Count() == 0; attemptsOfEvaluateVariables++; } if (Interrupted) { collectRequest.Status = CollectRequestStatus.Canceled; } else { if ((!allObjectWasCollect) && (!anErrorOccured)) { CloseExecutionIfIncomplete(session, collectRequest, collectExecution, plataform, objectTypes); } } session.SaveChanges(); }
public MultiLevelPatternMatchOperation(FamilyEnumeration platform) { this.Platform = platform; }
private IProbeCapabilities GetProbeCapability(string ovalObject, FamilyEnumeration plataform) { return new ProbeCapabilities() { OvalObject = ovalObject, PlataformName = plataform }; }
/// <summary> /// Gets the system information service by the plataform name. /// </summary> /// <param name="plataformName">Name of the plataform.</param> /// <returns></returns> public ISystemInformationService GetSystemInformationService(FamilyEnumeration plataformName) { var systemInformationService = this.systemInformationServices.SingleOrDefault(systemInfo => systemInfo.Metadata.PlataformName == plataformName); if (systemInformationService != null) { return systemInformationService.Value; } return null; }
public IEnumerable<SelectedProbe> GetNotSupportedObjects(IEnumerable<ObjectType> objectTypes, FamilyEnumeration plataform) { List<SelectedProbe> selectedProbes = new List<SelectedProbe>(); var objectTypesByComponentString = from t in objectTypes group t by t.ComponentString into types select new { Capability = types.Key, objectsTypes = types }; foreach (var type in objectTypesByComponentString) { IProbeCapabilities capability = this.CreateProbeCapability(type.Capability, plataform); IProbe probe = this.GetProbe(capability); if (probe == null) { probe = this.probes.First().Value; SelectedProbe selectedProbe = new SelectedProbe(probe, type.objectsTypes, (ProbeCapabilities)capability); selectedProbes.Add(selectedProbe); } } return selectedProbes; }
private void StartCollect(IDocumentSession session, CollectRequest collectRequest, CollectExecution collectExecution, FamilyEnumeration plataform, ExecutionLogBuilder executionLog) { int attemptsOfEvaluateVariables = 1; bool anErrorOccured = false; bool allObjectWasCollect = false; IEnumerable <ObjectType> objectTypes = collectRequest.GetObjectTypesWasNotCollected(session); session.SaveChanges(); while (!collectTimeOut.IsExceededTheMaxAttemptsOfEvaluateVariables(attemptsOfEvaluateVariables) && !allObjectWasCollect && !anErrorOccured && !Interrupted) { IEnumerable <StateType> states = collectRequest.GetStates(session); IEnumerable <SelectedProbe> selectedProbes = ProbeManager.GetProbesFor(objectTypes, plataform); VariablesEvaluated variables = variableEvaluatorService.Evaluate(collectRequest, session); session.SaveChanges(); try { this.UpdateSystemInformationOfTarget(session, collectRequest, plataform, executionLog); this.ExecuteCollectWithProbes(session, selectedProbes, collectRequest, variables, states, collectExecution, executionLog); session.SaveChanges(); } catch (SystemInformationException ex) { string logMessage; if (ex.InnerException == null) { logMessage = String.Format(EXECUTION_ERROR_MESSAGE, ex.Message, ex.StackTrace); } else { logMessage = String.Format(EXECUTION_ERROR_MESSAGE_WITH_INNER_EXCEPTION, ex.Message, ex.InnerException.StackTrace, ex.StackTrace); } Logger.Error(logMessage); collectRequest.SetResultError(); collectRequest.Close(); anErrorOccured = true; session.SaveChanges(); break; } catch { // only ends the loop. The error already was treated anErrorOccured = true; } objectTypes = collectRequest.GetObjectTypesWasNotCollected(session); allObjectWasCollect = objectTypes.Count() == 0; attemptsOfEvaluateVariables++; } if (Interrupted) { collectRequest.Status = CollectRequestStatus.Canceled; } else { if ((!allObjectWasCollect) && (!anErrorOccured)) { CloseExecutionIfIncomplete(session, collectRequest, collectExecution, plataform, objectTypes); } } session.SaveChanges(); }
private IProbeCapabilities CreateProbeCapability(String capabilityName, FamilyEnumeration plataform) { ProbeCapabilities probeCapability = new ProbeCapabilities(); probeCapability.OvalObject = capabilityName; probeCapability.PlataformName = plataform; return probeCapability; }