Search in sources :

Example 1 with ImagesContainterParametersBase

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

the class AddVmCommand method addVmCinderDisks.

protected void addVmCinderDisks(Collection<DiskImage> templateDisks) {
    List<CinderDisk> cinderDisks = DisksFilter.filterCinderDisks(templateDisks);
    if (cinderDisks.isEmpty()) {
        return;
    }
    Map<Guid, Guid> diskImageMap = new HashMap<>();
    for (CinderDisk cinderDisk : cinderDisks) {
        ImagesContainterParametersBase params = buildCloneCinderDiskCommandParameters(cinderDisk);
        ActionReturnValue actionReturnValue = runInternalAction(ActionType.CloneSingleCinderDisk, params, cloneContext().withoutExecutionContext().withoutLock());
        if (!actionReturnValue.getSucceeded()) {
            log.error("Error cloning Cinder disk '{}': {}", cinderDisk.getDiskAlias());
            getReturnValue().setFault(actionReturnValue.getFault());
            return;
        }
        Guid imageId = actionReturnValue.getActionReturnValue();
        diskImageMap.put(cinderDisk.getId(), imageId);
    }
    srcDiskIdToTargetDiskIdMapping.putAll(diskImageMap);
}
Also used : HashMap(java.util.HashMap) ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue) ImagesContainterParametersBase(org.ovirt.engine.core.common.action.ImagesContainterParametersBase) Guid(org.ovirt.engine.core.compat.Guid) CinderDisk(org.ovirt.engine.core.common.businessentities.storage.CinderDisk)

Example 2 with ImagesContainterParametersBase

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

the class AddVmCommand method buildCloneCinderDiskCommandParameters.

private ImagesContainterParametersBase buildCloneCinderDiskCommandParameters(CinderDisk cinderDisk) {
    ImagesContainterParametersBase createParams = new ImagesContainterParametersBase(cinderDisk.getImageId());
    DiskImage templateDisk = diskInfoDestinationMap.get(cinderDisk.getId());
    createParams.setDiskAlias(templateDisk.getDiskAlias());
    createParams.setStorageDomainId(templateDisk.getStorageIds().get(0));
    createParams.setEntityInfo(getParameters().getEntityInfo());
    createParams.setParentCommand(getActionType());
    createParams.setParentParameters(getParameters());
    createParams.setVmSnapshotId(getVmSnapshotId());
    return createParams;
}
Also used : ImagesContainterParametersBase(org.ovirt.engine.core.common.action.ImagesContainterParametersBase) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage)

Example 3 with ImagesContainterParametersBase

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

the class RemoveAllVmTemplateImageTemplatesCommand method executeCommand.

@SuppressWarnings("unchecked")
@Override
protected void executeCommand() {
    List<DiskImage> imageTemplates = DisksFilter.filterImageDisks(diskDao.getAllForVm(getVmTemplateId()), ONLY_ACTIVE);
    for (DiskImage template : imageTemplates) {
        // remove this disk in all domain that were sent
        for (Guid domain : (Collection<Guid>) CollectionUtils.intersection(getParameters().getStorageDomainsList(), template.getStorageIds())) {
            ImagesContainterParametersBase tempVar = new ImagesContainterParametersBase(template.getImageId(), getVmTemplateId());
            tempVar.setStorageDomainId(domain);
            tempVar.setStoragePoolId(template.getStoragePoolId());
            tempVar.setImageGroupID(template.getId());
            tempVar.setEntityInfo(getParameters().getEntityInfo());
            tempVar.setWipeAfterDelete(template.isWipeAfterDelete());
            tempVar.setTransactionScopeOption(TransactionScopeOption.RequiresNew);
            tempVar.setParentCommand(getActionType());
            tempVar.setParentParameters(getParameters());
            ActionReturnValue actionReturnValue = runInternalActionWithTasksContext(ActionType.RemoveTemplateSnapshot, tempVar);
            if (actionReturnValue.getSucceeded()) {
                getReturnValue().getInternalVdsmTaskIdList().addAll(actionReturnValue.getInternalVdsmTaskIdList());
            } else {
                log.error("Can't remove image id '{}' for template id '{}' from domain id '{}' due to: {}.", template.getImageId(), getVmTemplateId(), domain, actionReturnValue.getFault().getMessage());
            }
            imageStorageDomainMapDao.remove(new ImageStorageDomainMapId(template.getImageId(), domain));
        }
        DiskImage diskImage = diskImageDao.get(template.getImageId());
        if (diskImage != null) {
            baseDiskDao.remove(template.getId());
            vmDeviceDao.remove(new VmDeviceId(diskImage.getImageId(), getVmTemplateId()));
            imageStorageDomainMapDao.remove(diskImage.getImageId());
            imageDao.remove(template.getImageId());
        }
    }
    setSucceeded(true);
}
Also used : ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue) ImagesContainterParametersBase(org.ovirt.engine.core.common.action.ImagesContainterParametersBase) ImageStorageDomainMapId(org.ovirt.engine.core.common.businessentities.storage.ImageStorageDomainMapId) Collection(java.util.Collection) Guid(org.ovirt.engine.core.compat.Guid) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage) VmDeviceId(org.ovirt.engine.core.common.businessentities.VmDeviceId)

Example 4 with ImagesContainterParametersBase

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

the class RemoveDiskSnapshotsCommand method performNextOperationColdMerge.

private boolean performNextOperationColdMerge(int completedChildren) {
    Guid nextImageId = getParameters().getImageIds().get(completedChildren);
    log.info("Starting child command {} of {}, image '{}'", completedChildren + 1, getParameters().getImageIds().size(), nextImageId);
    ImagesContainterParametersBase parameters = buildRemoveSnapshotSingleDiskParameters(nextImageId);
    ActionType actionType = FeatureSupported.isQemuimgCommitSupported(getStoragePool().getCompatibilityVersion()) ? ActionType.ColdMergeSnapshotSingleDisk : ActionType.RemoveSnapshotSingleDisk;
    commandCoordinatorUtil.executeAsyncCommand(actionType, parameters, cloneContextAndDetachFromParent());
    return true;
}
Also used : ActionType(org.ovirt.engine.core.common.action.ActionType) ImagesContainterParametersBase(org.ovirt.engine.core.common.action.ImagesContainterParametersBase) Guid(org.ovirt.engine.core.compat.Guid)

Example 5 with ImagesContainterParametersBase

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

the class RemoveDiskSnapshotsCommand method performNextOperationLiveMerge.

private boolean performNextOperationLiveMerge(int completedChildren) {
    if (completedChildren != 0) {
        checkImageIdConsistency(completedChildren - 1);
    }
    Guid nextImageId = getParameters().getImageIds().get(completedChildren);
    log.info("Starting child command {} of {}, image '{}'", completedChildren + 1, getParameters().getImageIds().size(), nextImageId);
    ImagesContainterParametersBase parameters = buildRemoveSnapshotSingleDiskLiveParameters(nextImageId, completedChildren);
    updateParameters(completedChildren, parameters.getDestinationImageId());
    persistCommandIfNeeded();
    commandCoordinatorUtil.executeAsyncCommand(ActionType.RemoveSnapshotSingleDiskLive, parameters, cloneContextAndDetachFromParent());
    return true;
}
Also used : ImagesContainterParametersBase(org.ovirt.engine.core.common.action.ImagesContainterParametersBase) Guid(org.ovirt.engine.core.compat.Guid)

Aggregations

ImagesContainterParametersBase (org.ovirt.engine.core.common.action.ImagesContainterParametersBase)16 DiskImage (org.ovirt.engine.core.common.businessentities.storage.DiskImage)8 Guid (org.ovirt.engine.core.compat.Guid)8 ActionReturnValue (org.ovirt.engine.core.common.action.ActionReturnValue)7 CinderDisk (org.ovirt.engine.core.common.businessentities.storage.CinderDisk)7 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)2 Snapshot (org.ovirt.engine.core.common.businessentities.Snapshot)2 ImageStatus (org.ovirt.engine.core.common.businessentities.storage.ImageStatus)2 Collection (java.util.Collection)1 List (java.util.List)1 ExecutionException (java.util.concurrent.ExecutionException)1 BaseImagesCommand (org.ovirt.engine.core.bll.storage.disk.image.BaseImagesCommand)1 ActionParametersBase (org.ovirt.engine.core.common.action.ActionParametersBase)1 ActionType (org.ovirt.engine.core.common.action.ActionType)1 RemoveCinderDiskParameters (org.ovirt.engine.core.common.action.RemoveCinderDiskParameters)1 RemoveCinderDiskVolumeParameters (org.ovirt.engine.core.common.action.RemoveCinderDiskVolumeParameters)1 RestoreFromSnapshotParameters (org.ovirt.engine.core.common.action.RestoreFromSnapshotParameters)1 VmDeviceId (org.ovirt.engine.core.common.businessentities.VmDeviceId)1 ImageStorageDomainMapId (org.ovirt.engine.core.common.businessentities.storage.ImageStorageDomainMapId)1