use of org.ovirt.engine.core.common.businessentities.storage.DiskVmElement in project ovirt-engine by oVirt.
the class UpdateVmDiskCommandTest method testInvalidDiskExtend.
@Test
public void testInvalidDiskExtend() {
DiskImage oldDiskImage = createDiskImage();
oldDiskImage.setSize(SizeConverter.convert(8L, SizeConverter.SizeUnit.GiB, SizeConverter.SizeUnit.BYTES).longValue());
DiskImage newDiskImage = createDiskImage();
newDiskImage.setSize(SizeConverter.convert(10L, SizeConverter.SizeUnit.GiB, SizeConverter.SizeUnit.BYTES).longValue());
command.getParameters().setDiskVmElement(new DiskVmElement(newDiskImage.getId(), vmId));
command.getParameters().setDiskInfo(newDiskImage);
when(diskDao.get(diskImageGuid)).thenReturn(oldDiskImage);
initializeCommand();
StorageDomain sd = new StorageDomain();
sd.setId(Guid.newGuid());
sd.setStorageType(StorageType.ISCSI);
when(storageDomainDao.get(any())).thenReturn(sd);
ValidateTestUtils.runAndAssertValidateFailure(command, EngineMessage.ACTION_TYPE_FAILED_DISK_MAX_SIZE_EXCEEDED);
}
use of org.ovirt.engine.core.common.businessentities.storage.DiskVmElement in project ovirt-engine by oVirt.
the class AttachDiskToVmCommandTest method createParameters.
private AttachDetachVmDiskParameters createParameters() {
DiskVmElement dve = new DiskVmElement(diskId, vmId);
dve.setReadOnly(true);
AttachDetachVmDiskParameters parameters = new AttachDetachVmDiskParameters(dve);
return parameters;
}
use of org.ovirt.engine.core.common.businessentities.storage.DiskVmElement in project ovirt-engine by oVirt.
the class GetAllDisksByVmIdQueryTest method setUpDaoMocks.
private void setUpDaoMocks() {
// Disk Image Dao
List<Disk> returnArray = new ArrayList<>();
returnArray.add(pluggedDisk);
returnArray.add(unpluggedDisk);
returnArray.add(pluggedDiskSnapshot);
returnArray.add(unpluggedDiskSnapshot);
when(diskDaoMock.getAllForVm(vmID, getUser().getId(), getQueryParameters().isFiltered())).thenReturn(returnArray);
when(diskVmElementDao.get(any())).thenReturn(new DiskVmElement(new VmDeviceId()));
// Snapshots
doReturn(new ArrayList<>(Collections.nCopies(NUM_DISKS_OF_EACH_KIND, createDiskSnapshot(pluggedDisk.getId())))).when(diskImageDao).getAllSnapshotsForLeaf(pluggedDisk.getImageId());
doReturn(Collections.nCopies(NUM_DISKS_OF_EACH_KIND, createDiskSnapshot(unpluggedDisk.getId()))).when(diskImageDao).getAllSnapshotsForLeaf(unpluggedDisk.getImageId());
doReturn(new ArrayList<>(Collections.nCopies(NUM_DISKS_OF_EACH_KIND, createDiskSnapshot(pluggedDiskSnapshot.getId())))).when(diskImageDao).getAllSnapshotsForLeaf(pluggedDiskSnapshot.getImageId());
doReturn(Collections.nCopies(NUM_DISKS_OF_EACH_KIND, createDiskSnapshot(unpluggedDiskSnapshot.getId()))).when(diskImageDao).getAllSnapshotsForLeaf(unpluggedDiskSnapshot.getImageId());
}
use of org.ovirt.engine.core.common.businessentities.storage.DiskVmElement in project ovirt-engine by oVirt.
the class HotPlugDiskToVmCommandTest method mockDiskImage.
private DiskImage mockDiskImage(DiskInterface iface) {
disk.setImageId(diskImageGuid);
ArrayList<Guid> storageIdList = new ArrayList<>();
storageIdList.add(storageDomainId);
disk.setStorageIds(storageIdList);
disk.setStoragePoolId(storagePoolId);
disk.setActive(true);
disk.setId(Guid.newGuid());
when(diskDao.get(diskImageGuid)).thenReturn(disk);
DiskVmElement dve = new DiskVmElement(disk.getId(), vmId);
dve.setDiskInterface(iface);
when(diskVmElementDao.get(new VmDeviceId(disk.getId(), vmId))).thenReturn(dve);
return disk;
}
use of org.ovirt.engine.core.common.businessentities.storage.DiskVmElement in project ovirt-engine by oVirt.
the class MoveDiskCommandTest method testVmUpAndDiskPlugged.
@Test
public void testVmUpAndDiskPlugged() {
VM vm = createMockVm(VMStatus.Up);
DiskVmElement diskVmElement = createMockDiskVmElement(vm.getId(), true);
doReturn(vm).when(vmDao).get(any());
assertEquals(ActionType.LiveMigrateDisk, command.getMoveActionType(Collections.singletonList(diskVmElement)));
}
Aggregations