Search in sources :

Example 81 with AuditLogableImpl

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

the class CertificationValidityChecker method checkCertificate.

private boolean checkCertificate(X509Certificate cert, AuditLogType alertExpirationEventType, AuditLogType alertAboutToExpireEventType, AuditLogType warnAboutToExpireEventType, VDS host) {
    Date expirationDate = cert.getNotAfter();
    Date certWarnTime = getExpirationDate(expirationDate, ConfigValues.CertExpirationWarnPeriodInDays);
    Date certAlertTime = getExpirationDate(expirationDate, ConfigValues.CertExpirationAlertPeriodInDays);
    Date now = new Date();
    AuditLogType eventType = null;
    if (now.compareTo(expirationDate) > 0) {
        eventType = alertExpirationEventType;
    } else if (now.compareTo(certAlertTime) > 0) {
        eventType = alertAboutToExpireEventType;
    } else if (now.compareTo(certWarnTime) > 0) {
        eventType = warnAboutToExpireEventType;
    }
    if (eventType != null) {
        AuditLogable event = new AuditLogableImpl();
        event.addCustomValue("ExpirationDate", new SimpleDateFormat("yyyy-MM-dd").format(expirationDate));
        if (host != null) {
            event.setVdsName(host.getName());
            event.setVdsId(host.getId());
        }
        auditLogDirector.log(event, eventType);
        return false;
    }
    return true;
}
Also used : AuditLogType(org.ovirt.engine.core.common.AuditLogType) AuditLogable(org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogable) AuditLogableImpl(org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogableImpl) SimpleDateFormat(java.text.SimpleDateFormat) Date(java.util.Date)

Example 82 with AuditLogableImpl

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

the class EngineBackupAwarenessManager method doBackupCheck.

private void doBackupCheck() {
    AuditLogable alert = new AuditLogableImpl();
    // try to get last backup record
    EngineBackupLog lastDbBackup = getLastBackupByScope(BackupScope.DB);
    EngineBackupLog lastFilesBackup = getLastBackupByScope(BackupScope.FILES);
    if (lastDbBackup == null || lastFilesBackup == null) {
        auditLogDirector.log(alert, AuditLogType.ENGINE_NO_FULL_BACKUP);
    } else {
        // check time elapsed from last full (db and files) backup
        Integer backupAlertPeriodInDays = Config.<Integer>getValue(ConfigValues.BackupAlertPeriodInDays);
        Date lastDbBackupDate = lastDbBackup.getDoneAt();
        Date lastFilesBackupDate = lastFilesBackup.getDoneAt();
        Date lastFullBackupDate = lastDbBackupDate.compareTo(lastFilesBackupDate) < 0 ? lastDbBackupDate : lastFilesBackupDate;
        long diffInDays = (Calendar.getInstance().getTimeInMillis() - lastFullBackupDate.getTime()) / TimeUnit.DAYS.toMillis(1);
        if (diffInDays > backupAlertPeriodInDays) {
            alert.addCustomValue("Date", lastFullBackupDate.toString());
            auditLogDirector.log(alert, AuditLogType.ENGINE_NO_WARM_BACKUP);
        }
    }
}
Also used : AuditLogable(org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogable) AuditLogableImpl(org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogableImpl) EngineBackupLog(org.ovirt.engine.core.common.businessentities.EngineBackupLog) Date(java.util.Date)

Example 83 with AuditLogableImpl

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

the class GetVmsFromExternalProviderQuery method logNoProxyAvailable.

private void logNoProxyAvailable(Guid dataCenterId) {
    AuditLogable logable = new AuditLogableImpl();
    StoragePool dataCenter = storagePoolDao.get(dataCenterId);
    logable.setStoragePoolId(dataCenter.getId());
    logable.setStoragePoolName(dataCenter.getName());
    logable.setUserName(String.format("%s@%s", getUser().getLoginName(), getUser().getDomain()));
    auditLogDirector.log(logable, AuditLogType.IMPORTEXPORT_NO_PROXY_HOST_AVAILABLE_IN_DC);
}
Also used : StoragePool(org.ovirt.engine.core.common.businessentities.StoragePool) AuditLogable(org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogable) AuditLogableImpl(org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogableImpl)

Example 84 with AuditLogableImpl

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

the class GetVmsFromExternalProviderQuery method logHostCannotBeProxy.

private void logHostCannotBeProxy(VDS host) {
    AuditLogable logable = new AuditLogableImpl();
    logable.setVdsName(host.getName());
    logable.setVdsId(host.getId());
    logable.setUserName(String.format("%s@%s", getUser().getLoginName(), getUser().getDomain()));
    auditLogDirector.log(logable, AuditLogType.IMPORTEXPORT_HOST_CANNOT_SERVE_AS_PROXY);
}
Also used : AuditLogable(org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogable) AuditLogableImpl(org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogableImpl)

Example 85 with AuditLogableImpl

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

the class DisplayNetworkClusterHelper method createLoggable.

private AuditLogable createLoggable() {
    AuditLogable loggable = new AuditLogableImpl();
    loggable.setClusterName(getClusterName());
    loggable.addCustomValue("NetworkName", networkName);
    return loggable;
}
Also used : AuditLogable(org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogable) AuditLogableImpl(org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogableImpl)

Aggregations

AuditLogableImpl (org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogableImpl)88 AuditLogable (org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogable)85 AuditLogDirector (org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogDirector)8 AuditLogType (org.ovirt.engine.core.common.AuditLogType)6 Guid (org.ovirt.engine.core.compat.Guid)5 EngineException (org.ovirt.engine.core.common.errors.EngineException)4 HostUpgradeManagerResult (org.ovirt.engine.core.common.HostUpgradeManagerResult)3 ActionReturnValue (org.ovirt.engine.core.common.action.ActionReturnValue)3 AnsibleCommandBuilder (org.ovirt.engine.core.common.utils.ansible.AnsibleCommandBuilder)3 AnsibleReturnValue (org.ovirt.engine.core.common.utils.ansible.AnsibleReturnValue)3 ArrayList (java.util.ArrayList)2 Date (java.util.Date)2 List (java.util.List)2 Collectors (java.util.stream.Collectors)2 StorageDomain (org.ovirt.engine.core.common.businessentities.StorageDomain)2 StorageDomainStatic (org.ovirt.engine.core.common.businessentities.StorageDomainStatic)2 StoragePool (org.ovirt.engine.core.common.businessentities.StoragePool)2 DiskImage (org.ovirt.engine.core.common.businessentities.storage.DiskImage)2 LUNs (org.ovirt.engine.core.common.businessentities.storage.LUNs)2 Event (org.ovirt.engine.core.common.eventqueue.Event)2