Search in sources :

Example 61 with EngineException

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

the class CreateAllOvaDisksCommand method copy.

private void copy(DiskImage source, DiskImage destination) {
    ActionReturnValue vdcRetValue = runInternalActionWithTasksContext(ActionType.CopyImageGroup, buildMoveOrCopyImageGroupParametersForDisk(source, destination));
    if (!vdcRetValue.getSucceeded()) {
        throw new EngineException(vdcRetValue.getFault().getError(), "Failed to copy disk!");
    }
    // TODO: Currently REST-API doesn't support coco for async commands, remove when bug 1199011 fixed
    getTaskIdList().addAll(vdcRetValue.getVdsmTaskIdList());
}
Also used : ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue) EngineException(org.ovirt.engine.core.common.errors.EngineException)

Example 62 with EngineException

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

the class CreateAllTemplateDisksCommand method addVmTemplateImage.

private void addVmTemplateImage(DiskImage diskImage, Map<Guid, Guid> srcDeviceIdToTargetDeviceIdMapping) {
    // The return value of this action is the 'copyImage' task GUID:
    Guid targetDiskId = getParameters().getTargetDiskIds()[targetDiskIdIndex++];
    ActionReturnValue returnValue = Backend.getInstance().runInternalAction(ActionType.CreateImageTemplate, buildCreateImageTemplateCommandParameters(diskImage, targetDiskId), ExecutionHandler.createDefaultContextForTasks(getContext()));
    if (!returnValue.getSucceeded()) {
        throw new EngineException(returnValue.getFault().getError(), returnValue.getFault().getMessage());
    }
    getReturnValue().getVdsmTaskIdList().addAll(returnValue.getInternalVdsmTaskIdList());
    DiskImage newImage = returnValue.getActionReturnValue();
    srcDeviceIdToTargetDeviceIdMapping.put(diskImage.getId(), newImage.getId());
}
Also used : ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue) EngineException(org.ovirt.engine.core.common.errors.EngineException) Guid(org.ovirt.engine.core.compat.Guid) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage)

Example 63 with EngineException

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

the class StorageHandlingCommandBase method handleDestroyStoragePoolCommand.

protected void handleDestroyStoragePoolCommand() {
    try {
        runVdsCommand(VDSCommandType.DestroyStoragePool, new IrsBaseVDSCommandParameters(getStoragePool().getId()));
    } catch (EngineException e) {
        try {
            TransactionSupport.executeInNewTransaction(() -> {
                runVdsCommand(VDSCommandType.SpmStopOnIrs, new SpmStopOnIrsVDSCommandParameters(getStoragePool().getId()));
                return null;
            });
        } catch (Exception e1) {
            log.error("Failed destroy storage pool with id '{}' and after that failed to stop spm: {}", getStoragePoolId(), e1.getMessage());
            log.debug("Exception", e1);
        }
        throw e;
    }
}
Also used : IrsBaseVDSCommandParameters(org.ovirt.engine.core.common.vdscommands.IrsBaseVDSCommandParameters) SpmStopOnIrsVDSCommandParameters(org.ovirt.engine.core.vdsbroker.irsbroker.SpmStopOnIrsVDSCommandParameters) EngineException(org.ovirt.engine.core.common.errors.EngineException) EngineException(org.ovirt.engine.core.common.errors.EngineException) IOException(java.io.IOException)

Example 64 with EngineException

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

the class AddStorageServerConnectionCommand method executeCommand.

@Override
protected void executeCommand() {
    // If not, just save the connection to the database
    if (!Guid.isNullOrEmpty(getParameters().getVdsId())) {
        Pair<Boolean, Integer> result = connectHostToStorage();
        boolean isValidConnection = result.getFirst();
        // Process failure
        if (!isValidConnection) {
            throw new EngineException(EngineError.forValue(result.getSecond()));
        }
    }
    StorageServerConnections connection = getConnection();
    connection.setId(Guid.newGuid().toString());
    saveConnection(connection);
    getReturnValue().setActionReturnValue(connection.getId());
    setSucceeded(true);
}
Also used : StorageServerConnections(org.ovirt.engine.core.common.businessentities.StorageServerConnections) EngineException(org.ovirt.engine.core.common.errors.EngineException)

Example 65 with EngineException

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

the class CINDERStorageHelper method activateCinderDomain.

public void activateCinderDomain(Guid storageDomainId, Guid storagePoolId) {
    OpenStackVolumeProviderProxy proxy = OpenStackVolumeProviderProxy.getFromStorageDomainId(storageDomainId, providerProxyFactory);
    if (proxy == null) {
        log.error("Couldn't create an OpenStackVolumeProviderProxy for storage domain ID: {}", storageDomainId);
        return;
    }
    try {
        proxy.testConnection();
        updateCinderDomainStatus(storageDomainId, storagePoolId, StorageDomainStatus.Active);
    } catch (EngineException e) {
        AuditLogable loggable = new AuditLogableImpl();
        loggable.addCustomValue("CinderException", e.getCause().getCause() != null ? e.getCause().getCause().getMessage() : e.getCause().getMessage());
        auditLogDirector.log(loggable, AuditLogType.CINDER_PROVIDER_ERROR);
        throw e;
    }
}
Also used : AuditLogable(org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogable) EngineException(org.ovirt.engine.core.common.errors.EngineException) AuditLogableImpl(org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogableImpl) OpenStackVolumeProviderProxy(org.ovirt.engine.core.bll.provider.storage.OpenStackVolumeProviderProxy)

Aggregations

EngineException (org.ovirt.engine.core.common.errors.EngineException)107 Guid (org.ovirt.engine.core.compat.Guid)30 ActionReturnValue (org.ovirt.engine.core.common.action.ActionReturnValue)25 VDSReturnValue (org.ovirt.engine.core.common.vdscommands.VDSReturnValue)25 DiskImage (org.ovirt.engine.core.common.businessentities.storage.DiskImage)18 ArrayList (java.util.ArrayList)17 VDS (org.ovirt.engine.core.common.businessentities.VDS)11 HashMap (java.util.HashMap)7 Pair (org.ovirt.engine.core.common.utils.Pair)7 HashSet (java.util.HashSet)6 List (java.util.List)6 Callable (java.util.concurrent.Callable)6 Snapshot (org.ovirt.engine.core.common.businessentities.Snapshot)6 IOException (java.io.IOException)5 EntityInfo (org.ovirt.engine.core.common.asynctasks.EntityInfo)5 Map (java.util.Map)4 PersistentHostSetupNetworksParameters (org.ovirt.engine.core.common.action.PersistentHostSetupNetworksParameters)4 Cluster (org.ovirt.engine.core.common.businessentities.Cluster)4 Set (java.util.Set)3 VdsActionParameters (org.ovirt.engine.core.common.action.VdsActionParameters)3