use of org.ovirt.engine.core.common.businessentities.storage.DiskVmElement in project ovirt-engine by oVirt.
the class StorageDomainDaoTest method testIsHostedEngineStorage.
@Test
public void testIsHostedEngineStorage() {
// create hosted engine vm
VmStatic vm = new VmStatic();
vm.setId(Guid.newGuid());
vm.setOrigin(OriginType.HOSTED_ENGINE);
dbFacade.getVmStaticDao().save(vm);
// create disk for HE
DiskImage disk = new DiskImage();
disk.setId(Guid.newGuid());
disk.setImageId(Guid.newGuid());
disk.setActive(true);
disk.setVolumeType(VolumeType.Preallocated);
disk.setVolumeFormat(VolumeFormat.RAW);
dbFacade.getImageDao().save(disk.getImage());
dbFacade.getBaseDiskDao().save(disk);
ImageStorageDomainMap map = new ImageStorageDomainMap(disk.getImageId(), existingDomain.getId(), null, null);
dbFacade.getImageStorageDomainMapDao().save(map);
// attach disk
VmDevice device = new VmDevice(new VmDeviceId(disk.getId(), vm.getId()), VmDeviceGeneralType.DISK, VmDeviceType.DISK.getName(), "", null, true, false, false, "", null, null, null);
dbFacade.getVmDeviceDao().save(device);
DiskVmElement diskVmElement = new DiskVmElement(device.getId());
diskVmElement.setDiskInterface(DiskInterface.IDE);
dbFacade.getDiskVmElementDao().save(diskVmElement);
// run test
StorageDomain domain = dao.get(existingDomain.getId());
assertTrue(domain.isHostedEngineStorage());
// change origin
vm.setOrigin(OriginType.MANAGED_HOSTED_ENGINE);
dbFacade.getVmStaticDao().update(vm);
// run test again
domain = dao.get(existingDomain.getId());
assertTrue(domain.isHostedEngineStorage());
}
use of org.ovirt.engine.core.common.businessentities.storage.DiskVmElement in project ovirt-engine by oVirt.
the class BackendVmDiskResourceTest method testActivate.
@Test
public void testActivate() throws Exception {
setUriInfo(setUpActionExpectations(ActionType.HotPlugDiskToVm, VmDiskOperationParameterBase.class, new String[] { "DiskVmElement" }, new Object[] { new DiskVmElement(DISK_ID, VM_ID) }, true, true));
Response response = resource.activate(new Action());
assertEquals(200, response.getStatus());
}
use of org.ovirt.engine.core.common.businessentities.storage.DiskVmElement in project ovirt-engine by oVirt.
the class VmInfoBuildUtilsTest method mockUnsortedDisksMap.
private Map<Guid, Disk> mockUnsortedDisksMap(VmDevice lunDiskVmDevice, VmDevice diskImageVmDevice) {
when(vmDeviceDao.get(lunDiskVmDevice.getId())).thenReturn(lunDiskVmDevice);
when(vmDeviceDao.get(diskImageVmDevice.getId())).thenReturn(diskImageVmDevice);
DiskVmElement nonBootDiskVmElement = new DiskVmElement(lunDiskVmDevice.getId());
nonBootDiskVmElement.setBoot(false);
nonBootDiskVmElement.setDiskInterface(DiskInterface.VirtIO_SCSI);
DiskVmElement bootDiskVmElement = new DiskVmElement(diskImageVmDevice.getId());
bootDiskVmElement.setBoot(true);
bootDiskVmElement.setDiskInterface(DiskInterface.VirtIO_SCSI);
LunDisk lunDisk = new LunDisk();
lunDisk.setId(LUN_DISK_ID);
lunDisk.setDiskVmElements(Collections.singleton(nonBootDiskVmElement));
DiskImage diskImage = new DiskImage();
diskImage.setId(DISK_IMAGE_ID);
diskImage.setDiskVmElements(Collections.singleton(bootDiskVmElement));
Map<Guid, Disk> map = new HashMap<>();
map.put(lunDisk.getId(), lunDisk);
map.put(diskImage.getId(), diskImage);
return map;
}
use of org.ovirt.engine.core.common.businessentities.storage.DiskVmElement in project ovirt-engine by oVirt.
the class UpdateVmCommandTest method testCannotDisableVirtioScsi.
@Test
public void testCannotDisableVirtioScsi() {
prepareVmToPassValidate();
command.getParameters().setVirtioScsiEnabled(false);
Disk disk = new DiskImage();
disk.setPlugged(true);
DiskVmElement dve = new DiskVmElement(disk.getId(), vm.getId());
dve.setDiskInterface(DiskInterface.VirtIO_SCSI);
disk.setDiskVmElements(Collections.singletonList(dve));
mockDiskDaoGetAllForVm(Collections.singletonList(disk));
mockVmValidator();
command.initEffectiveCompatibilityVersion();
ValidateTestUtils.runAndAssertValidateFailure(command, EngineMessage.CANNOT_DISABLE_VIRTIO_SCSI_PLUGGED_DISKS);
}
use of org.ovirt.engine.core.common.businessentities.storage.DiskVmElement in project ovirt-engine by oVirt.
the class UpdateVmCommandTest method getNoVirtioScsiDiskElement.
private DiskVmElement getNoVirtioScsiDiskElement() {
DiskVmElement dve = new DiskVmElement(Guid.Empty, vm.getId());
dve.setDiskInterface(DiskInterface.VirtIO_SCSI);
return dve;
}
Aggregations