Search in sources :

Example 91 with VDSReturnValue

use of org.ovirt.engine.core.common.vdscommands.VDSReturnValue in project ovirt-engine by oVirt.

the class HostSetupNetworksCommand method executeCommand.

@Override
protected void executeCommand() {
    if (noChangesDetected()) {
        log.info("No changes were detected in setup networks for host '{}' (ID: '{}')", getVdsName(), getVdsId());
        setSucceeded(true);
        return;
    }
    try (EngineLock monitoringLock = acquireMonitorLock("Host setup networks")) {
        int timeout = getSetupNetworksTimeout();
        FutureVDSCall<VDSReturnValue> setupNetworksTask = invokeSetupNetworksCommand(timeout);
        try {
            VDSReturnValue retVal = setupNetworksTask.get(timeout, TimeUnit.SECONDS);
            if (retVal != null) {
                if (!retVal.getSucceeded() && retVal.getVdsError() == null && getParameters().rollbackOnFailure()) {
                    throw new EngineException(EngineError.SETUP_NETWORKS_ROLLBACK, retVal.getExceptionString());
                }
                VdsHandler.handleVdsResult(retVal);
                if (retVal.getSucceeded()) {
                    VDSReturnValue returnValue = runVdsCommand(VDSCommandType.GetCapabilities, new VdsIdAndVdsVDSCommandParametersBase(getVds()));
                    VDS updatedHost = (VDS) returnValue.getReturnValue();
                    persistNetworkChanges(updatedHost);
                }
                setSucceeded(true);
            }
        } catch (TimeoutException e) {
            log.debug("Host Setup networks command timed out for {} seconds", timeout);
        }
    }
}
Also used : VDS(org.ovirt.engine.core.common.businessentities.VDS) VdsIdAndVdsVDSCommandParametersBase(org.ovirt.engine.core.common.vdscommands.VdsIdAndVdsVDSCommandParametersBase) EngineException(org.ovirt.engine.core.common.errors.EngineException) EngineLock(org.ovirt.engine.core.utils.lock.EngineLock) VDSReturnValue(org.ovirt.engine.core.common.vdscommands.VDSReturnValue) TimeoutException(java.util.concurrent.TimeoutException)

Example 92 with VDSReturnValue

use of org.ovirt.engine.core.common.vdscommands.VDSReturnValue in project ovirt-engine by oVirt.

the class CommitNetworkChangesCommand method executeCommand.

@Override
protected void executeCommand() {
    VDSReturnValue retVal = runVdsCommand(VDSCommandType.SetSafeNetworkConfig, new VdsIdVDSCommandParametersBase(getParameters().getVdsId()));
    vdsDynamicDao.updateNetConfigDirty(getParameters().getVdsId(), false);
    setSucceeded(retVal.getSucceeded());
}
Also used : VdsIdVDSCommandParametersBase(org.ovirt.engine.core.common.vdscommands.VdsIdVDSCommandParametersBase) VDSReturnValue(org.ovirt.engine.core.common.vdscommands.VDSReturnValue)

Example 93 with VDSReturnValue

use of org.ovirt.engine.core.common.vdscommands.VDSReturnValue in project ovirt-engine by oVirt.

the class VdsCommandsHelper method runVdsCommand.

private VDSReturnValue runVdsCommand(VDSCommandType vdsCommandType, VdsIdVDSCommandParametersBase params, Guid storagePoolId, CommandBase<?> cmd, boolean performFailover) {
    Set<Guid> executedHosts = new HashSet<>();
    VDSReturnValue returnValue = null;
    if (params.getVdsId() == null) {
        chooseHostForExecution(params, storagePoolId, cmd, Collections.emptyList());
        if (params.getVdsId() == null) {
            throw new EngineException(EngineError.RESOURCE_MANAGER_VDS_NOT_FOUND, "No host was found to perform the operation");
        }
    }
    int attempts = 0;
    while (attempts <= Config.<Integer>getValue(ConfigValues.HsmCommandFailOverRetries)) {
        try {
            attempts++;
            returnValue = resourceManager.runVdsCommand(vdsCommandType, params);
            if (returnValue != null && returnValue.getSucceeded()) {
                return returnValue;
            }
        } catch (EngineException e) {
            returnValue = e.getVdsReturnValue();
        }
        executedHosts.add(params.getVdsId());
        if (!performFailover || (returnValue != null && !returnValue.isCanTryOnDifferentVds())) {
            break;
        }
        chooseHostForExecution(params, storagePoolId, cmd, executedHosts);
        if (params.getVdsId() == null) {
            break;
        }
    }
    return VdsHandler.handleVdsResult(returnValue);
}
Also used : EngineException(org.ovirt.engine.core.common.errors.EngineException) Guid(org.ovirt.engine.core.compat.Guid) HashSet(java.util.HashSet) VDSReturnValue(org.ovirt.engine.core.common.vdscommands.VDSReturnValue)

Example 94 with VDSReturnValue

use of org.ovirt.engine.core.common.vdscommands.VDSReturnValue in project ovirt-engine by oVirt.

the class ExportRepoImageCommand method executeCommand.

@Override
protected void executeCommand() {
    DiskImage diskImage = getDiskImage();
    OpenStackImageProviderProxy proxy = getProviderProxy();
    acquireImageDbLock();
    String newImageId = proxy.createImageFromDiskImage(diskImage);
    getParameters().setParentCommand(ActionType.ExportRepoImage);
    Guid taskId = persistAsyncTaskPlaceHolder(getParameters().getParentCommand());
    getParameters().setEntityInfo(new EntityInfo(VdcObjectType.Disk, getParameters().getImageGroupID()));
    VDSReturnValue vdsReturnValue = runVdsCommand(VDSCommandType.UploadImage, new UploadImageVDSCommandParameters(getStorageDomain().getStoragePoolId(), getStorageDomain().getId(), diskImage.getId(), diskImage.getImageId(), new HttpLocationInfo(getProviderProxy().getImageUrl(newImageId), getProviderProxy().getUploadHeaders())));
    if (vdsReturnValue.getSucceeded()) {
        getReturnValue().getVdsmTaskIdList().add(createTask(taskId, vdsReturnValue.getCreationInfo(), getParameters().getParentCommand(), VdcObjectType.Disk, getParameters().getImageGroupID(), getParameters().getDestinationDomainId()));
    }
    getReturnValue().setActionReturnValue(newImageId);
    setSucceeded(true);
}
Also used : UploadImageVDSCommandParameters(org.ovirt.engine.core.common.vdscommands.UploadImageVDSCommandParameters) EntityInfo(org.ovirt.engine.core.common.asynctasks.EntityInfo) HttpLocationInfo(org.ovirt.engine.core.common.businessentities.HttpLocationInfo) Guid(org.ovirt.engine.core.compat.Guid) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage) OpenStackImageProviderProxy(org.ovirt.engine.core.bll.provider.storage.OpenStackImageProviderProxy) VDSReturnValue(org.ovirt.engine.core.common.vdscommands.VDSReturnValue)

Example 95 with VDSReturnValue

use of org.ovirt.engine.core.common.vdscommands.VDSReturnValue in project ovirt-engine by oVirt.

the class SPMAsyncTask method clearAsyncTask.

@Override
public void clearAsyncTask(boolean forceDelete) {
    VDSReturnValue vdsReturnValue = null;
    try {
        log.info("SPMAsyncTask::ClearAsyncTask: Attempting to clear task '{}'", getVdsmTaskId());
        vdsReturnValue = coco.clearTask(getStoragePoolID(), getVdsmTaskId());
    } catch (RuntimeException e) {
        log.error("SPMAsyncTask::ClearAsyncTask: Error during clearing task '{}': {}", getVdsmTaskId(), e.getMessage());
        log.error("Exception", e);
    }
    boolean shouldGracefullyDeleteTask = false;
    if (!isTaskStateError(vdsReturnValue)) {
        if (vdsReturnValue == null || !vdsReturnValue.getSucceeded()) {
            setState(AsyncTaskState.ClearFailed);
            onTaskCleanFailure();
        } else {
            setState(AsyncTaskState.Cleared);
            shouldGracefullyDeleteTask = true;
        }
    }
    // A task should be removed from DB if forceDelete is set to true, or if it was cleared successfully.
    if (shouldGracefullyDeleteTask || forceDelete) {
        removeTaskFromDB();
    }
}
Also used : VDSReturnValue(org.ovirt.engine.core.common.vdscommands.VDSReturnValue)

Aggregations

VDSReturnValue (org.ovirt.engine.core.common.vdscommands.VDSReturnValue)250 Guid (org.ovirt.engine.core.compat.Guid)65 ArrayList (java.util.ArrayList)43 VDS (org.ovirt.engine.core.common.businessentities.VDS)29 EngineException (org.ovirt.engine.core.common.errors.EngineException)29 Pair (org.ovirt.engine.core.common.utils.Pair)26 StorageDomain (org.ovirt.engine.core.common.businessentities.StorageDomain)23 List (java.util.List)16 Test (org.junit.Test)15 StorageDomainStatic (org.ovirt.engine.core.common.businessentities.StorageDomainStatic)15 DiskImage (org.ovirt.engine.core.common.businessentities.storage.DiskImage)15 VdsIdVDSCommandParametersBase (org.ovirt.engine.core.common.vdscommands.VdsIdVDSCommandParametersBase)15 HashMap (java.util.HashMap)13 VDSError (org.ovirt.engine.core.common.errors.VDSError)13 Map (java.util.Map)11 Callable (java.util.concurrent.Callable)11 StoragePool (org.ovirt.engine.core.common.businessentities.StoragePool)11 StoragePoolIsoMap (org.ovirt.engine.core.common.businessentities.StoragePoolIsoMap)11 EngineLock (org.ovirt.engine.core.utils.lock.EngineLock)9 GlusterGeoRepSession (org.ovirt.engine.core.common.businessentities.gluster.GlusterGeoRepSession)8