Search in sources :

Example 1 with DiskSnapshot

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

the class BackendStorageDomainDiskSnapshotResourceTest method testGet.

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

Example 2 with DiskSnapshot

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

the class BackendStorageDomainDiskSnapshotResource method get.

@Override
public DiskSnapshot get() {
    DiskSnapshot diskSnapshot = performGet(QueryType.GetDiskSnapshotByImageId, new IdQueryParameters(guid));
    // this code generates back-link to the corresponding SD
    diskSnapshot.setStorageDomain(new StorageDomain());
    diskSnapshot.getStorageDomain().setId(this.storageDomainId);
    return diskSnapshot;
}
Also used : StorageDomain(org.ovirt.engine.api.model.StorageDomain) IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) DiskSnapshot(org.ovirt.engine.api.model.DiskSnapshot)

Example 3 with DiskSnapshot

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

the class BackendStorageDomainDiskSnapshotsResource method mapCollection.

protected DiskSnapshots mapCollection(List<Disk> entities) {
    DiskSnapshots collection = new DiskSnapshots();
    for (Disk disk : entities) {
        DiskSnapshot diskSnapshot = getMapper(Disk.class, DiskSnapshot.class).map(disk, null);
        // this code generates back-link to the corresponding SD
        diskSnapshot.setStorageDomain(new StorageDomain());
        diskSnapshot.getStorageDomain().setId(this.storageDomainId.toString());
        collection.getDiskSnapshots().add(addLinks(populate(diskSnapshot, disk)));
    }
    return collection;
}
Also used : StorageDomain(org.ovirt.engine.api.model.StorageDomain) DiskSnapshots(org.ovirt.engine.api.model.DiskSnapshots) DiskSnapshot(org.ovirt.engine.api.model.DiskSnapshot) Disk(org.ovirt.engine.core.common.businessentities.storage.Disk)

Example 4 with DiskSnapshot

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

the class DiskSnapshotMapperTest method testRoundtrip.

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

Example 5 with DiskSnapshot

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

the class V3DiskSnapshotInAdapter method adapt.

@Override
public DiskSnapshot adapt(V3DiskSnapshot from) {
    DiskSnapshot to = new DiskSnapshot();
    if (from.isSetLinks()) {
        to.getLinks().addAll(adaptIn(from.getLinks()));
    }
    if (from.isSetActions()) {
        to.setActions(adaptIn(from.getActions()));
    }
    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.isSetDisk()) {
        to.setDisk(adaptIn(from.getDisk()));
    }
    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());
    }
    return to;
}
Also used : V3DiskSnapshot(org.ovirt.engine.api.v3.types.V3DiskSnapshot) DiskSnapshot(org.ovirt.engine.api.model.DiskSnapshot) StorageDomains(org.ovirt.engine.api.model.StorageDomains) Statistics(org.ovirt.engine.api.model.Statistics) Vms(org.ovirt.engine.api.model.Vms)

Aggregations

DiskSnapshot (org.ovirt.engine.api.model.DiskSnapshot)6 Test (org.junit.Test)2 StorageDomain (org.ovirt.engine.api.model.StorageDomain)2 Disk (org.ovirt.engine.core.common.businessentities.storage.Disk)2 DiskImage (org.ovirt.engine.core.common.businessentities.storage.DiskImage)2 Disk (org.ovirt.engine.api.model.Disk)1 DiskSnapshots (org.ovirt.engine.api.model.DiskSnapshots)1 Statistics (org.ovirt.engine.api.model.Statistics)1 StorageDomains (org.ovirt.engine.api.model.StorageDomains)1 Vms (org.ovirt.engine.api.model.Vms)1 V3DiskSnapshot (org.ovirt.engine.api.v3.types.V3DiskSnapshot)1 IdQueryParameters (org.ovirt.engine.core.common.queries.IdQueryParameters)1