Search in sources :

Example 31 with Disk

use of org.ovirt.engine.api.model.Disk in project ovirt-engine by oVirt.

the class BackendDiskResourceTest method testGet.

@Test
public void testGet() {
    setUriInfo(setUpBasicUriExpectations());
    setUpEntityQueryExpectations(QueryType.GetDiskAndSnapshotsByDiskId, IdQueryParameters.class, new String[] { "Id" }, new Object[] { DISK_ID }, getEntity(1));
    Disk disk = resource.get();
    verifyModelSpecific(disk, 1);
    verifyLinks(disk);
}
Also used : Disk(org.ovirt.engine.api.model.Disk) Test(org.junit.Test)

Example 32 with Disk

use of org.ovirt.engine.api.model.Disk in project ovirt-engine by oVirt.

the class V3DiskInAdapter method adapt.

@Override
public Disk adapt(V3Disk from) {
    Disk to = new Disk();
    if (from.isSetLinks()) {
        to.getLinks().addAll(adaptIn(from.getLinks()));
    }
    if (from.isSetActions()) {
        to.setActions(adaptIn(from.getActions()));
    }
    if (from.isSetActive()) {
        to.setActive(from.isActive());
    }
    if (from.isSetActualSize()) {
        to.setActualSize(from.getActualSize());
    }
    if (from.isSetAlias()) {
        to.setAlias(from.getAlias());
    }
    if (from.isSetComment()) {
        to.setComment(from.getComment());
    }
    if (from.isSetDescription()) {
        to.setDescription(from.getDescription());
    }
    if (from.isSetDiskProfile()) {
        to.setDiskProfile(adaptIn(from.getDiskProfile()));
    }
    if (from.isSetFormat()) {
        to.setFormat(DiskFormat.fromValue(from.getFormat()));
    }
    if (from.isSetId()) {
        to.setId(from.getId());
    }
    if (from.isSetHref()) {
        to.setHref(from.getHref());
    }
    if (from.isSetImageId()) {
        to.setImageId(from.getImageId());
    }
    if (from.isSetInstanceType()) {
        to.setInstanceType(adaptIn(from.getInstanceType()));
    }
    if (from.isSetLogicalName()) {
        to.setLogicalName(from.getLogicalName());
    }
    if (from.isSetLunStorage()) {
        to.setLunStorage(adaptIn(from.getLunStorage()));
    }
    if (from.isSetName()) {
        to.setName(from.getName());
    }
    if (from.isSetOpenstackVolumeType()) {
        to.setOpenstackVolumeType(adaptIn(from.getOpenstackVolumeType()));
    }
    if (from.isSetPropagateErrors()) {
        to.setPropagateErrors(from.isPropagateErrors());
    }
    if (from.isSetProvisionedSize()) {
        to.setProvisionedSize(from.getProvisionedSize());
    }
    if (from.isSetQuota()) {
        to.setQuota(adaptIn(from.getQuota()));
    }
    if (from.isSetReadOnly()) {
        to.setReadOnly(from.isReadOnly());
    }
    if (from.isSetSgio()) {
        to.setSgio(ScsiGenericIO.fromValue(from.getSgio()));
    }
    if (from.isSetShareable()) {
        to.setShareable(from.isShareable());
    }
    if (from.isSetSnapshot()) {
        to.setSnapshot(adaptIn(from.getSnapshot()));
    }
    if (from.isSetSparse()) {
        to.setSparse(from.isSparse());
    }
    if (from.isSetStatistics()) {
        to.setStatistics(new Statistics());
        to.getStatistics().getStatistics().addAll(adaptIn(from.getStatistics().getStatistics()));
    }
    if (from.isSetStatus() && from.getStatus().isSetState()) {
        to.setStatus(DiskStatus.fromValue(from.getStatus().getState()));
    }
    if (from.isSetStorageDomain()) {
        to.setStorageDomain(adaptIn(from.getStorageDomain()));
    }
    if (from.isSetStorageDomains()) {
        to.setStorageDomains(new StorageDomains());
        to.getStorageDomains().getStorageDomains().addAll(adaptIn(from.getStorageDomains().getStorageDomains()));
    }
    if (from.isSetStorageType()) {
        to.setStorageType(DiskStorageType.fromValue(from.getStorageType()));
    }
    if (from.isSetTemplate()) {
        to.setTemplate(adaptIn(from.getTemplate()));
    }
    if (from.isSetUsesScsiReservation()) {
        to.setUsesScsiReservation(from.isUsesScsiReservation());
    }
    if (from.isSetVm()) {
        to.setVm(adaptIn(from.getVm()));
    }
    if (from.isSetVms()) {
        to.setVms(new Vms());
        to.getVms().getVms().addAll(adaptIn(from.getVms().getVMs()));
    }
    if (from.isSetWipeAfterDelete()) {
        to.setWipeAfterDelete(from.isWipeAfterDelete());
    }
    if (from.isSetBootable()) {
        to.setBootable(from.isBootable());
    }
    if (from.isSetInterface()) {
        to.setInterface(DiskInterface.fromValue(from.getInterface()));
    }
    // In V3 "size" used to be a synonym of "provisioned_size":
    if (from.isSetSize() && !to.isSetProvisionedSize()) {
        to.setProvisionedSize(from.getSize());
    }
    return to;
}
Also used : StorageDomains(org.ovirt.engine.api.model.StorageDomains) Disk(org.ovirt.engine.api.model.Disk) V3Disk(org.ovirt.engine.api.v3.types.V3Disk) Statistics(org.ovirt.engine.api.model.Statistics) Vms(org.ovirt.engine.api.model.Vms)

Example 33 with Disk

use of org.ovirt.engine.api.model.Disk 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 34 with Disk

use of org.ovirt.engine.api.model.Disk 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 35 with Disk

use of org.ovirt.engine.api.model.Disk in project ovirt-engine by oVirt.

the class DiskMapperTest method testInitialSize.

@Test
public void testInitialSize() {
    Long initalSize = 54321L;
    Disk model = new Disk();
    model.setStorageType(DiskStorageType.IMAGE);
    model.setInitialSize(initalSize);
    DiskImage entity = (DiskImage) DiskMapper.map(model, null);
    assertEquals("ActualSizeInBytes doesn't match the initial size as expected", initalSize.longValue(), entity.getActualSizeInBytes());
    model = DiskMapper.map(entity, null);
    assertNull("initial size shouldn't be mapped back to the model", model.getInitialSize());
}
Also used : Disk(org.ovirt.engine.api.model.Disk) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage) Test(org.junit.Test)

Aggregations

Disk (org.ovirt.engine.api.model.Disk)68 Test (org.junit.Test)33 Response (javax.ws.rs.core.Response)13 Guid (org.ovirt.engine.core.compat.Guid)13 WebApplicationException (javax.ws.rs.WebApplicationException)10 DiskAttachment (org.ovirt.engine.api.model.DiskAttachment)10 DiskImage (org.ovirt.engine.core.common.businessentities.storage.DiskImage)10 StorageDomain (org.ovirt.engine.api.model.StorageDomain)9 AsyncTaskStatus (org.ovirt.engine.core.common.businessentities.AsyncTaskStatus)7 Vm (org.ovirt.engine.api.model.Vm)6 StorageDomains (org.ovirt.engine.api.model.StorageDomains)4 V3Disk (org.ovirt.engine.api.v3.types.V3Disk)4 DiskAttachments (org.ovirt.engine.api.model.DiskAttachments)3 V3Disks (org.ovirt.engine.api.v3.types.V3Disks)3 UriInfo (javax.ws.rs.core.UriInfo)2 HostStorage (org.ovirt.engine.api.model.HostStorage)2 V3CdRoms (org.ovirt.engine.api.v3.types.V3CdRoms)2 V3CustomProperties (org.ovirt.engine.api.v3.types.V3CustomProperties)2 V3Floppies (org.ovirt.engine.api.v3.types.V3Floppies)2 V3KatelloErrata (org.ovirt.engine.api.v3.types.V3KatelloErrata)2