use of org.ovirt.engine.api.model.DiskProfile in project ovirt-engine by oVirt.
the class DiskProfileMapper method map.
@Mapping(from = org.ovirt.engine.core.common.businessentities.profiles.DiskProfile.class, to = DiskProfile.class)
public static DiskProfile map(org.ovirt.engine.core.common.businessentities.profiles.DiskProfile entity, DiskProfile template) {
DiskProfile model = template != null ? template : new DiskProfile();
if (entity.getId() != null) {
model.setId(entity.getId().toString());
}
if (entity.getName() != null) {
model.setName(entity.getName());
}
if (entity.getDescription() != null) {
model.setDescription(entity.getDescription());
}
if (entity.getStorageDomainId() != null) {
model.setStorageDomain(new StorageDomain());
model.getStorageDomain().setId(entity.getStorageDomainId().toString());
}
if (entity.getQosId() != null) {
model.setQos(new Qos());
model.getQos().setId(entity.getQosId().toString());
}
return model;
}
use of org.ovirt.engine.api.model.DiskProfile in project ovirt-engine by oVirt.
the class AbstractBackendDiskProfilesResource method mapCollection.
protected DiskProfiles mapCollection(List<org.ovirt.engine.core.common.businessentities.profiles.DiskProfile> entities) {
DiskProfiles collection = new DiskProfiles();
Map<Guid, Qos> qosMap = new HashMap<>();
for (org.ovirt.engine.core.common.businessentities.profiles.DiskProfile entity : entities) {
DiskProfile profile = populate(map(entity), entity);
collection.getDiskProfiles().add(profile);
if (entity.getQosId() != null) {
qosMap.put(entity.getQosId(), profile.getQos());
}
}
handleQosDataCenterLinks(qosMap);
for (DiskProfile diskProfile : collection.getDiskProfiles()) {
addLinks(diskProfile);
}
return collection;
}
use of org.ovirt.engine.api.model.DiskProfile in project ovirt-engine by oVirt.
the class BackendDiskProfileResourceTest method getModel.
static DiskProfile getModel(int index) {
DiskProfile model = new DiskProfile();
model.setId(GUIDS[index].toString());
model.setName(NAMES[index]);
model.setDescription(DESCRIPTIONS[index]);
return model;
}
use of org.ovirt.engine.api.model.DiskProfile in project ovirt-engine by oVirt.
the class BackendDiskProfileResourceTest method testConflictedUpdate.
@Test
public void testConflictedUpdate() throws Exception {
setUriInfo(setUpBasicUriExpectations());
setUpEntityQueryExpectations(1, 0, false);
DiskProfile model = getModel(1);
model.setId(GUIDS[1].toString());
try {
resource.update(model);
fail("expected WebApplicationException");
} catch (WebApplicationException wae) {
verifyImmutabilityConstraint(wae);
}
}
use of org.ovirt.engine.api.model.DiskProfile 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