Arik Hadas has uploaded a new change for review.

Change subject: core: simplify MigrateVmCommand#getAuditLogTypeValue
......................................................................

core: simplify MigrateVmCommand#getAuditLogTypeValue

This method used to contain a ternary-if statement with 3 and 4 levels
which made it less readable. By extracting the those levels to separate
methods, the highest level within that ternary-if statement was reduced
to 2 and now it is more readable.

Change-Id: I54f4e026199187212a872eaef27933a845194b55
Signed-off-by: Arik Hadas <[email protected]>
---
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/MigrateVmCommand.java
1 file changed, 20 insertions(+), 7 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/21/21721/1

diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/MigrateVmCommand.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/MigrateVmCommand.java
index 13dbecd..e345056 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/MigrateVmCommand.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/MigrateVmCommand.java
@@ -247,15 +247,28 @@
         return getSucceeded() ?
                 getActionReturnValue() == VMStatus.Up ?
                         AuditLogType.VM_MIGRATION_DONE
-                        : isInternalExecution() ?
-                                
AuditLogType.VM_MIGRATION_START_SYSTEM_INITIATED
-                                : AuditLogType.VM_MIGRATION_START
+                        : getAuditLogForMigrationStarted()
                 : _isRerun ?
                         AuditLogType.VM_MIGRATION_TRYING_RERUN
-                        : getVds().getStatus() == 
VDSStatus.PreparingForMaintenance ?
-                                
AuditLogType.VM_MIGRATION_FAILED_DURING_MOVE_TO_MAINTENANCE
-                                : getDestinationVds() == null ? 
AuditLogType.VM_MIGRATION_FAILED_NO_VDS_TO_RUN_ON :
-                                    AuditLogType.VM_MIGRATION_FAILED;
+                        : getAuditLogForMigrationFailure();
+    }
+
+    private AuditLogType getAuditLogForMigrationStarted() {
+        return isInternalExecution() ?
+                AuditLogType.VM_MIGRATION_START_SYSTEM_INITIATED
+                : AuditLogType.VM_MIGRATION_START;
+    }
+
+    private AuditLogType getAuditLogForMigrationFailure() {
+        if (getVds().getStatus() == VDSStatus.PreparingForMaintenance) {
+            return AuditLogType.VM_MIGRATION_FAILED_DURING_MOVE_TO_MAINTENANCE;
+        }
+
+        if (getDestinationVds() == null) {
+            return AuditLogType.VM_MIGRATION_FAILED_NO_VDS_TO_RUN_ON;
+        }
+
+        return AuditLogType.VM_MIGRATION_FAILED;
     }
 
     protected Guid getVdsDestinationId() {


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

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

Reply via email to