Liron Ar has uploaded a new change for review.

Change subject: core: connect to sp when needed before "fencing"
......................................................................

core: connect to sp when needed before "fencing"

FenceVdsManualyCommand is being executed in order to mark that a new
spm can be started. The command executes the fenceSpmStorage verb using one
of the hsm's in the the pool to mark that in the pool metadata
(current implementation), if the host isn't connected to the pool the operation
would fail.

If the spm status results indicates that the host isn't connected to the
pool, it should be connected before executing fenceSpmStorage in order
to not fail. If the host failed to connect to the pool, there's no point
in executing fenceSpmStorage with it's current implementation.

Change-Id: I2770dd95a03afccd02174dadf902f443a0a66a49
Signed-off-by: Liron Aravot <lara...@redhat.com>
---
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/FenceVdsManualyCommand.java
1 file changed, 37 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/06/27306/1

diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/FenceVdsManualyCommand.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/FenceVdsManualyCommand.java
index 320f00a..b1987dc 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/FenceVdsManualyCommand.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/FenceVdsManualyCommand.java
@@ -14,6 +14,7 @@
 import org.ovirt.engine.core.common.action.FenceVdsManualyParameters;
 import org.ovirt.engine.core.common.action.VdcActionType;
 import org.ovirt.engine.core.common.action.VdsActionParameters;
+import org.ovirt.engine.core.common.businessentities.SpmStatus;
 import org.ovirt.engine.core.common.businessentities.SpmStatusResult;
 import org.ovirt.engine.core.common.businessentities.StorageDomain;
 import org.ovirt.engine.core.common.businessentities.StorageDomainStatus;
@@ -22,12 +23,16 @@
 import org.ovirt.engine.core.common.businessentities.VDS;
 import org.ovirt.engine.core.common.businessentities.VDSStatus;
 import org.ovirt.engine.core.common.businessentities.VdsSpmStatus;
+import org.ovirt.engine.core.common.errors.VDSError;
+import org.ovirt.engine.core.common.errors.VdcBLLException;
 import org.ovirt.engine.core.common.errors.VdcBllMessages;
 import org.ovirt.engine.core.common.utils.Pair;
+import 
org.ovirt.engine.core.common.vdscommands.ConnectStoragePoolVDSCommandParameters;
 import 
org.ovirt.engine.core.common.vdscommands.FenceSpmStorageVDSCommandParameters;
 import org.ovirt.engine.core.common.vdscommands.ResetIrsVDSCommandParameters;
 import org.ovirt.engine.core.common.vdscommands.SpmStatusVDSCommandParameters;
 import org.ovirt.engine.core.common.vdscommands.VDSCommandType;
+import org.ovirt.engine.core.common.vdscommands.VDSReturnValue;
 import org.ovirt.engine.core.compat.Guid;
 import org.ovirt.engine.core.dal.dbbroker.DbFacade;
 import org.ovirt.engine.core.dal.dbbroker.auditloghandling.AlertDirector;
@@ -189,6 +194,38 @@
                                     .RunVdsCommand(VDSCommandType.SpmStatus,
                                             new 
SpmStatusVDSCommandParameters(vds.getId(), getStoragePool().getId()))
                                     .getReturnValue();
+                            if (statusResult.getSpmStatus() == 
SpmStatus.Unknown_Pool) {
+                                log.infoFormat("vds {0} - {1} isn't connected 
to the storage pool, attempting to connect in order to perform the operation",
+                                        vds.getName(),
+                                        vds.getId());
+                                VDSError error = null;
+
+                                try {
+                                    VDSReturnValue vdsReturnValue =
+                                            runVdsCommand(
+                                                    
VDSCommandType.ConnectStoragePool,
+                                                    new 
ConnectStoragePoolVDSCommandParameters(vds.getId(),
+                                                            
getStoragePool().getId(),
+                                                            vds.getVdsSpmId(),
+                                                            
masterDomain.getId(),
+                                                            
getStoragePool().getmaster_domain_version()));
+                                    if (!vdsReturnValue.getSucceeded()) {
+                                        error = vdsReturnValue.getVdsError();
+                                    }
+                                } catch (VdcBLLException e) {
+                                    error = e.getVdsError();
+                                }
+
+                                if (error != null) {
+                                    log.infoFormat("Failed to connect host {0} 
to the storage pool with error code {1} (message {2}), " +
+                                            "trying using the next host (if 
available)",
+                                            vds.getName(),
+                                            error.getCode(),
+                                            error.getMessage());
+                                    continue;
+                                }
+
+                            }
                             log.infoFormat("Trying to fence spm {0} via vds 
{1}",
                                     _problematicVds.getName(),
                                     vds.getName());


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

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

Reply via email to