Search in sources :

Example 11 with AuditLogable

use of org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogable in project ovirt-engine by oVirt.

the class IsoDomainListSynchronizer method addToAuditLogErrorMessage.

/**
 * Add audit log message when fetch encounter problems.
 *
 * @param problematicRepoFilesList
 *            - List of Iso domain names, which encounter problem fetching from VDSM.
 */
private void addToAuditLogErrorMessage(String problematicRepoFilesList) {
    AuditLogable logable = new AuditLogableImpl();
    // Get translated error by error code ,if no translation found (should not happened) ,
    // will set the error code instead.
    logable.addCustomValue("imageDomains", problematicRepoFilesList);
    auditLogDirector.log(logable, AuditLogType.REFRESH_REPOSITORY_IMAGE_LIST_FAILED);
}
Also used : AuditLogable(org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogable) AuditLogableImpl(org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogableImpl)

Example 12 with AuditLogable

use of org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogable in project ovirt-engine by oVirt.

the class VdsBrokerObjectsBuilder method createAuditLogableForHost.

private static AuditLogable createAuditLogableForHost(VDS vds) {
    AuditLogable logable = new AuditLogableImpl();
    logable.setVdsId(vds.getId());
    logable.setVdsName(vds.getName());
    return logable;
}
Also used : AuditLogable(org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogable) AuditLogableImpl(org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogableImpl)

Example 13 with AuditLogable

use of org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogable in project ovirt-engine by oVirt.

the class VdsBrokerObjectsBuilder method createHostNetworkAuditLog.

protected static AuditLogable createHostNetworkAuditLog(String networkName, VDS vds) {
    AuditLogable logable = createAuditLogableForHost(vds);
    logable.addCustomValue("NetworkName", networkName);
    return logable;
}
Also used : AuditLogable(org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogable)

Example 14 with AuditLogable

use of org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogable in project ovirt-engine by oVirt.

the class MultipathHealthHandler method handleMultipathHealthReport.

public void handleMultipathHealthReport(VDS vds, Map<String, Object> statsMap) {
    if (!statsMap.containsKey(VdsProperties.MULTIPATH_HEALTH)) {
        return;
    }
    Map<String, Object> multipathHealthMap = (Map<String, Object>) statsMap.get(VdsProperties.MULTIPATH_HEALTH);
    // The following mechanism avoids to have the same events generated
    // when there was no changes in the health report.
    // Note that the EventFloodRegulator is solving the problem of not
    // emitting the same event reoccuring in the time frame of AuditLogTimeInterval.
    // In this case, using the EventFloodRegulator would filter events that are needed.
    // For example, having an event of NO_FAULTY_MULTIPATHS_ON_HOST, then
    // an event of FAULTY_MULTIPATHS_ON_HOST, and again NO_FAULTY_MULTIPATHS_ON_HOST.
    // The last event would have been filtered out.
    byte[] hash;
    String json;
    try {
        json = JsonHelper.mapToJson(new TreeMap<>(multipathHealthMap));
        MessageDigest digest = MessageDigest.getInstance("SHA1");
        digest.update(json.getBytes("UTF-8"));
        hash = digest.digest();
    } catch (Exception e) {
        log.error("failed building multipath events: {}", e.getMessage());
        log.debug("Exception", e);
        return;
    }
    byte[] previousHash = multipathHealthHash.get(vds.getId());
    if (Arrays.equals(hash, previousHash)) {
        // No changes in the report
        return;
    }
    multipathHealthHash.put(vds.getId(), hash);
    log.debug("Multipath health report for host {}: {}", vds.getName(), json);
    if (multipathHealthMap.isEmpty()) {
        AuditLogable logable = createAuditLogableForHost(vds);
        auditLogDirector.log(logable, AuditLogType.NO_FAULTY_MULTIPATHS_ON_HOST);
        return;
    }
    Map<Boolean, List<String>> multipathHealthMapPartition = multipathHealthMap.entrySet().stream().collect(Collectors.partitioningBy(entry -> {
        Map<String, Object> internalValue = (Map<String, Object>) entry.getValue();
        return (Integer) internalValue.get(VdsProperties.MULTIPATH_VALID_PATHS) > 0;
    }, Collectors.mapping(Map.Entry::getKey, Collectors.toList())));
    createAuditLog(multipathHealthMapPartition.get(Boolean.FALSE), AuditLogType.MULTIPATH_DEVICES_WITHOUT_VALID_PATHS_ON_HOST, vds);
    createAuditLog(multipathHealthMapPartition.get(Boolean.TRUE), AuditLogType.FAULTY_MULTIPATHS_ON_HOST, vds);
}
Also used : Arrays(java.util.Arrays) Logger(org.slf4j.Logger) AuditLogDirector(org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogDirector) MessageDigest(java.security.MessageDigest) Guid(org.ovirt.engine.core.compat.Guid) JsonHelper(org.ovirt.engine.core.utils.JsonHelper) LoggerFactory(org.slf4j.LoggerFactory) HashMap(java.util.HashMap) Singleton(javax.inject.Singleton) Collectors(java.util.stream.Collectors) AuditLogable(org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogable) Inject(javax.inject.Inject) List(java.util.List) TreeMap(java.util.TreeMap) Map(java.util.Map) AuditLogType(org.ovirt.engine.core.common.AuditLogType) VDS(org.ovirt.engine.core.common.businessentities.VDS) AuditLogableImpl(org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogableImpl) AuditLogable(org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogable) TreeMap(java.util.TreeMap) List(java.util.List) MessageDigest(java.security.MessageDigest) HashMap(java.util.HashMap) TreeMap(java.util.TreeMap) Map(java.util.Map)

Example 15 with AuditLogable

use of org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogable in project ovirt-engine by oVirt.

the class MultipathHealthHandler method createAuditLog.

private void createAuditLog(List<String> guids, AuditLogType type, VDS vds) {
    if (guids.isEmpty()) {
        return;
    }
    AuditLogable logable = createAuditLogableForHost(vds);
    logable.addCustomValue("MpathGuids", String.join(", ", guids));
    auditLogDirector.log(logable, type);
}
Also used : AuditLogable(org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogable)

Aggregations

AuditLogable (org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogable)126 AuditLogableImpl (org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogableImpl)86 AuditLogType (org.ovirt.engine.core.common.AuditLogType)10 AuditLogDirector (org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogDirector)9 Guid (org.ovirt.engine.core.compat.Guid)8 VdsNetworkInterface (org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface)6 ArrayList (java.util.ArrayList)5 Date (java.util.Date)3 HashMap (java.util.HashMap)3 List (java.util.List)3 Map (java.util.Map)3 Collectors (java.util.stream.Collectors)3 ActionReturnValue (org.ovirt.engine.core.common.action.ActionReturnValue)3 VDS (org.ovirt.engine.core.common.businessentities.VDS)3 EngineException (org.ovirt.engine.core.common.errors.EngineException)3 HashSet (java.util.HashSet)2 Inject (javax.inject.Inject)2 Singleton (javax.inject.Singleton)2 HostUpgradeManagerResult (org.ovirt.engine.core.common.HostUpgradeManagerResult)2 Cluster (org.ovirt.engine.core.common.businessentities.Cluster)2