Search in sources :

Example 51 with VmDevice

use of org.ovirt.engine.core.common.businessentities.VmDevice in project ovirt-engine by oVirt.

the class VmDeviceCommonUtils method addVideoDevice.

public static void addVideoDevice(VmBase vmBase) {
    if (vmBase.getDefaultDisplayType().getDefaultVmDeviceType() == null) {
        return;
    }
    VmDevice vmDevice = new VmDevice();
    vmDevice.setId(new VmDeviceId(Guid.newGuid(), vmBase.getId()));
    vmDevice.setType(VmDeviceGeneralType.VIDEO);
    vmDevice.setDevice(vmBase.getDefaultDisplayType().getDefaultVmDeviceType().getName());
    vmDevice.setManaged(true);
    vmDevice.setPlugged(true);
    vmDevice.setReadOnly(false);
    vmDevice.setAddress("");
    vmBase.getManagedDeviceMap().put(vmDevice.getDeviceId(), vmDevice);
}
Also used : VmDevice(org.ovirt.engine.core.common.businessentities.VmDevice) VmDeviceId(org.ovirt.engine.core.common.businessentities.VmDeviceId)

Example 52 with VmDevice

use of org.ovirt.engine.core.common.businessentities.VmDevice in project ovirt-engine by oVirt.

the class VmDeviceCommonUtils method addCdDevice.

public static void addCdDevice(VmBase vmBase) {
    VmDevice vmDevice = new VmDevice();
    vmDevice.setId(new VmDeviceId(Guid.newGuid(), vmBase.getId()));
    vmDevice.setType(VmDeviceGeneralType.DISK);
    vmDevice.setDevice(VmDeviceType.CDROM.getName());
    vmDevice.setManaged(true);
    vmDevice.setPlugged(true);
    vmDevice.setReadOnly(true);
    vmDevice.setAddress("");
    vmBase.getManagedDeviceMap().put(vmDevice.getDeviceId(), vmDevice);
}
Also used : VmDevice(org.ovirt.engine.core.common.businessentities.VmDevice) VmDeviceId(org.ovirt.engine.core.common.businessentities.VmDeviceId)

Example 53 with VmDevice

use of org.ovirt.engine.core.common.businessentities.VmDevice in project ovirt-engine by oVirt.

the class GetGraphicsDevicesQuery method executeQueryCommand.

@Override
protected void executeQueryCommand() {
    List<GraphicsDevice> result = new LinkedList<>();
    // we must use getVmDeviceByVmIdTypeAndDevice since it supports user filtering
    List<VmDevice> spiceDevs = vmDeviceDao.getVmDeviceByVmIdTypeAndDevice(getParameters().getId(), VmDeviceGeneralType.GRAPHICS, VmDeviceType.SPICE.getName(), getUserID(), getParameters().isFiltered());
    if (spiceDevs != null && !spiceDevs.isEmpty()) {
        result.add(new GraphicsDevice(spiceDevs.get(0)));
    }
    List<VmDevice> vncDevs = vmDeviceDao.getVmDeviceByVmIdTypeAndDevice(getParameters().getId(), VmDeviceGeneralType.GRAPHICS, VmDeviceType.VNC.getName(), getUserID(), getParameters().isFiltered());
    if (vncDevs != null && !vncDevs.isEmpty()) {
        result.add(new GraphicsDevice(vncDevs.get(0)));
    }
    setReturnValue(result);
}
Also used : VmDevice(org.ovirt.engine.core.common.businessentities.VmDevice) GraphicsDevice(org.ovirt.engine.core.common.businessentities.GraphicsDevice) LinkedList(java.util.LinkedList)

Example 54 with VmDevice

use of org.ovirt.engine.core.common.businessentities.VmDevice in project ovirt-engine by oVirt.

the class GetNextRunGraphicsDevicesQuery method executeQueryCommand.

@Override
protected void executeQueryCommand() {
    QueryReturnValue nextRun = runInternalQuery(QueryType.GetVmNextRunConfiguration, new IdQueryParameters(getParameters().getId()));
    VM vm = nextRun.getReturnValue();
    if (vm != null && vm.isNextRunConfigurationExists()) {
        List<GraphicsDevice> result = new LinkedList<>();
        for (GraphicsType graphicsType : GraphicsType.values()) {
            VmDevice device = VmDeviceCommonUtils.findVmDeviceByType(vm.getManagedVmDeviceMap(), graphicsType.getCorrespondingDeviceType());
            if (device != null) {
                result.add(new GraphicsDevice(device));
            }
        }
        setReturnValue(result);
    } else {
        super.executeQueryCommand();
    }
}
Also used : GraphicsType(org.ovirt.engine.core.common.businessentities.GraphicsType) VmDevice(org.ovirt.engine.core.common.businessentities.VmDevice) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) GraphicsDevice(org.ovirt.engine.core.common.businessentities.GraphicsDevice) VM(org.ovirt.engine.core.common.businessentities.VM) LinkedList(java.util.LinkedList)

Example 55 with VmDevice

use of org.ovirt.engine.core.common.businessentities.VmDevice in project ovirt-engine by oVirt.

the class GetSoundDevicesQuery method executeQueryCommand.

@Override
protected void executeQueryCommand() {
    List<VmDevice> soundDevList = vmDeviceDao.getVmDeviceByVmIdAndType(getParameters().getId(), VmDeviceGeneralType.SOUND);
    List<String> result = new ArrayList<>(soundDevList.size());
    for (VmDevice v : soundDevList) {
        result.add(v.getDevice());
    }
    getQueryReturnValue().setReturnValue(result);
}
Also used : VmDevice(org.ovirt.engine.core.common.businessentities.VmDevice) ArrayList(java.util.ArrayList)

Aggregations

VmDevice (org.ovirt.engine.core.common.businessentities.VmDevice)170 HashMap (java.util.HashMap)59 Guid (org.ovirt.engine.core.compat.Guid)53 VmDeviceId (org.ovirt.engine.core.common.businessentities.VmDeviceId)48 ArrayList (java.util.ArrayList)34 Map (java.util.Map)33 VM (org.ovirt.engine.core.common.businessentities.VM)29 DiskImage (org.ovirt.engine.core.common.businessentities.storage.DiskImage)28 List (java.util.List)26 GraphicsType (org.ovirt.engine.core.common.businessentities.GraphicsType)21 VmDeviceGeneralType (org.ovirt.engine.core.common.businessentities.VmDeviceGeneralType)21 VmDeviceType (org.ovirt.engine.core.common.utils.VmDeviceType)20 Collections (java.util.Collections)19 Test (org.junit.Test)19 Collectors (java.util.stream.Collectors)18 Arrays (java.util.Arrays)17 Optional (java.util.Optional)17 StringUtils (org.apache.commons.lang.StringUtils)17 HostDevice (org.ovirt.engine.core.common.businessentities.HostDevice)17 Inject (javax.inject.Inject)16