Search in sources :

Example 36 with Disk

use of org.ovirt.engine.api.model.Disk in project ovirt-engine by oVirt.

the class BackendTemplateDiskResource method copy.

@Override
public Response copy(Action action) {
    validateParameters(action, "storageDomain.id|name");
    Guid storageDomainId = getStorageDomainId(action);
    Disk disk = getDisk();
    Guid imageId = asGuid(disk.getImageId());
    MoveOrCopyImageGroupParameters params = new MoveOrCopyImageGroupParameters(imageId, Guid.Empty, storageDomainId, ImageOperation.Copy);
    params.setImageGroupID(asGuid(disk.getId()));
    return doAction(ActionType.MoveOrCopyDisk, params, action);
}
Also used : MoveOrCopyImageGroupParameters(org.ovirt.engine.core.common.action.MoveOrCopyImageGroupParameters) Guid(org.ovirt.engine.core.compat.Guid) Disk(org.ovirt.engine.api.model.Disk)

Example 37 with Disk

use of org.ovirt.engine.api.model.Disk in project ovirt-engine by oVirt.

the class V3SnapshotOutAdapter method adapt.

@Override
public V3Snapshot adapt(Snapshot from) {
    V3Snapshot to = new V3Snapshot();
    if (from.isSetLinks()) {
        to.getLinks().addAll(adaptOut(from.getLinks()));
    }
    if (from.isSetActions()) {
        to.setActions(adaptOut(from.getActions()));
    }
    if (from.isSetBios()) {
        to.setBios(adaptOut(from.getBios()));
    }
    if (from.isSetCdroms()) {
        to.setCdroms(new V3CdRoms());
        to.getCdroms().getCdRoms().addAll(adaptOut(from.getCdroms().getCdroms()));
    }
    if (from.isSetCluster()) {
        to.setCluster(adaptOut(from.getCluster()));
    }
    if (from.isSetComment()) {
        to.setComment(from.getComment());
    }
    if (from.isSetConsole()) {
        to.setConsole(adaptOut(from.getConsole()));
    }
    if (from.isSetCpu()) {
        to.setCpu(adaptOut(from.getCpu()));
    }
    if (from.isSetCpuProfile()) {
        to.setCpuProfile(adaptOut(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(new V3CustomProperties());
        to.getCustomProperties().getCustomProperty().addAll(adaptOut(from.getCustomProperties().getCustomProperties()));
    }
    if (from.isSetDate()) {
        to.setDate(from.getDate());
    }
    if (from.isSetDeleteProtected()) {
        to.setDeleteProtected(from.isDeleteProtected());
    }
    if (from.isSetDescription()) {
        to.setDescription(from.getDescription());
    }
    if (from.isSetDiskAttachments()) {
        V3Disks toDisks = new V3Disks();
        for (DiskAttachment fromDiskAttachment : from.getDiskAttachments().getDiskAttachments()) {
            Disk fromDisk = fromDiskAttachment.getDisk();
            if (fromDisk != null) {
                V3Disk toDisk = adaptOut(fromDisk);
                toDisks.getDisks().add(toDisk);
            }
        }
        to.setDisks(toDisks);
    }
    if (from.isSetDisplay()) {
        to.setDisplay(adaptOut(from.getDisplay()));
    }
    if (from.isSetDomain()) {
        to.setDomain(adaptOut(from.getDomain()));
    }
    if (from.isSetExternalHostProvider()) {
        to.setExternalHostProvider(adaptOut(from.getExternalHostProvider()));
    }
    if (from.isSetFloppies()) {
        to.setFloppies(new V3Floppies());
        to.getFloppies().getFloppies().addAll(adaptOut(from.getFloppies().getFloppies()));
    }
    if (from.isSetGuestOperatingSystem()) {
        to.setGuestOperatingSystem(adaptOut(from.getGuestOperatingSystem()));
    }
    if (from.isSetGuestTimeZone()) {
        to.setGuestTimeZone(adaptOut(from.getGuestTimeZone()));
    }
    if (from.isSetHighAvailability()) {
        to.setHighAvailability(adaptOut(from.getHighAvailability()));
    }
    if (from.isSetHost()) {
        to.setHost(adaptOut(from.getHost()));
    }
    if (from.isSetId()) {
        to.setId(from.getId());
    }
    if (from.isSetHref()) {
        to.setHref(from.getHref());
    }
    if (from.isSetInitialization()) {
        to.setInitialization(adaptOut(from.getInitialization()));
    }
    if (from.isSetInstanceType()) {
        to.setInstanceType(adaptOut(from.getInstanceType()));
    }
    if (from.isSetIo()) {
        to.setIo(adaptOut(from.getIo()));
    }
    if (from.isSetKatelloErrata()) {
        to.setKatelloErrata(new V3KatelloErrata());
        to.getKatelloErrata().getKatelloErrata().addAll(adaptOut(from.getKatelloErrata().getKatelloErrata()));
    }
    if (from.isSetLargeIcon()) {
        to.setLargeIcon(adaptOut(from.getLargeIcon()));
    }
    if (from.isSetMemory()) {
        to.setMemory(from.getMemory());
    }
    if (from.isSetMemoryPolicy()) {
        to.setMemoryPolicy(adaptOut(from.getMemoryPolicy()));
    }
    if (from.isSetMigration()) {
        to.setMigration(adaptOut(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(new V3Nics());
        to.getNics().getNics().addAll(adaptOut(from.getNics().getNics()));
    }
    if (from.isSetNumaTuneMode()) {
        to.setNumaTuneMode(from.getNumaTuneMode().value());
    }
    if (from.isSetOrigin()) {
        to.setOrigin(from.getOrigin());
    }
    if (from.isSetOs()) {
        to.setOs(adaptOut(from.getOs()));
    }
    if (from.isSetPayloads()) {
        to.setPayloads(new V3Payloads());
        to.getPayloads().getPayload().addAll(adaptOut(from.getPayloads().getPayloads()));
    }
    if (from.isSetPermissions()) {
        to.setPermissions(new V3Permissions());
        to.getPermissions().getPermissions().addAll(adaptOut(from.getPermissions().getPermissions()));
    }
    if (from.isSetPersistMemorystate()) {
        to.setPersistMemorystate(from.isPersistMemorystate());
    }
    if (from.isSetPlacementPolicy()) {
        to.setPlacementPolicy(adaptOut(from.getPlacementPolicy()));
    }
    if (from.isSetQuota()) {
        to.setQuota(adaptOut(from.getQuota()));
    }
    if (from.isSetReportedDevices()) {
        to.setReportedDevices(new V3ReportedDevices());
        to.getReportedDevices().getReportedDevices().addAll(adaptOut(from.getReportedDevices().getReportedDevices()));
    }
    if (from.isSetRngDevice()) {
        to.setRngDevice(adaptOut(from.getRngDevice()));
    }
    if (from.isSetRunOnce()) {
        to.setRunOnce(from.isRunOnce());
    }
    if (from.isSetSerialNumber()) {
        to.setSerialNumber(adaptOut(from.getSerialNumber()));
    }
    if (from.isSetSmallIcon()) {
        to.setSmallIcon(adaptOut(from.getSmallIcon()));
    }
    if (from.isSetSnapshotStatus()) {
        to.setSnapshotStatus(from.getSnapshotStatus().value());
    }
    if (from.isSetSnapshots()) {
        to.setSnapshots(new V3Snapshots());
        to.getSnapshots().getSnapshots().addAll(adaptOut(from.getSnapshots().getSnapshots()));
    }
    if (from.isSetSoundcardEnabled()) {
        to.setSoundcardEnabled(from.isSoundcardEnabled());
    }
    if (from.isSetSso()) {
        to.setSso(adaptOut(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(new V3Statistics());
        to.getStatistics().getStatistics().addAll(adaptOut(from.getStatistics().getStatistics()));
    }
    if (from.isSetStatus()) {
        V3Status status = new V3Status();
        status.setState(from.getStatus().value());
        to.setStatus(status);
    }
    if (from.isSetStopReason()) {
        to.setStopReason(from.getStopReason());
    }
    if (from.isSetStopTime()) {
        to.setStopTime(from.getStopTime());
    }
    if (from.isSetStorageDomain()) {
        to.setStorageDomain(adaptOut(from.getStorageDomain()));
    }
    if (from.isSetTags()) {
        to.setTags(new V3Tags());
        to.getTags().getTags().addAll(adaptOut(from.getTags().getTags()));
    }
    if (from.isSetTemplate()) {
        to.setTemplate(adaptOut(from.getTemplate()));
    }
    if (from.isSetTimeZone()) {
        to.setTimeZone(adaptOut(from.getTimeZone()));
    }
    if (from.isSetTunnelMigration()) {
        to.setTunnelMigration(from.isTunnelMigration());
    }
    if (from.isSetSnapshotType()) {
        to.setType(from.getSnapshotType().value());
    }
    if (from.isSetUsb()) {
        to.setUsb(adaptOut(from.getUsb()));
    }
    if (from.isSetUseLatestTemplateVersion()) {
        to.setUseLatestTemplateVersion(from.isUseLatestTemplateVersion());
    }
    if (from.isSetVirtioScsi()) {
        to.setVirtioScsi(adaptOut(from.getVirtioScsi()));
    }
    if (from.isSetVm()) {
        to.setVm(adaptOut(from.getVm()));
    }
    if (from.isSetVmPool()) {
        to.setVmPool(adaptOut(from.getVmPool()));
    }
    if (from.isSetWatchdogs()) {
        to.setWatchdogs(new V3WatchDogs());
        to.getWatchdogs().getWatchDogs().addAll(adaptOut(from.getWatchdogs().getWatchdogs()));
    }
    return to;
}
Also used : V3Floppies(org.ovirt.engine.api.v3.types.V3Floppies) V3Tags(org.ovirt.engine.api.v3.types.V3Tags) V3Snapshot(org.ovirt.engine.api.v3.types.V3Snapshot) V3Permissions(org.ovirt.engine.api.v3.types.V3Permissions) V3KatelloErrata(org.ovirt.engine.api.v3.types.V3KatelloErrata) V3Payloads(org.ovirt.engine.api.v3.types.V3Payloads) V3ReportedDevices(org.ovirt.engine.api.v3.types.V3ReportedDevices) V3Statistics(org.ovirt.engine.api.v3.types.V3Statistics) V3WatchDogs(org.ovirt.engine.api.v3.types.V3WatchDogs) DiskAttachment(org.ovirt.engine.api.model.DiskAttachment) V3CustomProperties(org.ovirt.engine.api.v3.types.V3CustomProperties) V3Disk(org.ovirt.engine.api.v3.types.V3Disk) V3Snapshots(org.ovirt.engine.api.v3.types.V3Snapshots) V3Disks(org.ovirt.engine.api.v3.types.V3Disks) V3Status(org.ovirt.engine.api.v3.types.V3Status) V3Nics(org.ovirt.engine.api.v3.types.V3Nics) Disk(org.ovirt.engine.api.model.Disk) V3Disk(org.ovirt.engine.api.v3.types.V3Disk) V3CdRoms(org.ovirt.engine.api.v3.types.V3CdRoms)

Example 38 with Disk

use of org.ovirt.engine.api.model.Disk in project ovirt-engine by oVirt.

the class DiskMapperTest method testRoundtrip.

@Test
@Override
public void testRoundtrip() throws Exception {
    setUpConfigExpectations();
    Disk model = Disk.class.cast(populate(Disk.class));
    model = postPopulate(model);
    Mapper<Disk, org.ovirt.engine.core.common.businessentities.storage.Disk> out = getMappingLocator().getMapper(Disk.class, org.ovirt.engine.core.common.businessentities.storage.Disk.class);
    Mapper<org.ovirt.engine.core.common.businessentities.storage.Disk, Disk> back = getMappingLocator().getMapper(org.ovirt.engine.core.common.businessentities.storage.Disk.class, Disk.class);
    DiskImage to = (DiskImage) out.map(model, null);
    DiskImage inverse = getInverse(to);
    Disk transform = back.map(inverse, null);
    verify(model, transform);
}
Also used : Disk(org.ovirt.engine.api.model.Disk) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage) Test(org.junit.Test)

Example 39 with Disk

use of org.ovirt.engine.api.model.Disk in project ovirt-engine by oVirt.

the class LinkFollowerTest method createDiskAttachments.

private DiskAttachments createDiskAttachments() {
    DiskAttachments disks = new DiskAttachments();
    DiskAttachment diskAttachment1 = new DiskAttachment();
    DiskAttachment diskAttachment2 = new DiskAttachment();
    DiskAttachment diskAttachment3 = new DiskAttachment();
    Disk disk1 = new Disk();
    disk1.setId("aaa");
    disk1.setHref("/ovirt-engine/api/disks/aaa");
    Disk disk2 = new Disk();
    disk2.setId("bbb");
    disk2.setHref("/ovirt-engine/api/disks/bbb");
    Disk disk3 = new Disk();
    disk3.setId("ccc");
    disk3.setHref("/ovirt-engine/api/disks/ccc");
    diskAttachment1.setDisk(disk1);
    diskAttachment2.setDisk(disk2);
    diskAttachment3.setDisk(disk3);
    disks.getDiskAttachments().add(diskAttachment1);
    disks.getDiskAttachments().add(diskAttachment2);
    disks.getDiskAttachments().add(diskAttachment3);
    return disks;
}
Also used : DiskAttachment(org.ovirt.engine.api.model.DiskAttachment) DiskAttachments(org.ovirt.engine.api.model.DiskAttachments) Disk(org.ovirt.engine.api.model.Disk)

Example 40 with Disk

use of org.ovirt.engine.api.model.Disk in project ovirt-engine by oVirt.

the class DiskStatisticalQueryTest method getParent.

private Disk getParent() {
    Disk disk = new Disk();
    disk.setId(Guid.Empty.toString());
    return disk;
}
Also used : Disk(org.ovirt.engine.api.model.Disk)

Aggregations

Disk (org.ovirt.engine.api.model.Disk)68 Test (org.junit.Test)33 Response (javax.ws.rs.core.Response)13 Guid (org.ovirt.engine.core.compat.Guid)13 WebApplicationException (javax.ws.rs.WebApplicationException)10 DiskAttachment (org.ovirt.engine.api.model.DiskAttachment)10 DiskImage (org.ovirt.engine.core.common.businessentities.storage.DiskImage)10 StorageDomain (org.ovirt.engine.api.model.StorageDomain)9 AsyncTaskStatus (org.ovirt.engine.core.common.businessentities.AsyncTaskStatus)7 Vm (org.ovirt.engine.api.model.Vm)6 StorageDomains (org.ovirt.engine.api.model.StorageDomains)4 V3Disk (org.ovirt.engine.api.v3.types.V3Disk)4 DiskAttachments (org.ovirt.engine.api.model.DiskAttachments)3 V3Disks (org.ovirt.engine.api.v3.types.V3Disks)3 UriInfo (javax.ws.rs.core.UriInfo)2 HostStorage (org.ovirt.engine.api.model.HostStorage)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