use of org.ovirt.engine.api.resource.DiskResource in project ovirt-engine by oVirt.
the class V3VmDiskServer method remove.
@DELETE
@Consumes({ "application/xml", "application/json" })
public Response remove(V3Action action) {
// Detach the disk from the VM:
Response response = adaptRemove(getDelegate()::remove);
// need to delete the disk using the top level disks collection.
if (!action.isSetDetach() || !action.isDetach()) {
DisksResource disksResource = BackendApiResource.getInstance().getDisksResource();
DiskResource diskResource = disksResource.getDiskResource(diskId);
response = adaptRemove(diskResource::remove);
}
// Return the response:
return response;
}
use of org.ovirt.engine.api.resource.DiskResource in project ovirt-engine by oVirt.
the class V3VmDisksServer method list.
@GET
public V3Disks list() {
SystemResource systemResource = BackendApiResource.getInstance();
// In version 4 of the API the collection of disks of a virtual machine has been replaced by the collection of
// disk attachments, so we need to fetch the disk attachments:
VmsResource vmsResource = systemResource.getVmsResource();
VmResource vmResource = vmsResource.getVmResource(vmId);
DiskAttachmentsResource attachmentsResource = vmResource.getDiskAttachmentsResource();
DiskAttachments attachments = attachmentsResource.list();
// For each disk, we need now to fetch it from the top level disks collection, and add the information from
// the corresponding attachment:
DisksResource disksResource = systemResource.getDisksResource();
V3Disks disks = new V3Disks();
for (DiskAttachment attachment : attachments.getDiskAttachments()) {
DiskResource diskResource = disksResource.getDiskResource(attachment.getDisk().getId());
Disk v4Disk = diskResource.get();
V3Disk v3Disk = adaptOut(v4Disk);
V3VmHelper.addDiskAttachmentDetails(attachment, v3Disk);
V3VmHelper.fixDiskLinks(vmId, v3Disk);
disks.getDisks().add(v3Disk);
}
return disks;
}
Aggregations