Search in sources :

Example 26 with VmDevice

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

the class VmDevicesListModel method syncSearch.

@Override
protected void syncSearch() {
    if (getEntity() != null) {
        final E vm = getEntity();
        final AsyncQuery<QueryReturnValue> asyncQuery = new AsyncQuery<QueryReturnValue>(new AsyncCallback<QueryReturnValue>() {

            @Override
            public void onSuccess(QueryReturnValue returnValue) {
                final Collection<VmDevice> vmDevices = returnValue.getReturnValue();
                final ArrayList<VmDeviceFeEntity> frontendDevices = new ArrayList<>();
                for (VmDevice vmDevice : vmDevices) {
                    // exclude USB controller devices with model property set to 'none'
                    if (vmDevice.getDevice().equals(VmDeviceType.USB.getName()) && vmDevice.getType() == VmDeviceGeneralType.CONTROLLER && (vmDevice.getSpecParams().get(MODEL)) != null && vmDevice.getSpecParams().get(MODEL).equals(UsbControllerModel.NONE.libvirtName)) {
                        continue;
                    }
                    frontendDevices.add(new VmDeviceFeEntity(vmDevice, vm, idsOfDevicesBeingUnplugged.contains(vmDevice.getId())));
                }
                setItems(frontendDevices);
            }
        }) {
        };
        super.syncSearch(QueryType.GetVmDevicesForVm, new IdQueryParameters(vm.getId()), asyncQuery);
    }
}
Also used : VmDevice(org.ovirt.engine.core.common.businessentities.VmDevice) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) ArrayList(java.util.ArrayList) Collection(java.util.Collection)

Example 27 with VmDevice

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

the class GetConsoleDevicesQuery method executeQueryCommand.

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

Example 28 with VmDevice

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

the class UpdateGraphicsDeviceCommand method executeCommand.

@Override
protected void executeCommand() {
    VmDevice graphicsDev = getParameters().getDev();
    vmDeviceDao.update(graphicsDev);
    setSucceeded(true);
    setActionReturnValue(graphicsDev.getId().getDeviceId());
}
Also used : VmDevice(org.ovirt.engine.core.common.businessentities.VmDevice)

Example 29 with VmDevice

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

the class UpdateRngDeviceCommand method executeCommand.

@Override
protected void executeCommand() {
    VmDevice rngDevice = getParameters().getRngDevice();
    vmDeviceDao.update(rngDevice);
    setSucceeded(true);
}
Also used : VmDevice(org.ovirt.engine.core.common.businessentities.VmDevice)

Example 30 with VmDevice

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

the class RemoveRngDeviceCommand method executeCommand.

@Override
protected void executeCommand() {
    List<VmDevice> rngDevices = getRngDevices();
    Set<VmDeviceId> idsToRemove = new HashSet<>();
    for (VmDevice dev : rngDevices) {
        idsToRemove.add(dev.getId());
    }
    vmDeviceDao.removeAll(idsToRemove);
    setSucceeded(true);
}
Also used : VmDevice(org.ovirt.engine.core.common.businessentities.VmDevice) VmDeviceId(org.ovirt.engine.core.common.businessentities.VmDeviceId) HashSet(java.util.HashSet)

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