use of org.ovirt.engine.core.common.action.RemoveImageParameters 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);
}
}
use of org.ovirt.engine.core.common.action.RemoveImageParameters in project ovirt-engine by oVirt.
the class RestoreAllSnapshotsCommand method deleteOrphanedImages.
protected void deleteOrphanedImages(List<CinderDisk> cinderDisksToRemove) {
ActionReturnValue returnValue;
boolean noImagesRemovedYet = getTaskIdList().isEmpty();
Set<Guid> deletedDisksIds = new HashSet<>();
for (DiskImage image : diskImageDao.getImagesWithNoDisk(getVm().getId())) {
if (!deletedDisksIds.contains(image.getId())) {
deletedDisksIds.add(image.getId());
if (image.getDiskStorageType() == DiskStorageType.CINDER) {
cinderDisksToRemove.add((CinderDisk) image);
continue;
}
returnValue = runAsyncTask(ActionType.RemoveImage, new RemoveImageParameters(image.getImageId()));
if (!returnValue.getSucceeded() && noImagesRemovedYet) {
setSucceeded(false);
getReturnValue().setFault(returnValue.getFault());
return;
}
noImagesRemovedYet = false;
}
}
}
use of org.ovirt.engine.core.common.action.RemoveImageParameters in project ovirt-engine by oVirt.
the class RestoreAllSnapshotsCommand method removeUnusedImages.
private void removeUnusedImages(List<CinderDisk> cinderVolumesToRemove) {
Set<Guid> imageIdsUsedByActiveSnapshot = new HashSet<>();
for (DiskImage diskImage : getImagesList()) {
imageIdsUsedByActiveSnapshot.add(diskImage.getId());
}
List<DiskImage> imagesToRemove = new ArrayList<>();
for (Guid snapshotToRemove : snapshotsToRemove) {
List<DiskImage> snapshotDiskImages = diskImageDao.getAllSnapshotsForVmSnapshot(snapshotToRemove);
imagesToRemove.addAll(snapshotDiskImages);
}
Set<Guid> removeInProcessImageIds = new HashSet<>();
for (DiskImage diskImage : imagesToRemove) {
if (imageIdsUsedByActiveSnapshot.contains(diskImage.getId()) || removeInProcessImageIds.contains(diskImage.getId())) {
continue;
}
List<DiskImage> diskImagesFromPreviewSnap = imagesFromPreviewSnapshot.stream().filter(diskImageFromPreview -> diskImageFromPreview.getImageId().equals(diskImage.getImageId())).collect(Collectors.toList());
if (!diskImagesFromPreviewSnap.isEmpty() && diskImagesFromPreviewSnap.get(0).getDiskStorageType() == DiskStorageType.CINDER) {
cinderVolumesToRemove.add((CinderDisk) diskImagesFromPreviewSnap.get(0));
continue;
}
ActionReturnValue retValue = runAsyncTask(ActionType.RemoveImage, new RemoveImageParameters(diskImage.getImageId()));
if (retValue.getSucceeded()) {
removeInProcessImageIds.add(diskImage.getImageId());
} else {
log.error("Failed to remove image '{}'", diskImage.getImageId());
}
}
}
use of org.ovirt.engine.core.common.action.RemoveImageParameters in project ovirt-engine by oVirt.
the class MoveImageGroupCommand method removeImage.
private void removeImage(Guid storageDomainId) {
RemoveImageParameters removeImageParams = new RemoveImageParameters(getParameters().getImageId());
removeImageParams.setStorageDomainId(storageDomainId);
removeImageParams.setParentCommand(ActionType.RemoveImage);
removeImageParams.setDbOperationScope(ImageDbOperationScope.NONE);
removeImageParams.setShouldLockImage(false);
removeImageParams.setCorrelationId(getParameters().getCorrelationId());
// TODO: should be removed as async task manager issues would be resolved, done in order
// to avoid operations on the image to wait for this remove operation as currently async
// task manager calls the end methods of command based on the entity id.
// the remove done here is a "clenaup", either on the source domain or on the target - so
// other operations on the image shouldn't be dependent and wait for it.
removeImageParams.setEntityInfo(new EntityInfo(VdcObjectType.Disk, Guid.newGuid()));
ActionReturnValue returnValue = runInternalAction(ActionType.RemoveImage, removeImageParams, cloneContextAndDetachFromParent());
if (returnValue.getSucceeded()) {
startPollingAsyncTasks(returnValue.getInternalVdsmTaskIdList());
} else {
addAuditLogOnRemoveFailure();
}
}
use of org.ovirt.engine.core.common.action.RemoveImageParameters in project ovirt-engine by oVirt.
the class CreateImageTemplateCommand method revertTasks.
@Override
protected void revertTasks() {
Guid destImageId = getDestinationDiskImage().getImageId();
RemoveImageParameters p = new RemoveImageParameters(destImageId);
p.setEntityInfo(new EntityInfo(VdcObjectType.Disk, destImageId));
p.setParentParameters(p);
p.setParentCommand(ActionType.RemoveImage);
ActionReturnValue returnValue = checkAndPerformRollbackUsingCommand(ActionType.RemoveImage, p, null);
if (returnValue.getSucceeded()) {
startPollingAsyncTasks(returnValue.getInternalVdsmTaskIdList());
}
}
Aggregations