Search in sources :

Example 81 with VDSReturnValue

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

the class CopyImageGroupCommand method performStorageOperation.

private boolean performStorageOperation() {
    Guid sourceDomainId = getParameters().getSourceDomainId() != null ? getParameters().getSourceDomainId() : getDiskImage().getStorageIds().get(0);
    if (isUsingSPDMFlow()) {
        CopyImageGroupWithDataCommandParameters p = new CopyImageGroupWithDataCommandParameters(getStorageDomain().getStoragePoolId(), sourceDomainId, getParameters().getStorageDomainId(), getParameters().getImageGroupID(), getParameters().getImageId(), getParameters().getImageGroupID(), getParameters().getImageId(), getVolumeFormatForDomain(), getParameters().getUseCopyCollapse());
        p.setParentParameters(getParameters());
        p.setParentCommand(getActionType());
        p.setEndProcedure(EndProcedure.COMMAND_MANAGED);
        p.setJobWeight(getParameters().getJobWeight());
        runInternalAction(ActionType.CopyImageGroupWithData, p);
        return true;
    } else {
        VDSReturnValue vdsReturnValue;
        Guid taskId = persistAsyncTaskPlaceHolder(getParameters().getParentCommand());
        if (getParameters().getUseCopyCollapse()) {
            vdsReturnValue = runVdsCommand(VDSCommandType.CopyImage, postDeleteActionHandler.fixParameters(new CopyImageVDSCommandParameters(getStorageDomain().getStoragePoolId(), sourceDomainId, getParameters().getContainerId(), getParameters().getImageGroupID(), getParameters().getImageId(), getParameters().getDestImageGroupId(), getParameters().getDestinationImageId(), "", getParameters().getStorageDomainId(), getParameters().getCopyVolumeType(), getVolumeFormatForDomain(), getParameters().getVolumeType(), isWipeAfterDelete(), getStorageDomain().getDiscardAfterDelete(), getParameters().getForceOverride())));
        } else {
            vdsReturnValue = runVdsCommand(VDSCommandType.MoveImageGroup, postDeleteActionHandler.fixParameters(new MoveImageGroupVDSCommandParameters(getDiskImage() != null ? getDiskImage().getStoragePoolId() : getStorageDomain().getStoragePoolId(), sourceDomainId, getDiskImage() != null ? getDiskImage().getId() : getParameters().getImageGroupID(), getParameters().getStorageDomainId(), getParameters().getContainerId(), ImageOperation.Copy, isWipeAfterDelete(), storageDomainDao.get(sourceDomainId).getDiscardAfterDelete(), getParameters().getForceOverride())));
        }
        if (vdsReturnValue.getSucceeded()) {
            AsyncTaskCreationInfo taskCreationInfo = vdsReturnValue.getCreationInfo();
            getTaskIdList().add(createTask(taskId, taskCreationInfo, getParameters().getParentCommand(), VdcObjectType.Storage, sourceDomainId, getParameters().getStorageDomainId()));
        }
        return vdsReturnValue.getSucceeded();
    }
}
Also used : MoveImageGroupVDSCommandParameters(org.ovirt.engine.core.common.vdscommands.MoveImageGroupVDSCommandParameters) CopyImageVDSCommandParameters(org.ovirt.engine.core.common.vdscommands.CopyImageVDSCommandParameters) AsyncTaskCreationInfo(org.ovirt.engine.core.common.asynctasks.AsyncTaskCreationInfo) Guid(org.ovirt.engine.core.compat.Guid) CopyImageGroupWithDataCommandParameters(org.ovirt.engine.core.common.action.CopyImageGroupWithDataCommandParameters) VDSReturnValue(org.ovirt.engine.core.common.vdscommands.VDSReturnValue)

Example 82 with VDSReturnValue

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

the class CreateImageTemplateCommand method executeCommand.

@Override
protected void executeCommand() {
    Guid storagePoolId = getDiskImage().getStoragePoolId() != null ? getDiskImage().getStoragePoolId() : Guid.Empty;
    Guid imageGroupId = getDiskImage().getId() != null ? getDiskImage().getId() : Guid.Empty;
    Guid snapshotId = getDiskImage().getImageId();
    // Create new image group id and image id:
    Guid destinationImageGroupID = Guid.newGuid();
    setDestinationImageId(Guid.newGuid());
    DiskImage newImage = cloneDiskImage(getDestinationImageId());
    if (getParameters().getVolumeFormat() == null || getParameters().getVolumeType() == null) {
        // At least one of the volume arguments should be copied from the ancestral image.
        fillVolumeInformation(newImage);
    }
    if (getParameters().getVolumeFormat() != null) {
        newImage.setVolumeFormat(getParameters().getVolumeFormat());
    }
    if (getParameters().getVolumeType() != null) {
        newImage.setVolumeType(getParameters().getVolumeType());
    }
    Guid taskId = persistAsyncTaskPlaceHolder(getParameters().getParentCommand());
    VolumeFormat targetFormat = getTargetVolumeFormat(newImage.getVolumeFormat(), newImage.getVolumeType(), getParameters().getDestinationStorageDomainId());
    newImage.setDiskAlias(getParameters().getDiskAlias() != null ? getParameters().getDiskAlias() : getDiskImage().getDiskAlias());
    VDSReturnValue vdsReturnValue = runVdsCommand(VDSCommandType.CopyImage, postDeleteActionHandler.fixParameters(new CopyImageVDSCommandParameters(storagePoolId, getParameters().getStorageDomainId(), getParameters().getVmId(), imageGroupId, snapshotId, destinationImageGroupID, getDestinationImageId(), getJsonDiskDescription(newImage), getParameters().getDestinationStorageDomainId(), getParameters().getCopyVolumeType(), targetFormat, newImage.getVolumeType(), getDiskImage().isWipeAfterDelete(), storageDomainDao.get(getParameters().getDestinationStorageDomainId()).getDiscardAfterDelete(), false)));
    getReturnValue().getInternalVdsmTaskIdList().add(createTask(taskId, vdsReturnValue.getCreationInfo(), getParameters().getParentCommand(), VdcObjectType.Storage, getParameters().getStorageDomainId(), getParameters().getDestinationStorageDomainId()));
    newImage.setId(destinationImageGroupID);
    newImage.setDiskDescription(getParameters().getDescription() != null ? getParameters().getDescription() : getDiskImage().getDiskDescription());
    newImage.setVmSnapshotId(getParameters().getVmSnapshotId());
    newImage.setQuotaId(getParameters().getQuotaId());
    newImage.setDiskProfileId(getParameters().getDiskProfileId());
    newImage.setParentId(Guid.Empty);
    newImage.setImageTemplateId(Guid.Empty);
    newImage.setStorageIds(new ArrayList<>(Arrays.asList(getParameters().getDestinationStorageDomainId())));
    newImage.setActive(true);
    imagesHandler.saveImage(newImage);
    baseDiskDao.save(newImage);
    DiskImageDynamic diskDynamic = new DiskImageDynamic();
    diskDynamic.setId(newImage.getImageId());
    diskDynamic.setActualSize(getDiskImage().getActualSizeInBytes());
    diskImageDynamicDao.save(diskDynamic);
    setActionReturnValue(newImage);
    // set source image as locked:
    lockImage();
    setSucceeded(true);
}
Also used : VolumeFormat(org.ovirt.engine.core.common.businessentities.storage.VolumeFormat) CopyImageVDSCommandParameters(org.ovirt.engine.core.common.vdscommands.CopyImageVDSCommandParameters) Guid(org.ovirt.engine.core.compat.Guid) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage) DiskImageDynamic(org.ovirt.engine.core.common.businessentities.storage.DiskImageDynamic) VDSReturnValue(org.ovirt.engine.core.common.vdscommands.VDSReturnValue)

Example 83 with VDSReturnValue

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

the class CreateVolumeContainerCommand method executeCommand.

@Override
protected void executeCommand() {
    Guid taskId = persistAsyncTaskPlaceHolder(getParameters().getParentCommand());
    VDSReturnValue vdsReturnValue = runVdsCommand(VDSCommandType.CreateVolume, getCreateVDSCommandParameters());
    if (vdsReturnValue.getSucceeded()) {
        getParameters().setVdsmTaskIds(new ArrayList<>());
        getParameters().getVdsmTaskIds().add(createTask(taskId, vdsReturnValue.getCreationInfo(), getParameters().getParentCommand(), VdcObjectType.Storage, getParameters().getStorageDomainId()));
        getTaskIdList().add(getParameters().getVdsmTaskIds().get(0));
        setSucceeded(true);
    }
}
Also used : Guid(org.ovirt.engine.core.compat.Guid) VDSReturnValue(org.ovirt.engine.core.common.vdscommands.VDSReturnValue)

Example 84 with VDSReturnValue

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

the class GetUnregisteredDisksQuery method executeQueryCommand.

@Override
protected void executeQueryCommand() {
    StorageDomain storageDomain = storageDomainDao.get(getStorageDomainId());
    if (storageDomain == null) {
        getQueryReturnValue().setExceptionString(EngineMessage.STORAGE_DOMAIN_DOES_NOT_EXIST.toString());
        getQueryReturnValue().setSucceeded(false);
        return;
    }
    if (storageDomain.getStorageType().isCinderDomain()) {
        QueryReturnValue returnValue = runInternalQuery(QueryType.GetUnregisteredCinderDisksByStorageDomainId, new IdQueryParameters(getStorageDomainId()));
        setReturnValue(returnValue.getReturnValue());
        return;
    }
    // first, run getImagesList query into vdsm to get all of the images on the storage domain - then store in
    // imagesList
    VDSReturnValue imagesListResult = runVdsCommand(VDSCommandType.GetImagesList, new GetImagesListVDSCommandParameters(getStorageDomainId(), getStoragePoolId()));
    @SuppressWarnings("unchecked") List<Guid> imagesList = (List<Guid>) imagesListResult.getReturnValue();
    // fromDao is a list of all disk images on the domain from the Dao
    List<DiskImage> fromDao = diskImageDao.getAllSnapshotsForStorageDomain(getStorageDomainId());
    // if the ID in imagesList is recognized by oVirt, remove from list
    for (DiskImage image : fromDao) {
        imagesList.remove(image.getId());
    }
    List<Disk> unregisteredDisks = new ArrayList<>();
    for (Guid unregisteredDiskId : imagesList) {
        GetUnregisteredDiskQueryParameters unregQueryParams = new GetUnregisteredDiskQueryParameters(unregisteredDiskId, getStorageDomainId(), getStoragePoolId());
        QueryReturnValue unregQueryReturn = runInternalQuery(QueryType.GetUnregisteredDisk, unregQueryParams);
        if (unregQueryReturn.getSucceeded()) {
            unregisteredDisks.add(unregQueryReturn.getReturnValue());
        } else {
            log.debug("Could not get populated disk: {}", unregQueryReturn.getExceptionString());
        }
    }
    getQueryReturnValue().setReturnValue(unregisteredDisks);
}
Also used : ArrayList(java.util.ArrayList) Guid(org.ovirt.engine.core.compat.Guid) VDSReturnValue(org.ovirt.engine.core.common.vdscommands.VDSReturnValue) StorageDomain(org.ovirt.engine.core.common.businessentities.StorageDomain) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) ArrayList(java.util.ArrayList) List(java.util.List) GetUnregisteredDiskQueryParameters(org.ovirt.engine.core.common.queries.GetUnregisteredDiskQueryParameters) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage) Disk(org.ovirt.engine.core.common.businessentities.storage.Disk) GetImagesListVDSCommandParameters(org.ovirt.engine.core.common.vdscommands.GetImagesListVDSCommandParameters)

Example 85 with VDSReturnValue

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

the class ExtendImageSizeCommand method executeCommand.

@Override
protected void executeCommand() {
    VDSReturnValue vdsReturnValue = extendUnderlyingVolumeSize(getImage());
    setSucceeded(vdsReturnValue.getSucceeded());
    if (vdsReturnValue.getSucceeded()) {
        Guid taskId = createTask(getAsyncTaskId(), vdsReturnValue.getCreationInfo(), getParameters().getParentCommand());
        getReturnValue().getInternalVdsmTaskIdList().add(taskId);
        if (getParameters().getParentNotifiesCallback()) {
            getParameters().setVdsmTaskIds(new ArrayList<>(Collections.singletonList(taskId)));
            getReturnValue().getVdsmTaskIdList().add(taskId);
            persistCommand(getParameters().getParentCommand(), true);
        }
    } else {
        updateAuditLog(AuditLogType.USER_EXTEND_DISK_SIZE_FAILURE, getParameters().getNewSizeInGB());
    }
}
Also used : Guid(org.ovirt.engine.core.compat.Guid) 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