Search in sources :

Example 76 with DiskVmElement

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

Example 77 with DiskVmElement

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());
}
Also used : Response(javax.ws.rs.core.Response) Action(org.ovirt.engine.api.model.Action) DiskVmElement(org.ovirt.engine.core.common.businessentities.storage.DiskVmElement) VmDiskOperationParameterBase(org.ovirt.engine.core.common.action.VmDiskOperationParameterBase) Test(org.junit.Test)

Example 78 with DiskVmElement

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

Example 79 with DiskVmElement

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

Example 80 with DiskVmElement

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

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