Search in sources :

Example 1 with EngineError

use of org.ovirt.engine.core.common.errors.EngineError 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 EngineError

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

the class BrokerCommandBase method getReturnValueFromStatus.

protected EngineError getReturnValueFromStatus(Status status) {
    try {
        EngineError bllErrors = EngineError.forValue(status.code);
        if (bllErrors == null) {
            log.warn("Unexpected return value: {}", status);
            bllErrors = EngineError.unexpected;
        }
        return bllErrors;
    } catch (Exception e) {
        return EngineError.unexpected;
    }
}
Also used : EngineError(org.ovirt.engine.core.common.errors.EngineError) IRSNonOperationalException(org.ovirt.engine.core.vdsbroker.irsbroker.IRSNonOperationalException) IRSNoMasterDomainException(org.ovirt.engine.core.vdsbroker.irsbroker.IRSNoMasterDomainException) IRSUnicodeArgumentException(org.ovirt.engine.core.vdsbroker.irsbroker.IRSUnicodeArgumentException) IrsOperationFailedNoFailoverException(org.ovirt.engine.core.vdsbroker.irsbroker.IrsOperationFailedNoFailoverException)

Example 3 with EngineError

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

the class GetVolumesListVDSCommand method proceedProxyReturnValue.

@Override
protected void proceedProxyReturnValue() {
    EngineError returnStatus = getReturnValueFromStatus(getReturnStatus());
    switch(returnStatus) {
        case GetStorageDomainListError:
            getVDSReturnValue().setVdsError(new VDSError(returnStatus, getReturnStatus().message));
            getVDSReturnValue().setSucceeded(false);
            break;
        default:
            super.proceedProxyReturnValue();
            break;
    }
}
Also used : VDSError(org.ovirt.engine.core.common.errors.VDSError) EngineError(org.ovirt.engine.core.common.errors.EngineError)

Example 4 with EngineError

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

the class RemoveVMVDSCommand method proceedProxyReturnValue.

@Override
protected void proceedProxyReturnValue() {
    EngineError returnStatus = getReturnValueFromStatus(getReturnStatus());
    switch(returnStatus) {
        case Done:
            return;
        default:
            VDSExceptionBase outEx = createDefaultConcreteException(getReturnStatus().message);
            initializeVdsError(returnStatus);
            outEx.setVdsError(getVDSReturnValue().getVdsError());
            throw outEx;
    }
}
Also used : EngineError(org.ovirt.engine.core.common.errors.EngineError) VDSExceptionBase(org.ovirt.engine.core.vdsbroker.vdsbroker.VDSExceptionBase)

Example 5 with EngineError

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

the class UpdateVMVDSCommand method proceedProxyReturnValue.

@Override
protected void proceedProxyReturnValue() {
    EngineError returnStatus = getReturnValueFromStatus(getReturnStatus());
    switch(returnStatus) {
        case Done:
            return;
        default:
            VDSExceptionBase outEx = createDefaultConcreteException(getReturnStatus().message);
            initializeVdsError(returnStatus);
            outEx.setVdsError(getVDSReturnValue().getVdsError());
            throw outEx;
    }
}
Also used : EngineError(org.ovirt.engine.core.common.errors.EngineError) VDSExceptionBase(org.ovirt.engine.core.vdsbroker.vdsbroker.VDSExceptionBase)

Aggregations

EngineError (org.ovirt.engine.core.common.errors.EngineError)19 VDSError (org.ovirt.engine.core.common.errors.VDSError)6 StorageDomain (org.ovirt.engine.core.common.businessentities.StorageDomain)2 IRSNoMasterDomainException (org.ovirt.engine.core.vdsbroker.irsbroker.IRSNoMasterDomainException)2 IRSNonOperationalException (org.ovirt.engine.core.vdsbroker.irsbroker.IRSNonOperationalException)2 IRSUnicodeArgumentException (org.ovirt.engine.core.vdsbroker.irsbroker.IRSUnicodeArgumentException)2 IrsOperationFailedNoFailoverException (org.ovirt.engine.core.vdsbroker.irsbroker.IrsOperationFailedNoFailoverException)2 VDSExceptionBase (org.ovirt.engine.core.vdsbroker.vdsbroker.VDSExceptionBase)2 HashSet (java.util.HashSet)1 Map (java.util.Map)1 AuditLogType (org.ovirt.engine.core.common.AuditLogType)1 StorageDomainStatic (org.ovirt.engine.core.common.businessentities.StorageDomainStatic)1 StorageDomainStatus (org.ovirt.engine.core.common.businessentities.StorageDomainStatus)1 StoragePool (org.ovirt.engine.core.common.businessentities.StoragePool)1 StoragePoolIsoMap (org.ovirt.engine.core.common.businessentities.StoragePoolIsoMap)1 AuditLogable (org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogable)1 AuditLogableImpl (org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogableImpl)1 IrsBrokerCommand (org.ovirt.engine.core.vdsbroker.irsbroker.IrsBrokerCommand)1