Search in sources :

Example 1 with AuditLogableImpl

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

the class IrsProxy method handleSelectedVdsForSPM.

private String handleSelectedVdsForSPM(StoragePool storagePool, RefObject<VDS> selectedVds, RefObject<SpmStatusResult> spmStatus, StoragePoolStatus prevStatus) {
    String returnValue = null;
    if (spmStatus.argvalue == null || spmStatus.argvalue.getSpmStatus() != SpmStatus.SPM) {
        movePoolToProblematicInDB(storagePool);
        selectedVds.argvalue = null;
        log.info("spm start treatment ended and status is not SPM!!! status: '{}' - setting selectedVds to null!", spmStatus.argvalue != null ? spmStatus.argvalue.getSpmStatus() : null);
    } else {
        init(selectedVds.argvalue);
        storagePool.setLVER(spmStatus.argvalue.getSpmLVER());
        storagePool.setSpmVdsId(selectedVds.argvalue.getId());
        // host move pool to up
        if (prevStatus != StoragePoolStatus.NotOperational && prevStatus != StoragePoolStatus.NonResponsive) {
            storagePool.setStatus(prevStatus);
        } else {
            storagePool.setStatus(StoragePoolStatus.Up);
        }
        storagePoolDao.update(storagePool);
        getEventListener().storagePoolStatusChanged(storagePool.getId(), storagePool.getStatus());
        setFencedIrs(null);
        returnValue = selectedVds.argvalue.getHostName();
        log.info("Initialize Irs proxy from vds: {}", returnValue);
        AuditLogable logable = new AuditLogableImpl();
        logable.setVdsName(selectedVds.argvalue.getHostName());
        logable.addCustomValue("ServerIp", returnValue);
        logable.addCustomValue("StoragePoolName", storagePool.getName());
        auditLogDirector.log(logable, AuditLogType.IRS_HOSTED_ON_VDS);
    }
    return returnValue;
}
Also used : AuditLogable(org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogable) AuditLogableImpl(org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogableImpl)

Example 2 with AuditLogableImpl

use of org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogableImpl 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 3 with AuditLogableImpl

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

the class StorageDomainHelper method checkNumberOfLVsForBlockDomain.

/**
 * If the storage domain given in the parameter is a block domain, the number of LVs on this domain will be fetched
 * and if it exceeds the maximum number of LVs defined in the AlertOnNumberOfLVs config value, an audit log will
 * be logged to indicate that the number of LVs on this domain exceeded the allowed number of LVs
 */
public void checkNumberOfLVsForBlockDomain(Guid storageDomainId) {
    StorageDomainStatic domain = storageDomainStaticDao.get(storageDomainId);
    if (domain.getStorageType().isBlockDomain()) {
        long numOfLVs = storageDomainDao.getNumberOfImagesInStorageDomain(storageDomainId);
        Integer maxNumOfLVs = Config.getValue(ConfigValues.AlertOnNumberOfLVs);
        if (numOfLVs >= maxNumOfLVs) {
            AuditLogable logable = new AuditLogableImpl();
            logable.setStorageDomainName(domain.getName());
            logable.addCustomValue("maxNumOfLVs", maxNumOfLVs.toString());
            logable.setStorageDomainId(storageDomainId);
            auditLogDirector.log(logable, AuditLogType.NUMBER_OF_LVS_ON_STORAGE_DOMAIN_EXCEEDED_THRESHOLD);
        }
    }
}
Also used : StorageDomainStatic(org.ovirt.engine.core.common.businessentities.StorageDomainStatic) AuditLogable(org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogable) AuditLogableImpl(org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogableImpl)

Example 4 with AuditLogableImpl

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

the class PostDeleteActionHandler method fixDiscardField.

/**
 * Since a storage domain's discard support may be changed since the discard after delete value was chosen by the
 * user, we should check its support before sending it to vdsm. If it doesn't support discard any more, that means
 * that discarding the disk will not work, and we can let the user know about it and send discard=false to vdsm.
 * @param parameters the parameters of the command that should be executed.
 * @param storageDomain the storage domain that the disk or snapshot belongs to.
 * @param <T> the parameters type.
 * @return the fixed parameters.
 */
protected <T extends StoragePoolDomainAndGroupIdBaseVDSCommandParameters & PostDeleteAction> T fixDiscardField(T parameters, StorageDomain storageDomain) {
    if (storageDomain.getDiscardAfterDelete()) {
        if (!Boolean.TRUE.equals(storageDomain.getSupportsDiscard())) {
            parameters.setDiscard(false);
            AuditLogable auditLog = new AuditLogableImpl();
            auditLog.setStorageDomainId(storageDomain.getId());
            auditLogDirector.log(auditLog, AuditLogType.ILLEGAL_STORAGE_DOMAIN_DISCARD_AFTER_DELETE);
        }
    } else if (diskVmElementWithPassDiscardExists(parameters.getImageGroupId()) && Boolean.TRUE.equals(storageDomain.getSupportsDiscard())) {
        // At least one vm has this disk with pass discard enabled.
        // Thus, although the relevant storage domain's discard after
        // delete value is false, we send discard = true to vdsm.
        parameters.setDiscard(true);
    }
    return parameters;
}
Also used : AuditLogable(org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogable) AuditLogableImpl(org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogableImpl)

Example 5 with AuditLogableImpl

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

the class IsoDomainListSynchronizer method addToAuditLogSuccessMessage.

/**
 * Add audit log message when fetch encounter problems.
 */
private void addToAuditLogSuccessMessage(StorageDomain isoDomain, String imageType) {
    AuditLogable logable = new AuditLogableImpl();
    logable.addCustomValue("imageDomains", String.format("%s (%s file type)", isoDomain.getName(), imageType));
    logable.setStorageDomainId(isoDomain.getId());
    logable.setStorageDomainName(isoDomain.getName());
    auditLogDirector.log(logable, AuditLogType.REFRESH_REPOSITORY_IMAGE_LIST_SUCCEEDED);
}
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