Martin Peřina has uploaded a new change for review.

Change subject: core: Fix skipped status in fencing
......................................................................

core: Fix skipped status in fencing

Fixes the distinction between two types of skipping fencing operation:

 1. Skipped due to status
      - on/off operation is skipped because host power status is already
        on/off

 2. Skipped due to fencing policy
      - on/off operation is skipped becuase host is non responsive but
        it's still connected to storage

Change-Id: Ia0c2a76d10a7e501ed5a53b323acb251c05c06fb
Bug-Url: https://bugzilla.redhat.com/1192596
Signed-off-by: Martin Perina <mper...@redhat.com>
---
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/FenceExecutor.java
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/FenceVdsBaseCommand.java
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RestartVdsCommand.java
M 
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/FenceStatusReturnValue.java
M 
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/vdscommands/VDSFenceReturnValue.java
M 
backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/FenceVdsVDSCommand.java
6 files changed, 35 insertions(+), 11 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/57/37857/1

diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/FenceExecutor.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/FenceExecutor.java
index 085b1ed..65c1810 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/FenceExecutor.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/FenceExecutor.java
@@ -153,7 +153,7 @@
         }
         VDSFenceReturnValue returnVal = new VDSFenceReturnValue(result);
         returnVal.setFenceAgentUsed(agent);
-        returnVal.setSucceeded(result.getSucceeded() || 
returnVal.isSkipped()); // skipping due to policy
+        returnVal.setSucceeded(result.getSucceeded() || 
returnVal.isSkippedDueToPolicy()); // skipping due to policy
         return returnVal;
     }
 
diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/FenceVdsBaseCommand.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/FenceVdsBaseCommand.java
index a619285..20d052c 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/FenceVdsBaseCommand.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/FenceVdsBaseCommand.java
@@ -372,7 +372,9 @@
      * 'skipped' as having occurred to due a fencing policy violation.
      */
     private boolean wasSkippedDueToPolicy(VDSFenceReturnValue result) {
-        return result != null && result.isSkipped() && 
getParameters().getParentCommand() == VdcActionType.RestartVds;
+        return result != null
+                && result.isSkippedDueToPolicy()
+                && getParameters().getParentCommand() == 
VdcActionType.RestartVds;
     }
 
     /**
@@ -380,7 +382,9 @@
      * we interpret the skip as having occurred because the host is already at 
the required state.
      */
     private boolean wasSkippedDueToStatus(VDSFenceReturnValue result) {
-        return result != null && result.isSkipped() && 
getParameters().getParentCommand() != VdcActionType.RestartVds;
+        return result != null
+                && result.isSkippedDueToStatus()
+                && getParameters().getParentCommand() != 
VdcActionType.RestartVds;
     }
 
     public FenceValidator getFenceValidator() {
diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RestartVdsCommand.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RestartVdsCommand.java
index 2c5dcc3..8cfa7f2 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RestartVdsCommand.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RestartVdsCommand.java
@@ -209,7 +209,7 @@
         if (result.getActionReturnValue() instanceof VDSFenceReturnValue) {
             VDSFenceReturnValue fenceReturnValue = 
result.getActionReturnValue();
             if (fenceReturnValue.getReturnValue() instanceof 
FenceStatusReturnValue) {
-                skipped = ((FenceStatusReturnValue) 
fenceReturnValue.getReturnValue()).getIsSkipped();
+                skipped = ((FenceStatusReturnValue) 
fenceReturnValue.getReturnValue()).getIsSkippedDueToPolicy();
             }
         }
         return skipped;
diff --git 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/FenceStatusReturnValue.java
 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/FenceStatusReturnValue.java
index c12d619..eac8348 100644
--- 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/FenceStatusReturnValue.java
+++ 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/FenceStatusReturnValue.java
@@ -7,7 +7,8 @@
 public class FenceStatusReturnValue implements Serializable {
     private static final long serialVersionUID = 8070963676213797507L;
     // indicates that operation was skipped because Host is already in 
requested state.
-    public static final String SKIPPED = "skipped";
+    public static final String SKIPPED_DUE_TO_STATUS = "skipped_due_to_status";
+    public static final String SKIPPED_DUE_TO_POLICY = "skipped";
     public static final String INITIATED = "initiated";
     public FenceStatusReturnValue(String status, String message) {
         _status = status;
@@ -30,8 +31,12 @@
         return (StringHelper.isNullOrEmpty(getMessage()));
     }
 
-    public boolean getIsSkipped() {
-        return SKIPPED.equalsIgnoreCase(_status);
+    public boolean getIsSkippedDueToStatus() {
+        return SKIPPED_DUE_TO_STATUS.equalsIgnoreCase(_status);
+    }
+
+    public boolean getIsSkippedDueToPolicy() {
+        return SKIPPED_DUE_TO_POLICY.equalsIgnoreCase(_status);
     }
 
     public boolean getIsInitiated() {
diff --git 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/vdscommands/VDSFenceReturnValue.java
 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/vdscommands/VDSFenceReturnValue.java
index 67e04d6..5b6ce85 100644
--- 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/vdscommands/VDSFenceReturnValue.java
+++ 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/vdscommands/VDSFenceReturnValue.java
@@ -44,13 +44,28 @@
     }
 
     /**
-     * Determines according to the return status from fence invocation whether 
the fence-operation has been skipped.
+     * Determines according to the return status from fence invocation whether 
the fence-operation has been skipped
+     * due to status already reached
      */
-    public boolean isSkipped() {
+    public boolean isSkippedDueToStatus() {
         if (getReturnValue() != null && getReturnValue() instanceof 
FenceStatusReturnValue) {
             FenceStatusReturnValue fenceStatus =
                     (FenceStatusReturnValue) getReturnValue();
-            return fenceStatus.getIsSkipped();
+            return fenceStatus.getIsSkippedDueToStatus();
+        } else {
+            return false;
+        }
+    }
+
+    /**
+     * Determines according to the return status from fence invocation whether 
the fence-operation has been skipped
+     * due to fencing policy
+     */
+    public boolean isSkippedDueToPolicy() {
+        if (getReturnValue() != null && getReturnValue() instanceof 
FenceStatusReturnValue) {
+            FenceStatusReturnValue fenceStatus =
+                    (FenceStatusReturnValue) getReturnValue();
+            return fenceStatus.getIsSkippedDueToPolicy();
         } else {
             return false;
         }
diff --git 
a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/FenceVdsVDSCommand.java
 
b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/FenceVdsVDSCommand.java
index a6f627e..c28bd38 100644
--- 
a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/FenceVdsVDSCommand.java
+++ 
b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/FenceVdsVDSCommand.java
@@ -124,7 +124,7 @@
      * Handles cases where fence operation was skipped (host is already in 
requested state)
      */
     private void handleSkippedOperation() {
-        FenceStatusReturnValue fenceStatusReturnValue = new 
FenceStatusReturnValue(FenceStatusReturnValue.SKIPPED, "");
+        FenceStatusReturnValue fenceStatusReturnValue = new 
FenceStatusReturnValue(FenceStatusReturnValue.SKIPPED_DUE_TO_STATUS, "");
         AuditLogableBase auditLogable = new AuditLogableBase();
         auditLogable.addCustomValue("HostName",
                 
(DbFacade.getInstance().getVdsDao().get(getParameters().getTargetVdsID())).getName());


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ia0c2a76d10a7e501ed5a53b323acb251c05c06fb
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Martin Peřina <mper...@redhat.com>
_______________________________________________
Engine-patches mailing list
Engine-patches@ovirt.org
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to