Search in sources :

Example 31 with LunDisk

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

the class VmHandlerTest method createLunDisk.

private LunDisk createLunDisk() {
    LunDisk lunDisk = new LunDisk();
    lunDisk.setId(Guid.newGuid());
    return lunDisk;
}
Also used : LunDisk(org.ovirt.engine.core.common.businessentities.storage.LunDisk)

Example 32 with LunDisk

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

the class DiskMapper method map.

@Mapping(from = org.ovirt.engine.core.common.businessentities.storage.Disk.class, to = Disk.class)
public static Disk map(org.ovirt.engine.core.common.businessentities.storage.Disk entity, Disk template) {
    Disk model = template != null ? template : new Disk();
    // name is depreciated, use alias instead.
    model.setName(entity.getDiskAlias());
    model.setAlias(entity.getDiskAlias());
    if (entity.getId() != null) {
        model.setId(entity.getId().toString());
    }
    model.setPropagateErrors(PropagateErrors.On == entity.getPropagateErrors());
    model.setWipeAfterDelete(entity.isWipeAfterDelete());
    model.setShareable(entity.isShareable());
    model.setDescription(entity.getDiskDescription());
    model.setLogicalName(entity.getLogicalName());
    model.setStorageType(map(entity.getDiskStorageType()));
    if (entity.getDiskStorageType() == org.ovirt.engine.core.common.businessentities.storage.DiskStorageType.IMAGE || entity.getDiskStorageType() == org.ovirt.engine.core.common.businessentities.storage.DiskStorageType.CINDER) {
        mapDiskImageToDiskFields((DiskImage) entity, model);
    } else {
        model.setLunStorage(StorageLogicalUnitMapper.map(((LunDisk) entity).getLun(), new HostStorage()));
        if (entity.getSgio() != null) {
            model.setSgio(map(entity.getSgio(), null));
        }
    }
    model.setContentType(mapDiskContentType(entity.getContentType()));
    return model;
}
Also used : HostStorage(org.ovirt.engine.api.model.HostStorage) CinderDisk(org.ovirt.engine.core.common.businessentities.storage.CinderDisk) LunDisk(org.ovirt.engine.core.common.businessentities.storage.LunDisk) Disk(org.ovirt.engine.api.model.Disk) LunDisk(org.ovirt.engine.core.common.businessentities.storage.LunDisk)

Example 33 with LunDisk

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

the class LunDiskMapperTest method testRoundtrip.

@Test
@Override
public void testRoundtrip() throws Exception {
    setUpConfigExpectations();
    Disk model = Disk.class.cast(populate(Disk.class));
    model = postPopulate(model);
    Mapper<Disk, org.ovirt.engine.core.common.businessentities.storage.Disk> out = getMappingLocator().getMapper(Disk.class, org.ovirt.engine.core.common.businessentities.storage.Disk.class);
    Mapper<org.ovirt.engine.core.common.businessentities.storage.Disk, Disk> back = getMappingLocator().getMapper(org.ovirt.engine.core.common.businessentities.storage.Disk.class, Disk.class);
    LunDisk to = (LunDisk) out.map(model, null);
    LunDisk inverse = getInverse(to);
    Disk transform = back.map(inverse, null);
    verify(model, transform);
}
Also used : Disk(org.ovirt.engine.api.model.Disk) LunDisk(org.ovirt.engine.core.common.businessentities.storage.LunDisk) LunDisk(org.ovirt.engine.core.common.businessentities.storage.LunDisk) Test(org.junit.Test)

Example 34 with LunDisk

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

the class LibvirtVmXmlBuilder method writeDiskSource.

private void writeDiskSource(Disk disk, String dev) {
    writer.writeStartElement("source");
    switch(disk.getDiskStorageType()) {
        case IMAGE:
            DiskImage diskImage = (DiskImage) disk;
            // Change parameters for the HE disk
            if (vm.isHostedEngine()) {
                // Hosted engine disk images have to have empty storage pool ID,
                // so they can be mounted even if storage pool is not connected.
                diskImage.setStoragePoolId(Guid.Empty);
                diskImage.setPropagateErrors(PropagateErrors.Off);
                // The disk requires a lease
                addVolumeLease(diskImage.getImageId(), diskImage.getStorageIds().get(0));
            }
            String diskType = this.vmInfoBuildUtils.getDiskType(this.vm, diskImage);
            switch(diskType) {
                case "block":
                    writer.writeAttributeString("dev", vmInfoBuildUtils.getPathToImage(diskImage));
                    break;
                case "network":
                    String[] volInfo = vmInfoBuildUtils.getGlusterVolInfo(disk);
                    // drop to the 'file' case as a fallback.
                    if (volInfo != null) {
                        writer.writeAttributeString("protocol", "gluster");
                        writer.writeAttributeString("name", String.format("%s/%s/images/%s/%s", volInfo[1], diskImage.getStorageIds().get(0), diskImage.getId(), diskImage.getImageId()));
                        writer.writeStartElement("host");
                        writer.writeAttributeString("name", volInfo[0]);
                        writer.writeAttributeString("port", "0");
                        writer.writeEndElement();
                        break;
                    }
                case "file":
                    writer.writeAttributeString("file", vmInfoBuildUtils.getPathToImage(diskImage));
                    break;
            }
            diskMetadata.put(dev, createDiskParams(diskImage));
            break;
        case LUN:
            LunDisk lunDisk = (LunDisk) disk;
            writer.writeAttributeString("dev", String.format("/dev/mapper/%s", lunDisk.getLun().getLUNId()));
            diskMetadata.put(dev, Collections.singletonMap("GUID", lunDisk.getLun().getLUNId()));
            break;
        case CINDER:
            // case RBD
            CinderDisk cinderDisk = (CinderDisk) disk;
            Map<String, Object> connectionInfoData = cinderDisk.getCinderConnectionInfo().getData();
            writer.writeAttributeString("protocol", cinderDisk.getCinderConnectionInfo().getDriverVolumeType());
            writer.writeAttributeString("name", connectionInfoData.get("name").toString());
            List<String> hostAddresses = (List<String>) connectionInfoData.get("hosts");
            List<String> hostPorts = (List<String>) connectionInfoData.get("ports");
            // (Cinder should ensure that the addresses and ports lists are synced in order).
            for (int i = 0; i < hostAddresses.size(); i++) {
                writer.writeStartElement("host");
                writer.writeAttributeString("name", hostAddresses.get(i));
                writer.writeAttributeString("port", hostPorts.get(i));
                // If no transport is specified, "tcp" is assumed.
                writer.writeEndElement();
            }
            break;
    }
    writer.writeEndElement();
}
Also used : List(java.util.List) ArrayList(java.util.ArrayList) CinderDisk(org.ovirt.engine.core.common.businessentities.storage.CinderDisk) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage) LunDisk(org.ovirt.engine.core.common.businessentities.storage.LunDisk)

Example 35 with LunDisk

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

the class DisksFilterTest method testFilterNonLunDisks.

@Test
public void testFilterNonLunDisks() {
    Disk lunDisk = createDisk(DiskStorageType.LUN, false, false, false, false);
    Disk imageDisk = createDisk(DiskStorageType.IMAGE, false, false, true, false);
    Disk cinderDisk = createDisk(DiskStorageType.CINDER, false, false, true, false);
    List<Disk> disksList = Arrays.asList(lunDisk, imageDisk, cinderDisk);
    List<LunDisk> filteredList = DisksFilter.filterLunDisks(disksList);
    assertEquals(1, filteredList.size());
    assertThat(filteredList, containsInAnyOrder(lunDisk));
}
Also used : CinderDisk(org.ovirt.engine.core.common.businessentities.storage.CinderDisk) LunDisk(org.ovirt.engine.core.common.businessentities.storage.LunDisk) Disk(org.ovirt.engine.core.common.businessentities.storage.Disk) LunDisk(org.ovirt.engine.core.common.businessentities.storage.LunDisk) Test(org.junit.Test)

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