use of org.ovirt.engine.api.model.Snapshot in project ovirt-engine by oVirt.
the class BackendSnapshotResource method get.
@Override
public Snapshot get() {
org.ovirt.engine.core.common.businessentities.Snapshot entity = getSnapshot();
Snapshot snapshot = populate(map(entity, null), entity);
snapshot = addLinks(snapshot);
snapshot = collection.addVmConfiguration(entity, snapshot);
return snapshot;
}
use of org.ovirt.engine.api.model.Snapshot in project ovirt-engine by oVirt.
the class SnapshotMapper method map.
@Mapping(from = org.ovirt.engine.core.common.businessentities.Snapshot.class, to = Snapshot.class)
public static Snapshot map(org.ovirt.engine.core.common.businessentities.Snapshot entity, Snapshot template) {
Snapshot model = template != null ? template : new Snapshot();
model.setId(entity.getId().toString());
if (entity.getDescription() != null) {
model.setDescription(entity.getDescription());
}
if (entity.getCreationDate() != null) {
model.setDate(DateMapper.map(entity.getCreationDate(), null));
}
if (entity.getStatus() != null) {
model.setSnapshotStatus(map(entity.getStatus(), null));
}
if (entity.getType() != null) {
model.setSnapshotType(map(entity.getType(), null));
}
model.setPersistMemorystate(entity.containsMemory());
return model;
}
use of org.ovirt.engine.api.model.Snapshot in project ovirt-engine by oVirt.
the class BackendSnapshotsResourceTest method testGetWithPopulate.
@Test
public void testGetWithPopulate() throws Exception {
List<String> populates = new ArrayList<>();
populates.add("true");
String ovfData = "data";
org.ovirt.engine.core.common.businessentities.Snapshot resultSnapshot0 = new org.ovirt.engine.core.common.businessentities.Snapshot();
resultSnapshot0.setVmConfiguration(ovfData);
resultSnapshot0.setId(SNAPSHOT_IDS[0]);
org.ovirt.engine.core.common.businessentities.Snapshot resultSnapshot1 = new org.ovirt.engine.core.common.businessentities.Snapshot();
resultSnapshot1.setVmConfiguration(ovfData);
resultSnapshot1.setId(SNAPSHOT_IDS[1]);
when(httpHeaders.getRequestHeader(BackendResource.POPULATE)).thenReturn(populates);
UriInfo uriInfo = setUpUriExpectations(null);
setUriInfo(setUpBasicUriExpectations());
setUpGetEntityExpectations(1);
setUpGetSnapshotVmConfiguration(SNAPSHOT_IDS[0]);
setUpGetSnapshotVmConfiguration(SNAPSHOT_IDS[1]);
setUpEntityQueryExpectations(QueryType.GetSnapshotBySnapshotId, IdQueryParameters.class, new String[] { "Id" }, new Object[] { SNAPSHOT_IDS[1] }, resultSnapshot0);
setUpEntityQueryExpectations(QueryType.GetSnapshotBySnapshotId, IdQueryParameters.class, new String[] { "Id" }, new Object[] { SNAPSHOT_IDS[0] }, resultSnapshot1);
collection.setUriInfo(uriInfo);
List<Snapshot> snapshots = getCollection();
verifyCollection(snapshots);
for (int i = 0; i < 2; i++) {
verifyAllContent(snapshots.get(i), ConfigurationType.OVF, ovfData);
}
}
use of org.ovirt.engine.api.model.Snapshot in project ovirt-engine by oVirt.
the class DiskMapper method mapDiskImageToDiskFields.
private static void mapDiskImageToDiskFields(DiskImage entity, Disk model) {
if (entity.getImageId() != null) {
model.setImageId(entity.getImageId().toString());
}
model.setProvisionedSize(entity.getSize());
if (entity.hasActualSize()) {
model.setActualSize(entity.getActualSizeInBytes());
if (entity.isAllowSnapshot()) {
model.setTotalSize((long) entity.getActualDiskWithSnapshotsSizeInBytes());
}
}
if (entity.getSnapshotId() != null) {
model.setSnapshot(new Snapshot());
model.getSnapshot().setId(entity.getSnapshotId().toString());
}
if (entity.getVolumeFormat() != null) {
model.setFormat(map(entity.getVolumeFormat(), null));
}
if (entity.getQcowCompat() != null) {
model.setQcowVersion(mapQcowCompat(entity.getQcowCompat()));
}
if (entity.getImageStatus() != null) {
model.setStatus(mapDiskStatus(entity.getImageStatus()));
}
model.setSparse(VolumeType.Sparse == entity.getVolumeType());
if (entity.getStorageIds() != null && entity.getStorageIds().size() > 0) {
if (!model.isSetStorageDomains()) {
model.setStorageDomains(new StorageDomains());
}
for (Guid id : entity.getStorageIds()) {
StorageDomain storageDomain = new StorageDomain();
storageDomain.setId(id.toString());
model.getStorageDomains().getStorageDomains().add(storageDomain);
}
}
if (entity.getQuotaId() != null) {
Quota quota = new Quota();
quota.setId(entity.getQuotaId().toString());
// Add DataCenter to the quota, so links are properly created
if (entity.getStoragePoolId() != null) {
quota.setDataCenter(new DataCenter());
quota.getDataCenter().setId(entity.getStoragePoolId().toString());
}
model.setQuota(quota);
}
if (entity.getDiskProfileId() != null) {
DiskProfile diskProfile = new DiskProfile();
diskProfile.setId(entity.getDiskProfileId().toString());
model.setDiskProfile(diskProfile);
}
if (entity.getCinderVolumeType() != null) {
OpenStackVolumeType volumeType = model.getOpenstackVolumeType();
if (volumeType == null) {
volumeType = new OpenStackVolumeType();
model.setOpenstackVolumeType(volumeType);
}
volumeType.setName(entity.getCinderVolumeType());
}
}
Aggregations