Roy Golan has uploaded a new change for review.

Change subject: core: AddVM - Show an Event when exeeding the mem range
......................................................................

core: AddVM - Show an Event when exeeding the mem range

Change-Id: I52067ea090bb8d3b239b4dd8a6ac0b5188dbdc20
Signed-off-by: Roy Golan <[email protected]>
Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=1014952
---
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/VmHandler.java
M 
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/AuditLogType.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
4 files changed, 15 insertions(+), 6 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/19/21219/1

diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/VmHandler.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/VmHandler.java
index 941b14f..9745cb3 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/VmHandler.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/VmHandler.java
@@ -14,6 +14,7 @@
 import org.ovirt.engine.core.bll.network.MacPoolManager;
 import org.ovirt.engine.core.bll.validator.StorageDomainValidator;
 import org.ovirt.engine.core.bll.validator.VmValidationUtils;
+import org.ovirt.engine.core.common.AuditLogType;
 import org.ovirt.engine.core.common.FeatureSupported;
 import org.ovirt.engine.core.common.action.VdcActionType;
 import org.ovirt.engine.core.common.backendinterfaces.BaseHandler;
@@ -53,6 +54,8 @@
 import org.ovirt.engine.core.compat.RpmVersion;
 import org.ovirt.engine.core.compat.Version;
 import org.ovirt.engine.core.dal.dbbroker.DbFacade;
+import org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogDirector;
+import org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogableBase;
 import org.ovirt.engine.core.utils.ObjectIdentityChecker;
 import org.ovirt.engine.core.utils.linq.LinqUtils;
 import org.ovirt.engine.core.utils.linq.Predicate;
@@ -352,12 +355,15 @@
      */
     public static void warnMemorySizeLegal(VmBase vm, Version clusterVersion) {
         if (! VmValidationUtils.isMemorySizeLegal(vm.getOsId(), 
vm.getMemSizeMb(), clusterVersion)) {
-            log.warnFormat("RAM value {0}mb for {1} is exceeding the 
recommended values {2}mb - {3}mb for {4}",
-                    vm.getMemSizeMb(),
-                    vm.getName(),
-                    VmValidationUtils.getMinMemorySizeInMb(vm.getOsId(), 
clusterVersion),
-                    VmValidationUtils.getMaxMemorySizeInMb(vm.getOsId(), 
clusterVersion),
-                    osRepository.getOsName(vm.getOsId()));
+            AuditLogableBase logable = new AuditLogableBase();
+            logable.addCustomValue("VmName", vm.getName());
+            logable.addCustomValue("VmMemInMb", 
String.valueOf(vm.getMemSizeMb()));
+            logable.addCustomValue("VmMinMemInMb",
+                    
String.valueOf(VmValidationUtils.getMinMemorySizeInMb(vm.getOsId(), 
clusterVersion)));
+            logable.addCustomValue("VmMaxMemInMb",
+                    
String.valueOf(VmValidationUtils.getMaxMemorySizeInMb(vm.getOsId(), 
clusterVersion)));
+
+            AuditLogDirector.log(logable, 
AuditLogType.VM_MEMORY_NOT_IN_RECOMMENDED_RANGE);
         }
     }
 
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..acb79a6 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
@@ -412,6 +412,7 @@
     VM_MEMORY_UNDER_GUARANTEED_VALUE(148, 
AuditLogTimeInterval.MINUTE.getValue() * 15),
     VM_BALLOON_DRIVER_ERROR(149, AuditLogTimeInterval.MINUTE.getValue() * 15),
     VM_BALLOON_DRIVER_UNCONTROLLED(150, AuditLogTimeInterval.MINUTE.getValue() 
* 15),
+    VM_MEMORY_NOT_IN_RECOMMENDED_RANGE(151),
 
     USER_ADD_VM_POOL(300),
     USER_ADD_VM_POOL_FAILED(301),
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..f0b6727 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
@@ -521,6 +521,7 @@
         severities.put(AuditLogType.VM_PAUSED_EPERM, AuditLogSeverity.ERROR);
         severities.put(AuditLogType.VM_POWER_DOWN_FAILED, 
AuditLogSeverity.WARNING);
         severities.put(AuditLogType.VM_MEMORY_UNDER_GUARANTEED_VALUE, 
AuditLogSeverity.ERROR);
+        severities.put(AuditLogType.VM_MEMORY_NOT_IN_RECOMMENDED_RANGE, 
AuditLogSeverity.WARNING);
         severities.put(AuditLogType.VM_BALLOON_DRIVER_ERROR, 
AuditLogSeverity.ERROR);
         severities.put(AuditLogType.VM_BALLOON_DRIVER_UNCONTROLLED, 
AuditLogSeverity.ERROR);
         severities.put(AuditLogType.USER_RUN_VM, AuditLogSeverity.NORMAL);
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..28a7e54 100644
--- 
a/backend/manager/modules/dal/src/main/resources/bundles/AuditLogMessages.properties
+++ 
b/backend/manager/modules/dal/src/main/resources/bundles/AuditLogMessages.properties
@@ -703,3 +703,4 @@
 DISK_ALIGNMENT_SCAN_START=Starting alignment scan of disk '${DiskAlias}'.
 DISK_ALIGNMENT_SCAN_FAILURE=Alignment scan of disk '${DiskAlias}' failed.
 DISK_ALIGNMENT_SCAN_SUCCESS=Alignment scan of disk '${DiskAlias}' is complete.
+VM_MEMORY_NOT_IN_RECOMMENDED_RANGE=VM ${VmName} was configured with 
${VmMemInMb}mb of memory while the recommended value range is ${VmMinMemInMb}mb 
- ${VmMaxMemInMb}mb


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

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

Reply via email to