use of org.ovirt.engine.core.common.businessentities.storage.DiskImage in project ovirt-engine by oVirt.
the class DiskOperationsValidatorTest method testDisallowedOperations.
@Test
public void testDisallowedOperations() {
Disk disk = new DiskImage();
for (Map.Entry<ActionType, List<DiskContentType>> entry : DiskOperationsValidator.allowedCommandsOnTypes.entrySet()) {
EnumSet<DiskContentType> allowedTypes = EnumSet.copyOf(entry.getValue());
EnumSet<DiskContentType> disallowedTypes = EnumSet.complementOf(allowedTypes);
if (disallowedTypes.isEmpty()) {
continue;
}
disk.setContentType(disallowedTypes.iterator().next());
DiskOperationsValidator validator = new DiskOperationsValidator(disk);
assertThat(validator.isOperationAllowedOnDisk(entry.getKey()), failsWith(EngineMessage.ACTION_TYPE_FAILED_DISK_CONTENT_TYPE_NOT_SUPPORTED_FOR_OPERATION, String.format("$diskContentType %s", disk.getContentType())));
}
}
use of org.ovirt.engine.core.common.businessentities.storage.DiskImage in project ovirt-engine by oVirt.
the class DiskOperationsValidatorTest method testAllowedOperations.
@Test
public void testAllowedOperations() {
Disk disk = new DiskImage();
for (Map.Entry<ActionType, List<DiskContentType>> entry : DiskOperationsValidator.allowedCommandsOnTypes.entrySet()) {
disk.setContentType(entry.getValue().get(0));
DiskOperationsValidator validator = new DiskOperationsValidator(disk);
assertThat(validator.isOperationAllowedOnDisk(entry.getKey()), isValid());
}
}
use of org.ovirt.engine.core.common.businessentities.storage.DiskImage in project ovirt-engine by oVirt.
the class DiskSnapshotsValidatorTest method createDisk.
private static DiskImage createDisk() {
DiskImage disk = new DiskImage();
disk.setImageId(Guid.newGuid());
disk.setActive(true);
disk.setImageStatus(ImageStatus.OK);
ArrayList<Guid> storageDomainIds = new ArrayList<>();
storageDomainIds.add(Guid.newGuid());
disk.setStorageIds(storageDomainIds);
return disk;
}
use of org.ovirt.engine.core.common.businessentities.storage.DiskImage in project ovirt-engine by oVirt.
the class DiskValidatorTest method canCopyDiskFails.
@Test
public void canCopyDiskFails() {
StorageDomain domain = createStorageDomainForDisk(StorageType.ISCSI);
domain.setStorageFormat(StorageFormatType.V3);
disk.setSize(1000);
DiskImage child = createDiskImage();
child.setSize(1000);
child.setStorageIds(Collections.singletonList(domain.getId()));
DiskImage parent = createDiskImage();
parent.setId(Guid.newGuid());
parent.setSize(500);
parent.setStorageIds(Collections.singletonList(domain.getId()));
child.setParentId(parent.getParentId());
List<DiskImage> diskImages = new ArrayList<>(2);
diskImages.add(parent);
diskImages.add(child);
when(validator.getDiskImageDao().getAllSnapshotsForImageGroup(disk.getId())).thenReturn(diskImages);
assertThat(diskImagesValidator.childDiskWasExtended(domain), failsWith(EngineMessage.CANNOT_MOVE_DISK_SNAPSHOTS));
}
use of org.ovirt.engine.core.common.businessentities.storage.DiskImage in project ovirt-engine by oVirt.
the class DiskVmElementDiscardSupportValidatorTest method data.
@Parameters
public static Object[][] data() {
ValidationResult passDiscardNotSupportedByDiskInterface = new ValidationResult(EngineMessage.ACTION_TYPE_FAILED_PASS_DISCARD_NOT_SUPPORTED_BY_DISK_INTERFACE, getDiskAliasVarReplacement());
ValidationResult passDiscardNotSupportedForDirectLunByUnderlyingStorage = new ValidationResult(EngineMessage.ACTION_TYPE_FAILED_PASS_DISCARD_NOT_SUPPORTED_FOR_DIRECT_LUN_BY_UNDERLYING_STORAGE, getDiskAliasVarReplacement());
ValidationResult passDiscardNotSupportedForDiskImageByUnderlyingStorage = new ValidationResult(EngineMessage.ACTION_TYPE_FAILED_PASS_DISCARD_NOT_SUPPORTED_FOR_DISK_IMAGE_BY_UNDERLYING_STORAGE, getDiskAliasVarReplacement(), getStorageDomainNameVarReplacement());
ValidationResult passDiscardNotSupportedByCinder = new ValidationResult(EngineMessage.ACTION_TYPE_FAILED_PASS_DISCARD_NOT_SUPPORTED_BY_DISK_STORAGE_TYPE, getDiskAliasVarReplacement(), String.format("$diskStorageType %s", DiskStorageType.CINDER));
// sdSupportsDiscard, diskWipeAfterDelete, expectedResult.
return new Object[][] { // isPassDiscard == false
{ new DiskImage(), false, null, null, null, null, null, ValidationResult.VALID }, // Unsupported interface
{ new DiskImage(), true, DiskInterface.VirtIO, null, null, null, null, passDiscardNotSupportedByDiskInterface }, { new DiskImage(), true, DiskInterface.SPAPR_VSCSI, null, null, null, null, passDiscardNotSupportedByDiskInterface }, // Direct lun without support from underlying storage (different interfaces)
{ new LunDisk(), true, DiskInterface.VirtIO_SCSI, 0L, null, null, null, passDiscardNotSupportedForDirectLunByUnderlyingStorage }, { new LunDisk(), true, DiskInterface.IDE, 0L, null, null, null, passDiscardNotSupportedForDirectLunByUnderlyingStorage }, // Direct lun with support from underlying storage (different interfaces)
{ new LunDisk(), true, DiskInterface.VirtIO_SCSI, 1024L, null, null, null, ValidationResult.VALID }, { new LunDisk(), true, DiskInterface.IDE, 1024L, null, null, null, ValidationResult.VALID }, /*
Image on file storage domain:
- with/without support from underlying storage
- different interfaces
- different file storage types
*/
{ new DiskImage(), true, DiskInterface.VirtIO_SCSI, null, StorageType.NFS, true, null, ValidationResult.VALID }, { new DiskImage(), true, DiskInterface.IDE, null, StorageType.POSIXFS, false, null, ValidationResult.VALID }, { new DiskImage(), true, DiskInterface.IDE, null, StorageType.POSIXFS, null, null, ValidationResult.VALID }, /*
Image on block storage domain without support from underlying storage:
- different interfaces
- different block storage types
*/
{ new DiskImage(), true, DiskInterface.VirtIO_SCSI, null, StorageType.ISCSI, false, null, passDiscardNotSupportedForDiskImageByUnderlyingStorage }, { new DiskImage(), true, DiskInterface.IDE, null, StorageType.FCP, false, null, passDiscardNotSupportedForDiskImageByUnderlyingStorage }, /*
Image on block storage domain with support from underlying storage:
- different interfaces
- different block storage types
*/
{ new DiskImage(), true, DiskInterface.VirtIO_SCSI, null, StorageType.ISCSI, true, null, ValidationResult.VALID }, { new DiskImage(), true, DiskInterface.IDE, null, StorageType.FCP, true, null, ValidationResult.VALID }, /*
Image on block storage domain with support from underlying storage and WAD enabled:
- different interfaces
- different block storage types
*/
{ new DiskImage(), true, DiskInterface.VirtIO_SCSI, null, StorageType.ISCSI, true, true, new ValidationResult(EngineMessage.ACTION_TYPE_FAILED_PASS_DISCARD_NOT_SUPPORTED_BY_UNDERLYING_STORAGE_WHEN_WAD_IS_ENABLED, getStorageDomainNameVarReplacement(), getDiskAliasVarReplacement()) }, { new DiskImage(), true, DiskInterface.IDE, null, StorageType.FCP, true, true, new ValidationResult(EngineMessage.ACTION_TYPE_FAILED_PASS_DISCARD_NOT_SUPPORTED_BY_UNDERLYING_STORAGE_WHEN_WAD_IS_ENABLED, getStorageDomainNameVarReplacement(), getDiskAliasVarReplacement()) }, /*
Image on non file or block storage domain:
- different interfaces
- different non file or block storage types
*/
{ new DiskImage(), true, DiskInterface.VirtIO_SCSI, null, StorageType.UNKNOWN, null, null, createPassDiscardNotSupportedByStorageTypeValResult(StorageType.UNKNOWN) }, { new DiskImage(), true, DiskInterface.IDE, null, StorageType.CINDER, null, null, createPassDiscardNotSupportedByStorageTypeValResult(StorageType.CINDER) }, // Unsupported disk storage type (different interfaces)
{ new CinderDisk(), true, DiskInterface.VirtIO_SCSI, null, null, null, null, passDiscardNotSupportedByCinder }, { new CinderDisk(), true, DiskInterface.IDE, null, null, null, null, passDiscardNotSupportedByCinder } };
}
Aggregations