Search in sources :

Example 21 with VmRngDevice

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

the class GetRngDeviceQuery method executeQueryCommand.

@Override
protected void executeQueryCommand() {
    final List<VmDevice> vmDevices = vmDeviceDao.getVmDeviceByVmIdTypeAndDevice(getParameters().getId(), VmDeviceGeneralType.RNG, VmDeviceType.VIRTIO.getName(), getUserID(), getParameters().isFiltered());
    if (vmDevices != null && !vmDevices.isEmpty()) {
        VmDevice dev = vmDevices.get(0);
        setReturnValue(Collections.singletonList(new VmRngDevice(dev)));
    } else {
        setReturnValue(Collections.emptyList());
    }
}
Also used : VmDevice(org.ovirt.engine.core.common.businessentities.VmDevice) VmRngDevice(org.ovirt.engine.core.common.businessentities.VmRngDevice)

Example 22 with VmRngDevice

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

the class BackendInstanceTypesResource method doPopulate.

@Override
protected InstanceType doPopulate(InstanceType model, org.ovirt.engine.core.common.businessentities.InstanceType entity) {
    if (!model.isSetConsole()) {
        model.setConsole(new Console());
    }
    model.getConsole().setEnabled(!getConsoleDevicesForEntity(entity.getId()).isEmpty());
    if (!model.isSetVirtioScsi()) {
        model.setVirtioScsi(new VirtioScsi());
    }
    model.getVirtioScsi().setEnabled(!VmHelper.getVirtioScsiControllersForEntity(this, entity.getId()).isEmpty());
    model.setSoundcardEnabled(!VmHelper.getSoundDevicesForEntity(this, entity.getId()).isEmpty());
    List<VmRngDevice> rngDevices = getRngDevices(entity.getId());
    if (rngDevices != null && !rngDevices.isEmpty()) {
        model.setRngDevice(RngDeviceMapper.map(rngDevices.get(0), null));
    }
    MemoryPolicyHelper.setupMemoryBalloon(model, this);
    return model;
}
Also used : VirtioScsi(org.ovirt.engine.api.model.VirtioScsi) Console(org.ovirt.engine.api.model.Console) VmRngDevice(org.ovirt.engine.core.common.businessentities.VmRngDevice)

Example 23 with VmRngDevice

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

the class RngDeviceMapperTest method testMapFromRestToBackend.

@Test
public void testMapFromRestToBackend() throws Exception {
    RngDevice model = new RngDevice();
    model.setSource(RngSource.HWRNG);
    model.setRate(new Rate());
    model.getRate().setBytes(10);
    model.getRate().setPeriod(11);
    VmRngDevice expected = new VmRngDevice();
    expected.setBytes(10);
    expected.setPeriod(11);
    expected.setSource(VmRngDevice.Source.HWRNG);
    assertEquals(expected, RngDeviceMapper.map(model, null));
}
Also used : Rate(org.ovirt.engine.api.model.Rate) VmRngDevice(org.ovirt.engine.core.common.businessentities.VmRngDevice) VmRngDevice(org.ovirt.engine.core.common.businessentities.VmRngDevice) RngDevice(org.ovirt.engine.api.model.RngDevice) Test(org.junit.Test)

Example 24 with VmRngDevice

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

the class RngDeviceMapperTest method testMapFromBackendToRest.

@Test
public void testMapFromBackendToRest() throws Exception {
    VmRngDevice entity = new VmRngDevice();
    entity.setBytes(11);
    entity.setPeriod(10);
    entity.setSource(VmRngDevice.Source.RANDOM);
    RngDevice expected = new RngDevice();
    expected.setRate(new Rate());
    expected.getRate().setBytes(11);
    expected.getRate().setPeriod(10);
    expected.setSource(RngSource.RANDOM);
    assertEquals(expected.getRate().getBytes(), RngDeviceMapper.map(entity, null).getRate().getBytes());
    assertEquals(expected.getRate().getPeriod(), RngDeviceMapper.map(entity, null).getRate().getPeriod());
    assertEquals(expected.getSource(), RngDeviceMapper.map(entity, null).getSource());
}
Also used : Rate(org.ovirt.engine.api.model.Rate) VmRngDevice(org.ovirt.engine.core.common.businessentities.VmRngDevice) VmRngDevice(org.ovirt.engine.core.common.businessentities.VmRngDevice) RngDevice(org.ovirt.engine.api.model.RngDevice) Test(org.junit.Test)

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