use of org.ovirt.engine.core.common.businessentities.storage.CinderDisk in project ovirt-engine by oVirt.
the class AddVmTemplateCommand method validateImages.
protected boolean validateImages() {
// images related checks
if (!images.isEmpty()) {
if (!validateVmNotDuringSnapshot()) {
return false;
}
if (!validate(new StoragePoolValidator(getStoragePool()).existsAndUp())) {
return false;
}
List<CinderDisk> cinderDisks = getCinderDisks();
CinderDisksValidator cinderDisksValidator = new CinderDisksValidator(cinderDisks);
if (!validate(cinderDisksValidator.validateCinderDiskLimits())) {
return false;
}
if (!validate(isPassDiscardSupportedForImagesDestSds())) {
return false;
}
List<DiskImage> diskImagesToCheck = DisksFilter.filterImageDisks(images, ONLY_NOT_SHAREABLE, ONLY_ACTIVE);
diskImagesToCheck.addAll(cinderDisks);
DiskImagesValidator diskImagesValidator = new DiskImagesValidator(diskImagesToCheck);
if (!validate(diskImagesValidator.diskImagesNotIllegal()) || !validate(diskImagesValidator.diskImagesNotLocked())) {
return false;
}
MultipleStorageDomainsValidator storageDomainsValidator = getStorageDomainsValidator(getStoragePoolId(), sourceImageDomainsImageMap.keySet());
if (!validate(storageDomainsValidator.allDomainsExistAndActive())) {
return false;
}
Set<Guid> destImageDomains = getStorageGuidSet();
destImageDomains.removeAll(sourceImageDomainsImageMap.keySet());
for (Guid destImageDomain : destImageDomains) {
StorageDomain storage = storageDomainDao.getForStoragePool(destImageDomain, getVm().getStoragePoolId());
if (storage == null) {
// domain is not in the same storage pool as the vm
if (storageDomainStaticDao.get(destImageDomain) == null) {
addValidationMessage(EngineMessage.ACTION_TYPE_FAILED_STORAGE_DOMAIN_NOT_EXIST);
} else {
addValidationMessage(EngineMessage.ACTION_TYPE_FAILED_STORAGE_DOMAIN_NOT_IN_STORAGE_POOL);
}
return false;
}
if (storage.getStatus() == null || storage.getStatus() != StorageDomainStatus.Active) {
addValidationMessage(EngineMessage.ACTION_TYPE_FAILED_STORAGE_DOMAIN_STATUS_ILLEGAL);
return false;
}
if (storage.getStorageDomainType().isIsoOrImportExportDomain()) {
addValidationMessage(EngineMessage.ACTION_TYPE_FAILED_STORAGE_DOMAIN_TYPE_ILLEGAL);
return false;
}
}
return validateSpaceRequirements();
}
return true;
}
use of org.ovirt.engine.core.common.businessentities.storage.CinderDisk in project ovirt-engine by oVirt.
the class AddVmAndCloneImageCommand method addVmImages.
@Override
protected boolean addVmImages() {
int numberOfStartedCopyTasks = 0;
List<DiskImage> cinderDisks = new ArrayList<>();
try {
if (!getAdjustedDiskImagesFromConfiguration().isEmpty()) {
lockEntities();
for (DiskImage diskImage : getAdjustedDiskImagesFromConfiguration()) {
// query returned to UI an illegal image)
if (diskImage.getImageStatus() == ImageStatus.ILLEGAL) {
DiskImage snapshotImageInDb = diskImageDao.getSnapshotById(diskImage.getImageId());
if (snapshotImageInDb == null) {
// If the snapshot diskImage is null, it means the disk was probably
// erased after the snapshot was created.
// Create a disk to reflect the fact the disk existed during snapshot
saveIllegalDisk(diskImage);
}
} else {
// Only legal images can be copied
if (diskImage.getDiskStorageType() == DiskStorageType.CINDER) {
CinderDisk cinder = (CinderDisk) diskImage;
cinder.setVmSnapshotId(getVmSnapshotId());
cinderDisks.add(cinder);
continue;
}
copyDiskImage(diskImage, diskImage.getStorageIds().get(0), diskInfoDestinationMap.get(diskImage.getId()).getStorageIds().get(0), diskInfoDestinationMap.get(diskImage.getId()).getDiskProfileId(), getActionType());
numberOfStartedCopyTasks++;
}
}
addVmCinderDisks(cinderDisks);
}
} finally {
// it is still needed to unlock the entities
if ((numberOfStartedCopyTasks == 0) && cinderDisks.isEmpty()) {
unlockEntities();
}
}
return true;
}
use of org.ovirt.engine.core.common.businessentities.storage.CinderDisk in project ovirt-engine by oVirt.
the class NewDiskModel method flush.
@Override
public void flush() {
if (!validate()) {
return;
}
super.flush();
switch(getDiskStorageType().getEntity()) {
case LUN:
LunDisk lunDisk = (LunDisk) getDisk();
LUNs luns = getSanStorageModelBase().getAddedLuns().get(0).getEntity();
luns.setLunType(getStorageType().getSelectedItem());
lunDisk.setLun(luns);
break;
case CINDER:
CinderDisk cinderDisk = (CinderDisk) getDisk();
cinderDisk.setSizeInGigabytes(getSize().getEntity());
cinderDisk.setVolumeFormat(VolumeFormat.RAW);
cinderDisk.setCinderVolumeType(getCinderVolumeType().getSelectedItem());
break;
default:
DiskImage diskImage = (DiskImage) getDisk();
if (getSize() != null && getSize().getEntity() != null) {
diskImage.setSizeInGigabytes(getSize().getEntity());
}
diskImage.setVolumeType(getVolumeType().getSelectedItem());
diskImage.setVolumeFormat(AsyncDataProvider.getInstance().getDiskVolumeFormat(diskImage.getVolumeType(), getStorageDomain().getSelectedItem().getStorageType()));
break;
}
}
use of org.ovirt.engine.core.common.businessentities.storage.CinderDisk in project ovirt-engine by oVirt.
the class NewTemplateVmModelBehavior method initDisks.
private void initDisks(ArrayList<Disk> disks) {
Collections.sort(disks, new DiskByDiskAliasComparator());
ArrayList<DiskModel> list = new ArrayList<>();
for (Disk disk : disks) {
DiskModel diskModel = new DiskModel();
switch(disk.getDiskStorageType()) {
case IMAGE:
DiskImage diskImage = (DiskImage) disk;
diskModel.setSize(new EntityModel<>((int) diskImage.getSizeInGigabytes()));
ListModel volumes = new ListModel();
volumes.setItems(diskImage.getVolumeType() == VolumeType.Preallocated ? new ArrayList<>(Arrays.asList(new VolumeType[] { VolumeType.Preallocated })) : AsyncDataProvider.getInstance().getVolumeTypeList(), diskImage.getVolumeType());
diskModel.setVolumeType(volumes);
diskModel.getAlias().setEntity(diskImage.getDiskAlias());
break;
case CINDER:
CinderDisk cinderDisk = (CinderDisk) disk;
diskModel.setSize(new EntityModel<>((int) cinderDisk.getSizeInGigabytes()));
ListModel volumeTypes = new ListModel();
volumeTypes.setItems(new ArrayList<>(Arrays.asList(cinderDisk.getVolumeType())), cinderDisk.getVolumeType());
diskModel.setVolumeType(volumeTypes);
diskModel.getAlias().setEntity(cinderDisk.getDiskAlias());
diskModel.getVolumeFormat().setIsChangeable(false);
break;
}
diskModel.setDisk(disk);
list.add(diskModel);
diskModel.getVolumeFormat().setIsAvailable(true);
}
getModel().setDisks(list);
}
Aggregations