Darshan N has uploaded a new change for review.

Change subject: gluster: event message for rebalance and remove brick complete
......................................................................

gluster: event message for rebalance and remove brick complete

A suitable event message will be displayed when rebalance is
completed in a volume and when data migration for brick removal is complete.

Change-Id: If4da9730cd8c251bc5707df981204b092948fb6f
bug url: https://bugzilla.redhat.com/show_bug.cgi?id=1015016
Signed-off-by: ndarshan <dnara...@redhat.com>
---
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/GlusterTasksSyncJob.java
M 
backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/gluster/GlusterTasksSyncJobTest.java
M 
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/AuditLogType.java
M 
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/VdcEventNotificationUtils.java
M 
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/asynctasks/gluster/GlusterTaskType.java
M 
backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/dbbroker/auditloghandling/AuditLogDirector.java
M 
backend/manager/modules/dal/src/main/resources/bundles/AuditLogMessages.properties
M 
frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/LocalizedEnums.java
M 
frontend/webadmin/modules/uicompat/src/main/resources/org/ovirt/engine/ui/uicompat/LocalizedEnums.properties
A packaging/dbscripts/upgrade/03_04_0120_gluster_volume_rebalance_finished.sql
A 
packaging/dbscripts/upgrade/03_04_0130_gluster_volume_remove_brick_data_migration_finished.sql
11 files changed, 66 insertions(+), 18 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/80/21080/1

diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/GlusterTasksSyncJob.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/GlusterTasksSyncJob.java
index bc0d382..3cf2a66 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/GlusterTasksSyncJob.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/GlusterTasksSyncJob.java
@@ -13,6 +13,7 @@
 import org.ovirt.engine.core.bll.job.ExecutionHandler;
 import org.ovirt.engine.core.bll.job.JobRepository;
 import org.ovirt.engine.core.bll.job.JobRepositoryFactory;
+import org.ovirt.engine.core.common.AuditLogType;
 import org.ovirt.engine.core.common.action.AddInternalJobParameters;
 import org.ovirt.engine.core.common.action.AddStepParameters;
 import org.ovirt.engine.core.common.action.VdcActionType;
@@ -50,6 +51,15 @@
     private static GlusterTasksSyncJob instance = new GlusterTasksSyncJob();
 
     private final GlusterTasksService provider = new GlusterTasksService();
+
+    private static final Map<GlusterTaskType, String> taskTypeStrMap = new 
HashMap<>();
+    private static final Map<GlusterTaskType, AuditLogType> taskTypeAuditMsg = 
new HashMap<>();
+    static {
+        taskTypeStrMap.put(GlusterTaskType.REBALANCE, "Rebalance");
+        taskTypeStrMap.put(GlusterTaskType.REMOVE_BRICK, "Data Migration");
+        taskTypeAuditMsg.put(GlusterTaskType.REBALANCE, 
AuditLogType.GLUSTER_VOLUME_REBALANCE_FINISHED);
+        taskTypeAuditMsg.put(GlusterTaskType.REMOVE_BRICK, 
AuditLogType.GLUSTER_VOLUME_REMOVE_BRICK_DATA_MIGRATION_FINISHED);
+    }
 
     public static GlusterTasksSyncJob getInstance() {
         return instance;
@@ -100,6 +110,7 @@
             final GlusterAsyncTask task =  entry.getValue();
 
             List<Step> steps = getStepDao().getStepsByExternalId(taskId);
+            GlusterVolumeEntity volume = 
getVolumeDao().getVolumeByGlusterTask(taskId);
             if (steps.isEmpty()) {
                 // the task may have been started from the CLI
                 // need to add job to monitor
@@ -122,12 +133,18 @@
                     //we have already processed the task
                     continue;
                 }
+                JobExecutionStatus oldStatus = step.getStatus();
                 step.setDescription(getTaskMessage(cluster, 
step.getStepType(), task));
                 step.setStatus(task.getStatus());
+                if(JobExecutionStatus.FINISHED == task.getStatus()) {
+                    if(oldStatus != task.getStatus()) {
+                        logMessage(volume.getClusterId(), volume, 
taskTypeStrMap.get(task.getType()), task.getStatus().name().toLowerCase(), 
taskTypeAuditMsg.get(task.getType()));
+                    }
+                }
                 if (hasTaskCompleted(task)) {
-                    step.markStepEnded(task.getStatus());
-                    endStepJob(step);
-                    releaseVolumeLock(task.getTaskId());
+                  step.markStepEnded(task.getStatus());
+                  endStepJob(step);
+                  releaseVolumeLock(task.getTaskId());
                 } else {
                     getJobRepository().updateStep(step);
                 }
@@ -284,7 +301,8 @@
         }
     }
 
-    private static boolean hasTaskCompleted(GlusterAsyncTask task) {
+
+    private boolean hasTaskCompleted(GlusterAsyncTask task) {
         //Remove brick task is marked completed only if committed or aborted.
         if (JobExecutionStatus.ABORTED == task.getStatus() ||
                 (JobExecutionStatus.FINISHED == task.getStatus() && 
task.getType() != GlusterTaskType.REMOVE_BRICK)
@@ -345,4 +363,13 @@
     private boolean supportsGlusterAsyncTasksFeature(VDSGroup cluster) {
         return cluster.supportsGlusterService() && 
GlusterFeatureSupported.glusterAsyncTasks(cluster.getcompatibility_version());
     }
+
+    @SuppressWarnings("serial")
+    public void logMessage(Guid clusterId, GlusterVolumeEntity volume, final 
String action, final String status, AuditLogType logType) {
+        logUtil.logAuditMessage(clusterId, volume, null, logType, new 
HashMap<String, String>(){
+            {
+                put("action", action);
+                put("status", status);
+            }});
+    }
 }
diff --git 
a/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/gluster/GlusterTasksSyncJobTest.java
 
b/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/gluster/GlusterTasksSyncJobTest.java
index f56b97f..94b00f1 100644
--- 
a/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/gluster/GlusterTasksSyncJobTest.java
+++ 
b/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/gluster/GlusterTasksSyncJobTest.java
@@ -30,6 +30,7 @@
 import org.ovirt.engine.core.common.asynctasks.gluster.GlusterAsyncTask;
 import org.ovirt.engine.core.common.asynctasks.gluster.GlusterTaskParameters;
 import org.ovirt.engine.core.common.asynctasks.gluster.GlusterTaskType;
+import org.ovirt.engine.core.common.businessentities.VDS;
 import org.ovirt.engine.core.common.businessentities.VDSGroup;
 import 
org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity;
 import org.ovirt.engine.core.common.config.ConfigValues;
@@ -94,8 +95,7 @@
         MockitoAnnotations.initMocks(this);
         tasksSyncJob = Mockito.spy(GlusterTasksSyncJob.getInstance());
         logUtil = Mockito.spy(GlusterAuditLogUtil.getInstance());
-        doNothing().when(logUtil).logClusterMessage(any(Guid.class),
-                                any(AuditLogType.class));
+        tasksSyncJob.setLogUtil(logUtil);
         doReturn(clusterDao).when(tasksSyncJob).getClusterDao();
         doReturn(getClusters()).when(clusterDao).getAll();
         doReturn(provider).when(tasksSyncJob).getProvider();
@@ -105,7 +105,8 @@
         doReturn(backend).when(tasksSyncJob).getBackend();
         doNothing().when(tasksSyncJob).releaseLock(any(Guid.class));
         doNothing().when(tasksSyncJob).endStepJob(any(Step.class));
-
+        doNothing().when(tasksSyncJob).logMessage(any(Guid.class), 
any(GlusterVolumeEntity.class), any(String.class), any(String.class), 
any(AuditLogType.class));
+        doNothing().when(logUtil).logAuditMessage(any(Guid.class), 
any(GlusterVolumeEntity.class), any(VDS.class), any(AuditLogType.class), 
any(Map.class));
     }
 
     @Test
diff --git 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/AuditLogType.java
 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/AuditLogType.java
index c82ee15..ef0e9bf 100644
--- 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/AuditLogType.java
+++ 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/AuditLogType.java
@@ -305,6 +305,9 @@
     GLUSTER_VOLUME_REMOVE_BRICKS_COMMIT(4084),
     GLUSTER_VOLUME_REMOVE_BRICKS_COMMIT_FAILED(4085),
     GLUSTER_BRICK_STATUS_CHANGED(4086),
+    GLUSTER_VOLUME_REBALANCE_FINISHED(4087),
+    GLUSTER_VOLUME_REMOVE_BRICK_DATA_MIGRATION_FINISHED(4088),
+
 
     USER_FORCE_SELECTED_SPM(159),
     USER_VDS_RESTART(41),
diff --git 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/VdcEventNotificationUtils.java
 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/VdcEventNotificationUtils.java
index 0ac9763..739630f 100644
--- 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/VdcEventNotificationUtils.java
+++ 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/VdcEventNotificationUtils.java
@@ -107,6 +107,8 @@
         AddEventNotificationEntry(EventNotificationEntity.DWH, 
AuditLogType.DWH_ERROR);
         AddEventNotificationEntry(EventNotificationEntity.GlusterVolume, 
AuditLogType.GLUSTER_VOLUME_ADD_BRICK);
         AddEventNotificationEntry(EventNotificationEntity.GlusterVolume, 
AuditLogType.GLUSTER_VOLUME_ADD_BRICK_FAILED);
+        AddEventNotificationEntry(EventNotificationEntity.GlusterVolume, 
AuditLogType.GLUSTER_VOLUME_REBALANCE_FINISHED);
+        AddEventNotificationEntry(EventNotificationEntity.GlusterVolume, 
AuditLogType.GLUSTER_VOLUME_REMOVE_BRICK_DATA_MIGRATION_FINISHED);
 
         //Trusted Service
         AddEventNotificationEntry(EventNotificationEntity.Host, 
AuditLogType.VDS_UNTRUSTED);
diff --git 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/asynctasks/gluster/GlusterTaskType.java
 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/asynctasks/gluster/GlusterTaskType.java
index 8cfdae3..b5fa90f 100644
--- 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/asynctasks/gluster/GlusterTaskType.java
+++ 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/asynctasks/gluster/GlusterTaskType.java
@@ -1,7 +1,7 @@
 package org.ovirt.engine.core.common.asynctasks.gluster;
 
-import java.util.HashMap;
 import java.util.Map;
+import java.util.HashMap;
 
 import org.ovirt.engine.core.common.job.StepEnum;
 
@@ -28,15 +28,16 @@
         return step;
     }
 
-     public static GlusterTaskType forValue(StepEnum step) {
+    public static GlusterTaskType forValue(StepEnum step) {
         return mappings.get(step);
     }
 
-     public static GlusterTaskType fromValue(String v) {
-         try {
-             return valueOf(v.toUpperCase());
-         } catch (IllegalArgumentException e) {
-             return GlusterTaskType.UNKNOWN;
-         }
-     }
+    public static GlusterTaskType fromValue(String v) {
+        try {
+            return valueOf(v.toUpperCase());
+        } catch (IllegalArgumentException e) {
+            return GlusterTaskType.UNKNOWN;
+        }
+    }
+
 }
diff --git 
a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/dbbroker/auditloghandling/AuditLogDirector.java
 
b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/dbbroker/auditloghandling/AuditLogDirector.java
index 1d6915b..2075e90 100644
--- 
a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/dbbroker/auditloghandling/AuditLogDirector.java
+++ 
b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/dbbroker/auditloghandling/AuditLogDirector.java
@@ -96,6 +96,8 @@
         severities.put(AuditLogType.GLUSTER_VOLUME_REBALANCE_START, 
AuditLogSeverity.NORMAL);
         severities.put(AuditLogType.GLUSTER_VOLUME_REBALANCE_START_FAILED, 
AuditLogSeverity.ERROR);
         severities.put(AuditLogType.GLUSTER_VOLUME_REBALANCE_STOP, 
AuditLogSeverity.NORMAL);
+        severities.put(AuditLogType.GLUSTER_VOLUME_REBALANCE_FINISHED, 
AuditLogSeverity.NORMAL);
+        
severities.put(AuditLogType.GLUSTER_VOLUME_REMOVE_BRICK_DATA_MIGRATION_FINISHED,
 AuditLogSeverity.NORMAL);
         severities.put(AuditLogType.GLUSTER_VOLUME_REBALANCE_STOP_FAILED, 
AuditLogSeverity.ERROR);
         severities.put(AuditLogType.GLUSTER_VOLUME_REMOVE_BRICKS_STOP, 
AuditLogSeverity.NORMAL);
         severities.put(AuditLogType.GLUSTER_VOLUME_REMOVE_BRICKS_STOP_FAILED, 
AuditLogSeverity.ERROR);
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 dba2e2b..09e320a 100644
--- 
a/backend/manager/modules/dal/src/main/resources/bundles/AuditLogMessages.properties
+++ 
b/backend/manager/modules/dal/src/main/resources/bundles/AuditLogMessages.properties
@@ -621,6 +621,8 @@
 GLUSTER_VOLUME_REPLACE_BRICK_FAILED=Replace Gluster Volume Brick failed
 GLUSTER_VOLUME_REPLACE_BRICK_START=Gluster Volume ${glusterVolumeName} Replace 
Brick started.
 GLUSTER_VOLUME_REPLACE_BRICK_START_FAILED=Could not start Gluster Volume 
${glusterVolumeName} Replace Brick.
+GLUSTER_VOLUME_REBALANCE_FINISHED=${action} ${status} on volume 
${glusterVolumeName}.
+GLUSTER_VOLUME_REMOVE_BRICK_DATA_MIGRATION_FINISHED=${action} ${status} for 
brick(s) on volume ${glusterVolumeName}. Please review to abort or commit.
 GLUSTER_SERVER_ADD_FAILED=Failed to add gluster server ${VdsName} into Cluster 
${VdsGroupName}.
 GLUSTER_SERVER_REMOVE=Gluster server ${VdsName} removed from Cluster 
${VdsGroupName}.
 GLUSTER_SERVER_REMOVE_FAILED=Failed to remove gluster server ${VdsName} from 
Cluster ${VdsGroupName}.
diff --git 
a/frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/LocalizedEnums.java
 
b/frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/LocalizedEnums.java
index 1e2df51..4663218 100644
--- 
a/frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/LocalizedEnums.java
+++ 
b/frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/LocalizedEnums.java
@@ -286,6 +286,10 @@
 
     String AuditLogType___GLUSTER_VOLUME_REMOVE_BRICKS_COMMIT();
 
+    String AuditLogType___GLUSTER_VOLUME_REBALANCE_FINISHED();
+
+    String 
AuditLogType___GLUSTER_VOLUME_REMOVE_BRICK_DATA_MIGRATION_FINISHED();
+
     String AuditLogType___GLUSTER_VOLUME_REMOVE_BRICKS_COMMIT_FAILED();
 
        String AuditLogType___GLUSTER_VOLUME_REPLACE_BRICK_FAILED();
diff --git 
a/frontend/webadmin/modules/uicompat/src/main/resources/org/ovirt/engine/ui/uicompat/LocalizedEnums.properties
 
b/frontend/webadmin/modules/uicompat/src/main/resources/org/ovirt/engine/ui/uicompat/LocalizedEnums.properties
index df6b6f5..3c717cf 100644
--- 
a/frontend/webadmin/modules/uicompat/src/main/resources/org/ovirt/engine/ui/uicompat/LocalizedEnums.properties
+++ 
b/frontend/webadmin/modules/uicompat/src/main/resources/org/ovirt/engine/ui/uicompat/LocalizedEnums.properties
@@ -130,8 +130,10 @@
 AuditLogType___GLUSTER_VOLUME_DELETE_FAILED=Gluster Volume could not be deleted
 AuditLogType___GLUSTER_VOLUME_REMOVE_BRICKS=Gluster Volume Bricks Removed
 AuditLogType___GLUSTER_VOLUME_REMOVE_BRICKS_FAILED=Gluster Volume Bricks could 
not be removed
-AuditLogType___START_REMOVING_GLUSTER_VOLUME_BRICKS=Started removing bricks 
from Volume
-AuditLogType___START_REMOVING_GLUSTER_VOLUME_BRICKS_FAILED=Could not remove 
volume bricks
+AuditLogType___GLUSTER_VOLUME_REBALANCE_FINISHED=Gluster Volume rebalance 
finished
+AuditLogType___GLUSTER_VOLUME_REMOVE_BRICK_DATA_MIGRATION_FINISHED=Gluster 
Volume migration of data for remove brick finished
+AuditLogType___START_REMOVING_GLUSTER_VOLUME_BRICKS=Started removing bricks 
from Gluster Volume
+AuditLogType___START_REMOVING_GLUSTER_VOLUME_BRICKS_FAILED=Could not remove 
Gluster volume bricks
 AuditLogType___GLUSTER_VOLUME_ADD_BRICK=Gluster Volume brick(s) added
 AuditLogType___GLUSTER_VOLUME_ADD_BRICK_FAILED=Failed to add brick(s) on 
Gluster Volume
 AuditLogType___GLUSTER_VOLUME_REBALANCE_START=Gluster Volume Rebalance started
diff --git 
a/packaging/dbscripts/upgrade/03_04_0120_gluster_volume_rebalance_finished.sql 
b/packaging/dbscripts/upgrade/03_04_0120_gluster_volume_rebalance_finished.sql
new file mode 100644
index 0000000..8d4d87b
--- /dev/null
+++ 
b/packaging/dbscripts/upgrade/03_04_0120_gluster_volume_rebalance_finished.sql
@@ -0,0 +1,2 @@
+insert into event_map(event_up_name, event_down_name) 
values('GLUSTER_VOLUME_REBALANCE_FINISHED', 'UNASSI
+GNED');
diff --git 
a/packaging/dbscripts/upgrade/03_04_0130_gluster_volume_remove_brick_data_migration_finished.sql
 
b/packaging/dbscripts/upgrade/03_04_0130_gluster_volume_remove_brick_data_migration_finished.sql
new file mode 100644
index 0000000..61f2ba2
--- /dev/null
+++ 
b/packaging/dbscripts/upgrade/03_04_0130_gluster_volume_remove_brick_data_migration_finished.sql
@@ -0,0 +1,2 @@
+insert into event_map(event_up_name, event_down_name) 
values('GLUSTER_VOLUME_REMOVE_BRICK_DATA_MIGRATION_FINISHED', 'UNASSI
+GNED');


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

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

Reply via email to