Search in sources :

Example 31 with ActionReturnValue

use of org.ovirt.engine.core.common.action.ActionReturnValue in project ovirt-engine by oVirt.

the class ProcessOvfUpdateForStorageDomainCommand method createOvfStoreDisks.

public boolean createOvfStoreDisks(int missingDiskCount) {
    boolean allOvfStoreDisksCreated = true;
    for (int i = 0; i < missingDiskCount; i++) {
        CreateOvfVolumeForStorageDomainCommandParameters parameters = createCreateOvfVolumeForStorageDomainParams();
        ActionReturnValue returnValue = runInternalAction(ActionType.CreateOvfVolumeForStorageDomain, parameters, getContext().clone().withoutLock());
        if (!returnValue.getSucceeded()) {
            allOvfStoreDisksCreated = false;
        }
    }
    return allOvfStoreDisksCreated;
}
Also used : CreateOvfVolumeForStorageDomainCommandParameters(org.ovirt.engine.core.common.action.CreateOvfVolumeForStorageDomainCommandParameters) ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue)

Example 32 with ActionReturnValue

use of org.ovirt.engine.core.common.action.ActionReturnValue in project ovirt-engine by oVirt.

the class GlusterStorageSyncCommand method executeCommand.

@Override
protected void executeCommand() {
    // Get list of running VMs that have disks on storage domain
    List<VM> vms = runInternalQuery(QueryType.GetVmsByStorageDomain, new IdQueryParameters(getStorageDomain().getId())).getReturnValue();
    // Snapshot the VMs
    Map<Guid, Guid> vmIdSnapshotIdMap = new HashMap<>();
    for (VM vm : vms) {
        try {
            Future<ActionReturnValue> future = commandCoordinatorUtil.executeAsyncCommand(ActionType.CreateSnapshotForVm, getCreateSnapshotParameters(vm), cloneContextAndDetachFromParent());
            vmIdSnapshotIdMap.put(vm.getId(), future.get().getActionReturnValue());
        } catch (InterruptedException | ExecutionException e) {
            log.error("Error creating VM snapshot for VM with id '{}', name '{}' for DR sync", vm.getId(), vm.getName(), e.getMessage());
            log.debug("Exception", e);
            endWithFailure();
            getParameters().setTaskGroupSuccess(false);
        }
    }
    getParameters().setVmIdSnapshotIds(vmIdSnapshotIdMap);
    getParameters().setNextStep(DRStep.GEO_REP);
    persistCommandIfNeeded();
    setSucceeded(true);
}
Also used : IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) HashMap(java.util.HashMap) ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue) VM(org.ovirt.engine.core.common.businessentities.VM) Guid(org.ovirt.engine.core.compat.Guid) ExecutionException(java.util.concurrent.ExecutionException)

Example 33 with ActionReturnValue

use of org.ovirt.engine.core.common.action.ActionReturnValue in project ovirt-engine by oVirt.

the class LiveMigrateDiskCommand method removeImage.

private void removeImage(Guid storageDomainId, Guid imageGroupId, Guid imageId, AuditLogType failureAuditLog) {
    RemoveImageParameters removeImageParams = new RemoveImageParameters(imageId);
    removeImageParams.setStorageDomainId(storageDomainId);
    removeImageParams.setParentCommand(ActionType.RemoveImage);
    removeImageParams.setDbOperationScope(ImageDbOperationScope.NONE);
    removeImageParams.setShouldLockImage(false);
    ActionReturnValue returnValue = runInternalAction(ActionType.RemoveImage, removeImageParams, cloneContextAndDetachFromParent());
    if (returnValue.getSucceeded()) {
        startPollingAsyncTasks(returnValue.getInternalVdsmTaskIdList());
    } else {
        addCustomValue("DiskAlias", baseDiskDao.get(imageGroupId).getDiskAlias());
        addCustomValue("StorageDomainName", storageDomainStaticDao.get(storageDomainId).getName());
        addCustomValue("UserName", getUserName());
        auditLogDirector.log(this, failureAuditLog);
    }
}
Also used : RemoveImageParameters(org.ovirt.engine.core.common.action.RemoveImageParameters) ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue)

Example 34 with ActionReturnValue

use of org.ovirt.engine.core.common.action.ActionReturnValue in project ovirt-engine by oVirt.

the class UpdateOvfStoreForStorageDomainCommand method executeCommand.

@Override
protected void executeCommand() {
    Guid storageDomainId = getStorageDomainId();
    ProcessOvfUpdateParameters parameters = new ProcessOvfUpdateParameters(getStoragePoolId(), getStorageDomainId());
    ActionReturnValue actionReturnValue = runInternalAction(ActionType.ProcessOvfUpdateForStoragePool, parameters, getContext());
    Set<Guid> proccessedDomains = actionReturnValue.getActionReturnValue();
    if (!actionReturnValue.getSucceeded()) {
        propagateFailure(actionReturnValue);
        return;
    }
    if (proccessedDomains != null && proccessedDomains.contains(storageDomainId)) {
        actionReturnValue = runInternalActionWithTasksContext(ActionType.ProcessOvfUpdateForStorageDomain, createProcessOvfUpdateForDomainParams());
        if (!actionReturnValue.getSucceeded()) {
            propagateFailure(actionReturnValue);
            return;
        }
    } else {
        addCustomValue("StorageDomainName", getStorageDomain().getName());
        auditLogDirector.log(this, AuditLogType.OVF_STORES_UPDATE_IGNORED);
    }
    setSucceeded(true);
}
Also used : ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue) Guid(org.ovirt.engine.core.compat.Guid) ProcessOvfUpdateParameters(org.ovirt.engine.core.common.action.ProcessOvfUpdateParameters)

Example 35 with ActionReturnValue

use of org.ovirt.engine.core.common.action.ActionReturnValue in project ovirt-engine by oVirt.

the class GlusterStorageGeoRepSyncInternalCommand method executeCommand.

@Override
protected void executeCommand() {
    if (getSession().getStatus() != GeoRepSessionStatus.ACTIVE) {
        // Start geo-replication
        Future<ActionReturnValue> geoRepCmd = commandCoordinatorUtil.executeAsyncCommand(ActionType.StartGlusterVolumeGeoRep, new GlusterVolumeGeoRepSessionParameters(getSession().getMasterVolumeId(), getSession().getId()), cloneContext());
        ActionReturnValue result;
        try {
            result = geoRepCmd.get();
            if (!result.getSucceeded()) {
                propagateFailure(result);
                return;
            }
        } catch (InterruptedException | ExecutionException e) {
            log.error("Exception", e);
            return;
        }
    }
    // checkpoint the replication session
    GlusterVolumeGeoRepSessionConfigParameters configParams = new GlusterVolumeGeoRepSessionConfigParameters(getSession().getMasterVolumeId(), getSession().getId(), GlusterConstants.GEOREP_CHECKPOINT_OPTION, GlusterConstants.GEOREP_CHECKPOINT_VALUE);
    ActionReturnValue result = runInternalAction(ActionType.SetGeoRepConfig, configParams);
    if (!result.getSucceeded()) {
        propagateFailure(result);
        return;
    }
    setSucceeded(true);
}
Also used : GlusterVolumeGeoRepSessionConfigParameters(org.ovirt.engine.core.common.action.gluster.GlusterVolumeGeoRepSessionConfigParameters) ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue) GlusterVolumeGeoRepSessionParameters(org.ovirt.engine.core.common.action.gluster.GlusterVolumeGeoRepSessionParameters) ExecutionException(java.util.concurrent.ExecutionException)

Aggregations

ActionReturnValue (org.ovirt.engine.core.common.action.ActionReturnValue)293 ArrayList (java.util.ArrayList)57 Guid (org.ovirt.engine.core.compat.Guid)55 ActionParametersBase (org.ovirt.engine.core.common.action.ActionParametersBase)50 Test (org.junit.Test)37 DiskImage (org.ovirt.engine.core.common.businessentities.storage.DiskImage)27 ActionType (org.ovirt.engine.core.common.action.ActionType)26 EngineException (org.ovirt.engine.core.common.errors.EngineException)25 VDS (org.ovirt.engine.core.common.businessentities.VDS)23 HashSet (java.util.HashSet)16 QueryReturnValue (org.ovirt.engine.core.common.queries.QueryReturnValue)15 ExecutionException (java.util.concurrent.ExecutionException)13 StorageDomain (org.ovirt.engine.core.common.businessentities.StorageDomain)13 CinderDisk (org.ovirt.engine.core.common.businessentities.storage.CinderDisk)13 StorageServerConnectionParametersBase (org.ovirt.engine.core.common.action.StorageServerConnectionParametersBase)12 StoragePool (org.ovirt.engine.core.common.businessentities.StoragePool)12 List (java.util.List)11 ChangeVDSClusterParameters (org.ovirt.engine.core.common.action.ChangeVDSClusterParameters)11 VM (org.ovirt.engine.core.common.businessentities.VM)11 UICommand (org.ovirt.engine.ui.uicommonweb.UICommand)11