Search in sources :

Example 11 with EngineFault

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

the class ConnectStorageToVdsCommand method setErrorMessageAtReturn.

private void setErrorMessageAtReturn(Pair<Boolean, Integer> result) {
    EngineFault fault = new EngineFault();
    fault.setError(result.getSecond());
    if (fault.getError() != null) {
        fault.setMessage(Backend.getInstance().getVdsErrorsTranslator().translateErrorTextSingle(fault.getError().toString()));
    }
    getReturnValue().setFault(fault);
}
Also used : EngineFault(org.ovirt.engine.core.common.errors.EngineFault)

Example 12 with EngineFault

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

the class FCPStorageHelper method runConnectionStorageToDomain.

@Override
protected Pair<Boolean, EngineFault> runConnectionStorageToDomain(StorageDomain storageDomain, Guid vdsId, int type, LUNs lun, Guid storagePoolId) {
    VDSReturnValue returnValue = backend.getResourceManager().runVdsCommand(VDSCommandType.forValue(type), new StorageServerConnectionManagementVDSParameters(vdsId, storagePoolId, StorageType.FCP, Collections.singletonList(getFCPConnection())));
    boolean isSuccess = returnValue.getSucceeded();
    EngineFault engineFault = null;
    if (!isSuccess && returnValue.getVdsError() != null) {
        engineFault = new EngineFault();
        engineFault.setError(returnValue.getVdsError().getCode());
    }
    return new Pair<>(isSuccess, engineFault);
}
Also used : StorageServerConnectionManagementVDSParameters(org.ovirt.engine.core.common.vdscommands.StorageServerConnectionManagementVDSParameters) EngineFault(org.ovirt.engine.core.common.errors.EngineFault) VDSReturnValue(org.ovirt.engine.core.common.vdscommands.VDSReturnValue) Pair(org.ovirt.engine.core.common.utils.Pair)

Example 13 with EngineFault

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

the class FileStorageHelper method runConnectionStorageToDomain.

@Override
protected Pair<Boolean, EngineFault> runConnectionStorageToDomain(StorageDomain storageDomain, Guid vdsId, int type) {
    Pair<Boolean, EngineFault> result;
    StorageServerConnections connection = storageServerConnectionDao.get(storageDomain.getStorage());
    if (connection != null) {
        ActionReturnValue returnValue = backend.runInternalAction(ActionType.forValue(type), new StorageServerConnectionParametersBase(connection, vdsId, false));
        result = new Pair<>(returnValue.getSucceeded(), returnValue.getFault());
    } else {
        result = new Pair<>(false, null);
        log.warn("Did not connect host '{}' to storage domain '{}' because connection for connectionId '{}' is null.", vdsId, storageDomain.getStorageName(), storageDomain.getStorage());
    }
    return result;
}
Also used : StorageServerConnections(org.ovirt.engine.core.common.businessentities.StorageServerConnections) ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue) EngineFault(org.ovirt.engine.core.common.errors.EngineFault) StorageServerConnectionParametersBase(org.ovirt.engine.core.common.action.StorageServerConnectionParametersBase)

Example 14 with EngineFault

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

the class CINDERStorageHelper method registerLibvirtSecrets.

public Pair<Boolean, EngineFault> registerLibvirtSecrets(StorageDomain storageDomain, VDS vds, List<LibvirtSecret> libvirtSecrets) {
    VDSReturnValue returnValue;
    if (!libvirtSecrets.isEmpty()) {
        try {
            returnValue = backend.getResourceManager().runVdsCommand(VDSCommandType.RegisterLibvirtSecrets, new RegisterLibvirtSecretsVDSParameters(vds.getId(), libvirtSecrets));
        } catch (RuntimeException e) {
            log.error("Failed to register libvirt secret for storage domain {} on vds {}. Error: {}", storageDomain.getName(), vds.getName(), e.getMessage());
            log.debug("Exception", e);
            return new Pair<>(false, null);
        }
        if (!returnValue.getSucceeded()) {
            addMessageToAuditLog(AuditLogType.FAILED_TO_REGISTER_LIBVIRT_SECRET, storageDomain, vds);
            log.error("Failed to register libvirt secret for storage domain {} on vds {}.", storageDomain.getName(), vds.getName());
            EngineFault engineFault = new EngineFault();
            engineFault.setError(returnValue.getVdsError().getCode());
            return new Pair<>(false, engineFault);
        }
    }
    return new Pair<>(true, null);
}
Also used : RegisterLibvirtSecretsVDSParameters(org.ovirt.engine.core.common.vdscommands.RegisterLibvirtSecretsVDSParameters) EngineFault(org.ovirt.engine.core.common.errors.EngineFault) VDSReturnValue(org.ovirt.engine.core.common.vdscommands.VDSReturnValue) Pair(org.ovirt.engine.core.common.utils.Pair)

Example 15 with EngineFault

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

the class RestoreFromSnapshotCommand method performImageVdsmOperation.

@Override
protected boolean performImageVdsmOperation() {
    VDSReturnValue vdsReturnValue = null;
    try {
        Guid storagePoolId = getDiskImage().getStoragePoolId() != null ? getDiskImage().getStoragePoolId() : Guid.Empty;
        Guid storageDomainId = getDiskImage().getStorageIds() != null && !getDiskImage().getStorageIds().isEmpty() ? getDiskImage().getStorageIds().get(0) : Guid.Empty;
        Guid imageGroupId = getDiskImage().getId() != null ? getDiskImage().getId() : Guid.Empty;
        Guid taskId = persistAsyncTaskPlaceHolder(ActionType.RestoreAllSnapshots);
        vdsReturnValue = runVdsCommand(VDSCommandType.DestroyImage, postDeleteActionHandler.fixParameters(new DestroyImageVDSCommandParameters(storagePoolId, storageDomainId, imageGroupId, _imagesToDelete, getDiskImage().isWipeAfterDelete(), storageDomainDao.get(storageDomainId).getDiscardAfterDelete(), true)));
        if (vdsReturnValue.getSucceeded()) {
            getReturnValue().getInternalVdsmTaskIdList().add(createTask(taskId, vdsReturnValue.getCreationInfo(), ActionType.RestoreAllSnapshots, VdcObjectType.Storage, storageDomainId));
        }
    }// Don't throw an exception when cannot destroy image in the VDSM.
     catch (EngineException e) {
        // Set fault for parent command RestoreAllSnapshotCommand to use, if decided to fail the command.
        getReturnValue().setFault(new EngineFault(e, e.getVdsError().getCode()));
        log.info("Image '{}' not exist in Irs", getDiskImage().getImageId());
    }
    return vdsReturnValue != null ? vdsReturnValue.getSucceeded() : false;
}
Also used : DestroyImageVDSCommandParameters(org.ovirt.engine.core.common.vdscommands.DestroyImageVDSCommandParameters) EngineFault(org.ovirt.engine.core.common.errors.EngineFault) EngineException(org.ovirt.engine.core.common.errors.EngineException) Guid(org.ovirt.engine.core.compat.Guid) VDSReturnValue(org.ovirt.engine.core.common.vdscommands.VDSReturnValue)

Aggregations

EngineFault (org.ovirt.engine.core.common.errors.EngineFault)20 ActionReturnValue (org.ovirt.engine.core.common.action.ActionReturnValue)6 VDSReturnValue (org.ovirt.engine.core.common.vdscommands.VDSReturnValue)6 Test (org.junit.Test)4 ActionParametersBase (org.ovirt.engine.core.common.action.ActionParametersBase)4 Pair (org.ovirt.engine.core.common.utils.Pair)3 ArrayList (java.util.ArrayList)2 StorageDomain (org.ovirt.engine.core.common.businessentities.StorageDomain)2 StorageServerConnections (org.ovirt.engine.core.common.businessentities.StorageServerConnections)2 EngineException (org.ovirt.engine.core.common.errors.EngineException)2 StorageServerConnectionManagementVDSParameters (org.ovirt.engine.core.common.vdscommands.StorageServerConnectionManagementVDSParameters)2 Guid (org.ovirt.engine.core.compat.Guid)2 Map (java.util.Map)1 StorageServerConnectionParametersBase (org.ovirt.engine.core.common.action.StorageServerConnectionParametersBase)1 StoragePoolIsoMap (org.ovirt.engine.core.common.businessentities.StoragePoolIsoMap)1 VDS (org.ovirt.engine.core.common.businessentities.VDS)1 LUNStorageServerConnectionMap (org.ovirt.engine.core.common.businessentities.storage.LUNStorageServerConnectionMap)1 Event (org.ovirt.engine.core.common.eventqueue.Event)1 EventResult (org.ovirt.engine.core.common.eventqueue.EventResult)1 DestroyImageVDSCommandParameters (org.ovirt.engine.core.common.vdscommands.DestroyImageVDSCommandParameters)1