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;
}
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;
}
}
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;
}
}
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;
}
}
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;
}
}
Aggregations