Search in sources :

Example 1 with SubchainInfo

use of org.ovirt.engine.core.common.businessentities.SubchainInfo in project ovirt-engine by oVirt.

the class RemoveSnapshotCommand method getAllDisksSnapshot.

/**
 * The base snapshot is the parent of the top snapshot. This is reversed the if old cold merge
 * is performed (pre-4.1).
 *
 * @param snapshots list of the parent snapshot disks
 * @return list of subchains which contain the base and top snapshots.
 */
protected List<SubchainInfo> getAllDisksSnapshot(List<DiskImage> snapshots) {
    Set<DiskImage> topSnapshots = diskImageDao.getAllSnapshotsForParents(snapshots.stream().map(DiskImage::getImageId).collect(Collectors.toList()));
    Map<Guid, DiskImage> baseSnapshotMap = snapshots.stream().collect(Collectors.toMap(DiskImage::getImageId, Function.identity()));
    return topSnapshots.stream().map(topSnapshot -> {
        if (!isQemuimgCommitSupported() && getSnapshotActionType() == ActionType.RemoveSnapshotSingleDisk) {
            return new SubchainInfo(topSnapshot, baseSnapshotMap.get(topSnapshot.getParentId()));
        } else {
            return new SubchainInfo(baseSnapshotMap.get(topSnapshot.getParentId()), topSnapshot);
        }
    }).collect(Collectors.toList());
}
Also used : LockMessagesMatchUtil(org.ovirt.engine.core.bll.LockMessagesMatchUtil) StringUtils(org.apache.commons.lang.StringUtils) CinderDisk(org.ovirt.engine.core.common.businessentities.storage.CinderDisk) RemoveSnapshotParameters(org.ovirt.engine.core.common.action.RemoveSnapshotParameters) EngineException(org.ovirt.engine.core.common.errors.EngineException) SnapshotDao(org.ovirt.engine.core.dao.SnapshotDao) ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue) VmTemplateDao(org.ovirt.engine.core.dao.VmTemplateDao) CommandContext(org.ovirt.engine.core.bll.context.CommandContext) ActionType(org.ovirt.engine.core.common.action.ActionType) DisksFilter(org.ovirt.engine.core.bll.storage.disk.image.DisksFilter) Map(java.util.Map) Snapshot(org.ovirt.engine.core.common.businessentities.Snapshot) Instance(javax.enterprise.inject.Instance) RemoveMemoryVolumesParameters(org.ovirt.engine.core.common.action.RemoveMemoryVolumesParameters) DiskImagesValidator(org.ovirt.engine.core.bll.validator.storage.DiskImagesValidator) DiskStorageType(org.ovirt.engine.core.common.businessentities.storage.DiskStorageType) Collection(java.util.Collection) EngineMessage(org.ovirt.engine.core.common.errors.EngineMessage) Set(java.util.Set) Collectors(java.util.stream.Collectors) ConcurrentChildCommandsExecutionCallback(org.ovirt.engine.core.bll.ConcurrentChildCommandsExecutionCallback) ONLY_NOT_SHAREABLE(org.ovirt.engine.core.bll.storage.disk.image.DisksFilter.ONLY_NOT_SHAREABLE) List(java.util.List) ValidationResult(org.ovirt.engine.core.bll.ValidationResult) VmValidator(org.ovirt.engine.core.bll.validator.VmValidator) MultipleStorageDomainsValidator(org.ovirt.engine.core.bll.validator.storage.MultipleStorageDomainsValidator) AuditLogType(org.ovirt.engine.core.common.AuditLogType) VdcObjectType(org.ovirt.engine.core.common.VdcObjectType) SubchainInfo(org.ovirt.engine.core.common.businessentities.SubchainInfo) QuotaConsumptionParameter(org.ovirt.engine.core.bll.quota.QuotaConsumptionParameter) FeatureSupported(org.ovirt.engine.core.common.FeatureSupported) QuotaStorageDependent(org.ovirt.engine.core.bll.quota.QuotaStorageDependent) EntityInfo(org.ovirt.engine.core.common.asynctasks.EntityInfo) LockProperties(org.ovirt.engine.core.common.action.LockProperties) Guid(org.ovirt.engine.core.compat.Guid) TransactionSupport(org.ovirt.engine.core.utils.transaction.TransactionSupport) Function(java.util.function.Function) ActionParametersBase(org.ovirt.engine.core.common.action.ActionParametersBase) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage) ArrayList(java.util.ArrayList) CommandCoordinatorUtil(org.ovirt.engine.core.bll.tasks.CommandCoordinatorUtil) Inject(javax.inject.Inject) DiskImageDao(org.ovirt.engine.core.dao.DiskImageDao) OvfManager(org.ovirt.engine.core.utils.ovf.OvfManager) ONLY_ACTIVE(org.ovirt.engine.core.bll.storage.disk.image.DisksFilter.ONLY_ACTIVE) RemoveSnapshotSingleDiskParameters(org.ovirt.engine.core.common.action.RemoveSnapshotSingleDiskParameters) VmCommand(org.ovirt.engine.core.bll.VmCommand) Pair(org.ovirt.engine.core.common.utils.Pair) DisableInPrepareMode(org.ovirt.engine.core.bll.DisableInPrepareMode) ImagesHandler(org.ovirt.engine.core.bll.storage.disk.image.ImagesHandler) StoragePoolValidator(org.ovirt.engine.core.bll.validator.storage.StoragePoolValidator) SnapshotStatus(org.ovirt.engine.core.common.businessentities.Snapshot.SnapshotStatus) LockingGroup(org.ovirt.engine.core.common.locks.LockingGroup) EndProcedure(org.ovirt.engine.core.common.action.ActionParametersBase.EndProcedure) ImagesContainterParametersBase(org.ovirt.engine.core.common.action.ImagesContainterParametersBase) AuditLogDirector(org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogDirector) Scope(org.ovirt.engine.core.common.action.LockProperties.Scope) Typed(javax.enterprise.inject.Typed) Disk(org.ovirt.engine.core.common.businessentities.storage.Disk) EngineError(org.ovirt.engine.core.common.errors.EngineError) VM(org.ovirt.engine.core.common.businessentities.VM) CommandCallback(org.ovirt.engine.core.bll.tasks.interfaces.CommandCallback) DiskDao(org.ovirt.engine.core.dao.DiskDao) Collections(java.util.Collections) SubchainInfo(org.ovirt.engine.core.common.businessentities.SubchainInfo) Guid(org.ovirt.engine.core.compat.Guid) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage)

Example 2 with SubchainInfo

use of org.ovirt.engine.core.common.businessentities.SubchainInfo in project ovirt-engine by oVirt.

the class ColdMergeSnapshotSingleDiskCommand method buildColdMergeParameters.

private ColdMergeCommandParameters buildColdMergeParameters(DiskImage baseVolume, DiskImage topVolume) {
    SubchainInfo subchainInfo = new SubchainInfo(getDiskImage().getStorageIds().get(0), baseVolume, topVolume);
    ColdMergeCommandParameters parameters = new ColdMergeCommandParameters(getDiskImage().getStoragePoolId(), subchainInfo);
    parameters.setEndProcedure(ActionParametersBase.EndProcedure.COMMAND_MANAGED);
    parameters.setParentCommand(getActionType());
    parameters.setParentParameters(getParameters());
    return parameters;
}
Also used : ColdMergeCommandParameters(org.ovirt.engine.core.common.action.ColdMergeCommandParameters) SubchainInfo(org.ovirt.engine.core.common.businessentities.SubchainInfo)

Example 3 with SubchainInfo

use of org.ovirt.engine.core.common.businessentities.SubchainInfo in project ovirt-engine by oVirt.

the class MultipleStorageDomainsValidator method allDomainsHaveSpaceForMerge.

/**
 * Validates that all the domains have enough space for the request
 * @return {@link ValidationResult#VALID} if all the domains have enough free space, or a {@link ValidationResult} with the first low-on-space domain encountered.
 */
public ValidationResult allDomainsHaveSpaceForMerge(List<SubchainInfo> snapshots, ActionType snapshotActionType) {
    final Map<Guid, List<SubchainInfo>> storageToSnapshots = getDomainsToSnapshotsMap(snapshots);
    return validOrFirstFailure(entry -> {
        Guid sdId = entry.getKey();
        List<SubchainInfo> subchain = storageToSnapshots.get(sdId);
        return getStorageDomainValidator(entry).hasSpaceForMerge(subchain, snapshotActionType);
    });
}
Also used : SubchainInfo(org.ovirt.engine.core.common.businessentities.SubchainInfo) ArrayList(java.util.ArrayList) List(java.util.List) Guid(org.ovirt.engine.core.compat.Guid)

Example 4 with SubchainInfo

use of org.ovirt.engine.core.common.businessentities.SubchainInfo in project ovirt-engine by oVirt.

the class ColdMergeCommand method completeGenerationInfo.

private void completeGenerationInfo() {
    SubchainInfo info = getParameters().getSubchainInfo();
    DiskImage image = imagesHandler.getVolumeInfoFromVdsm(getParameters().getStoragePoolId(), info.getStorageDomainId(), info.getImageGroupId(), info.getBaseImageId());
    info.setBaseImageGeneration(image.getImage().getGeneration());
    persistCommandIfNeeded();
}
Also used : SubchainInfo(org.ovirt.engine.core.common.businessentities.SubchainInfo) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage)

Example 5 with SubchainInfo

use of org.ovirt.engine.core.common.businessentities.SubchainInfo in project ovirt-engine by oVirt.

the class ColdMergeCommand method attemptToFenceJob.

@Override
public void attemptToFenceJob() {
    SubchainInfo info = getParameters().getSubchainInfo();
    VdsmImageLocationInfo locationInfo = new VdsmImageLocationInfo(info.getStorageDomainId(), info.getImageGroupId(), info.getBaseImageId(), info.getBaseImageGeneration());
    FenceVolumeJobCommandParameters parameters = new FenceVolumeJobCommandParameters(locationInfo);
    parameters.setParentCommand(getActionType());
    parameters.setParentParameters(getParameters());
    parameters.setStoragePoolId(getParameters().getStoragePoolId());
    parameters.setEndProcedure(ActionParametersBase.EndProcedure.COMMAND_MANAGED);
    runInternalActionWithTasksContext(ActionType.FenceVolumeJob, parameters);
}
Also used : FenceVolumeJobCommandParameters(org.ovirt.engine.core.common.action.FenceVolumeJobCommandParameters) SubchainInfo(org.ovirt.engine.core.common.businessentities.SubchainInfo) VdsmImageLocationInfo(org.ovirt.engine.core.common.businessentities.VdsmImageLocationInfo)

Aggregations

SubchainInfo (org.ovirt.engine.core.common.businessentities.SubchainInfo)5 ArrayList (java.util.ArrayList)2 List (java.util.List)2 Collection (java.util.Collection)1 Collections (java.util.Collections)1 Map (java.util.Map)1 Set (java.util.Set)1 Function (java.util.function.Function)1 Collectors (java.util.stream.Collectors)1 Instance (javax.enterprise.inject.Instance)1 Typed (javax.enterprise.inject.Typed)1 Inject (javax.inject.Inject)1 StringUtils (org.apache.commons.lang.StringUtils)1 ConcurrentChildCommandsExecutionCallback (org.ovirt.engine.core.bll.ConcurrentChildCommandsExecutionCallback)1 DisableInPrepareMode (org.ovirt.engine.core.bll.DisableInPrepareMode)1 LockMessagesMatchUtil (org.ovirt.engine.core.bll.LockMessagesMatchUtil)1 ValidationResult (org.ovirt.engine.core.bll.ValidationResult)1 VmCommand (org.ovirt.engine.core.bll.VmCommand)1 CommandContext (org.ovirt.engine.core.bll.context.CommandContext)1 QuotaConsumptionParameter (org.ovirt.engine.core.bll.quota.QuotaConsumptionParameter)1