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);
}
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);
}
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);
}
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();
}
}
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);
}
Aggregations