Search in sources :

Example 11 with EngineError

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;
    }
}
Also used : EngineError(org.ovirt.engine.core.common.errors.EngineError)

Example 12 with EngineError

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;
    }
}
Also used : StorageDomain(org.ovirt.engine.core.common.businessentities.StorageDomain) EngineError(org.ovirt.engine.core.common.errors.EngineError) StorageDomainStatus(org.ovirt.engine.core.common.businessentities.StorageDomainStatus) Map(java.util.Map) HashSet(java.util.HashSet)

Example 13 with EngineError

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;
}
Also used : EngineError(org.ovirt.engine.core.common.errors.EngineError)

Example 14 with EngineError

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;
    }
}
Also used : VDSError(org.ovirt.engine.core.common.errors.VDSError) EngineError(org.ovirt.engine.core.common.errors.EngineError)

Example 15 with EngineError

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;
    }
}
Also used : EngineError(org.ovirt.engine.core.common.errors.EngineError)

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