Search in sources :

Example 1 with AuditLogSeverity

use of org.ovirt.engine.core.common.AuditLogSeverity in project ovirt-engine by oVirt.

the class EventHelper method getEventStatus.

/**
 * Looks up the total number of Alerts/Warning/Error events from the Audit log.
 * @param dataSource The {@code DataSource} to use for the queries.
 * @return An {@code InventoryEntitySummary} object containing the event data.
 * @throws DashboardDataException Unable to load query properties.
 */
public static InventoryStatus getEventStatus(DataSource dataSource) throws DashboardDataException {
    InventoryStatus result = new InventoryStatus();
    EventDao dao = new EventDao(dataSource);
    Map<AuditLogSeverity, Integer> data = dao.getEventStatusCount();
    for (Map.Entry<AuditLogSeverity, Integer> entry : data.entrySet()) {
        switch(entry.getKey()) {
            case ALERT:
                result.setStatusCount(AuditLogSeverity.ALERT.name().toLowerCase(), entry.getValue());
                result.setTotalCount(result.getTotalCount() + entry.getValue());
                break;
            case ERROR:
                result.setStatusCount(AuditLogSeverity.ERROR.name().toLowerCase(), entry.getValue());
                result.setTotalCount(result.getTotalCount() + entry.getValue());
                break;
            case NORMAL:
                // Do nothing
                break;
            case WARNING:
                result.setStatusCount(AuditLogSeverity.WARNING.name().toLowerCase(), entry.getValue());
                result.setTotalCount(result.getTotalCount() + entry.getValue());
                break;
            default:
                // Do nothing
                break;
        }
    }
    return result;
}
Also used : EventDao(org.ovirt.engine.ui.frontend.server.dashboard.dao.EventDao) AuditLogSeverity(org.ovirt.engine.core.common.AuditLogSeverity) Map(java.util.Map)

Example 2 with AuditLogSeverity

use of org.ovirt.engine.core.common.AuditLogSeverity in project ovirt-engine by oVirt.

the class EventMapper method map.

@Mapping(from = Event.class, to = AuditLog.class)
public static AuditLog map(Event event, AuditLog entity) {
    AuditLog auditLog = (entity != null) ? entity : new AuditLog();
    AuditLogSeverity severity = map(event.getSeverity(), null);
    if (severity != null) {
        auditLog.setSeverity(severity);
    }
    auditLog.setLogTime(event.isSetTime() ? event.getTime().toGregorianCalendar().getTime() : new Date(Calendar.getInstance().getTimeInMillis()));
    auditLog.setMessage(event.getDescription());
    if (event.isSetUser() && event.getUser().isSetId()) {
        Guid guid = GuidUtils.asGuid(event.getUser().getId());
        if (!Guid.isNullOrEmpty(guid)) {
            auditLog.setUserId(guid);
        }
    }
    if (event.isSetVm() && event.getVm().isSetId()) {
        Guid guid = GuidUtils.asGuid(event.getVm().getId());
        if (!Guid.isNullOrEmpty(guid)) {
            auditLog.setVmId(guid);
        }
    }
    if (event.isSetStorageDomain() && event.getStorageDomain().isSetId()) {
        Guid guid = GuidUtils.asGuid(event.getStorageDomain().getId());
        if (!Guid.isNullOrEmpty(guid)) {
            auditLog.setStorageDomainId(guid);
        }
    }
    if (event.isSetHost() && event.getHost().isSetId()) {
        Guid guid = GuidUtils.asGuid(event.getHost().getId());
        if (!Guid.isNullOrEmpty(guid)) {
            auditLog.setVdsId(guid);
        }
    }
    if (event.isSetTemplate() && event.getTemplate().isSetId()) {
        Guid guid = GuidUtils.asGuid(event.getTemplate().getId());
        if (!Guid.isNullOrEmpty(guid)) {
            auditLog.setVmTemplateId(guid);
        }
    }
    if (event.isSetCluster() && event.getCluster().isSetId()) {
        Guid guid = GuidUtils.asGuid(event.getCluster().getId());
        if (!Guid.isNullOrEmpty(guid)) {
            auditLog.setClusterId(guid);
        }
    }
    if (event.isSetDataCenter() && event.getDataCenter().isSetId()) {
        Guid guid = GuidUtils.asGuid(event.getDataCenter().getId());
        if (!Guid.isNullOrEmpty(guid)) {
            auditLog.setStoragePoolId(guid);
        }
    }
    if (event.isSetCorrelationId()) {
        auditLog.setCorrelationId(event.getCorrelationId());
    }
    if (event.isSetOrigin()) {
        auditLog.setOrigin(event.getOrigin());
    }
    if (event.isSetCustomId()) {
        auditLog.setCustomEventId(event.getCustomId());
    }
    if (event.isSetFloodRate()) {
        auditLog.setEventFloodInSec(event.getFloodRate());
    }
    if (event.isSetCustomData()) {
        auditLog.setCustomData(event.getCustomData());
    }
    return auditLog;
}
Also used : AuditLogSeverity(org.ovirt.engine.core.common.AuditLogSeverity) Guid(org.ovirt.engine.core.compat.Guid) AuditLog(org.ovirt.engine.core.common.businessentities.AuditLog) Date(java.sql.Date)

Aggregations

AuditLogSeverity (org.ovirt.engine.core.common.AuditLogSeverity)2 Date (java.sql.Date)1 Map (java.util.Map)1 AuditLog (org.ovirt.engine.core.common.businessentities.AuditLog)1 Guid (org.ovirt.engine.core.compat.Guid)1 EventDao (org.ovirt.engine.ui.frontend.server.dashboard.dao.EventDao)1