use of org.ovirt.engine.core.common.businessentities.storage.DiskImage in project ovirt-engine by oVirt.
the class ExportRepoImageModel method setDiskImages.
public void setDiskImages(List<DiskImage> diskImages) {
ArrayList<EntityModel> entities = new ArrayList<>();
for (DiskImage i : diskImages) {
entities.add(new EntityModel(i));
}
setEntities(entities);
}
use of org.ovirt.engine.core.common.businessentities.storage.DiskImage in project ovirt-engine by oVirt.
the class MoveOrCopyDiskModel method getDestinationDomains.
private ArrayList<StorageDomain> getDestinationDomains(ArrayList<StorageDomain> activeStorageDomains, List<StorageDomain> sourceActiveStorageDomains, DiskModel diskModel, boolean isDiskBasedOnTemplate) {
DiskImage diskImage = (DiskImage) diskModel.getDisk();
DiskModel templateDisk = null;
if (isDiskBasedOnTemplate) {
templateDisk = getTemplateDiskByVmDisk(diskModel);
}
ArrayList<StorageDomain> destinationDomains = new ArrayList<>();
for (StorageDomain sd : activeStorageDomains) {
// Storage domain destination should not be a domain which the disk is attached to.
if (!allowedStorageDomain(sourceActiveStorageDomains, diskImage, templateDisk, sd)) {
continue;
}
// All conditions are valid for moving the current disk to this domain.
destinationDomains.add(sd);
}
return destinationDomains;
}
use of org.ovirt.engine.core.common.businessentities.storage.DiskImage in project ovirt-engine by oVirt.
the class MoveOrCopyDiskModel method getParameters.
protected ArrayList<ActionParametersBase> getParameters() {
ArrayList<ActionParametersBase> parameters = new ArrayList<>();
for (DiskModel diskModel : getDisks()) {
StorageDomain destStorageDomain = diskModel.getStorageDomain().getSelectedItem();
StorageDomain sourceStorageDomain = diskModel.getSourceStorageDomain().getSelectedItem();
Guid sourceStorageDomainGuid = sourceStorageDomain != null ? sourceStorageDomain.getId() : Guid.Empty;
DiskImage disk = (DiskImage) diskModel.getDisk();
DiskProfile diskProfile = diskModel.getDiskProfile().getSelectedItem();
disk.setDiskProfileId(diskProfile != null ? diskProfile.getId() : null);
disk.setDiskAlias(diskModel.getAlias().getEntity());
if (diskModel.getQuota().getSelectedItem() != null) {
disk.setQuotaId(diskModel.getQuota().getSelectedItem().getId());
}
if (destStorageDomain == null || sourceStorageDomain == null) {
continue;
}
Guid destStorageDomainGuid = destStorageDomain.getId();
addMoveOrCopyParameters(parameters, sourceStorageDomainGuid, destStorageDomainGuid, disk);
}
return parameters;
}
use of org.ovirt.engine.core.common.businessentities.storage.DiskImage in project ovirt-engine by oVirt.
the class VmListModel method initRemoveDisksChecboxesPost.
private void initRemoveDisksChecboxesPost(Guid vmId, List<Disk> disks) {
EntityModel model = vmsRemoveMap.get(vmId);
if (disks.isEmpty()) {
updateRemoveDisksCheckBox(model, false, false, ConstantsManager.getInstance().getConstants().removeVmDisksNoDisksMsg());
return;
}
boolean isOnlySharedDisks = true;
boolean isSnapshotExists = false;
for (Disk disk : disks) {
if (!disk.isShareable()) {
isOnlySharedDisks = false;
if (disk.getDiskStorageType() == DiskStorageType.IMAGE) {
if (((DiskImage) disk).getSnapshots().size() > 1) {
isSnapshotExists = true;
break;
}
}
}
}
if (isSnapshotExists) {
updateRemoveDisksCheckBox(model, true, false, ConstantsManager.getInstance().getConstants().removeVmDisksSnapshotsMsg());
return;
}
if (isOnlySharedDisks) {
updateRemoveDisksCheckBox(model, false, false, ConstantsManager.getInstance().getConstants().removeVmDisksAllSharedMsg());
return;
}
}
use of org.ovirt.engine.core.common.businessentities.storage.DiskImage in project ovirt-engine by oVirt.
the class VmModelBehaviorBase method initTemplateDisks.
protected void initTemplateDisks(List<DiskImage> disks) {
disks.sort(new DiskByDiskAliasComparator());
ArrayList<DiskModel> list = new ArrayList<>();
for (DiskImage disk : disks) {
DiskModel diskModel = new DiskModel();
diskModel.getAlias().setEntity(disk.getDiskAlias());
diskModel.getVolumeType().setIsAvailable(false);
switch(disk.getDiskStorageType()) {
case IMAGE:
diskModel.setSize(new EntityModel<>((int) disk.getSizeInGigabytes()));
ListModel volumes = new ListModel();
volumes.setItems(disk.getVolumeType() == VolumeType.Preallocated ? new ArrayList<>(Collections.singletonList(VolumeType.Preallocated)) : AsyncDataProvider.getInstance().getVolumeTypeList(), disk.getVolumeType());
diskModel.setVolumeType(volumes);
break;
case CINDER:
CinderDisk cinderDisk = (CinderDisk) disk;
diskModel.setSize(new EntityModel<>((int) cinderDisk.getSizeInGigabytes()));
ListModel volumeTypes = new ListModel();
volumeTypes.setItems(new ArrayList<>(Collections.singletonList(cinderDisk.getVolumeType())), cinderDisk.getVolumeType());
diskModel.setVolumeType(volumeTypes);
ListModel volumeFormats = new ListModel();
volumeFormats.setItems(new ArrayList<>(Collections.singletonList(cinderDisk.getVolumeFormat())), cinderDisk.getVolumeFormat());
diskModel.setVolumeFormat(volumeFormats);
break;
}
diskModel.setDisk(disk);
list.add(diskModel);
}
getModel().setDisks(list);
updateIsDisksAvailable();
initStorageDomains();
}
Aggregations