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