Search in sources :

Example 1 with V3Disk

use of org.ovirt.engine.api.v3.types.V3Disk in project ovirt-engine by oVirt.

the class V3VmDiskServer method get.

@GET
public V3Disk get() {
    V3Disk disk = adaptGet(getDelegate()::get);
    V3VmHelper.fixDiskLinks(vmId, disk);
    V3VmHelper.addDiskAttachmentDetails(vmId, disk);
    return disk;
}
Also used : V3Disk(org.ovirt.engine.api.v3.types.V3Disk) GET(javax.ws.rs.GET)

Example 2 with V3Disk

use of org.ovirt.engine.api.v3.types.V3Disk in project ovirt-engine by oVirt.

the class V3VmDisksServer method add.

@POST
@Consumes({ "application/xml", "application/json" })
public Response add(V3Disk disk) {
    Response response = adaptAdd(getDelegate()::add, disk);
    Object entity = response.getEntity();
    if (entity instanceof V3Disk) {
        disk = (V3Disk) entity;
        V3VmHelper.fixDiskLinks(vmId, disk);
        V3VmHelper.addDiskAttachmentDetails(vmId, disk);
    }
    return response;
}
Also used : Response(javax.ws.rs.core.Response) V3Disk(org.ovirt.engine.api.v3.types.V3Disk) POST(javax.ws.rs.POST) Consumes(javax.ws.rs.Consumes)

Example 3 with V3Disk

use of org.ovirt.engine.api.v3.types.V3Disk 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;
}
Also used : VmResource(org.ovirt.engine.api.resource.VmResource) DiskResource(org.ovirt.engine.api.resource.DiskResource) DiskAttachmentsResource(org.ovirt.engine.api.resource.DiskAttachmentsResource) DiskAttachment(org.ovirt.engine.api.model.DiskAttachment) V3Disk(org.ovirt.engine.api.v3.types.V3Disk) VmsResource(org.ovirt.engine.api.resource.VmsResource) V3Disks(org.ovirt.engine.api.v3.types.V3Disks) VmDisksResource(org.ovirt.engine.api.resource.VmDisksResource) DisksResource(org.ovirt.engine.api.resource.DisksResource) SystemResource(org.ovirt.engine.api.resource.SystemResource) DiskAttachments(org.ovirt.engine.api.model.DiskAttachments) Disk(org.ovirt.engine.api.model.Disk) V3Disk(org.ovirt.engine.api.v3.types.V3Disk) GET(javax.ws.rs.GET)

Example 4 with V3Disk

use of org.ovirt.engine.api.v3.types.V3Disk in project ovirt-engine by oVirt.

the class V3VMInAdapter method adapt.

@Override
public Vm adapt(V3VM from) {
    Vm to = new Vm();
    if (from.isSetLinks()) {
        to.getLinks().addAll(adaptIn(from.getLinks()));
    }
    if (from.isSetActions()) {
        to.setActions(adaptIn(from.getActions()));
    }
    if (from.isSetBios()) {
        to.setBios(adaptIn(from.getBios()));
    }
    if (from.isSetCdroms()) {
        to.setCdroms(adaptIn(from.getCdroms()));
    }
    if (from.isSetCluster()) {
        to.setCluster(adaptIn(from.getCluster()));
    }
    if (from.isSetComment()) {
        to.setComment(from.getComment());
    }
    if (from.isSetConsole()) {
        to.setConsole(adaptIn(from.getConsole()));
    }
    if (from.isSetCpu()) {
        to.setCpu(adaptIn(from.getCpu()));
    }
    if (from.isSetCpuProfile()) {
        to.setCpuProfile(adaptIn(from.getCpuProfile()));
    }
    if (from.isSetCpuShares()) {
        to.setCpuShares(from.getCpuShares());
    }
    if (from.isSetCreationTime()) {
        to.setCreationTime(from.getCreationTime());
    }
    if (from.isSetCustomCpuModel()) {
        to.setCustomCpuModel(from.getCustomCpuModel());
    }
    if (from.isSetCustomEmulatedMachine()) {
        to.setCustomEmulatedMachine(from.getCustomEmulatedMachine());
    }
    if (from.isSetCustomProperties()) {
        to.setCustomProperties(adaptIn(from.getCustomProperties()));
    }
    if (from.isSetDeleteProtected()) {
        to.setDeleteProtected(from.isDeleteProtected());
    }
    if (from.isSetDescription()) {
        to.setDescription(from.getDescription());
    }
    if (from.isSetDisks()) {
        DiskAttachments toAttachments = new DiskAttachments();
        for (V3Disk fromDisk : from.getDisks().getDisks()) {
            DiskAttachment toAttachment = new DiskAttachment();
            toAttachment.setDisk(adaptIn(fromDisk));
            toAttachments.getDiskAttachments().add(toAttachment);
        }
        to.setDiskAttachments(toAttachments);
    }
    if (from.isSetDisplay()) {
        to.setDisplay(adaptIn(from.getDisplay()));
    }
    if (from.isSetDomain()) {
        to.setDomain(adaptIn(from.getDomain()));
    }
    if (from.isSetExternalHostProvider()) {
        to.setExternalHostProvider(adaptIn(from.getExternalHostProvider()));
    }
    if (from.isSetFloppies()) {
        to.setFloppies(adaptIn(from.getFloppies()));
    }
    if (from.isSetGuestOperatingSystem()) {
        to.setGuestOperatingSystem(adaptIn(from.getGuestOperatingSystem()));
    }
    if (from.isSetGuestTimeZone()) {
        to.setGuestTimeZone(adaptIn(from.getGuestTimeZone()));
    }
    if (from.isSetHighAvailability()) {
        to.setHighAvailability(adaptIn(from.getHighAvailability()));
    }
    if (from.isSetHost()) {
        to.setHost(adaptIn(from.getHost()));
    }
    if (from.isSetId()) {
        to.setId(from.getId());
    }
    if (from.isSetHref()) {
        to.setHref(from.getHref());
    }
    if (from.isSetInitialization()) {
        to.setInitialization(adaptIn(from.getInitialization()));
    }
    if (from.isSetInstanceType()) {
        to.setInstanceType(adaptIn(from.getInstanceType()));
    }
    if (from.isSetIo()) {
        to.setIo(adaptIn(from.getIo()));
    }
    if (from.isSetKatelloErrata()) {
        to.setKatelloErrata(adaptIn(from.getKatelloErrata()));
    }
    if (from.isSetLargeIcon()) {
        to.setLargeIcon(adaptIn(from.getLargeIcon()));
    }
    if (from.isSetMemory()) {
        to.setMemory(from.getMemory());
    }
    if (from.isSetMemoryPolicy()) {
        to.setMemoryPolicy(adaptIn(from.getMemoryPolicy()));
    }
    if (from.isSetMigration()) {
        to.setMigration(adaptIn(from.getMigration()));
    }
    if (from.isSetMigrationDowntime()) {
        to.setMigrationDowntime(from.getMigrationDowntime());
    }
    if (from.isSetName()) {
        to.setName(from.getName());
    }
    if (from.isSetNextRunConfigurationExists()) {
        to.setNextRunConfigurationExists(from.isNextRunConfigurationExists());
    }
    if (from.isSetNics()) {
        to.setNics(adaptIn(from.getNics()));
    }
    if (from.isSetNumaTuneMode()) {
        to.setNumaTuneMode(NumaTuneMode.fromValue(from.getNumaTuneMode()));
    }
    if (from.isSetOrigin()) {
        to.setOrigin(from.getOrigin());
    }
    if (from.isSetOs()) {
        to.setOs(adaptIn(from.getOs()));
    }
    if (from.isSetPayloads()) {
        to.setPayloads(adaptIn(from.getPayloads()));
    }
    if (from.isSetPermissions()) {
        to.setPermissions(adaptIn(from.getPermissions()));
    }
    if (from.isSetPlacementPolicy()) {
        to.setPlacementPolicy(adaptIn(from.getPlacementPolicy()));
    }
    if (from.isSetQuota()) {
        to.setQuota(adaptIn(from.getQuota()));
    }
    if (from.isSetReportedDevices()) {
        to.setReportedDevices(adaptIn(from.getReportedDevices()));
    }
    if (from.isSetRngDevice()) {
        to.setRngDevice(adaptIn(from.getRngDevice()));
    }
    if (from.isSetRunOnce()) {
        to.setRunOnce(from.isRunOnce());
    }
    if (from.isSetSerialNumber()) {
        to.setSerialNumber(adaptIn(from.getSerialNumber()));
    }
    if (from.isSetSmallIcon()) {
        to.setSmallIcon(adaptIn(from.getSmallIcon()));
    }
    if (from.isSetSnapshots()) {
        to.setSnapshots(adaptIn(from.getSnapshots()));
    }
    if (from.isSetSoundcardEnabled()) {
        to.setSoundcardEnabled(from.isSoundcardEnabled());
    }
    if (from.isSetSso()) {
        to.setSso(adaptIn(from.getSso()));
    }
    if (from.isSetStartPaused()) {
        to.setStartPaused(from.isStartPaused());
    }
    if (from.isSetStartTime()) {
        to.setStartTime(from.getStartTime());
    }
    if (from.isSetStateless()) {
        to.setStateless(from.isStateless());
    }
    if (from.isSetStatistics()) {
        to.setStatistics(adaptIn(from.getStatistics()));
    }
    V3Status status = from.getStatus();
    if (status != null) {
        if (status.isSetState()) {
            to.setStatus(VmStatus.fromValue(status.getState()));
        }
        if (status.isSetDetail()) {
            to.setStatusDetail(status.getDetail());
        }
    }
    if (from.isSetStopReason()) {
        to.setStopReason(from.getStopReason());
    }
    if (from.isSetStopTime()) {
        to.setStopTime(from.getStopTime());
    }
    if (from.isSetStorageDomain()) {
        to.setStorageDomain(adaptIn(from.getStorageDomain()));
    }
    if (from.isSetTags()) {
        to.setTags(adaptIn(from.getTags()));
    }
    if (from.isSetTemplate()) {
        to.setTemplate(adaptIn(from.getTemplate()));
    }
    if (from.isSetTimeZone()) {
        to.setTimeZone(adaptIn(from.getTimeZone()));
    }
    if (from.isSetTunnelMigration()) {
        to.setTunnelMigration(from.isTunnelMigration());
    }
    if (from.isSetType()) {
        to.setType(VmType.fromValue(from.getType()));
    }
    if (from.isSetUsb()) {
        to.setUsb(adaptIn(from.getUsb()));
    }
    if (from.isSetUseLatestTemplateVersion()) {
        to.setUseLatestTemplateVersion(from.isUseLatestTemplateVersion());
    }
    if (from.isSetVirtioScsi()) {
        to.setVirtioScsi(adaptIn(from.getVirtioScsi()));
    }
    if (from.isSetVmPool()) {
        to.setVmPool(adaptIn(from.getVmPool()));
    }
    if (from.isSetWatchdogs()) {
        to.setWatchdogs(adaptIn(from.getWatchdogs()));
    }
    // new structured "time_zone" element containing the name of the time zone and the UTC offset:
    if (from.isSetTimezone() && !to.isSetTimeZone()) {
        TimeZone timeZone = new TimeZone();
        timeZone.setName(from.getTimezone());
        to.setTimeZone(timeZone);
    }
    return to;
}
Also used : TimeZone(org.ovirt.engine.api.model.TimeZone) DiskAttachment(org.ovirt.engine.api.model.DiskAttachment) V3Disk(org.ovirt.engine.api.v3.types.V3Disk) Vm(org.ovirt.engine.api.model.Vm) DiskAttachments(org.ovirt.engine.api.model.DiskAttachments) V3Status(org.ovirt.engine.api.v3.types.V3Status)

Example 5 with V3Disk

use of org.ovirt.engine.api.v3.types.V3Disk 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;
}
Also used : StorageDomains(org.ovirt.engine.api.model.StorageDomains) Disk(org.ovirt.engine.api.model.Disk) V3Disk(org.ovirt.engine.api.v3.types.V3Disk) Statistics(org.ovirt.engine.api.model.Statistics) Vms(org.ovirt.engine.api.model.Vms)

Aggregations

V3Disk (org.ovirt.engine.api.v3.types.V3Disk)10 DiskAttachment (org.ovirt.engine.api.model.DiskAttachment)5 Disk (org.ovirt.engine.api.model.Disk)4 V3Status (org.ovirt.engine.api.v3.types.V3Status)4 GET (javax.ws.rs.GET)3 DiskAttachments (org.ovirt.engine.api.model.DiskAttachments)3 V3Disks (org.ovirt.engine.api.v3.types.V3Disks)3 V3Link (org.ovirt.engine.api.v3.types.V3Link)3 V3Statistics (org.ovirt.engine.api.v3.types.V3Statistics)3 Statistics (org.ovirt.engine.api.model.Statistics)2 TimeZone (org.ovirt.engine.api.model.TimeZone)2 Vm (org.ovirt.engine.api.model.Vm)2 V3Actions (org.ovirt.engine.api.v3.types.V3Actions)2 V3CdRoms (org.ovirt.engine.api.v3.types.V3CdRoms)2 V3CustomProperties (org.ovirt.engine.api.v3.types.V3CustomProperties)2 V3Floppies (org.ovirt.engine.api.v3.types.V3Floppies)2 V3KatelloErrata (org.ovirt.engine.api.v3.types.V3KatelloErrata)2 V3Nics (org.ovirt.engine.api.v3.types.V3Nics)2 V3Payloads (org.ovirt.engine.api.v3.types.V3Payloads)2 V3Permissions (org.ovirt.engine.api.v3.types.V3Permissions)2