use of org.ovirt.engine.core.common.businessentities.storage.CinderDisk in project ovirt-engine by oVirt.
the class RemoveCinderDiskCommand method executeCommand.
@Override
public void executeCommand() {
CinderDisk disk = getDisk();
lockDisk();
VM vm = getVmForNonShareableDiskImage(disk);
// so no lock is required.
if (getParameters().isLockVM() && vm != null) {
getParameters().setVmId(vm.getId());
lockVmSnapshotsWithWait(vm);
}
getParameters().setRemovedVolume(getDisk());
getParameters().setStorageDomainId(getDisk().getStorageIds().get(0));
getParameters().setUpdateSnapshot(true);
if (getDisk().getImageStatus() == ImageStatus.ILLEGAL) {
handleRemoveCinderVolumesForIllegal();
setCommandStatus(CommandStatus.SUCCEEDED);
setSucceeded(true);
return;
}
// Get the first volume to delete from.
CinderDisk parentVolume = (CinderDisk) diskImageDao.getSnapshotById(disk.getId());
initCinderDiskVolumesParametersList(parentVolume);
if (!removeCinderVolume(0)) {
imageDao.updateStatusOfImagesByImageGroupId(getDisk().getId(), ImageStatus.ILLEGAL);
setSucceeded(false);
return;
}
persistCommand(getParameters().getParentCommand(), true);
getReturnValue().setActionReturnValue(disk.getId());
setSucceeded(true);
}
use of org.ovirt.engine.core.common.businessentities.storage.CinderDisk in project ovirt-engine by oVirt.
the class RemoveCinderDiskCommand method handleRemoveCinderVolumesForIllegal.
private void handleRemoveCinderVolumesForIllegal() {
final List<DiskImage> diskSnapshots = diskImageDao.getAllSnapshotsForImageGroup(cinderDisk.getId());
ImagesHandler.sortImageList(diskSnapshots);
TransactionSupport.executeInScope(TransactionScopeOption.Required, () -> {
int indCinderVolumeToDelete = diskSnapshots.size() - 1;
while (indCinderVolumeToDelete >= 0) {
CinderDisk cinderVolume = (CinderDisk) diskSnapshots.get(indCinderVolumeToDelete);
Snapshot updated = getSnapshotWithoutCinderVolume(cinderVolume);
removeDiskFromDb(cinderVolume, updated);
indCinderVolumeToDelete--;
}
return null;
});
}
use of org.ovirt.engine.core.common.businessentities.storage.CinderDisk in project ovirt-engine by oVirt.
the class RemoveCinderDiskVolumeCommandCallback method childCommandsExecutionEnded.
@Override
protected void childCommandsExecutionEnded(CommandBase<?> command, boolean anyFailed, List<Guid> childCmdIds, CommandExecutionStatus status, int completedChildren) {
RemoveCinderDiskVolumeCommand<RemoveCinderDiskVolumeParameters> removeCinderDiskVolumeCommand = (RemoveCinderDiskVolumeCommand<RemoveCinderDiskVolumeParameters>) command;
CinderDisk removedVolume = removeCinderDiskVolumeCommand.getParameters().getRemovedVolume();
// In case the volume/snapshot has been deleted from Cinder.
if (!removeCinderDiskVolumeCommand.getCinderBroker().isVolumeExistsByClassificationType(removedVolume)) {
setCommandEndStatus(command, false, status, childCmdIds);
}
ImageStatus imageStatus = checkImageStatus(removedVolume, removeCinderDiskVolumeCommand);
if (imageStatus != null && imageStatus != removedVolume.getImageStatus()) {
switch(imageStatus) {
case ILLEGAL:
setCommandEndStatus(command, true, status, childCmdIds);
break;
}
}
}
use of org.ovirt.engine.core.common.businessentities.storage.CinderDisk in project ovirt-engine by oVirt.
the class DisksFilterTest method testFilterNonLunDisks.
@Test
public void testFilterNonLunDisks() {
Disk lunDisk = createDisk(DiskStorageType.LUN, false, false, false, false);
Disk imageDisk = createDisk(DiskStorageType.IMAGE, false, false, true, false);
Disk cinderDisk = createDisk(DiskStorageType.CINDER, false, false, true, false);
List<Disk> disksList = Arrays.asList(lunDisk, imageDisk, cinderDisk);
List<LunDisk> filteredList = DisksFilter.filterLunDisks(disksList);
assertEquals(1, filteredList.size());
assertThat(filteredList, containsInAnyOrder(lunDisk));
}
use of org.ovirt.engine.core.common.businessentities.storage.CinderDisk in project ovirt-engine by oVirt.
the class GetDiskAndSnapshotsByDiskIdQueryTest method testQueryWithCinderDisk.
@Test
public void testQueryWithCinderDisk() {
DiskImage disk = executeQuery(cinderDisk);
assertTrue("disk should be from type CinderDisk", disk instanceof CinderDisk);
}
Aggregations