Search in sources :

Example 46 with LunDisk

use of org.ovirt.engine.core.common.businessentities.storage.LunDisk in project ovirt-engine by oVirt.

the class DiskValidatorTest method testIsUsingScsiReservationValidWhenSgioIsUnFiltered.

@Test
public void testIsUsingScsiReservationValidWhenSgioIsUnFiltered() {
    setupForLun();
    LunDisk lunDisk1 = createLunDisk(ScsiGenericIO.UNFILTERED);
    assertThat(lunValidator.isUsingScsiReservationValid(createVM(), createDiskVmElementUsingScsiReserevation(), lunDisk1), isValid());
}
Also used : LunDisk(org.ovirt.engine.core.common.businessentities.storage.LunDisk) Test(org.junit.Test)

Example 47 with LunDisk

use of org.ovirt.engine.core.common.businessentities.storage.LunDisk in project ovirt-engine by oVirt.

the class DiskValidatorTest method createLunDisk.

private static LunDisk createLunDisk() {
    LunDisk disk = new LunDisk();
    LUNs lun = new LUNs();
    lun.setLUNId("lun_id");
    lun.setLunType(StorageType.ISCSI);
    disk.setLun(lun);
    return disk;
}
Also used : LunDisk(org.ovirt.engine.core.common.businessentities.storage.LunDisk) LUNs(org.ovirt.engine.core.common.businessentities.storage.LUNs)

Example 48 with LunDisk

use of org.ovirt.engine.core.common.businessentities.storage.LunDisk in project ovirt-engine by oVirt.

the class DiskValidatorTest method testIsUsingScsiReservationValidWhenSgioIsFiltered.

@Test
public void testIsUsingScsiReservationValidWhenSgioIsFiltered() {
    setupForLun();
    LunDisk lunDisk1 = createLunDisk(ScsiGenericIO.FILTERED);
    assertThat(lunValidator.isUsingScsiReservationValid(createVM(), createDiskVmElementUsingScsiReserevation(), lunDisk1), failsWith(EngineMessage.ACTION_TYPE_FAILED_SGIO_IS_FILTERED));
}
Also used : LunDisk(org.ovirt.engine.core.common.businessentities.storage.LunDisk) Test(org.junit.Test)

Example 49 with LunDisk

use of org.ovirt.engine.core.common.businessentities.storage.LunDisk in project ovirt-engine by oVirt.

the class OvfHelper method buildMetadataDictionaryForVm.

/**
 * Adds the given vm metadata to the given map
 */
private String buildMetadataDictionaryForVm(VM vm) {
    List<DiskImage> allVmImages = new ArrayList<>();
    List<DiskImage> filteredDisks = DisksFilter.filterImageDisks(vm.getDiskList(), ONLY_SNAPABLE, ONLY_ACTIVE);
    List<LunDisk> lunDisks = DisksFilter.filterLunDisks(vm.getDiskMap().values());
    List<AffinityGroup> affinityGroups = affinityGroupDao.getAllAffinityGroupsByVmId(vm.getId());
    Set<DbUser> dbUsers = new HashSet<>(dbUserDao.getAllForVm(vm.getId()));
    List<Label> affinityLabels = labelDao.getAllByEntityIds(Collections.singletonList(vm.getId()));
    for (DiskImage diskImage : filteredDisks) {
        List<DiskImage> images = diskImageDao.getAllSnapshotsForLeaf(diskImage.getImageId());
        images.forEach(d -> d.setDiskVmElements(Collections.singletonList(diskImage.getDiskVmElementForVm(vm.getId()))));
        allVmImages.addAll(images);
    }
    FullEntityOvfData fullEntityOvfData = new FullEntityOvfData(vm);
    fullEntityOvfData.setDiskImages(allVmImages);
    fullEntityOvfData.setLunDisks(lunDisks);
    fullEntityOvfData.setAffinityGroups(affinityGroups);
    fullEntityOvfData.setAffinityLabels(affinityLabels);
    fullEntityOvfData.setDbUsers(dbUsers);
    populateUserToRoles(fullEntityOvfData, vm.getId());
    return ovfManager.exportVm(vm, fullEntityOvfData, clusterUtils.getCompatibilityVersion(vm));
}
Also used : ArrayList(java.util.ArrayList) Label(org.ovirt.engine.core.common.businessentities.Label) FullEntityOvfData(org.ovirt.engine.core.common.businessentities.storage.FullEntityOvfData) LunDisk(org.ovirt.engine.core.common.businessentities.storage.LunDisk) AffinityGroup(org.ovirt.engine.core.common.scheduling.AffinityGroup) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage) DbUser(org.ovirt.engine.core.common.businessentities.aaa.DbUser) HashSet(java.util.HashSet)

Example 50 with LunDisk

use of org.ovirt.engine.core.common.businessentities.storage.LunDisk 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)

Aggregations

LunDisk (org.ovirt.engine.core.common.businessentities.storage.LunDisk)62 Test (org.junit.Test)29 DiskImage (org.ovirt.engine.core.common.businessentities.storage.DiskImage)21 CinderDisk (org.ovirt.engine.core.common.businessentities.storage.CinderDisk)18 BaseCommandTest (org.ovirt.engine.core.bll.BaseCommandTest)16 Disk (org.ovirt.engine.core.common.businessentities.storage.Disk)13 LUNs (org.ovirt.engine.core.common.businessentities.storage.LUNs)13 VM (org.ovirt.engine.core.common.businessentities.VM)10 ArrayList (java.util.ArrayList)9 StorageServerConnections (org.ovirt.engine.core.common.businessentities.StorageServerConnections)7 Guid (org.ovirt.engine.core.compat.Guid)7 DiskVmElement (org.ovirt.engine.core.common.businessentities.storage.DiskVmElement)6 HashMap (java.util.HashMap)5 VDS (org.ovirt.engine.core.common.businessentities.VDS)5 StorageServerConnectionManagementVDSParameters (org.ovirt.engine.core.common.vdscommands.StorageServerConnectionManagementVDSParameters)5 HashSet (java.util.HashSet)3 FullEntityOvfData (org.ovirt.engine.core.common.businessentities.storage.FullEntityOvfData)3 StorageType (org.ovirt.engine.core.common.businessentities.storage.StorageType)3 ImageResource (com.google.gwt.resources.client.ImageResource)2 List (java.util.List)2