Search in sources :

Example 16 with DiskVmElement

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);
}
Also used : StorageDomain(org.ovirt.engine.core.common.businessentities.StorageDomain) DiskVmElement(org.ovirt.engine.core.common.businessentities.storage.DiskVmElement) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage) Test(org.junit.Test) BaseCommandTest(org.ovirt.engine.core.bll.BaseCommandTest)

Example 17 with DiskVmElement

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;
}
Also used : AttachDetachVmDiskParameters(org.ovirt.engine.core.common.action.AttachDetachVmDiskParameters) DiskVmElement(org.ovirt.engine.core.common.businessentities.storage.DiskVmElement)

Example 18 with DiskVmElement

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());
}
Also used : ArrayList(java.util.ArrayList) DiskVmElement(org.ovirt.engine.core.common.businessentities.storage.DiskVmElement) Disk(org.ovirt.engine.core.common.businessentities.storage.Disk) VmDeviceId(org.ovirt.engine.core.common.businessentities.VmDeviceId)

Example 19 with DiskVmElement

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;
}
Also used : ArrayList(java.util.ArrayList) DiskVmElement(org.ovirt.engine.core.common.businessentities.storage.DiskVmElement) Guid(org.ovirt.engine.core.compat.Guid) VmDeviceId(org.ovirt.engine.core.common.businessentities.VmDeviceId)

Example 20 with DiskVmElement

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)));
}
Also used : VM(org.ovirt.engine.core.common.businessentities.VM) DiskVmElement(org.ovirt.engine.core.common.businessentities.storage.DiskVmElement) Test(org.junit.Test) BaseCommandTest(org.ovirt.engine.core.bll.BaseCommandTest)

Aggregations

DiskVmElement (org.ovirt.engine.core.common.businessentities.storage.DiskVmElement)91 DiskImage (org.ovirt.engine.core.common.businessentities.storage.DiskImage)30 Test (org.junit.Test)26 VmDeviceId (org.ovirt.engine.core.common.businessentities.VmDeviceId)23 Disk (org.ovirt.engine.core.common.businessentities.storage.Disk)22 Guid (org.ovirt.engine.core.compat.Guid)17 ArrayList (java.util.ArrayList)16 VM (org.ovirt.engine.core.common.businessentities.VM)12 BaseCommandTest (org.ovirt.engine.core.bll.BaseCommandTest)11 HashMap (java.util.HashMap)8 CinderDisk (org.ovirt.engine.core.common.businessentities.storage.CinderDisk)8 Map (java.util.Map)7 VmDevice (org.ovirt.engine.core.common.businessentities.VmDevice)7 LunDisk (org.ovirt.engine.core.common.businessentities.storage.LunDisk)7 ActionType (org.ovirt.engine.core.common.action.ActionType)6 AttachDetachVmDiskParameters (org.ovirt.engine.core.common.action.AttachDetachVmDiskParameters)6 List (java.util.List)5 Collectors (java.util.stream.Collectors)5 VmDiskOperationParameterBase (org.ovirt.engine.core.common.action.VmDiskOperationParameterBase)5 Collection (java.util.Collection)4