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