use of org.ovirt.engine.ui.uicommonweb.models.vms.DiskModel in project ovirt-engine by oVirt.
the class DisksAllocationModel method setDiskProfilesList.
private void setDiskProfilesList(final ListModel<DiskProfile> diskProfiles, List<DiskProfile> fetchedDiskProfiles) {
if (fetchedDiskProfiles != null) {
// normal flow, set items and selected item according to current selected.
if (diskProfiles == null) {
for (DiskModel diskModel : getDisks()) {
diskModel.getDiskProfile().setItems(fetchedDiskProfiles);
for (DiskProfile diskProfile : fetchedDiskProfiles) {
if (diskModel.getDisk().getDiskStorageType() == DiskStorageType.IMAGE && diskProfile.getId().equals(((DiskImage) diskModel.getDisk()).getDiskProfileId())) {
diskModel.getDiskProfile().setSelectedItem(diskProfile);
}
}
}
// inner model disk profiles
} else {
DiskProfile selectedDiskProfile = null;
if (diskProfiles.getSelectedItem() != null) {
selectedDiskProfile = diskProfiles.getSelectedItem();
}
diskProfiles.setItems(fetchedDiskProfiles);
if (selectedDiskProfile != null && fetchedDiskProfiles.size() > 1) {
for (DiskProfile diskProfile : fetchedDiskProfiles) {
if (diskProfile.getId().equals(selectedDiskProfile.getId())) {
diskProfiles.setSelectedItem(diskProfile);
break;
}
}
}
}
}
}
use of org.ovirt.engine.ui.uicommonweb.models.vms.DiskModel in project ovirt-engine by oVirt.
the class DisksAllocationModel method setDefaultVolumeInformationSelection.
protected void setDefaultVolumeInformationSelection(List<DiskModel> diskModels) {
final Map<Guid, DiskModel> diskModelsMap = new HashMap<>();
for (DiskModel diskModel : diskModels) {
diskModelsMap.put(((DiskImage) diskModel.getDisk()).getImageId(), diskModel);
}
AsyncDataProvider.getInstance().getAncestorImagesByImagesIds(new AsyncQuery<>(imagesAncestors -> {
for (Map.Entry<Guid, DiskImage> entry : imagesAncestors.entrySet()) {
DiskModel diskModel = diskModelsMap.get(entry.getKey());
diskModel.getVolumeType().setSelectedItem(entry.getValue().getVolumeType());
diskModel.getVolumeFormat().setSelectedItem(entry.getValue().getVolumeFormat());
updateStorageDomainsAvailability();
}
}), new ArrayList<>(diskModelsMap.keySet()));
}
use of org.ovirt.engine.ui.uicommonweb.models.vms.DiskModel in project ovirt-engine by oVirt.
the class DisksAllocationModel method validateEntity.
@Override
public void validateEntity(IValidation[] validations) {
super.validateEntity(validations);
if (getDisks() == null) {
return;
}
boolean isModelValid = true;
for (DiskModel diskModel : getDisks()) {
ListModel<StorageDomain> diskStorageDomains = diskModel.getStorageDomain();
if (!diskStorageDomains.getItems().iterator().hasNext() || diskStorageDomains.getSelectedItem() == null) {
diskModel.getStorageDomain().getInvalidityReasons().add(constants.storageDomainMustBeSpecifiedInvalidReason());
diskModel.getStorageDomain().setIsValid(false);
isModelValid = false;
}
diskModel.getAlias().validateEntity(new IValidation[] { new NotEmptyValidation(), new I18NNameValidation() });
isModelValid = isModelValid && diskModel.getAlias().getIsValid();
}
setIsValid(isModelValid);
}
use of org.ovirt.engine.ui.uicommonweb.models.vms.DiskModel in project ovirt-engine by oVirt.
the class DisksAllocationModel method updateStorageDomainsAvailability.
private void updateStorageDomainsAvailability() {
if (disks == null) {
return;
}
for (DiskModel diskModel : disks) {
diskModel.getSourceStorageDomain().setIsAvailable(isSourceStorageDomainAvailable);
diskModel.getSourceStorageDomainName().setIsAvailable(isSourceStorageDomainNameAvailable);
diskModel.getStorageDomain().setIsAvailable(isTargetAvailable);
diskModel.getVolumeType().setIsAvailable(isVolumeTypeAvailable);
diskModel.getVolumeType().setIsChangeable(isVolumeTypeChangable);
diskModel.getVolumeFormat().setIsAvailable(isVolumeFormatAvailable);
diskModel.getVolumeFormat().setIsChangeable(isVolumeFormatChangeable);
diskModel.getAlias().setIsChangeable(isAliasChangable);
boolean isCinder = diskModel.getDisk().getDiskStorageType() == DiskStorageType.CINDER;
if (isCinder) {
diskModel.getVolumeFormat().setIsChangeable(false);
diskModel.getVolumeFormat().setSelectedItem(VolumeFormat.RAW);
} else if (isThinProvisioning) {
diskModel.getVolumeFormat().setSelectedItem(VolumeFormat.COW);
}
}
}
use of org.ovirt.engine.ui.uicommonweb.models.vms.DiskModel 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;
}
Aggregations