Shireesh Anjal has uploaded a new change for review.

Change subject: gluster: Log details of option being set
......................................................................

gluster: Log details of option being set

Modified the audit log message for setting a volume option
to include the key and value of the option, so that user
knows exactly what option was set to what value.

Change-Id: Icd42c40562c06993496bf25c4275415b42ff191b
Signed-off-by: Shireesh Anjal <san...@redhat.com>
---
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/CreateGlusterVolumeCommand.java
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/SetGlusterVolumeOptionCommand.java
M 
backend/manager/modules/dal/src/main/resources/bundles/AuditLogMessages.properties
3 files changed, 22 insertions(+), 4 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/29/11129/1

diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/CreateGlusterVolumeCommand.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/CreateGlusterVolumeCommand.java
index 5b766c6..4fd9c66 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/CreateGlusterVolumeCommand.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/CreateGlusterVolumeCommand.java
@@ -25,6 +25,7 @@
 import 
org.ovirt.engine.core.common.vdscommands.gluster.CreateGlusterVolumeVDSParameters;
 import org.ovirt.engine.core.dal.VdcBllMessages;
 import org.ovirt.engine.core.dal.dbbroker.DbFacade;
+import org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogDirector;
 
 /**
  * BLL command to create a new Gluster Volume
@@ -135,6 +136,12 @@
         setVolumeType(createdVolume);
         setBrickOrder(createdVolume.getBricks());
         addVolumeToDb(createdVolume);
+
+        // If we log successful volume creation at the end of this command,
+        // the messages from SetGlusterVolumeOptionCommand appear first,
+        // making it look like options were set before volume was created.
+        // Hence we explicitly log the volume creation before setting the 
options.
+        AuditLogDirector.log(this, AuditLogType.GLUSTER_VOLUME_CREATE);
 
         // set all options of the volume
         setVolumeOptions(createdVolume);
@@ -263,10 +270,11 @@
 
     @Override
     public AuditLogType getAuditLogTypeValue() {
-        if (getSucceeded()) {
-            return AuditLogType.GLUSTER_VOLUME_CREATE;
-        } else {
+        if (!getSucceeded()) {
+            // Success need not be logged at the end of execution,
+            // as it is already logged by executeCommand()
             return errorType == null ? 
AuditLogType.GLUSTER_VOLUME_CREATE_FAILED : errorType;
         }
+        return super.getAuditLogTypeValue();
     }
 }
diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/SetGlusterVolumeOptionCommand.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/SetGlusterVolumeOptionCommand.java
index ed07d71..1d4f997 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/SetGlusterVolumeOptionCommand.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/SetGlusterVolumeOptionCommand.java
@@ -1,10 +1,13 @@
 package org.ovirt.engine.core.bll.gluster;
 
+import java.util.Map;
+
 import org.ovirt.engine.core.bll.LockIdNameAttribute;
 import org.ovirt.engine.core.bll.NonTransactiveCommandAttribute;
 import org.ovirt.engine.core.common.AuditLogType;
 import 
org.ovirt.engine.core.common.action.gluster.GlusterVolumeOptionParameters;
 import 
org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeOptionEntity;
+import org.ovirt.engine.core.common.constants.gluster.GlusterConstants;
 import org.ovirt.engine.core.common.vdscommands.VDSCommandType;
 import org.ovirt.engine.core.common.vdscommands.VDSReturnValue;
 import 
org.ovirt.engine.core.common.vdscommands.gluster.GlusterVolumeOptionVDSParameters;
@@ -23,6 +26,13 @@
     }
 
     @Override
+    public Map<String, String> getCustomValues() {
+        AddCustomValue(GlusterConstants.OPTION_KEY, 
getParameters().getVolumeOption().getKey());
+        AddCustomValue(GlusterConstants.OPTION_VALUE, 
getParameters().getVolumeOption().getValue());
+        return super.getCustomValues();
+    }
+
+    @Override
     protected void setActionMessageParameters() {
         addCanDoActionMessage(VdcBllMessages.VAR__ACTION__SET);
         addCanDoActionMessage(VdcBllMessages.VAR__TYPE__GLUSTER_VOLUME_OPTION);
diff --git 
a/backend/manager/modules/dal/src/main/resources/bundles/AuditLogMessages.properties
 
b/backend/manager/modules/dal/src/main/resources/bundles/AuditLogMessages.properties
index 59ab260..d1358bd 100644
--- 
a/backend/manager/modules/dal/src/main/resources/bundles/AuditLogMessages.properties
+++ 
b/backend/manager/modules/dal/src/main/resources/bundles/AuditLogMessages.properties
@@ -539,7 +539,7 @@
 # Gluster Messages
 GLUSTER_VOLUME_CREATE=Gluster Volume ${glusterVolumeName} created.
 GLUSTER_VOLUME_CREATE_FAILED=Creation of Gluster Volume ${glusterVolumeName} 
failed.
-GLUSTER_VOLUME_OPTION_SET=Volume Option set on  ${glusterVolumeName}.
+GLUSTER_VOLUME_OPTION_SET=Volume Option ${Key}=${Value} set on 
${glusterVolumeName}.
 GLUSTER_VOLUME_OPTION_SET_FAILED=Volume Option could not be set on 
${glusterVolumeName}.
 GLUSTER_VOLUME_START=Gluster Volume ${glusterVolumeName} started.
 GLUSTER_VOLUME_START_FAILED=Could not start Gluster Volume 
${glusterVolumeName}.


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

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

Reply via email to