Shireesh Anjal has uploaded a new change for review.

Change subject: gluster: Log volume creation before option set
......................................................................

gluster: Log volume creation before option set

Since the command to set options on the volume is being set from inside
CreateGlusterVolumeCommand, the audit logs were getting generated in a
way that looked like options were set before creating the volume.

Adjusted the audit log flow in such a way that volume creation gets
logged before setting options.

Change-Id: Icd96508e768ede181d8c0374c6de74fd9a20549f
Signed-off-by: Shireesh Anjal <[email protected]>
---
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/CreateGlusterVolumeCommand.java
1 file changed, 11 insertions(+), 3 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/07/10907/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 4f150a7..dfe8a7e 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
@@ -32,6 +32,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
@@ -151,6 +152,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);
@@ -310,10 +317,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();
     }
 }


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

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

Reply via email to