Dima Kuznetsov has uploaded a new change for review.

Change subject: webadmin: Add selinux state to host general subtab
......................................................................

webadmin: Add selinux state to host general subtab

Add selinux enforce mode display to host general subtab

Change-Id: If8067594169e46f8b09cc8b6247660da6e10de80
Signed-off-by: Dima Kuznetsov <[email protected]>
---
A 
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/SELinuxEnforcementState.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/hosts/HostGeneralModel.java
M 
frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/UIConstants.java
M 
frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/ApplicationConstants.java
M 
frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/tab/host/SubTabHostGeneralView.java
6 files changed, 84 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/62/26962/1

diff --git 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/SELinuxEnforcementState.java
 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/SELinuxEnforcementState.java
new file mode 100644
index 0000000..dd31f83
--- /dev/null
+++ 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/SELinuxEnforcementState.java
@@ -0,0 +1,36 @@
+package org.ovirt.engine.core.common.businessentities;
+
+/**
+ * Created by dkuznets on 4/13/14.
+ */
+import java.util.EnumSet;
+import java.util.HashMap;
+
+public enum SELinuxEnforcementState {
+    NO_SELINUX(-2),
+    DISABLED(-1),
+    PERMISSIVE(0),
+    ENABLED(1);
+
+    private int intValue;
+    private static final HashMap<Integer, SELinuxEnforcementState> mappings =
+            new HashMap<Integer, SELinuxEnforcementState>();
+
+    static {
+        for (SELinuxEnforcementState status : 
EnumSet.allOf(SELinuxEnforcementState.class)) {
+            mappings.put(status.getValue(), status);
+        }
+    }
+
+    private SELinuxEnforcementState(int value) {
+        intValue = value;
+    }
+
+    public int getValue() {
+        return intValue;
+    }
+
+    public static SELinuxEnforcementState forValue(int value) {
+        return mappings.get(value);
+    }
+}
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 2d34284..acbe0e0 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
@@ -178,6 +178,7 @@
                <include name="common/businessentities/InstanceType.java" />
                <include name="common/businessentities/ImageType.java" />
                <include 
name="common/businessentities/SnapshotActionEnum.java"/>
+               <include 
name="common/businessentities/SELinuxEnforcementState.java"/>
                <include name="common/job/*.java" />
 
                <!-- Quota -->
diff --git 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/hosts/HostGeneralModel.java
 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/hosts/HostGeneralModel.java
index 9b0c6de..cb44a4d 100644
--- 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/hosts/HostGeneralModel.java
+++ 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/hosts/HostGeneralModel.java
@@ -9,6 +9,7 @@
 import org.ovirt.engine.core.common.action.VdcActionType;
 import org.ovirt.engine.core.common.action.VdsActionParameters;
 import org.ovirt.engine.core.common.businessentities.NonOperationalReason;
+import org.ovirt.engine.core.common.businessentities.SELinuxEnforcementState;
 import org.ovirt.engine.core.common.businessentities.VDS;
 import org.ovirt.engine.core.common.businessentities.VDSStatus;
 import org.ovirt.engine.core.common.businessentities.VdsSpmStatus;
@@ -881,6 +882,37 @@
         onPropertyChanged(new PropertyChangedEventArgs("bootTime")); 
//$NON-NLS-1$
     }
 
+    private SELinuxEnforcementState selinuxState = 
SELinuxEnforcementState.NO_SELINUX;
+
+    public String getSelinuxState() {
+        switch (selinuxState) {
+            case DISABLED:
+                return constants.disabled();
+            case PERMISSIVE:
+                return constants.permissive();
+            case ENABLED:
+                return constants.enabled();
+            case NO_SELINUX:
+            default:
+                return constants.notAvailableLabel();
+        }
+    }
+
+    public void setSelinuxState(Integer enforce_mode) {
+        SELinuxEnforcementState newState;
+        if (enforce_mode == null || enforce_mode < -1 || enforce_mode > 1) {
+            // Shouldn't be null or < -1, > 1
+            newState = SELinuxEnforcementState.NO_SELINUX;
+        } else {
+            newState = SELinuxEnforcementState.forValue(enforce_mode);
+        }
+
+        if (!newState.equals(selinuxState)) {
+            selinuxState = newState;
+            onPropertyChanged(new PropertyChangedEventArgs("selinuxState")); 
//$NON-NLS-1$
+        }
+    }
+
     static
     {
         requestEditEventDefinition = new EventDefinition("RequestEditEvent", 
HostGeneralModel.class); //$NON-NLS-1$
@@ -1003,6 +1035,7 @@
         setMemoryPageSharing(vds.getKsmState());
         setAutomaticLargePage(vds.getTransparentHugePagesState());
         setBootTime(vds.getBootTime());
+        setSelinuxState(vds.getSELinuxEnforceMode());
 
         if (!vds.getHighlyAvailableIsConfigured()) {
             setHostedEngineHaIsConfigured(false);
diff --git 
a/frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/UIConstants.java
 
b/frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/UIConstants.java
index 121babc..b692575 100644
--- 
a/frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/UIConstants.java
+++ 
b/frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/UIConstants.java
@@ -2236,5 +2236,14 @@
 
     @DefaultStringValue("When the VM is running, cannot activate a disk 
attached with IDE interface.")
     String cannotHotPlugDiskWithIdeInterface();
+
+    @DefaultStringValue("Enabled")
+    String enabled();
+
+    @DefaultStringValue("Disabled")
+    String disabled();
+
+    @DefaultStringValue("Permissive")
+    String permissive();
 }
 
diff --git 
a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/ApplicationConstants.java
 
b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/ApplicationConstants.java
index 87a3e6f..98e6a87 100644
--- 
a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/ApplicationConstants.java
+++ 
b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/ApplicationConstants.java
@@ -1449,6 +1449,9 @@
     @DefaultStringValue("Boot Time")
     String bootTimeHostGeneral();
 
+    @DefaultStringValue("SELinux enforcement")
+    String selinuxStateGeneral();
+
     // Storage
     @DefaultStringValue("Domain Name")
     String domainNameStorage();
diff --git 
a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/tab/host/SubTabHostGeneralView.java
 
b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/tab/host/SubTabHostGeneralView.java
index f8e2529..bbfb99c 100644
--- 
a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/tab/host/SubTabHostGeneralView.java
+++ 
b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/tab/host/SubTabHostGeneralView.java
@@ -70,6 +70,7 @@
     TextBoxLabel spmPriority = new TextBoxLabel();
     TextBoxLabel hostedEngineHa = new TextBoxLabel();
     FullDateTimeLabel bootTime = new FullDateTimeLabel();
+    TextBoxLabel selinuxState = new TextBoxLabel();
 
     MemorySizeTextBoxLabel<Integer> physicalMemory;
     MemorySizeTextBoxLabel<Integer> usedMemory;
@@ -164,6 +165,7 @@
         formBuilder.addFormItem(new 
FormItem(constants.memPageSharingHostGeneral(), memoryPageSharing, 
2).withAutoPlacement());
         formBuilder.addFormItem(new 
FormItem(constants.autoLargePagesHostGeneral(), automaticLargePage, 
2).withAutoPlacement());
         formBuilder.addFormItem(new 
FormItem(constants.isciInitNameHostGeneral(), iScsiInitiatorName, 2, 
virtSupported).withAutoPlacement());
+        formBuilder.addFormItem(new FormItem(constants.selinuxStateGeneral(), 
selinuxState, 2).withAutoPlacement());
     }
 
     void initMemorySizeLabels() {


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: If8067594169e46f8b09cc8b6247660da6e10de80
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Dima Kuznetsov <[email protected]>
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to