Search in sources :

Example 1 with AuditLogType

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

the class IrsProxy method proceedStorageDomain.

private boolean proceedStorageDomain(StorageDomain domainFromVdsm, int dataMasterVersion, StoragePool storagePool) {
    StorageDomain storage_domain = storageDomainDao.getForStoragePool(domainFromVdsm.getId(), storagePoolId);
    if (storage_domain != null) {
        StorageDomainStatic domainFromDb = storage_domain.getStorageStaticData();
        StoragePoolIsoMap domainPoolMapFromDb = storage_domain.getStoragePoolIsoMapData();
        // If the domain is master in the DB
        if (domainFromDb.getStorageDomainType() == StorageDomainType.Master && domainPoolMapFromDb != null && domainPoolMapFromDb.getStatus() != StorageDomainStatus.Locked) {
            // and the domain is not master in the VDSM
            if (!((domainFromVdsm.getStorageDomainType() == StorageDomainType.Master) || (domainFromVdsm.getStorageDomainType() == StorageDomainType.Unknown))) {
                reconstructMasterDomainNotInSync(domainFromVdsm.getStoragePoolId(), domainFromDb, "Mismatch between master in DB and VDSM", MessageFormat.format("Master domain is not in sync between DB and VDSM. " + "Domain {0} marked as master in DB and not in the storage", domainFromDb.getStorageName()));
            } else // mismatch
            if (dataMasterVersion != storagePool.getMasterDomainVersion()) {
                reconstructMasterDomainNotInSync(domainFromVdsm.getStoragePoolId(), domainFromDb, "Mismatch between master version in DB and VDSM", MessageFormat.format("Master domain version is not in sync between DB and VDSM. " + "Domain {0} marked as master, but the version in DB: {1} and in VDSM: {2}", domainFromDb.getStorageName(), storagePool.getMasterDomainVersion(), dataMasterVersion));
            }
        }
        boolean statusChanged = false;
        if (domainPoolMapFromDb == null) {
            domainFromVdsm.setStoragePoolId(storagePoolId);
            storagePoolIsoMapDao.save(domainFromVdsm.getStoragePoolIsoMapData());
            statusChanged = true;
        } else if (!domainPoolMapFromDb.getStatus().isStorageDomainInProcess() && domainPoolMapFromDb.getStatus() != domainFromVdsm.getStatus()) {
            if (domainPoolMapFromDb.getStatus() != StorageDomainStatus.Inactive && domainFromVdsm.getStatus() != StorageDomainStatus.Inactive) {
                storagePoolIsoMapDao.update(domainFromVdsm.getStoragePoolIsoMapData());
                statusChanged = true;
            }
            if (domainFromVdsm.getStatus() != null && domainFromVdsm.getStatus() == StorageDomainStatus.Inactive && domainFromDb.getStorageDomainType() == StorageDomainType.Master) {
                StoragePool pool = storagePoolDao.get(domainPoolMapFromDb.getStoragePoolId());
                if (pool != null) {
                    storagePoolDao.updateStatus(pool.getId(), StoragePoolStatus.Maintenance);
                    pool.setStatus(StoragePoolStatus.Maintenance);
                    getEventListener().storagePoolStatusChanged(pool.getId(), StoragePoolStatus.Maintenance);
                }
            }
        }
        // update dynamic data
        if (statusChanged || (domainPoolMapFromDb.getStatus() != StorageDomainStatus.Inactive && domainFromVdsm.getStatus() == StorageDomainStatus.Active)) {
            storageDomainDynamicDao.update(domainFromVdsm.getStorageDynamicData());
            if (domainFromVdsm.getAvailableDiskSize() != null && domainFromVdsm.getUsedDiskSize() != null) {
                double freePercent = domainFromVdsm.getStorageDynamicData().getfreeDiskPercent();
                AuditLogType type = AuditLogType.UNASSIGNED;
                Integer freeDiskInGB = domainFromVdsm.getStorageDynamicData().getAvailableDiskSize();
                if (freeDiskInGB != null) {
                    if (freePercent < domainFromDb.getWarningLowSpaceIndicator()) {
                        type = AuditLogType.IRS_DISK_SPACE_LOW;
                    }
                    if (freeDiskInGB < domainFromDb.getCriticalSpaceActionBlocker()) {
                        // Note, if both conditions are met, only IRS_DISK_SPACE_LOW_ERROR will be shown
                        type = AuditLogType.IRS_DISK_SPACE_LOW_ERROR;
                    }
                }
                if (type != AuditLogType.UNASSIGNED) {
                    AuditLogable logable = new AuditLogableImpl();
                    logable.setStorageDomainName(domainFromDb.getStorageName());
                    logable.addCustomValue("DiskSpace", domainFromVdsm.getAvailableDiskSize().toString());
                    domainFromVdsm.setStorageName(domainFromDb.getStorageName());
                    auditLogDirector.log(logable, type);
                }
            }
            Set<EngineError> alerts = domainFromVdsm.getAlerts();
            if (alerts != null && !alerts.isEmpty()) {
                AuditLogable logable = new AuditLogableImpl();
                logable.setStorageDomainName(domainFromDb.getStorageName());
                domainFromVdsm.setStorageName(domainFromDb.getStorageName());
                for (EngineError alert : alerts) {
                    switch(alert) {
                        case VG_METADATA_CRITICALLY_FULL:
                            auditLogDirector.log(logable, AuditLogType.STORAGE_ALERT_VG_METADATA_CRITICALLY_FULL);
                            break;
                        case SMALL_VG_METADATA:
                            auditLogDirector.log(logable, AuditLogType.STORAGE_ALERT_SMALL_VG_METADATA);
                            break;
                        default:
                            log.error("Unrecognized alert for domain {}(id = {}): {}", domainFromVdsm.getStorageName(), domainFromVdsm.getId(), alert);
                            break;
                    }
                }
            }
        }
        // Block domains should have their LUNs synchronized and updated in the DB.
        if (statusChanged && domainFromVdsm.getStatus() == StorageDomainStatus.Active && storage_domain.getStorageType().isBlockDomain()) {
            return true;
        }
    } else {
        log.debug("The domain with id '{}' was not found in DB", domainFromVdsm.getId());
    }
    return false;
}
Also used : StorageDomainStatic(org.ovirt.engine.core.common.businessentities.StorageDomainStatic) StorageDomain(org.ovirt.engine.core.common.businessentities.StorageDomain) AuditLogType(org.ovirt.engine.core.common.AuditLogType) StoragePool(org.ovirt.engine.core.common.businessentities.StoragePool) AuditLogable(org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogable) StoragePoolIsoMap(org.ovirt.engine.core.common.businessentities.StoragePoolIsoMap) EngineError(org.ovirt.engine.core.common.errors.EngineError) AuditLogableImpl(org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogableImpl)

Example 2 with AuditLogType

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

the class VmAnalyzer method auditVmPausedError.

private void auditVmPausedError(VmDynamic vdsmVmDynamic) {
    AuditLogType logType = vmPauseStatusToAuditLogType(vdsmVmDynamic.getPauseStatus());
    AuditLogableBase logable = Injector.injectMembers(new AuditLogableBase(vdsManager.getVdsId(), dbVm.getId()));
    auditLog(logable, logType);
}
Also used : AuditLogableBase(org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogableBase) AuditLogType(org.ovirt.engine.core.common.AuditLogType)

Example 3 with AuditLogType

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

the class VmAnalyzer method auditVmSuspended.

private void auditVmSuspended() {
    VmDynamic vm = vdsmVm.getVmDynamic();
    AuditLogType type = vm.getExitStatus() == VmExitStatus.Normal ? AuditLogType.USER_SUSPEND_VM_OK : AuditLogType.USER_FAILED_SUSPEND_VM;
    AuditLogableBase logable = Injector.injectMembers(new AuditLogableBase(vdsManager.getVdsId(), vm.getId()));
    auditLog(logable, type);
}
Also used : AuditLogableBase(org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogableBase) AuditLogType(org.ovirt.engine.core.common.AuditLogType) VmDynamic(org.ovirt.engine.core.common.businessentities.VmDynamic)

Example 4 with AuditLogType

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

the class CreateSnapshotFromTemplateCommand method addAuditLogOnRemoveFailure.

private void addAuditLogOnRemoveFailure() {
    addCustomValue("DiskAlias", getParameters().getDiskAlias());
    AuditLogType logType = AuditLogType.USER_COPY_IMAGE_GROUP_FAILED_TO_DELETE_DST_IMAGE;
    auditLogDirector.log(this, logType);
}
Also used : AuditLogType(org.ovirt.engine.core.common.AuditLogType)

Example 5 with AuditLogType

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

the class GlusterTasksSyncJob method logTaskStartedFromCLI.

private void logTaskStartedFromCLI(Cluster cluster, GlusterAsyncTask task, GlusterVolumeEntity vol) {
    Map<String, String> values = new HashMap<>();
    AuditLogType logType;
    switch(task.getType()) {
        case REBALANCE:
            logType = AuditLogType.GLUSTER_VOLUME_REBALANCE_START_DETECTED_FROM_CLI;
            break;
        case REMOVE_BRICK:
            logType = AuditLogType.START_REMOVING_GLUSTER_VOLUME_BRICKS_DETECTED_FROM_CLI;
            values.put(GlusterConstants.BRICK, StringUtils.join(task.getTaskParameters().getBricks(), ','));
            break;
        default:
            logType = AuditLogType.UNASSIGNED;
            break;
    }
    logUtil.logAuditMessage(cluster.getId(), cluster.getName(), vol, null, logType, values);
}
Also used : AuditLogType(org.ovirt.engine.core.common.AuditLogType) HashMap(java.util.HashMap)

Aggregations

AuditLogType (org.ovirt.engine.core.common.AuditLogType)23 AuditLogable (org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogable)8 AuditLogableImpl (org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogableImpl)5 AuditLogDirector (org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogDirector)4 AuditLogableBase (org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogableBase)3 ArrayList (java.util.ArrayList)2 Date (java.util.Date)2 StoragePool (org.ovirt.engine.core.common.businessentities.StoragePool)2 StandardCharsets (java.nio.charset.StandardCharsets)1 SimpleDateFormat (java.text.SimpleDateFormat)1 Collections (java.util.Collections)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Map (java.util.Map)1 MissingResourceException (java.util.MissingResourceException)1 Objects (java.util.Objects)1 Set (java.util.Set)1 Collectors (java.util.stream.Collectors)1 Inject (javax.inject.Inject)1