use of org.ovirt.engine.core.common.businessentities.storage.CinderDisk in project ovirt-engine by oVirt.
the class VmDiskAttachPopupWidget method initCinderDisksTable.
private void initCinderDisksTable() {
cinderDiskTable.enableColumnResizing();
AbstractTextColumn<EntityModel> aliasColumn = new AbstractTextColumn<EntityModel>() {
@Override
public String getValue(EntityModel object) {
CinderDisk disk = (CinderDisk) ((DiskModel) object.getEntity()).getDisk();
return disk.getDiskAlias();
}
};
// $NON-NLS-1$
cinderDiskTable.addColumn(aliasColumn, constants.aliasVmDiskTable(), "100px");
AbstractTextColumn<EntityModel> descriptionColumn = new AbstractTextColumn<EntityModel>() {
@Override
public String getValue(EntityModel object) {
CinderDisk disk = (CinderDisk) ((DiskModel) object.getEntity()).getDisk();
return disk.getDiskDescription();
}
};
// $NON-NLS-1$
cinderDiskTable.addColumn(descriptionColumn, constants.descriptionVmDiskTable(), "100px");
AbstractDiskSizeColumn<EntityModel> sizeColumn = new AbstractDiskSizeColumn<EntityModel>(SizeConverter.SizeUnit.GiB) {
@Override
protected Long getRawValue(EntityModel object) {
CinderDisk disk = (CinderDisk) ((DiskModel) object.getEntity()).getDisk();
return disk.getSizeInGigabytes();
}
};
// $NON-NLS-1$
cinderDiskTable.addColumn(sizeColumn, constants.provisionedSizeVmDiskTable(), "100px");
// $NON-NLS-1$
cinderDiskTable.addColumn(getDiskInterfaceSelectionColumn(), constants.interfaceVmDiskPopup(), "115px");
AbstractTextColumn<EntityModel> cinderVolumeTypeColumn = new AbstractTextColumn<EntityModel>() {
@Override
public String getValue(EntityModel object) {
Disk disk = ((DiskModel) object.getEntity()).getDisk();
return disk.getCinderVolumeType();
}
};
// $NON-NLS-1$
cinderDiskTable.addColumn(cinderVolumeTypeColumn, constants.cinderVolumeTypeDisk(), "90px");
cinderDiskTable.addColumn(getReadOnlyCheckBoxColumn(), new ImageResourceHeader(resources.readOnlyDiskIcon(), SafeHtmlUtils.fromTrustedString(constants.readOnly())), // $NON-NLS-1$
"30px");
cinderDiskTable.addColumn(getBootCheckBoxColumn(), new ImageResourceHeader(resources.bootableDiskIcon(), SafeHtmlUtils.fromTrustedString(constants.bootableDisk())), // $NON-NLS-1$
"30px");
cinderDiskTable.addColumn(new AbstractImageResourceColumn<EntityModel>() {
@Override
public ImageResource getValue(EntityModel object) {
Disk disk = ((DiskModel) object.getEntity()).getDisk();
return disk.isShareable() ? resources.shareableDiskIcon() : null;
}
@Override
public SafeHtml getTooltip(EntityModel object) {
Disk disk = ((DiskModel) object.getEntity()).getDisk();
if (disk.isShareable()) {
return SafeHtmlUtils.fromSafeConstant(constants.shareable());
}
return null;
}
}, new ImageResourceHeader(resources.shareableDiskIcon(), SafeHtmlUtils.fromTrustedString(constants.shareable())), // $NON-NLS-1$
"30px");
// $NON-NLS-1$
cinderDiskTable.setWidth("100%");
cinderDiskTable.setEmptyTableWidget(new NoItemsLabel());
}
use of org.ovirt.engine.core.common.businessentities.storage.CinderDisk in project ovirt-engine by oVirt.
the class NewTemplateVmModelBehavior method initStorageDomainsForCinderDisks.
private void initStorageDomainsForCinderDisks(List<DiskModel> cinderDisks, Collection<StorageDomain> cinderStorageDomains) {
for (DiskModel diskModel : cinderDisks) {
CinderDisk cinderDisk = (CinderDisk) diskModel.getDisk();
diskModel.getStorageDomain().setItems(Linq.filterStorageDomainById(cinderStorageDomains, cinderDisk.getStorageIds().get(0)));
diskModel.getDiskProfile().setIsChangeable(false);
diskModel.getDiskProfile().setChangeProhibitionReason(ConstantsManager.getInstance().getConstants().notSupportedForCinderDisks());
}
}
use of org.ovirt.engine.core.common.businessentities.storage.CinderDisk in project ovirt-engine by oVirt.
the class RestoreAllSnapshotsCommand method executeVmCommand.
@Override
protected void executeVmCommand() {
if (!getImagesList().isEmpty()) {
lockVmWithCompensationIfNeeded();
if (!isInternalExecution()) {
freeLock();
}
}
initializeSnapshotsLeasesDomainIds();
restoreSnapshotAndRemoveObsoleteSnapshots(getSnapshot());
boolean succeeded = removeLeaseIfNeeded();
List<CinderDisk> cinderDisksToRestore = new ArrayList<>();
for (DiskImage image : imagesToRestore) {
if (image.getImageStatus() != ImageStatus.ILLEGAL) {
if (image.getDiskStorageType() == DiskStorageType.CINDER) {
cinderDisksToRestore.add((CinderDisk) image);
continue;
}
ImagesContainterParametersBase params = new RestoreFromSnapshotParameters(image.getImageId(), getVmId(), getSnapshot(), removedSnapshot.getId());
ActionReturnValue returnValue = runAsyncTask(ActionType.RestoreFromSnapshot, params);
// Save the first fault
if (succeeded && !returnValue.getSucceeded()) {
succeeded = false;
getReturnValue().setFault(returnValue.getFault());
}
}
}
List<CinderDisk> cinderVolumesToRemove = new ArrayList<>();
List<CinderDisk> cinderDisksToRemove = new ArrayList<>();
removeUnusedImages(cinderVolumesToRemove);
if (getSnapshot().getType() == SnapshotType.REGULAR) {
snapshotsToRemove.addAll(findSnapshotsWithOnlyIllegalDisks());
setNewerVmConfigurationsAsBroken();
}
removeSnapshotsFromDB();
succeeded = updateLeaseInfoIfNeeded() && succeeded;
if (!getTaskIdList().isEmpty() || !cinderDisksToRestore.isEmpty() || !cinderVolumesToRemove.isEmpty()) {
deleteOrphanedImages(cinderDisksToRemove);
if (!restoreCinderDisks(removedSnapshot.getId(), cinderDisksToRestore, cinderDisksToRemove, cinderVolumesToRemove)) {
log.error("Error to restore Cinder volumes snapshots");
}
} else {
vmStaticDao.incrementDbGeneration(getVm().getId());
snapshotDao.updateStatus(getSnapshot().getId(), SnapshotStatus.OK);
unlockVm();
}
setSucceeded(succeeded);
}
use of org.ovirt.engine.core.common.businessentities.storage.CinderDisk in project ovirt-engine by oVirt.
the class RestoreAllSnapshotsCommand method addRedundantCinderSnapshots.
private void addRedundantCinderSnapshots(Guid previewedSnapshotId, List<DiskImage> imagesFromActiveSnapshot) {
List<CinderDisk> cinderImagesForPreviewedSnapshot = DisksFilter.filterCinderDisks(diskImageDao.getAllSnapshotsForVmSnapshot(previewedSnapshotId));
Set<Guid> criticalSnapshotsChain = getCriticalSnapshotsChain(imagesFromActiveSnapshot, cinderImagesForPreviewedSnapshot);
for (DiskImage image : cinderImagesForPreviewedSnapshot) {
List<Guid> redundantSnapshotIdsToDelete = getRedundantVolumesToDeleteAfterCommitSnapshot(image.getId(), criticalSnapshotsChain);
snapshotsToRemove.addAll(redundantSnapshotIdsToDelete.stream().filter(snapIdToDelete -> isSnapshotEligibleToBeDeleted(snapshotDao.get(snapIdToDelete))).collect(Collectors.toList()));
}
}
use of org.ovirt.engine.core.common.businessentities.storage.CinderDisk 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());
}
}
}
Aggregations