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);
}
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;
}
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;
}
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);
}
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());
}
Aggregations