Search in sources :

Example 1 with DiskDao

use of org.ovirt.engine.core.dao.DiskDao in project ovirt-engine by oVirt.

the class RemoveSnapshotCommand method validateSnapshotDisksArePlugged.

private boolean validateSnapshotDisksArePlugged() {
    Map<Guid, Disk> vmDisks = diskDao.getAllForVm(getVmId()).stream().collect(Collectors.toMap(Disk::getId, Function.identity()));
    // If there is an unattached disk, it will not be included in vmDisks, hence it is
    // retrieved by the diskDao. This is less likely to happen as it is not possible
    // to unattach disks with snapshots.
    String unpluggedDisks = getSourceImages().stream().map(DiskImage::getId).map(vmDiskId -> vmDisks.getOrDefault(vmDiskId, diskDao.get(vmDiskId))).filter(disk -> !disk.getPlugged()).map(Disk::getDiskAlias).collect(Collectors.joining(System.lineSeparator()));
    if (!unpluggedDisks.isEmpty()) {
        return validate(new ValidationResult(EngineMessage.ACTION_TYPE_FAILED_VM_SNAPSHOT_HAS_UNPLUGGED_OR_UNATTACHED_DISKS, String.format("$diskAliases %s", unpluggedDisks)));
    }
    return true;
}
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) Guid(org.ovirt.engine.core.compat.Guid) ValidationResult(org.ovirt.engine.core.bll.ValidationResult) CinderDisk(org.ovirt.engine.core.common.businessentities.storage.CinderDisk) Disk(org.ovirt.engine.core.common.businessentities.storage.Disk) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage)

Aggregations

ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 Collections (java.util.Collections)1 List (java.util.List)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 QuotaStorageDependent (org.ovirt.engine.core.bll.quota.QuotaStorageDependent)1