Search in sources :

Example 16 with Vm

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

the class HostDeviceMapper method map.

@Mapping(from = org.ovirt.engine.core.common.businessentities.HostDevice.class, to = HostDevice.class)
public static HostDevice map(org.ovirt.engine.core.common.businessentities.HostDevice entity, HostDevice model) {
    if (model == null) {
        model = new HostDevice();
    }
    if (!model.isSetHost()) {
        model.setHost(new Host());
    }
    model.getHost().setId(entity.getHostId().toString());
    model.setId(HexUtils.string2hex(entity.getDeviceName()));
    model.setName(entity.getDeviceName());
    model.setCapability(entity.getCapability());
    model.setParentDevice(getSameHostDeviceReference(entity.getHostId(), entity.getParentDeviceName()));
    model.setDriver(entity.getDriver());
    if (entity.getProductId() != null || entity.getProductName() != null) {
        if (!model.isSetProduct()) {
            model.setProduct(new Product());
        }
        model.getProduct().setId(entity.getProductId());
        model.getProduct().setName(entity.getProductName());
    }
    if (entity.getVendorId() != null || entity.getVendorName() != null) {
        if (!model.isSetVendor()) {
            model.setVendor(new Vendor());
        }
        model.getVendor().setId(entity.getVendorId());
        model.getVendor().setName(entity.getVendorName());
    }
    model.setIommuGroup(entity.getIommuGroup());
    if (entity.getParentPhysicalFunction() != null) {
        model.setPhysicalFunction(getSameHostDeviceReference(entity.getHostId(), entity.getParentPhysicalFunction()));
    }
    model.setVirtualFunctions(entity.getTotalVirtualFunctions());
    if (entity.getVmId() != null) {
        model.setVm(new Vm());
        model.getVm().setId(entity.getVmId().toString());
    }
    return model;
}
Also used : HostDevice(org.ovirt.engine.api.model.HostDevice) Vm(org.ovirt.engine.api.model.Vm) Product(org.ovirt.engine.api.model.Product) Host(org.ovirt.engine.api.model.Host) Vendor(org.ovirt.engine.api.model.Vendor)

Example 17 with Vm

use of org.ovirt.engine.api.model.Vm 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);
                }
            }
        }
    }
}
Also used : VolumeFormat(org.ovirt.engine.core.common.businessentities.storage.VolumeFormat) DiskAttachment(org.ovirt.engine.api.model.DiskAttachment) Vm(org.ovirt.engine.api.model.Vm) Guid(org.ovirt.engine.core.compat.Guid) Disk(org.ovirt.engine.api.model.Disk) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage)

Example 18 with Vm

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

the class BackendStorageDomainVmsResource method list.

@Override
public Vms list() {
    Vms vms = new Vms();
    boolean unregistered = ParametersHelper.getBooleanParameter(httpHeaders, uriInfo, UNREGISTERED_CONSTRAINT_PARAMETER, true, false);
    if (unregistered) {
        List<org.ovirt.engine.core.common.businessentities.VM> unregisteredVms = getBackendCollection(QueryType.GetUnregisteredVms, new IdQueryParameters(storageDomainId));
        List<Vm> collection = new ArrayList<>();
        for (org.ovirt.engine.core.common.businessentities.VM entity : unregisteredVms) {
            Vm vm = map(entity);
            collection.add(addLinks(populate(vm, entity)));
        }
        vms.getVms().addAll(collection);
    } else {
        vms.getVms().addAll(getCollection());
    }
    return vms;
}
Also used : ArrayList(java.util.ArrayList) IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) Vm(org.ovirt.engine.api.model.Vm) Vms(org.ovirt.engine.api.model.Vms)

Example 19 with Vm

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

the class BackendSnapshotsResource method addVmConfiguration.

protected Snapshot addVmConfiguration(org.ovirt.engine.core.common.businessentities.Snapshot entity, Snapshot snapshot) {
    if (entity.isVmConfigurationAvailable()) {
        snapshot.setVm(new Vm());
        getMapper(org.ovirt.engine.core.common.businessentities.VM.class, Vm.class).map(getVmPreview(snapshot), snapshot.getVm());
    } else {
        snapshot.setVm(null);
        snapshot.getLinks().clear();
    }
    return snapshot;
}
Also used : Vm(org.ovirt.engine.api.model.Vm)

Example 20 with Vm

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

the class BackendSnapshotsResource method addParents.

@Override
protected Snapshot addParents(Snapshot snapshot) {
    snapshot.setVm(new Vm());
    snapshot.getVm().setId(parentId.toString());
    return snapshot;
}
Also used : Vm(org.ovirt.engine.api.model.Vm)

Aggregations

Vm (org.ovirt.engine.api.model.Vm)145 Test (org.junit.Test)80 Response (javax.ws.rs.core.Response)26 Host (org.ovirt.engine.api.model.Host)21 WebApplicationException (javax.ws.rs.WebApplicationException)19 Guid (org.ovirt.engine.core.compat.Guid)15 Template (org.ovirt.engine.api.model.Template)11 Hosts (org.ovirt.engine.api.model.Hosts)10 Action (org.ovirt.engine.api.model.Action)9 VmPlacementPolicy (org.ovirt.engine.api.model.VmPlacementPolicy)9 Vms (org.ovirt.engine.api.model.Vms)8 RunVmOnceParams (org.ovirt.engine.core.common.action.RunVmOnceParams)8 VM (org.ovirt.engine.core.common.businessentities.VM)8 Disk (org.ovirt.engine.api.model.Disk)7 IdQueryParameters (org.ovirt.engine.core.common.queries.IdQueryParameters)7 ArrayList (java.util.ArrayList)6 Nic (org.ovirt.engine.api.model.Nic)6 VmManagementParametersBase (org.ovirt.engine.core.common.action.VmManagementParametersBase)6 Configuration (org.ovirt.engine.api.model.Configuration)5 DiskAttachment (org.ovirt.engine.api.model.DiskAttachment)5