use of org.ovirt.engine.core.common.errors.EngineError in project ovirt-engine by oVirt.
the class ConnectStorageServerVDSCommand method proceedProxyReturnValue.
@Override
protected void proceedProxyReturnValue() {
EngineError returnStatus = getReturnValueFromStatus(getReturnStatus());
switch(returnStatus) {
case StorageServerConnectionRefIdAlreadyInUse:
case StorageServerConnectionRefIdDoesNotExist:
VDSExceptionBase outEx = new VDSErrorException(String.format("Failed in vdscommand %1$s, error = %2$s", getCommandName(), getReturnStatus().message));
initializeVdsError(returnStatus);
getVDSReturnValue().setSucceeded(false);
throw outEx;
default:
super.proceedProxyReturnValue();
break;
}
}
use of org.ovirt.engine.core.common.errors.EngineError in project ovirt-engine by oVirt.
the class GetStorageDomainStatsVDSCommand method buildStorageDynamicStruct.
@SuppressWarnings("unchecked")
public static StorageDomain buildStorageDynamicStruct(Map<String, Object> struct) {
try {
StorageDomain domain = new StorageDomain();
if (struct.containsKey("status")) {
if ("Attached".equals(struct.get("status").toString())) {
domain.setStatus(StorageDomainStatus.Inactive);
} else {
domain.setStatus(EnumUtils.valueOf(StorageDomainStatus.class, struct.get("status").toString(), true));
}
}
Long size = IrsBrokerCommand.assignLongValue(struct, "diskfree");
domain.setAvailableDiskSize((size == null) ? null : (int) (size / SizeConverter.BYTES_IN_GB));
size = IrsBrokerCommand.assignLongValue(struct, "disktotal");
domain.setUsedDiskSize((size == null || domain.getAvailableDiskSize() == null) ? null : (int) (size / SizeConverter.BYTES_IN_GB) - domain.getAvailableDiskSize());
if (struct.containsKey("alerts")) {
Object[] rawAlerts = (Object[]) struct.get("alerts");
Set<EngineError> alerts = new HashSet<>(rawAlerts.length);
for (Object rawAlert : rawAlerts) {
Map<String, Object> alert = (Map<String, Object>) rawAlert;
Integer alertCode = (Integer) alert.get("code");
if (alertCode == null || EngineError.forValue(alertCode) == null) {
log.warn("Unrecognized alert code: {}.", alertCode);
StringBuilder alertStringBuilder = new StringBuilder();
ObjectDescriptor.toStringBuilder(alert, alertStringBuilder);
log.info("The received alert is: {}", alertStringBuilder);
} else {
alerts.add(EngineError.forValue(alertCode));
}
}
domain.setAlerts(alerts);
}
return domain;
} catch (RuntimeException ex) {
log.error("vdsBroker::buildStorageDynamicFromStruct::Failed building Storage dynamic, struct = {}", struct);
VDSErrorException outEx = new VDSErrorException(ex);
log.error("Exception", outEx);
throw outEx;
}
}
use of org.ovirt.engine.core.common.errors.EngineError in project ovirt-engine by oVirt.
the class StorageHelperBase method getTranslatedStorageError.
/**
* Get translated error by error code ,if no enum for the error code (should not happened) , will set the error code
* instead. <BR/>
* When no enum found for the error code, we should check it with the vdsm team.
*
* @param errorCode
* - The error code we want to translate.
* @return - Translated error if found or error code.
*/
private String getTranslatedStorageError(String errorCode) {
String translatedError = errorCode;
EngineError error = EngineError.forValue(Integer.parseInt(errorCode));
if (error != null) {
translatedError = backend.getVdsErrorsTranslator().translateErrorTextSingle(error.toString());
}
return translatedError;
}
use of org.ovirt.engine.core.common.errors.EngineError in project ovirt-engine by oVirt.
the class SpmStopVDSCommand method proceedProxyReturnValue.
@Override
protected void proceedProxyReturnValue() {
EngineError returnStatus = getReturnValueFromStatus(getReturnStatus());
switch(returnStatus) {
case StoragePoolUnknown:
case SpmStatusError:
// ignore this, the parser can handle the empty result.
break;
case TaskInProgress:
getVDSReturnValue().setVdsError(new VDSError(returnStatus, getReturnStatus().message));
getVDSReturnValue().setSucceeded(false);
break;
default:
super.proceedProxyReturnValue();
initializeVdsError(returnStatus);
break;
}
}
use of org.ovirt.engine.core.common.errors.EngineError in project ovirt-engine by oVirt.
the class ExtendStorageDomainVDSCommand method proceedProxyReturnValue.
@Override
protected void proceedProxyReturnValue() {
EngineError returnStatus = getReturnValueFromStatus(getReturnStatus());
switch(returnStatus) {
case DeviceNotFound:
getVDSReturnValue().setSucceeded(false);
break;
default:
super.proceedProxyReturnValue();
initializeVdsError(returnStatus);
break;
}
}
Aggregations