Sahina Bose has uploaded a new change for review.

Change subject: engine: Audit log for brick status change
......................................................................

engine: Audit log for brick status change

During periodic sync of gluster with engine
if change in brick status is detected this
needs to be logged.

Added corresponding entries for event
notification

Change-Id: If1764dd5c41b484637595b0fa20598849f9ba347
Bug-Url: https://bugzilla.redhat.com/958813
Signed-off-by: Sahina Bose <sab...@redhat.com>
---
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/GlusterSyncJob.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/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_0060_add_brick_status_change_event_map.sql
8 files changed, 24 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/33/20433/1

diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/GlusterSyncJob.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/GlusterSyncJob.java
index d871115..4189965 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/GlusterSyncJob.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/GlusterSyncJob.java
@@ -803,6 +803,7 @@
             // if fetchedStatus is null, it means this is a new brick added 
from gluster cli and doesn't exist in engine
             // DB yet. Don't do anything, wait for it to be added by the 
'lightweight' refresh job
             if (fetchedStatus != null && fetchedStatus != brick.getStatus()) {
+                logBrickStatusChange(volume, brick, fetchedStatus);
                 brick.setStatus(fetchedStatus);
                 bricksToUpdate.add(brick);
             }
@@ -813,6 +814,20 @@
         }
     }
 
+    private void logBrickStatusChange(GlusterVolumeEntity volume, final 
GlusterBrickEntity brick, final GlusterStatus fetchedStatus) {
+        log.debugFormat("Detected that status of brick {0} in volume {1} 
changed from {2} to {3}",
+                brick.getQualifiedName(), volume.getName(), brick.getStatus(), 
fetchedStatus);
+        logUtil.logAuditMessage(volume.getClusterId(), volume, null,
+                AuditLogType.GLUSTER_BRICK_STATUS_CHANGED,
+                new HashMap<String, String>() {
+                    {
+                        put(GlusterConstants.BRICK_PATH, 
brick.getQualifiedName());
+                        put(GlusterConstants.OPTION_OLD_VALUE, 
brick.getStatus().toString());
+                        put(GlusterConstants.OPTION_NEW_VALUE, 
fetchedStatus.toString());
+                    }
+                });
+    }
+
     private Map<Guid, GlusterStatus> 
getBrickStatusMap(GlusterVolumeAdvancedDetails volumeDetails) {
         Map<Guid, GlusterStatus> brickStatusMap = new HashMap<Guid, 
GlusterStatus>();
         for (BrickDetails brickDetails : volumeDetails.getBrickDetails()) {
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 c802c71..466045f 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
@@ -299,6 +299,7 @@
     GLUSTER_VOLUME_REMOVE_BRICKS_STOP_FAILED(4083),
     GLUSTER_VOLUME_REMOVE_BRICKS_COMMIT(4084),
     GLUSTER_VOLUME_REMOVE_BRICKS_COMMIT_FAILED(4085),
+    GLUSTER_BRICK_STATUS_CHANGED(4086),
 
     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 0b4355d..af0ccda 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
@@ -100,6 +100,7 @@
         AddEventNotificationEntry(EventNotificationEntity.GlusterService, 
AuditLogType.GLUSTER_SERVICE_STOP_FAILED);
         AddEventNotificationEntry(EventNotificationEntity.GlusterService, 
AuditLogType.GLUSTER_SERVICE_RESTARTED);
         AddEventNotificationEntry(EventNotificationEntity.GlusterService, 
AuditLogType.GLUSTER_SERVICE_RESTART_FAILED);
+        AddEventNotificationEntry(EventNotificationEntity.GlusterVolume, 
AuditLogType.GLUSTER_BRICK_STATUS_CHANGED);
 
         // DWH
         AddEventNotificationEntry(EventNotificationEntity.DWH, 
AuditLogType.DWH_STOPPED);
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 85ce98a..9834a12 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
@@ -157,6 +157,7 @@
         severities.put(AuditLogType.GLUSTER_SERVICE_RESTARTED, 
AuditLogSeverity.NORMAL);
         severities.put(AuditLogType.GLUSTER_SERVICE_RESTART_FAILED, 
AuditLogSeverity.ERROR);
         severities.put(AuditLogType.GLUSTER_HOST_UUID_NOT_FOUND, 
AuditLogSeverity.ERROR);
+        severities.put(AuditLogType.GLUSTER_BRICK_STATUS_CHANGED, 
AuditLogSeverity.WARNING);
     }
 
     private static void initDefaultSeverities() {
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 eab93ad..8b40e5f 100644
--- 
a/backend/manager/modules/dal/src/main/resources/bundles/AuditLogMessages.properties
+++ 
b/backend/manager/modules/dal/src/main/resources/bundles/AuditLogMessages.properties
@@ -691,6 +691,7 @@
 GLUSTER_SERVICE_RESTARTED=${servicetype} service re-started on host ${VdsName} 
on cluster ${VdsGroupName}.
 GLUSTER_SERVICE_RESTART_FAILED=Could not re-start ${servicetype} service on 
host ${VdsName} on cluster ${VdsGroupName}.
 GLUSTER_VOLUME_BRICK_ADDED=Brick [${brickpath}] on host [${servername}] added 
to volume [${glusterVolumeName}]
+GLUSTER_BRICK_STATUS_CHANGED=Detected change in status of brick ${brickpath} 
of volume ${glusterVolumeName} from ${oldValue} to ${newValue}.
 VDS_UNTRUSTED=Host ${VdsName} was set to non-operational. Host is not trusted 
by the attestation service.
 USER_ADDED_NETWORK_QOS=Network QoS ${NetworkQoSName} was added. (User: 
${UserName})
 USER_FAILED_TO_ADD_NETWORK_QOS=Failed to add Network QoS ${NetworkQoSName}. 
(User: ${UserName})
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 88aa146..fd29141 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
@@ -354,6 +354,8 @@
 
     String AuditLogType___GLUSTER_VOLUME_REMOVE_BRICKS_STOP_FAILED();
 
+    String AuditLogType___GLUSTER_BRICK_STATUS_CHANGED();
+
     String VdcActionType___ActivateVds();
 
        String VdcActionType___RecoveryStoragePool();
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 392c565..095ead4 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
@@ -173,6 +173,7 @@
 AuditLogType___GLUSTER_SERVICE_RESTART_FAILED=Failed to re-start Gluster 
Service
 AuditLogType___GLUSTER_VOLUME_REMOVE_BRICKS_STOPPED=Gluster volume remove 
brick stopped
 AuditLogType___GLUSTER_VOLUME_REMOVE_BRICKS_STOP_FAILED=Failed to stop gluster 
volume remove brick
+AuditLogType___GLUSTER_BRICK_STATUS_CHANGED=Detected change in status of brick
 
 
 VdcActionType___ActivateVds=Activate Host
diff --git 
a/packaging/dbscripts/upgrade/03_04_0060_add_brick_status_change_event_map.sql 
b/packaging/dbscripts/upgrade/03_04_0060_add_brick_status_change_event_map.sql
new file mode 100644
index 0000000..0661c98
--- /dev/null
+++ 
b/packaging/dbscripts/upgrade/03_04_0060_add_brick_status_change_event_map.sql
@@ -0,0 +1,2 @@
+insert into event_map(event_up_name, event_down_name) 
values('GLUSTER_BRICK_STATUS_CHANGED', 'UNASSIGNED');
+


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

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

Reply via email to