Search in sources :

Example 1 with VmRngDevice

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

the class ExistingNonClusterModelBehavior method doBuild.

public void doBuild() {
    buildModel(entity, (source, destination) -> {
        Frontend.getInstance().runQuery(QueryType.IsBalloonEnabled, new IdQueryParameters(entity.getId()), new AsyncQuery<>((QueryReturnValue returnValue) -> getModel().getMemoryBalloonDeviceEnabled().setEntity((Boolean) returnValue.getReturnValue())));
        getInstance().isVirtioScsiEnabledForVm(new AsyncQuery<>(returnValue -> getModel().getIsVirtioScsiEnabled().setEntity(returnValue)), entity.getId());
        getInstance().getWatchdogByVmId(new AsyncQuery<QueryReturnValue>(returnValue -> {
            @SuppressWarnings("unchecked") Collection<VmWatchdog> watchdogs = returnValue.getReturnValue();
            for (VmWatchdog watchdog : watchdogs) {
                getModel().getWatchdogAction().setSelectedItem(watchdog.getAction());
                getModel().getWatchdogModel().setSelectedItem(watchdog.getModel());
            }
        }), entity.getId());
        Frontend.getInstance().runQuery(QueryType.GetRngDevice, new IdQueryParameters(entity.getId()), new AsyncQuery<QueryReturnValue>(returnValue -> {
            List<VmDevice> rngDevices = returnValue.getReturnValue();
            getModel().getIsRngEnabled().setEntity(!rngDevices.isEmpty());
            if (!rngDevices.isEmpty()) {
                VmRngDevice rngDevice = new VmRngDevice(rngDevices.get(0));
                getModel().setRngDevice(rngDevice);
            }
        }));
        getModel().getEmulatedMachine().setSelectedItem(entity.getCustomEmulatedMachine());
        getModel().getCustomCpu().setSelectedItem(entity.getCustomCpuName());
        getModel().getMigrationMode().setSelectedItem(entity.getMigrationSupport());
        postBuild();
    });
}
Also used : UsbPolicy(org.ovirt.engine.core.common.businessentities.UsbPolicy) QueryType(org.ovirt.engine.core.common.queries.QueryType) AsyncDataProvider.getInstance(org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider.getInstance) Arrays(java.util.Arrays) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) GraphicsDevice(org.ovirt.engine.core.common.businessentities.GraphicsDevice) VmBase(org.ovirt.engine.core.common.businessentities.VmBase) BuilderExecutor(org.ovirt.engine.ui.uicommonweb.builders.BuilderExecutor) NameAndDescriptionVmBaseToUnitBuilder(org.ovirt.engine.ui.uicommonweb.builders.vm.NameAndDescriptionVmBaseToUnitBuilder) Guid(org.ovirt.engine.core.compat.Guid) Collection(java.util.Collection) VmTemplate(org.ovirt.engine.core.common.businessentities.VmTemplate) Set(java.util.Set) IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) HashSet(java.util.HashSet) HwOnlyVmBaseToUnitBuilder(org.ovirt.engine.ui.uicommonweb.builders.vm.HwOnlyVmBaseToUnitBuilder) Frontend(org.ovirt.engine.ui.frontend.Frontend) List(java.util.List) VmRngDevice(org.ovirt.engine.core.common.businessentities.VmRngDevice) UnitVmModel(org.ovirt.engine.ui.uicommonweb.models.vms.UnitVmModel) VmDevice(org.ovirt.engine.core.common.businessentities.VmDevice) AsyncQuery(org.ovirt.engine.ui.frontend.AsyncQuery) GraphicsType(org.ovirt.engine.core.common.businessentities.GraphicsType) VmWatchdog(org.ovirt.engine.core.common.businessentities.VmWatchdog) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) Collection(java.util.Collection) List(java.util.List) VmWatchdog(org.ovirt.engine.core.common.businessentities.VmWatchdog) VmRngDevice(org.ovirt.engine.core.common.businessentities.VmRngDevice)

Example 2 with VmRngDevice

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

the class RngDeviceSpecParamsTest method testGenerateSpecParams.

@Test
public void testGenerateSpecParams() {
    VmRngDevice dev = new VmRngDevice();
    dev.setSource(VmRngDevice.Source.HWRNG);
    Map<String, Object> expectedParams = new HashMap<>();
    expectedParams.put("source", "hwrng");
    assertEquals(expectedParams, dev.getSpecParams());
}
Also used : HashMap(java.util.HashMap) VmRngDevice(org.ovirt.engine.core.common.businessentities.VmRngDevice) Test(org.junit.Test)

Example 3 with VmRngDevice

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

the class UnitVmModel method generateRngDevice.

public VmRngDevice generateRngDevice() {
    VmRngDevice dev = new VmRngDevice();
    dev.setBytes(rngBytes.getEntity());
    dev.setPeriod(rngPeriod.getEntity());
    dev.setSource(Boolean.TRUE.equals(rngSourceUrandom.getEntity()) ? getBehavior().getUrandomOrRandomRngSource() : VmRngDevice.Source.HWRNG);
    return dev;
}
Also used : VmRngDevice(org.ovirt.engine.core.common.businessentities.VmRngDevice)

Example 4 with VmRngDevice

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

the class UpdateVmCommand method updateRngDevice.

private void updateRngDevice() {
    if (!getParameters().isUpdateRngDevice()) {
        return;
    }
    QueryReturnValue query = runInternalQuery(QueryType.GetRngDevice, new IdQueryParameters(getParameters().getVmId()));
    List<VmRngDevice> rngDevs = query.getReturnValue();
    ActionReturnValue rngCommandResult = null;
    if (rngDevs.isEmpty()) {
        if (getParameters().getRngDevice() != null) {
            RngDeviceParameters params = new RngDeviceParameters(getParameters().getRngDevice(), true);
            rngCommandResult = runInternalAction(ActionType.AddRngDevice, params, cloneContextAndDetachFromParent());
        }
    } else {
        if (getParameters().getRngDevice() == null) {
            RngDeviceParameters params = new RngDeviceParameters(rngDevs.get(0), true);
            rngCommandResult = runInternalAction(ActionType.RemoveRngDevice, params, cloneContextAndDetachFromParent());
        } else {
            RngDeviceParameters params = new RngDeviceParameters(getParameters().getRngDevice(), true);
            params.getRngDevice().setDeviceId(rngDevs.get(0).getDeviceId());
            rngCommandResult = runInternalAction(ActionType.UpdateRngDevice, params, cloneContextAndDetachFromParent());
        }
    }
    if (rngCommandResult != null && !rngCommandResult.getSucceeded()) {
        log.error("Updating RNG device of VM {} ({}) failed. Old RNG device = {}. New RNG device = {}.", getVm().getName(), getVm().getId(), rngDevs.isEmpty() ? null : rngDevs.get(0), getParameters().getRngDevice());
    }
}
Also used : RngDeviceParameters(org.ovirt.engine.core.common.action.RngDeviceParameters) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue) VmRngDevice(org.ovirt.engine.core.common.businessentities.VmRngDevice)

Example 5 with VmRngDevice

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

the class UpdateClusterCommand method updateRngDeviceIfNecessary.

/**
 * This can be dropped together with support of 4.0 compatibility level.
 */
private void updateRngDeviceIfNecessary(Guid vmBaseId, Version customCompatibilityLevel, HasRngDevice updateParameters) {
    final Version oldEffectiveVersion = CompatibilityVersionUtils.getEffective(customCompatibilityLevel, () -> oldCluster.getCompatibilityVersion());
    final Version newEffectiveVersion = CompatibilityVersionUtils.getEffective(customCompatibilityLevel, () -> getCluster().getCompatibilityVersion());
    final Optional<VmRngDevice> updatedDeviceOptional = rngDeviceUtils.createUpdatedRngDeviceIfNecessary(oldEffectiveVersion, newEffectiveVersion, vmBaseId, cloneContext());
    if (updatedDeviceOptional.isPresent()) {
        updateParameters.setUpdateRngDevice(true);
        updateParameters.setRngDevice(updatedDeviceOptional.get());
    }
}
Also used : Version(org.ovirt.engine.core.compat.Version) VmRngDevice(org.ovirt.engine.core.common.businessentities.VmRngDevice)

Aggregations

VmRngDevice (org.ovirt.engine.core.common.businessentities.VmRngDevice)24 VmDevice (org.ovirt.engine.core.common.businessentities.VmDevice)8 GraphicsType (org.ovirt.engine.core.common.businessentities.GraphicsType)5 IdQueryParameters (org.ovirt.engine.core.common.queries.IdQueryParameters)5 QueryReturnValue (org.ovirt.engine.core.common.queries.QueryReturnValue)5 Test (org.junit.Test)4 GraphicsDevice (org.ovirt.engine.core.common.businessentities.GraphicsDevice)4 VmTemplate (org.ovirt.engine.core.common.businessentities.VmTemplate)4 VmWatchdog (org.ovirt.engine.core.common.businessentities.VmWatchdog)4 Guid (org.ovirt.engine.core.compat.Guid)4 Collection (java.util.Collection)3 HashMap (java.util.HashMap)3 HashSet (java.util.HashSet)3 List (java.util.List)3 Set (java.util.Set)3 Rate (org.ovirt.engine.api.model.Rate)3 RngDevice (org.ovirt.engine.api.model.RngDevice)3 ActionReturnValue (org.ovirt.engine.core.common.action.ActionReturnValue)3 RngDeviceParameters (org.ovirt.engine.core.common.action.RngDeviceParameters)3 VmBase (org.ovirt.engine.core.common.businessentities.VmBase)3