use of org.ovirt.engine.api.model.Disk in project ovirt-engine by oVirt.
the class BackendStorageDomainVmResource method setVolumesTypeFormat.
private void setVolumesTypeFormat(Action action) {
if (action.isSetVm()) {
Vm modelVm = action.getVm();
if (!modelVm.isSetDiskAttachments()) {
return;
}
Map<Guid, org.ovirt.engine.core.common.businessentities.storage.Disk> entityDisks = getDiskMap();
for (DiskAttachment modelDiskAttachment : modelVm.getDiskAttachments().getDiskAttachments()) {
Disk modelDisk = modelDiskAttachment.getDisk();
if (modelDisk != null) {
validateParameters(modelDisk, "id");
Guid modelDiskId = Guid.createGuidFromString(modelDisk.getId());
DiskImage entityDisk = (DiskImage) entityDisks.get(modelDiskId);
if (entityDisk == null) {
continue;
}
if (modelDisk.isSetFormat()) {
VolumeFormat entityDiskFormat = DiskMapper.map(modelDisk.getFormat(), null);
entityDisk.setVolumeFormat(entityDiskFormat);
}
if (modelDisk.isSetSparse()) {
entityDisk.setVolumeType(modelDisk.isSparse() ? VolumeType.Sparse : VolumeType.Preallocated);
}
}
}
}
}
use of org.ovirt.engine.api.model.Disk in project ovirt-engine by oVirt.
the class BackendStorageDomainDiskResource method get.
@Override
public Disk get() {
Disk disk;
boolean unregistered = ParametersHelper.getBooleanParameter(httpHeaders, uriInfo, UNREGISTERED_CONSTRAINT_PARAMETER, true, false);
if (unregistered) {
QueryReturnValue result = runQuery(QueryType.GetDiskByDiskId, new IdQueryParameters(guid));
if (!result.getSucceeded() || result.getReturnValue() == null) {
Guid dataCenterId = BackendDataCenterHelper.lookupByStorageDomainId(this, storageDomainId);
disk = performGet(QueryType.GetUnregisteredDisk, new GetUnregisteredDiskQueryParameters(guid, storageDomainId, dataCenterId));
} else {
// parameter was passed.
return notFound();
}
} else {
disk = getDelegate().get();
}
if (disk.isSetStorageDomains() && !disk.getStorageDomains().getStorageDomains().isEmpty()) {
for (StorageDomain sd : disk.getStorageDomains().getStorageDomains()) {
if (sd.isSetId() && sd.getId().equals(storageDomainId.toString())) {
return disk;
}
}
}
return notFound();
}
use of org.ovirt.engine.api.model.Disk in project ovirt-engine by oVirt.
the class BackendSnapshotDisksResource method list.
@Override
public Disks list() {
Disks disks = new Disks();
if (parent.getSnapshot().isVmConfigurationAvailable()) {
VM vm = parent.collection.getVmPreview(parent.get());
for (DiskImage disk : vm.getDiskList()) {
Disk d = DiskMapper.map(disk, null);
map(d, parent.id);
disks.getDisks().add(d);
}
}
return disks;
}
use of org.ovirt.engine.api.model.Disk in project ovirt-engine by oVirt.
the class BackendVmDiskResourceTest method testUpdate.
@Test
public void testUpdate() throws Exception {
setUpGetEntityExpectations(2);
setUpDiskVmElementExpectations();
setUriInfo(setUpActionExpectations(ActionType.UpdateVmDisk, VmDiskOperationParameterBase.class, new String[] { "VmId", "DiskInfo.WipeAfterDelete" }, new Object[] { VM_ID, Boolean.FALSE }, true, true));
Disk disk = resource.update(getUpdate());
assertNotNull(disk);
}
use of org.ovirt.engine.api.model.Disk in project ovirt-engine by oVirt.
the class BackendVmDiskResourceTest method testGetIncludeStatistics.
@Test
public void testGetIncludeStatistics() throws Exception {
try {
accepts.add("application/xml; detail=statistics");
setUriInfo(setUpBasicUriExpectations());
setUpEntityQueryExpectations(1);
Disk disk = resource.get();
assertTrue(disk.isSetStatistics());
verifyModelSpecific(disk, 1);
verifyLinks(disk);
} finally {
accepts.clear();
}
}
Aggregations