use of org.ovirt.engine.core.common.businessentities.VmDevice in project ovirt-engine by oVirt.
the class AddUnmanagedVmsCommand method importHostedEngineVm.
// Visible for testing
protected void importHostedEngineVm(Map<String, Object> vmStruct) {
VM vm = VdsBrokerObjectsBuilder.buildVmsDataFromExternalProvider(vmStruct);
if (vm != null) {
vm.setImages(VdsBrokerObjectsBuilder.buildDiskImagesFromDevices(vmStruct, vm.getId()));
vm.setInterfaces(VdsBrokerObjectsBuilder.buildVmNetworkInterfacesFromDevices(vmStruct));
for (DiskImage diskImage : vm.getImages()) {
vm.getDiskMap().put(diskImage.getId(), diskImage);
}
vm.setClusterId(getClusterId());
vm.setRunOnVds(getVdsId());
List<GraphicsDevice> graphicsDevices = extractGraphicsDevices(vm.getId(), (Object[]) vmStruct.get(VdsProperties.Devices));
if (graphicsDevices.size() == 1 && VmDeviceType.valueOf(graphicsDevices.get(0).getDevice().toUpperCase()) == VmDeviceType.VNC) {
vm.setDefaultDisplayType(DisplayType.vga);
} else {
vm.setDefaultDisplayType(DisplayType.qxl);
}
// HE VM does not support that feature, disable it
vm.setSingleQxlPci(false);
for (GraphicsDevice graphicsDevice : graphicsDevices) {
vm.getManagedVmDeviceMap().put(graphicsDevice.getDeviceId(), graphicsDevice);
}
VmDevice consoleDevice = VdsBrokerObjectsBuilder.buildConsoleDevice(vmStruct, vm.getId());
if (consoleDevice != null) {
vm.getManagedVmDeviceMap().put(consoleDevice.getDeviceId(), consoleDevice);
}
importHostedEngineVm(vm);
}
}
use of org.ovirt.engine.core.common.businessentities.VmDevice in project ovirt-engine by oVirt.
the class AddWatchdogCommand method executeCommand.
@Override
protected void executeCommand() {
VmDevice watchdogDevice = vmDeviceUtils.addWatchdogDevice(getParameters().getId(), getSpecParams());
setSucceeded(true);
setActionReturnValue(watchdogDevice.getId().getDeviceId());
}
use of org.ovirt.engine.core.common.businessentities.VmDevice in project ovirt-engine by oVirt.
the class CloneVmCommand method setupParameters.
private void setupParameters() {
setVmId(Guid.newGuid());
VM vmToClone = getVm();
getParameters().setNewVmGuid(getVmId());
getParameters().setVm(vmToClone);
List<VmDevice> devices = vmDeviceDao.getVmDeviceByVmId(oldVmId);
getParameters().setSoundDeviceEnabled(containsDeviceWithType(devices, VmDeviceGeneralType.SOUND));
getParameters().setConsoleEnabled(containsDeviceWithType(devices, VmDeviceGeneralType.CONSOLE));
getParameters().setVirtioScsiEnabled(containsDeviceWithType(devices, VmDeviceGeneralType.CONTROLLER, VmDeviceType.VIRTIOSCSI));
getParameters().setBalloonEnabled(containsDeviceWithType(devices, VmDeviceGeneralType.BALLOON));
setGraphicsDevices(devices);
QueryReturnValue watchdogs = runInternalQuery(QueryType.GetWatchdog, new IdQueryParameters(oldVmId));
if (!((List<VmWatchdog>) watchdogs.getReturnValue()).isEmpty()) {
VmWatchdog watchdog = ((List<VmWatchdog>) watchdogs.getReturnValue()).iterator().next();
getParameters().setUpdateWatchdog(true);
getParameters().setWatchdog(watchdog);
}
fillDisksToParameters();
}
use of org.ovirt.engine.core.common.businessentities.VmDevice in project ovirt-engine by oVirt.
the class AddGraphicsAndVideoDevicesCommand method executeCommand.
@Override
protected void executeCommand() {
VmDevice graphicsDev = getParameters().getDev();
if (graphicsDev.getDeviceId() == null) {
graphicsDev.setDeviceId(Guid.newGuid());
}
vmDeviceDao.save(graphicsDev);
if (getPrevDevices().isEmpty()) {
if (getParameters().isVm()) {
setVmToNonHeadlessMode();
} else {
setTemplateToNonHeadlessMode();
}
}
setSucceeded(true);
setActionReturnValue(graphicsDev.getId().getDeviceId());
}
use of org.ovirt.engine.core.common.businessentities.VmDevice in project ovirt-engine by oVirt.
the class VmDeviceCommonUtils method sortInterfacesByName.
private static List<VmDevice> sortInterfacesByName(List<VmDevice> pluggedInterfaces, List<VmNetworkInterface> interfaces) {
if (pluggedInterfaces.size() < 2) {
return pluggedInterfaces;
}
final Map<Guid, String> deviceIdToIfaceName = new HashMap<>();
for (VmNetworkInterface iface : interfaces) {
deviceIdToIfaceName.put(iface.getId(), iface.getName());
}
Collections.sort(pluggedInterfaces, Comparator.comparing(d -> deviceIdToIfaceName.get(d.getId().getDeviceId())));
return pluggedInterfaces;
}
Aggregations