Frank Kobzik has uploaded a new change for review. Change subject: backend: [WIP] Control virtio rng device ......................................................................
backend: [WIP] Control virtio rng device This patch adds the possibility of attaching/detaching virtio paravirualized device for VMs. TODO: - tests - handle templates - TODOs Change-Id: Ifc26a484c84244074426f4b0c790e2cc4ebb8da6 Signed-off-by: Frantisek Kobzik <[email protected]> Bug-Url: https://bugzilla.redhat.com/977079 --- A backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AbstractRngDeviceCommand.java A backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddRngDeviceCommand.java M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddVmCommand.java A backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/GetRndDeviceQuery.java A backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RemoveRngDeviceCommand.java A backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/UpdateRngDeviceCommand.java M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/UpdateVmCommand.java A backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/RngDeviceParameters.java M backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/VdcActionType.java M backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/VmManagementParametersBase.java M backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VmDeviceGeneralType.java A backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VmRngDevice.java M backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/errors/VdcBllMessages.java M backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/queries/VdcQueryType.java M backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/utils/VmDeviceType.java M frontend/webadmin/modules/gwt-common/src/main/resources/org/ovirt/engine/core/Common.gwt.xml M frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/VmListModel.java 17 files changed, 450 insertions(+), 2 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/76/18176/1 diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AbstractRngDeviceCommand.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AbstractRngDeviceCommand.java new file mode 100644 index 0000000..46c6cf0 --- /dev/null +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AbstractRngDeviceCommand.java @@ -0,0 +1,63 @@ +package org.ovirt.engine.core.bll; + +import java.util.ArrayList; +import java.util.List; +import org.ovirt.engine.core.bll.utils.PermissionSubject; +import org.ovirt.engine.core.common.VdcObjectType; +import org.ovirt.engine.core.common.action.RngDeviceParameters; +import org.ovirt.engine.core.common.businessentities.VDSGroup; +import org.ovirt.engine.core.common.businessentities.VmDevice; +import org.ovirt.engine.core.common.businessentities.VmDeviceGeneralType; +import org.ovirt.engine.core.common.errors.VdcBllMessages; +import org.ovirt.engine.core.compat.Guid; +import org.ovirt.engine.core.compat.Version; + +/** + * Base class for crud for random number generator devices + */ +public abstract class AbstractRngDeviceCommand<T extends RngDeviceParameters> extends CommandBase<T> { + + protected AbstractRngDeviceCommand(T parameters) { + super(parameters); + } + + @Override + public List<PermissionSubject> getPermissionCheckSubjects() { + List<PermissionSubject> permissionList = new ArrayList<PermissionSubject>(); + permissionList.add(new PermissionSubject(getParameters().getRngDevice().getVmId(), + getParameters().isVm() ? VdcObjectType.VM : VdcObjectType.VmTemplate, + getActionType().getActionGroup())); + return permissionList; + } + + @Override + protected boolean canDoAction() { + if (getParameters().getRngDevice().getVmId() == null || !entityExists()) { + return failCanDoAction(getParameters().isVm() ? VdcBllMessages.ACTION_TYPE_FAILED_VM_NOT_FOUND + : VdcBllMessages.ACTION_TYPE_FAILED_TEMPLATE_DOES_NOT_EXIST); + } + + VDSGroup cluster = getVdsGroupDAO().get(getVdsGroupId()); + if (cluster == null || Version.v3_3.compareTo(cluster.getcompatibility_version()) < 0) { + return failCanDoAction(VdcBllMessages.ACTION_NOT_SUPPORTED_FOR_CLUSTER_LEVEL); + } + + return true; + } + + protected boolean entityExists() { + Guid entityId = getParameters().getRngDevice().getVmId(); + + if (getParameters().isVm()) { + return getVmDAO().get(entityId) != null; + } else { + return getVmTemplateDAO().get(entityId) != null; + } + } + + protected List<VmDevice> getRngDevices() { + return getDbFacade().getVmDeviceDao().getVmDeviceByVmIdAndType(getParameters().getRngDevice().getId(), + VmDeviceGeneralType.RNG); + } + +} diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddRngDeviceCommand.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddRngDeviceCommand.java new file mode 100644 index 0000000..390c265 --- /dev/null +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddRngDeviceCommand.java @@ -0,0 +1,44 @@ +package org.ovirt.engine.core.bll; + +import org.apache.commons.lang.StringUtils; +import org.ovirt.engine.core.common.action.RngDeviceParameters; +import org.ovirt.engine.core.common.businessentities.VmDevice; +import org.ovirt.engine.core.common.businessentities.VmDeviceGeneralType; +import org.ovirt.engine.core.common.businessentities.VmDeviceId; +import org.ovirt.engine.core.common.errors.VdcBllMessages; +import org.ovirt.engine.core.common.utils.VmDeviceType; +import org.ovirt.engine.core.compat.Guid; + +public class AddRngDeviceCommand extends AbstractRngDeviceCommand<RngDeviceParameters> { + + public AddRngDeviceCommand(RngDeviceParameters parameters) { + super(parameters); + } + + @Override + protected void executeCommand() { + VmDevice rngDevice = new VmDevice(); + rngDevice.setId(new VmDeviceId(Guid.Empty, getParameters().getRngDevice().getVmId())); + rngDevice.setDevice(VmDeviceType.VIRTIO.toString()); + rngDevice.setType(VmDeviceGeneralType.RNG); + rngDevice.setAddress(StringUtils.EMPTY); + rngDevice.setSpecParams(getParameters().getRngDevice().generateSpecParams()); + getDbFacade().getVmDeviceDao().save(rngDevice); + setSucceeded(true); + setActionReturnValue(rngDevice.getId()); + } + + protected boolean canDoAction() { + if (!super.canDoAction()) { + return false; + } + if (getParameters().getRngDevice() == null) { + return failCanDoAction(VdcBllMessages.RNG_NOT_FOUND); + } + if (!getRngDevices().isEmpty()) { + return failCanDoAction(VdcBllMessages.RNG_ALREADY_EXISTS); + } + + return true; + } +} diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddVmCommand.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddVmCommand.java index 0394530..30db855 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddVmCommand.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddVmCommand.java @@ -23,6 +23,7 @@ import org.ovirt.engine.core.common.AuditLogType; import org.ovirt.engine.core.common.VdcObjectType; import org.ovirt.engine.core.common.action.CreateSnapshotFromTemplateParameters; +import org.ovirt.engine.core.common.action.RngDeviceParameters; import org.ovirt.engine.core.common.action.VdcActionType; import org.ovirt.engine.core.common.action.VdcReturnValueBase; import org.ovirt.engine.core.common.action.VmManagementParametersBase; @@ -41,6 +42,7 @@ import org.ovirt.engine.core.common.businessentities.VmDeviceId; import org.ovirt.engine.core.common.businessentities.VmDynamic; import org.ovirt.engine.core.common.businessentities.VmPayload; +import org.ovirt.engine.core.common.businessentities.VmRngDevice; import org.ovirt.engine.core.common.businessentities.VmStatic; import org.ovirt.engine.core.common.businessentities.VmStatistics; import org.ovirt.engine.core.common.businessentities.VmType; @@ -555,6 +557,7 @@ addVmPayload(); updateSmartCardDevices(); addVmWatchdog(); + addVmRngDevice(); setActionReturnValue(getVm().getId()); setSucceeded(true); return null; @@ -585,6 +588,15 @@ } } + private void addVmRngDevice() { + VmRngDevice rngDev = getParameters().getRngDevice(); + if (rngDev != null) { + rngDev.setVmId(getParameters().getVmId()); + RngDeviceParameters params = new RngDeviceParameters(rngDev, true); + getBackend().runInternalAction(VdcActionType.AddRngDevice, params); + } + } + protected void addVmPayload() { VmPayload payload = getParameters().getVmPayload(); diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/GetRndDeviceQuery.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/GetRndDeviceQuery.java new file mode 100644 index 0000000..7a5cdda --- /dev/null +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/GetRndDeviceQuery.java @@ -0,0 +1,37 @@ +package org.ovirt.engine.core.bll; + +import java.util.Collections; +import java.util.List; +import org.ovirt.engine.core.common.businessentities.VmDevice; +import org.ovirt.engine.core.common.businessentities.VmDeviceGeneralType; +import org.ovirt.engine.core.common.businessentities.VmRngDevice; +import org.ovirt.engine.core.common.queries.IdQueryParameters; +import org.ovirt.engine.core.compat.Guid; + +public class GetRndDeviceQuery <P extends IdQueryParameters> extends QueriesCommandBase<P> { + + public GetRndDeviceQuery(P parameters) { + super(parameters); + } + + @Override + protected void executeQueryCommand() { + + final List<VmDevice> vmDevices = getDbFacade().getVmDeviceDao().getVmDeviceByVmIdAndType(getParameters().getId(), + VmDeviceGeneralType.RNG); + if (vmDevices != null && !vmDevices.isEmpty()) { + VmDevice device = vmDevices.get(0); + + Guid vmId = getParameters().getId(); + Guid id = device.getDeviceId(); + VmRngDevice.Rate devRate = new VmRngDevice.Rate(0, 0); + VmRngDevice.Backend devBackend = VmRngDevice.Backend.getBackendRandom("foo"); // TODO get info from specpars + VmRngDevice rndDev = new VmRngDevice(id, vmId, devRate,devBackend); + + setReturnValue(Collections.singletonList(rndDev)); + } else { + setReturnValue(Collections.emptyList()); + } + + } +} diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RemoveRngDeviceCommand.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RemoveRngDeviceCommand.java new file mode 100644 index 0000000..e4a51a2 --- /dev/null +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RemoveRngDeviceCommand.java @@ -0,0 +1,42 @@ +package org.ovirt.engine.core.bll; + +import java.util.HashSet; +import java.util.List; +import java.util.Set; +import org.ovirt.engine.core.common.action.RngDeviceParameters; +import org.ovirt.engine.core.common.businessentities.VmDevice; +import org.ovirt.engine.core.common.businessentities.VmDeviceId; +import org.ovirt.engine.core.common.errors.VdcBllMessages; + +public class RemoveRngDeviceCommand extends AbstractRngDeviceCommand<RngDeviceParameters> { + + RemoveRngDeviceCommand(RngDeviceParameters parameters) { + super(parameters); + } + + @Override + protected boolean canDoAction() { + if (!super.canDoAction()) { + return false; + } + + if (getRngDevices().isEmpty()) { + return failCanDoAction(VdcBllMessages.RNG_NOT_FOUND); + } + + return true; + } + + @Override + protected void executeCommand() { + List<VmDevice> rngDevices = getRngDevices(); + Set<VmDeviceId> idsToRemove = new HashSet<>(); + + for (VmDevice dev : rngDevices) { + idsToRemove.add(dev.getId()); + } + + getDbFacade().getVmDeviceDao().removeAll(idsToRemove); + setSucceeded(true); + } +} diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/UpdateRngDeviceCommand.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/UpdateRngDeviceCommand.java new file mode 100644 index 0000000..e6efa4b --- /dev/null +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/UpdateRngDeviceCommand.java @@ -0,0 +1,33 @@ +package org.ovirt.engine.core.bll; + +import org.ovirt.engine.core.common.action.RngDeviceParameters; +import org.ovirt.engine.core.common.businessentities.VmDevice; +import org.ovirt.engine.core.common.errors.VdcBllMessages; + +public class UpdateRngDeviceCommand extends AbstractRngDeviceCommand<RngDeviceParameters> { + + public UpdateRngDeviceCommand(RngDeviceParameters parameters) { + super(parameters); + } + + @Override + protected boolean canDoAction() { + if (!super.canDoAction()) { + return false; + } + + if (getRngDevices().isEmpty()) { + return failCanDoAction(VdcBllMessages.RNG_NOT_FOUND); + } + + return true; + } + + @Override + protected void executeCommand() { + VmDevice rngDevice = getRngDevices().get(0); + rngDevice.setSpecParams(getParameters().getRngDevice().generateSpecParams()); + getDbFacade().getVmDeviceDao().update(rngDevice); + setSucceeded(true); + } +} diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/UpdateVmCommand.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/UpdateVmCommand.java index 71d85f3..2223bad 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/UpdateVmCommand.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/UpdateVmCommand.java @@ -5,7 +5,6 @@ import java.util.Date; import java.util.List; import java.util.Map; - import org.apache.commons.codec.binary.Base64; import org.apache.commons.lang.ObjectUtils; import org.apache.commons.lang.StringUtils; @@ -18,6 +17,7 @@ import org.ovirt.engine.core.bll.utils.VmDeviceUtils; import org.ovirt.engine.core.common.AuditLogType; import org.ovirt.engine.core.common.VdcObjectType; +import org.ovirt.engine.core.common.action.RngDeviceParameters; import org.ovirt.engine.core.common.action.VdcActionType; import org.ovirt.engine.core.common.action.VmManagementParametersBase; import org.ovirt.engine.core.common.action.WatchdogParameters; @@ -29,6 +29,7 @@ import org.ovirt.engine.core.common.businessentities.VmDeviceGeneralType; import org.ovirt.engine.core.common.businessentities.VmDeviceId; import org.ovirt.engine.core.common.businessentities.VmPayload; +import org.ovirt.engine.core.common.businessentities.VmRngDevice; import org.ovirt.engine.core.common.businessentities.VmStatic; import org.ovirt.engine.core.common.businessentities.VmWatchdog; import org.ovirt.engine.core.common.businessentities.network.Network; @@ -89,10 +90,36 @@ updateVmPayload(); VmDeviceUtils.updateVmDevices(getParameters(), oldVm); updateWatchdog(); + updateRngDevice(); checkTrustedService(); setSucceeded(true); } + private void updateRngDevice() { + // do not update if this flag is not set + if (getParameters().isUpdateRngDevice()) { + VdcQueryReturnValue query = + getBackend().runInternalQuery(VdcQueryType.GetRngDevice, new IdQueryParameters(getParameters().getVmId())); + + @SuppressWarnings("unchecked") + List<VmRngDevice> rngDevs = (List<VmRngDevice>) query.getReturnValue(); + if (rngDevs.isEmpty()) { + if (getParameters().getRngDevice() != null) { + RngDeviceParameters params = new RngDeviceParameters(getParameters().getRngDevice(), true); + getBackend().runInternalAction(VdcActionType.AddRngDevice, params); + } + } else { + if (getParameters().getRngDevice() == null) { + RngDeviceParameters params = new RngDeviceParameters(rngDevs.get(0), true); + getBackend().runInternalAction(VdcActionType.RemoveRngDevice, params); + } else { + RngDeviceParameters params = new RngDeviceParameters(getParameters().getRngDevice(), true); + getBackend().runInternalAction(VdcActionType.UpdateRngDevice, params); + } + } + } + } + private void checkTrustedService() { AuditLogableBase logable = new AuditLogableBase(); logable.addCustomValue("VmName", getVmName()); diff --git a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/RngDeviceParameters.java b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/RngDeviceParameters.java new file mode 100644 index 0000000..94c0353 --- /dev/null +++ b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/RngDeviceParameters.java @@ -0,0 +1,23 @@ +package org.ovirt.engine.core.common.action; + +import org.ovirt.engine.core.common.businessentities.VmRngDevice; + +public class RngDeviceParameters extends VdcActionParametersBase { + + private boolean isVm = true; + private VmRngDevice rngDevice; + + public RngDeviceParameters(VmRngDevice rngDevice, boolean vm) { + this.rngDevice = rngDevice; + isVm = vm; + } + + public VmRngDevice getRngDevice() { + return rngDevice; + } + + public boolean isVm() { + return isVm; + } + +} diff --git a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/VdcActionType.java b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/VdcActionType.java index b0e17c1..53c9db1 100644 --- a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/VdcActionType.java +++ b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/VdcActionType.java @@ -289,7 +289,11 @@ AddExternalStep(1803, ActionGroup.INJECT_EXTERNAL_TASKS, false, QuotaDependency.NONE), EndExternalStep(1804, ActionGroup.INJECT_EXTERNAL_TASKS, false, QuotaDependency.NONE), - UpdateMomPolicy(1900, ActionGroup.MANIPUTLATE_HOST, false, QuotaDependency.NONE); + UpdateMomPolicy(1900, ActionGroup.MANIPUTLATE_HOST, false, QuotaDependency.NONE), + // Rng crud + AddRngDevice(1850, ActionGroup.EDIT_VM_PROPERTIES, QuotaDependency.NONE), + UpdateRngDevice(1851, ActionGroup.EDIT_VM_PROPERTIES, QuotaDependency.NONE), + RemoveRngDevice(1852, ActionGroup.EDIT_VM_PROPERTIES, QuotaDependency.NONE); private int intValue; private ActionGroup actionGroup; diff --git a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/VmManagementParametersBase.java b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/VmManagementParametersBase.java index 542e885..4eaeb29 100644 --- a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/VmManagementParametersBase.java +++ b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/VmManagementParametersBase.java @@ -7,6 +7,7 @@ import org.ovirt.engine.core.common.businessentities.DiskImage; import org.ovirt.engine.core.common.businessentities.VM; import org.ovirt.engine.core.common.businessentities.VmPayload; +import org.ovirt.engine.core.common.businessentities.VmRngDevice; import org.ovirt.engine.core.common.businessentities.VmStatic; import org.ovirt.engine.core.common.businessentities.VmWatchdog; import org.ovirt.engine.core.compat.Guid; @@ -25,7 +26,11 @@ private boolean balloonEnabled = true; private VM vm = null; private VmWatchdog watchdog = null; + private VmRngDevice rngDevice = null; private boolean copyTemplatePermissions = false; + + + //TODO updateRng for restapi /* * This parameter is needed at update to make sure that when we get a null watchdog from rest-api it is not meant to @@ -47,6 +52,8 @@ * for update the current configuration will remain */ private Boolean consoleEnabled = false; + + private boolean updateRngDevice = false; public VmManagementParametersBase() { } @@ -146,6 +153,22 @@ this.watchdog = watchdog; } + public VmRngDevice getRngDevice() { + return rngDevice; + } + + public void setRngDevice(VmRngDevice rngDevice) { + this.rngDevice = rngDevice; + } + + public boolean isUpdateRngDevice() { + return updateRngDevice; + } + + public void setUpdateRngDevice(boolean updateRngDevice) { + this.updateRngDevice = updateRngDevice; + } + public boolean isUpdateWatchdog() { return updateWatchdog; } diff --git a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VmDeviceGeneralType.java b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VmDeviceGeneralType.java index 694f27e..fb9ce92 100644 --- a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VmDeviceGeneralType.java +++ b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VmDeviceGeneralType.java @@ -52,6 +52,11 @@ CONSOLE, /** + * A random number generator device + */ + RNG, // TODO ask mperina + + /** * A smartcard device */ SMARTCARD, diff --git a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VmRngDevice.java b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VmRngDevice.java new file mode 100644 index 0000000..2921035 --- /dev/null +++ b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VmRngDevice.java @@ -0,0 +1,118 @@ +package org.ovirt.engine.core.common.businessentities; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import org.ovirt.engine.core.compat.Guid; + +/** + * This class represents paravirtualized rng device. + */ +public class VmRngDevice extends IVdcQueryable implements Serializable { + + enum Model { + RANDOM, + EGD + } + + private Guid vmId; + private Guid id; + + private Rate rate; + private Backend backend; + + public VmRngDevice(Guid id, Guid vmId, Rate rate, Backend backend) { + this.rate = rate; + this.backend = backend; + } + + public VmRngDevice(Rate rate, Backend backend) { + this.rate = rate; + this.backend = backend; + } + + public Map<String, Object> generateSpecParams() { + Map<String, Object> specPars = new HashMap<String, Object>(); + + //TODO + specPars.put("path", "test"); + return specPars; + } + + public Object getQueryableId() { + return vmId; + } + + + public Guid getVmId() { + return vmId; + } + + public void setVmId(Guid id) { + this.vmId = id; + } + + public Guid getId() { + return id; + } + + public void setId(Guid id) { + this.id = id; + } + +// Encapsulation classes: + + public static class Rate implements Serializable { + int period; + int bytes; + + public Rate(int period, int bytes) { + this.period = period; + this.bytes = bytes; + } + } + + /** + * This class encapsulates backend for rng device. + */ + public static class Backend implements Serializable { + + Model model; + String path; + + /** + * Representation of a single source parameters for rng backend. + * (represented in libvirt e.g. like <source param1="val1" param2="val2/>) + */ + public static class Source implements Serializable { + List<Map<String, String>> params; + + public Source(List<Map<String, String>> params) { + this.params = params; + } + + public List<Map<String, String>> getParams() { + return params; + } + } + + private Backend(Model model, String path) { + this.model = model; + this.path = path; + } + + private Backend(Model model, List<Source> sources) { + this.model = model; + } + + public static Backend getBackendRandom(String path) { + return new Backend(Model.RANDOM, path); + } + + public static Backend getBackendEgd(List<Source> sources) { + return new Backend(Model.EGD, sources); + } + } + +} diff --git a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/errors/VdcBllMessages.java b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/errors/VdcBllMessages.java index 02e3be2..87c20d0 100644 --- a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/errors/VdcBllMessages.java +++ b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/errors/VdcBllMessages.java @@ -537,6 +537,7 @@ ACTION_TYPE_FAILED_BOOKMARK_INVALID_ID(ErrorType.BAD_PARAMETERS), VDS_FENCE_OPERATION_FAILED(ErrorType.CONFLICT), ACTION_NOT_SUPPORTED_FOR_CLUSTER_POOL_LEVEL(ErrorType.INCOMPATIBLE_VERSION), + ACTION_NOT_SUPPORTED_FOR_CLUSTER_LEVEL(ErrorType.INCOMPATIBLE_VERSION), CAN_DO_ACTION_GENERAL_FAILURE(ErrorType.INTERNAL_ERROR), CAN_DO_ACTION_DATABASE_CONNECTION_FAILURE(ErrorType.INTERNAL_ERROR), /** @deprecated as it is too general error message */ @@ -768,6 +769,11 @@ WATCHDOG_ACTION_REQUIRED(ErrorType.BAD_PARAMETERS), WATCHDOG_MODEL_REQUIRED(ErrorType.BAD_PARAMETERS), + //rng device + RNG_NOT_FOUND(ErrorType.BAD_PARAMETERS), + RNG_ALREADY_EXISTS(ErrorType.CONFLICT), + RNG_MSG(ErrorType.BAD_PARAMETERS), + // network QoS ACTION_TYPE_FAILED_NETWORK_QOS_MISSING_VALUES(ErrorType.BAD_PARAMETERS), ACTION_TYPE_FAILED_NETWORK_QOS_NEGATIVE_VALUES(ErrorType.BAD_PARAMETERS), diff --git a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/queries/VdcQueryType.java b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/queries/VdcQueryType.java index c3c2040..fe819a6 100644 --- a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/queries/VdcQueryType.java +++ b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/queries/VdcQueryType.java @@ -276,6 +276,7 @@ GetWatchdog(VdcQueryAuthType.User), GetConsoleDevices(VdcQueryAuthType.User), + GetRngDevice(VdcQueryAuthType.User), GetDeviceCustomProperties(VdcQueryAuthType.User), diff --git a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/utils/VmDeviceType.java b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/utils/VmDeviceType.java index db2d69e..bb271ac 100644 --- a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/utils/VmDeviceType.java +++ b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/utils/VmDeviceType.java @@ -22,6 +22,7 @@ SMARTCARD("smartcard"), BALLOON("balloon"), CONSOLE("console"), + VIRTIO("virtio"), WATCHDOG("watchdog"), OTHER("other", "0"), UNKNOWN("unknown", "-1"); diff --git a/frontend/webadmin/modules/gwt-common/src/main/resources/org/ovirt/engine/core/Common.gwt.xml b/frontend/webadmin/modules/gwt-common/src/main/resources/org/ovirt/engine/core/Common.gwt.xml index ade328e..f217f1e 100644 --- a/frontend/webadmin/modules/gwt-common/src/main/resources/org/ovirt/engine/core/Common.gwt.xml +++ b/frontend/webadmin/modules/gwt-common/src/main/resources/org/ovirt/engine/core/Common.gwt.xml @@ -158,6 +158,7 @@ <include name="common/businessentities/VmWatchdog.java" /> <include name="common/businessentities/VmWatchdogAction.java" /> <include name="common/businessentities/VmWatchdogType.java" /> + <include name="common/businessentities/VmRngDevice.java" /> <include name="common/job/*.java" /> <!-- Quota --> diff --git a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/VmListModel.java b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/VmListModel.java index c9f19b8..f0f9e29 100644 --- a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/VmListModel.java +++ b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/VmListModel.java @@ -38,6 +38,7 @@ import org.ovirt.engine.core.common.businessentities.UsbPolicy; import org.ovirt.engine.core.common.businessentities.VDS; import org.ovirt.engine.core.common.businessentities.VM; +import org.ovirt.engine.core.common.businessentities.VmRngDevice; import org.ovirt.engine.core.common.businessentities.VmTemplate; import org.ovirt.engine.core.common.businessentities.VmType; import org.ovirt.engine.core.common.businessentities.VmWatchdog; @@ -2039,6 +2040,13 @@ parameters.setConsoleEnabled((Boolean) model.getIsConsoleDeviceEnabled().getEntity()); parameters.setBalloonEnabled(balloonEnabled(model)); + // MOCK + VmRngDevice.Rate rate = new VmRngDevice.Rate(1, 2); + VmRngDevice.Backend backend = VmRngDevice.Backend.getBackendRandom("/dev/myrandom"); //$NON-NLS-1$ + VmRngDevice rng = new VmRngDevice(rate, backend); + parameters.setRngDevice(rng); + // MOCK + setVmWatchdogToParams(model, parameters); Frontend.RunAction(VdcActionType.AddVmFromScratch, parameters, new NetworkCreateFrontendAsyncCallback(model, addVmFromScratchNetworkManager), this); -- To view, visit http://gerrit.ovirt.org/18176 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ifc26a484c84244074426f4b0c790e2cc4ebb8da6 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Frank Kobzik <[email protected]> _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
