Kobi Ianko has uploaded a new change for review.

Change subject: engine: Adding a down event for HA Reservation
......................................................................

engine: Adding a down event for HA Reservation

Adding a down event to HA Reservation, this event will be triggered
only in case the current status of the Cluster was changed from not HA safe to 
HA safe.
This is done to ensure that the user is notified that his action
(freeing resources) have made the Cluster HA safe.

Change-Id: Iebc82d3cc190d439b77e45e7e6b3eb7451f71c3c
Bug-Url: https://bugzilla.redhat.com/1076211
Signed-off-by: Kobi Ianko <k...@redhat.com>
---
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/scheduling/SchedulingManager.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/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
6 files changed, 27 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/71/27471/1

diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/scheduling/SchedulingManager.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/scheduling/SchedulingManager.java
index 838dd7f..cea589b 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/scheduling/SchedulingManager.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/scheduling/SchedulingManager.java
@@ -88,6 +88,8 @@
     private final VdsFreeMemoryChecker noWaitingMemoryChecker = new 
VdsFreeMemoryChecker(new NonWaitingDelayer());
     private MigrationHandler migrationHandler;
 
+    private final Map<Guid, Boolean> clusterId2isHaReservationSafe = new 
HashMap<>();
+
     private SchedulingManager() {
         policyMap = new ConcurrentHashMap<Guid, ClusterPolicy>();
         policyUnits = new ConcurrentHashMap<Guid, PolicyUnitImpl>();
@@ -776,9 +778,9 @@
             for (VDSGroup cluster : clusters) {
                 if (cluster.supportsHaReservation()) {
                     List<VDS> returnedFailedHosts = new ArrayList<VDS>();
-                    boolean status =
+                    boolean clusterHaStatus =
                             
haReservationHandling.checkHaReservationStatusForCluster(cluster, 
returnedFailedHosts);
-                    if (!status) {
+                    if (!clusterHaStatus) {
                         // create Alert using returnedFailedHosts
                         AuditLogableBase logable = new AuditLogableBase();
                         logable.setVdsGroupId(cluster.getId());
@@ -790,6 +792,21 @@
                         AlertDirector.Alert(logable, 
AuditLogType.CLUSTER_ALERT_HA_RESERVATION);
                         log.infoFormat("Cluster: {0} fail to pass HA 
reservation check.", cluster.getName());
                     }
+
+                    boolean clusterHaStatusFromPreviousCycle =
+                            
clusterId2isHaReservationSafe.containsKey(cluster.getId()) ? 
clusterId2isHaReservationSafe.get(cluster.getId())
+                                    : true;
+
+                    // Update the status map with the new status
+                    clusterId2isHaReservationSafe.put(cluster.getId(), 
clusterHaStatus);
+
+                    // Create Alert if the status was changed from false to 
true
+                    if (!clusterHaStatusFromPreviousCycle && clusterHaStatus) {
+                        AuditLogableBase logable = new AuditLogableBase();
+                        logable.setVdsGroupId(cluster.getId());
+                        logable.addCustomValue("ClusterName", 
cluster.getName());
+                        AlertDirector.Alert(logable, 
AuditLogType.CLUSTER_ALERT_HA_RESERVATION_DOWN);
+                    }
                 }
             }
         }
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 4f5862f..860eb8a 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
@@ -888,6 +888,9 @@
     // HA Reservation
     CLUSTER_ALERT_HA_RESERVATION(10300, AuditLogTimeInterval.HOUR.getValue()),
 
+    CLUSTER_ALERT_HA_RESERVATION_DOWN(10301, AuditLogSeverity.ALERT),
+
+
     //affinity groups
     USER_ADDED_AFFINITY_GROUP(10350),
     USER_FAILED_TO_ADD_AFFINITY_GROUP(10351),
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 1fce252..ef02df0 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
@@ -17,6 +17,7 @@
         AddEventNotificationEntry(EventNotificationEntity.Engine, 
AuditLogType.VDC_STOP);
         // VDS GROUP
         AddEventNotificationEntry(EventNotificationEntity.VdsGroup, 
AuditLogType.CLUSTER_ALERT_HA_RESERVATION);
+        AddEventNotificationEntry(EventNotificationEntity.VdsGroup, 
AuditLogType.CLUSTER_ALERT_HA_RESERVATION_DOWN);
         // VDS
         AddEventNotificationEntry(EventNotificationEntity.Host, 
AuditLogType.VDS_FAILURE);
         AddEventNotificationEntry(EventNotificationEntity.Host, 
AuditLogType.USER_VDS_MAINTENANCE);
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 a8c07dd..3405ed3 100644
--- 
a/backend/manager/modules/dal/src/main/resources/bundles/AuditLogMessages.properties
+++ 
b/backend/manager/modules/dal/src/main/resources/bundles/AuditLogMessages.properties
@@ -768,6 +768,7 @@
 VM_CONSOLE_DISCONNECTED=User ${UserName} got disconnected from VM ${VmName}.
 VDS_STATUS_CHANGE_FAILED_DUE_TO_STOP_SPM_FAILURE=Failed to change status of 
host '${VdsName}' due to a failure to stop the spm.
 CLUSTER_ALERT_HA_RESERVATION=Cluster ${ClusterName} failed the HA Reservation 
check, HA VMs on host(s): ${Hosts} will fail to migrate in case of a failover, 
consider adding resources or shutting down unused VMs.
+CLUSTER_ALERT_HA_RESERVATION_DOWN=Cluster ${ClusterName} passed the HA 
Reservation check.
 PM_POLICY_UP_TO_MAINTENANCE=Host ${Host} is not currently needed, activating 
maintenance mode in preparation for shutdown.
 PM_POLICY_MAINTENANCE_TO_DOWN=Host ${Host} is not currently needed, shutting 
down.
 PM_POLICY_TO_UP=Reactivating host ${Host} according to the current power 
management policy.
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 2ddb87d..c1a03a4 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
@@ -268,6 +268,8 @@
 
     String AuditLogType___CLUSTER_ALERT_HA_RESERVATION();
 
+    String AuditLogType___CLUSTER_ALERT_HA_RESERVATION_DOWN();
+
     // Gluster Audit log types
     String AuditLogType___GLUSTER_VOLUME_CREATE();
 
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 d0fbf69..f049939 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,6 +130,7 @@
 AuditLogType___IRS_DISK_SPACE_LOW_ERROR=Critically low disk space
 AuditLogType___VDC_STOP=Engine has stopped
 AuditLogType___CLUSTER_ALERT_HA_RESERVATION=HA Reservation check has failed
+AuditLogType___CLUSTER_ALERT_HA_RESERVATION_DOWN=HA Reservation check has 
passed
 AuditLogType___VDS_NETWORK_MTU_DIFFER_FROM_LOGICAL_NETWORK=The MTU value of 
the Host network differs from logical network
 AuditLogType___GLUSTER_VOLUME_CREATE=Gluster Volume Created
 AuditLogType___GLUSTER_VOLUME_CREATE_FAILED=Gluster Volume could not be created


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Iebc82d3cc190d439b77e45e7e6b3eb7451f71c3c
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: ovirt-engine-3.4
Gerrit-Owner: Kobi Ianko <k...@redhat.com>
_______________________________________________
Engine-patches mailing list
Engine-patches@ovirt.org
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to