Frank Kobzik has uploaded a new change for review.

Change subject: frontend: RNG device sources reporting
......................................................................

frontend: RNG device sources reporting

This is a follow-up to original VirtIO RNG patches (18176, 18497).

This patch adds
 - required rng sources to cluster (set by admin),
 - supported rng sources to host (reported by VDSM).

The host-supported rng sources must comply with cluster-required rng
sources, otherwise corresponding host is set to non-operational state.

Frontend changes:
- added checkboxes for required rng sources on Cluster view (checkboxes
  for 'random' and 'hwrng' sources are added)

Change-Id: Ifd065835d18575b686ee805b032662205b31c966
Signed-off-by: Frantisek Kobzik <fkob...@redhat.com>
Bug-Url: https://bugzilla.redhat.com/977079
---
M 
frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/CommonApplicationConstants.java
M 
frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/clusters/ClusterListModel.java
M 
frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/clusters/ClusterModel.java
M 
frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/VmListModel.java
M 
frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/VmModelBehaviorBase.java
M 
frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/cluster/ClusterPopupView.java
M 
frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/cluster/ClusterPopupView.ui.xml
7 files changed, 152 insertions(+), 13 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/59/22259/1

diff --git 
a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/CommonApplicationConstants.java
 
b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/CommonApplicationConstants.java
index 06ea3d9..9ee2850 100644
--- 
a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/CommonApplicationConstants.java
+++ 
b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/CommonApplicationConstants.java
@@ -1626,4 +1626,7 @@
 
     @DefaultStringValue("Random Generator")
     String rngDeviceTab();
+
+    @DefaultStringValue("Required Random Number Generator sources:")
+    String requiredRngSources();
 }
diff --git 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/clusters/ClusterListModel.java
 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/clusters/ClusterListModel.java
index 957a2d9..40b10cf 100644
--- 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/clusters/ClusterListModel.java
+++ 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/clusters/ClusterListModel.java
@@ -15,6 +15,7 @@
 import org.ovirt.engine.core.common.businessentities.VDSGroup;
 import org.ovirt.engine.core.common.businessentities.VDSStatus;
 import org.ovirt.engine.core.common.businessentities.VM;
+import org.ovirt.engine.core.common.businessentities.VmRngDevice;
 import 
org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity;
 import org.ovirt.engine.core.common.interfaces.SearchType;
 import org.ovirt.engine.core.common.queries.IdQueryParameters;
@@ -695,6 +696,14 @@
         cluster.setClusterPolicyId(((ClusterPolicy) 
model.getClusterPolicy().getSelectedItem()).getId());
         
cluster.setClusterPolicyProperties(KeyValueModel.convertProperties(model.getCustomPropertySheet().getEntity()));
 
+        cluster.getRequiredRngSources().clear();
+        if 
(Boolean.TRUE.equals(model.getRngRandomSourceRequired().getEntity())) {
+            cluster.getRequiredRngSources().add(VmRngDevice.Source.RANDOM);
+        }
+        if 
(Boolean.TRUE.equals(model.getRngHwrngSourceRequired().getEntity())) {
+            cluster.getRequiredRngSources().add(VmRngDevice.Source.HWRNG);
+        }
+
         model.startProgress(null);
 
         Frontend.RunAction(model.getIsNew() ? VdcActionType.AddVdsGroup : 
VdcActionType.UpdateVdsGroup,
diff --git 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/clusters/ClusterModel.java
 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/clusters/ClusterModel.java
index a41a690..a2a7949 100644
--- 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/clusters/ClusterModel.java
+++ 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/clusters/ClusterModel.java
@@ -10,7 +10,9 @@
 import org.ovirt.engine.core.common.businessentities.StoragePool;
 import org.ovirt.engine.core.common.businessentities.StorageType;
 import org.ovirt.engine.core.common.businessentities.VDSGroup;
+import org.ovirt.engine.core.common.businessentities.VmRngDevice;
 import org.ovirt.engine.core.common.mode.ApplicationMode;
+import org.ovirt.engine.core.common.queries.ConfigurationValues;
 import org.ovirt.engine.core.common.queries.VdcQueryParametersBase;
 import org.ovirt.engine.core.common.queries.VdcQueryReturnValue;
 import org.ovirt.engine.core.common.queries.VdcQueryType;
@@ -43,6 +45,8 @@
 {
     private Map<Guid, PolicyUnit> policyUnitMap;
     private ListModel clusterPolicy;
+    private static final String RANDOM = "random"; //$NON-NLS-1$
+    private static final String HWRNG = "hwrng"; //$NON-NLS-1$
 
     public ListModel getClusterPolicy() {
         return clusterPolicy;
@@ -219,6 +223,26 @@
     public void setCPU(ListModel value)
     {
         privateCPU = value;
+    }
+
+    EntityModel<Boolean> rngRandomSourceRequired;
+
+    public EntityModel<Boolean> getRngRandomSourceRequired() {
+        return rngRandomSourceRequired;
+    }
+
+    public void setRngRandomSourceRequired(EntityModel<Boolean> 
rngRandomSourceRequired) {
+        this.rngRandomSourceRequired = rngRandomSourceRequired;
+    }
+
+    EntityModel<Boolean> rngHwrngSourceRequired;
+
+    public EntityModel<Boolean> getRngHwrngSourceRequired() {
+        return rngHwrngSourceRequired;
+    }
+
+    public void setRngHwrngSourceRequired(EntityModel<Boolean> 
rngHwrngSourceRequired) {
+        this.rngHwrngSourceRequired = rngHwrngSourceRequired;
     }
 
     private ListModel privateVersion;
@@ -637,8 +661,7 @@
         super();
     }
 
-    public void init(final boolean isEdit)
-    {
+    public void init(final boolean isEdit) {
         setIsEdit(isEdit);
         setName(new EntityModel());
         setDescription(new EntityModel());
@@ -686,6 +709,9 @@
         
getEnableOvirtService().setEntity(ApplicationModeHelper.isModeSupported(ApplicationMode.VirtOnly));
         
getEnableOvirtService().setIsAvailable(ApplicationModeHelper.getUiMode() != 
ApplicationMode.VirtOnly
                 && 
ApplicationModeHelper.isModeSupported(ApplicationMode.VirtOnly));
+
+        setRngRandomSourceRequired(new EntityModel<Boolean>());
+        setRngHwrngSourceRequired(new EntityModel<Boolean>());
 
         initImportCluster(isEdit);
 
@@ -867,6 +893,9 @@
         setVersion(new ListModel());
         getVersion().getSelectedItemChangedEvent().addListener(this);
         setMigrateOnErrorOption(MigrateOnErrorOptions.YES);
+
+        getRngRandomSourceRequired().setEntity(false);
+        getRngHwrngSourceRequired().setEntity(false);
 
         setIsGeneralTabValid(true);
         setIsResiliencePolicyTabAvailable(true);
@@ -1140,6 +1169,28 @@
         
getVersionSupportsCpuThreads().setEntity(version.compareTo(Version.v3_2) >= 0);
         
getEnableBallooning().setChangeProhibitionReason(ConstantsManager.getInstance().getConstants().ballooningNotAvailable());
         getEnableBallooning().setIsChangable(version.compareTo(Version.v3_3) 
>= 0);
+
+        setRngSourcesCheckboxes(version);
+    }
+
+    private void setRngSourcesCheckboxes(Version ver) {
+        boolean rngSupported = isRngSupportedForClusterVersion(ver);
+        getRngRandomSourceRequired().setIsAvailable(rngSupported);
+        getRngHwrngSourceRequired().setIsAvailable(rngSupported);
+
+        String defaultRequiredRngSourcesCsv = defaultClusterRngSourcesCsv(ver);
+
+        if (rngSupported) {
+            getRngRandomSourceRequired().setEntity(getIsNew()
+                    ? 
defaultRequiredRngSourcesCsv.contains(VmRngDevice.Source.RANDOM.toString())
+                    : 
getEntity().getRequiredRngSources().contains(VmRngDevice.Source.RANDOM));
+            getRngHwrngSourceRequired().setEntity(getIsNew()
+                    ? 
defaultRequiredRngSourcesCsv.contains(VmRngDevice.Source.HWRNG.toString())
+                    : 
getEntity().getRequiredRngSources().contains(VmRngDevice.Source.HWRNG));
+        } else { // reset
+            getRngRandomSourceRequired().setEntity(false);
+            getRngHwrngSourceRequired().setEntity(false);
+        }
     }
 
     private void initCPU()
@@ -1274,6 +1325,8 @@
 
         getVersion().validateSelectedItem(new IValidation[] { new 
NotEmptyValidation() });
 
+        validateRngRequiredSource();
+
         // TODO: async validation for webadmin
         // string name = (string)Name.Entity;
 
@@ -1312,16 +1365,38 @@
         setIsGeneralTabValid(getName().getIsValid() && 
getDataCenter().getIsValid() && getCPU().getIsValid()
                 && getVersion().getIsValid() && validService && 
getGlusterHostAddress().getIsValid()
                 && getGlusterHostPassword().getIsValid()
+                && getRngRandomSourceRequired().getIsValid()
+                && getRngHwrngSourceRequired().getIsValid()
                 && ((Boolean) getIsImportGlusterConfiguration().getEntity() ? 
(getGlusterHostAddress().getIsValid()
                         && getGlusterHostPassword().getIsValid()
                         && isFingerprintVerified()) : true));
 
-        return getName().getIsValid() && getDataCenter().getIsValid() && 
getCPU().getIsValid()
-                && getVersion().getIsValid() && validService && 
getGlusterHostAddress().getIsValid()
-                && getGlusterHostPassword().getIsValid()
-                && ((Boolean) getIsImportGlusterConfiguration().getEntity() ? 
(getGlusterHostAddress().getIsValid()
-                        && getGlusterHostPassword().getIsValid()
-                        && isFingerprintVerified()) : true) && 
getCustomPropertySheet().getIsValid();
+        return getIsGeneralTabValid() && getCustomPropertySheet().getIsValid();
     }
 
+    private void validateRngRequiredSource() {
+        Version cluVersion = (Version) getVersion().getSelectedItem();
+        boolean rngSupportedForCluster = 
isRngSupportedForClusterVersion(cluVersion);
+
+        getRngRandomSourceRequired().setIsValid(rngSupportedForCluster);
+        getRngHwrngSourceRequired().setIsValid(rngSupportedForCluster);
+    }
+
+    private boolean isRngSupportedForClusterVersion(Version ver) {
+        if (ver == null) {
+            return false;
+        }
+
+        Boolean supported = (Boolean) 
AsyncDataProvider.getConfigValuePreConverted(ConfigurationValues.VirtIoRngDeviceSupported,
 ver.toString());
+        return (supported == null)
+                ? false
+                : supported;
+    }
+
+    private String defaultClusterRngSourcesCsv(Version ver) {
+        String srcs = (String) 
AsyncDataProvider.getConfigValuePreConverted(ConfigurationValues.ClusterRequiredRngSourcesDefault,
 ver.toString());
+        return (srcs == null)
+                ? ""
+                : srcs;
+    }
 }
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 ad3d4fdc..cb2d9d7 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
@@ -2139,7 +2139,10 @@
 
     private void setRngDeviceToParams(UnitVmModel model, 
VmManagementParametersBase parameters) {
         parameters.setUpdateRngDevice(true);
-        parameters.setRngDevice((Boolean) model.getIsRngEnabled().getEntity() 
? model.generateRngDevice() : null);
+        boolean rngEnabledAndValid = (Boolean) 
model.getIsRngEnabled().getEntity() && 
!model.getSelectedCluster().getRequiredRngSources().isEmpty();
+        parameters.setRngDevice(rngEnabledAndValid
+                ? model.generateRngDevice()
+                : null);
     }
 
     private void retrieveIsoImages()
diff --git 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/VmModelBehaviorBase.java
 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/VmModelBehaviorBase.java
index 27d5d2b..853d503 100644
--- 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/VmModelBehaviorBase.java
+++ 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/VmModelBehaviorBase.java
@@ -93,12 +93,26 @@
             getModel().getQuota().setIsAvailable(false);
         }
 
-        
getModel().getIsRngEnabled().setIsChangable(isRngDeviceSupported(getModel()));
-        getModel().getIsRngEnabled().setMessage(constants.rngNotSupported());
+        setRngAvailability();
 
         postDataCenterWithClusterSelectedItemChanged();
     }
 
+    private void setRngAvailability() {
+        TModel model = getModel();
+        Set<VmRngDevice.Source> requiredRngSources = 
model.getSelectedCluster().getRequiredRngSources();
+        model.getIsRngEnabled().setIsChangable(!requiredRngSources.isEmpty());
+        
model.getIsRngEnabled().setMessage(constants.rngNotSupportedByCluster());
+        model.getRngPeriod().setIsChangable(!requiredRngSources.isEmpty());
+        model.getRngPeriod().setMessage(constants.rngNotSupportedByCluster());
+        model.getRngBytes().setIsChangable(!requiredRngSources.isEmpty());
+        model.getRngBytes().setMessage(constants.rngNotSupportedByCluster());
+        
model.getRngSourceRandom().setIsChangable(requiredRngSources.contains(VmRngDevice.Source.RANDOM));
+        
model.getRngSourceRandom().setMessage(messages.rngSourceNotSupportedByCluster(VmRngDevice.Source.RANDOM.toString()));
+        
model.getRngSourceHwrng().setIsChangable(requiredRngSources.contains(VmRngDevice.Source.HWRNG));
+        
model.getRngSourceHwrng().setMessage(messages.rngSourceNotSupportedByCluster(VmRngDevice.Source.HWRNG.toString()));
+    }
+
     protected void updateMigrationForLocalSD() {
         boolean isLocalSD =
                 getModel().getSelectedDataCenter() != null
diff --git 
a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/cluster/ClusterPopupView.java
 
b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/cluster/ClusterPopupView.java
index 2f994c9..f69dfb4 100644
--- 
a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/cluster/ClusterPopupView.java
+++ 
b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/cluster/ClusterPopupView.java
@@ -156,6 +156,20 @@
     Label messageLabel;
 
     @UiField
+    @Ignore
+    Label rngLabel;
+
+    @UiField(provided = true)
+    @Path(value = "rngRandomSourceRequired.entity")
+    @WithElementId
+    org.ovirt.engine.ui.common.widget.editor.generic.EntityModelCheckBoxEditor 
rngRandomSourceRequired;
+
+    @UiField(provided = true)
+    @Path(value = "rngHwrngSourceRequired.entity")
+    @WithElementId
+    org.ovirt.engine.ui.common.widget.editor.generic.EntityModelCheckBoxEditor 
rngHwrngSourceRequired;
+
+    @UiField
     @WithElementId
     DialogTab optimizationTab;
 
@@ -303,6 +317,10 @@
         
glusterHostFingerprintEditor.setLabel(constants.hostPopupHostFingerprintLabel());
         glusterHostPasswordEditor.setLabel(constants.hostPopupPasswordLabel());
 
+        rngLabel.setText(constants.requiredRngSources());
+        rngRandomSourceRequired.setLabel(constants.rngSourceRandom());
+        rngHwrngSourceRequired.setLabel(constants.rngSourceHwrng());
+
         optimizationTab.setLabel(constants.clusterPopupOptimizationTabLabel());
 
         
memoryOptimizationPanelTitle.setText(constants.clusterPopupMemoryOptimizationPanelTitle());
@@ -382,6 +400,9 @@
 
         enableBallooning = new EntityModelCheckBoxEditor(Align.RIGHT);
         enableBallooning.getContentWidgetContainer().setWidth("350px"); 
//$NON-NLS-1$
+
+        rngRandomSourceRequired = new 
org.ovirt.engine.ui.common.widget.editor.generic.EntityModelCheckBoxEditor(Align.RIGHT);
+        rngHwrngSourceRequired = new 
org.ovirt.engine.ui.common.widget.editor.generic.EntityModelCheckBoxEditor(Align.RIGHT);
     }
 
     private void initInfoIcons(ApplicationResources resources, 
ApplicationConstants constants, ApplicationTemplates templates)
@@ -466,8 +487,15 @@
             }
         });
 
-        
object.getCustomPropertySheet().getKeyValueLines().getItemsChangedEvent().addListener(new
 IEventListener() {
+        object.getVersion().getEntityChangedEvent().addListener(new 
IEventListener() {
+            @Override
+            public void eventRaised(Event ev, Object sender, EventArgs args) {
+                
rngLabel.setVisible(object.getRngRandomSourceRequired().getIsAvailable()
+                            && 
object.getRngHwrngSourceRequired().getIsAvailable());
+            }
+        });
 
+        
object.getCustomPropertySheet().getKeyValueLines().getItemsChangedEvent().addListener(new
 IEventListener() {
             @Override
             public void eventRaised(Event ev, Object sender, EventArgs args) {
                 
customPropertiesSheetEditor.edit(object.getCustomPropertySheet());
diff --git 
a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/cluster/ClusterPopupView.ui.xml
 
b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/cluster/ClusterPopupView.ui.xml
index 461122f..c18b422 100644
--- 
a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/cluster/ClusterPopupView.ui.xml
+++ 
b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/cluster/ClusterPopupView.ui.xml
@@ -2,6 +2,7 @@
 <!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent";>
 <ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder"
        xmlns:g="urn:import:com.google.gwt.user.client.ui" 
xmlns:d="urn:import:org.ovirt.engine.ui.common.widget.dialog"
+    xmlns:ge="urn:import:org.ovirt.engine.ui.common.widget.editor.generic"
        xmlns:e="urn:import:org.ovirt.engine.ui.common.widget.editor" 
xmlns:t="urn:import:org.ovirt.engine.ui.common.widget.dialog.tab"
        xmlns:f="urn:import:org.ovirt.engine.ui.common.widget.form"
        xmlns:k="urn:import:org.ovirt.engine.ui.common.widget.form.key_value">
@@ -171,7 +172,13 @@
                                                                
<e:EntityModelTextAreaLabelEditor addStyleNames="{style.fingerprintLabel}" 
ui:field="glusterHostFingerprintEditor" />
                                                                
<e:EntityModelPasswordBoxEditor ui:field="glusterHostPasswordEditor" />
                                                                <g:Label 
ui:field="messageLabel" addStyleNames="{style.messageLabel}" />
-                                                       </g:FlowPanel>
+
+                                <g:FlowPanel>
+                                    <g:Label ui:field="rngLabel"  
addStyleNames="{style.panelTitle}" />
+                                    <ge:EntityModelCheckBoxEditor 
ui:field="rngRandomSourceRequired" />
+                                    <ge:EntityModelCheckBoxEditor 
ui:field="rngHwrngSourceRequired" />
+                                </g:FlowPanel>
+                            </g:FlowPanel>
                                                </t:content>
                                        </t:DialogTab>
                                </t:tab>


-- 
To view, visit http://gerrit.ovirt.org/22259
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ifd065835d18575b686ee805b032662205b31c966
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Frank Kobzik <fkob...@redhat.com>
_______________________________________________
Engine-patches mailing list
Engine-patches@ovirt.org
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to