Timothy Asir has uploaded a new change for review. Change subject: gluster: add gluster host uuid along with host name/ip for remove host ......................................................................
gluster: add gluster host uuid along with host name/ip for remove host Add gluster host uuid in remove host request to uniquely identify the peer. Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=1024851 Change-Id: I799333a16dfffaa6125aa6d498e4292cbb97cf48 Signed-off-by: Timothy Asir <[email protected]> --- M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/ChangeVDSClusterCommand.java M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RemoveVdsCommand.java M backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/vdscommands/gluster/RemoveGlusterServerVDSParameters.java M backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/gluster/RemoveGlusterServerVDSCommand.java M backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/IVdsServer.java M backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/VdsServerConnector.java M backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/VdsServerWrapper.java 7 files changed, 63 insertions(+), 20 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/31/20731/1 diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/ChangeVDSClusterCommand.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/ChangeVDSClusterCommand.java index 01d82e2..218f83b 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/ChangeVDSClusterCommand.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/ChangeVDSClusterCommand.java @@ -18,6 +18,7 @@ import org.ovirt.engine.core.common.businessentities.VDS; import org.ovirt.engine.core.common.businessentities.VDSGroup; import org.ovirt.engine.core.common.businessentities.VdsStatic; +import org.ovirt.engine.core.common.businessentities.gluster.GlusterServer; import org.ovirt.engine.core.common.errors.VdcBllMessages; import org.ovirt.engine.core.common.vdscommands.VDSCommandType; import org.ovirt.engine.core.common.vdscommands.VDSReturnValue; @@ -201,8 +202,8 @@ private boolean glusterHostRemove(Guid sourceClusterId) { String hostName = - (getVds().getHostName().isEmpty()) ? getVds().getManagementIp() - : getVds().getHostName(); + (getVds().getHostName().isEmpty()) ? getVds().getManagementIp() + : getVds().getHostName(); VDS runningHostInSourceCluster = getClusterUtils().getUpServer(sourceClusterId); if (runningHostInSourceCluster == null) { log.error("Cannot remove host from source cluster, no host in Up status found in source cluster"); @@ -210,13 +211,22 @@ errorType = AuditLogType.GLUSTER_SERVER_REMOVE_FAILED; return false; } + Guid serverId = runningHostInSourceCluster.getId(); + GlusterServer glusterServer = getDbFacade().getGlusterServerDao().getByServerId(serverId); + Guid glusterHostId = + (glusterServer != null) ? glusterServer.getGlusterServerUuid() : null; + if (glusterHostId == null) { + handleError(-1, "Failed to get gluser UUID for the host:" + hostName); + errorType = AuditLogType.GLUSTER_SERVER_REMOVE_FAILED; + return false; + } VDSReturnValue returnValue = - runVdsCommand( - VDSCommandType.RemoveGlusterServer, - new RemoveGlusterServerVDSParameters(runningHostInSourceCluster.getId(), - hostName, - false)); - + runVdsCommand( + VDSCommandType.RemoveGlusterServer, + new RemoveGlusterServerVDSParameters(serverId, + hostName, + false, + glusterHostId)); if (!returnValue.getSucceeded()) { handleVdsError(returnValue); errorType = AuditLogType.GLUSTER_SERVER_REMOVE_FAILED; diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RemoveVdsCommand.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RemoveVdsCommand.java index b13bd11..49327c3 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RemoveVdsCommand.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RemoveVdsCommand.java @@ -13,6 +13,7 @@ import org.ovirt.engine.core.common.businessentities.VDS; import org.ovirt.engine.core.common.businessentities.VDSGroup; import org.ovirt.engine.core.common.businessentities.VDSStatus; +import org.ovirt.engine.core.common.businessentities.gluster.GlusterServer; import org.ovirt.engine.core.common.errors.VdcBllMessages; import org.ovirt.engine.core.common.locks.LockingGroup; import org.ovirt.engine.core.common.utils.Pair; @@ -26,6 +27,7 @@ import org.ovirt.engine.core.dao.gluster.GlusterBrickDao; import org.ovirt.engine.core.utils.transaction.TransactionMethod; import org.ovirt.engine.core.utils.transaction.TransactionSupport; +import org.ovirt.engine.core.dao.gluster.GlusterServerDao; @NonTransactiveCommandAttribute @LockIdNameAttribute @@ -195,22 +197,40 @@ private void glusterHostRemove() { if (clusterHasMultipleHosts() && !hasVolumeBricksOnServer()) { + GlusterServer glusterServer = getGlusterServerDao().getByServerId(getVds().getId()); + Guid glusterHostId = + (glusterServer != null) ? glusterServer.getGlusterServerUuid() : null; + if (glusterHostId == null) { + handleError(-1, "Failed to get gluser UUID for the host:" + getVds().getId()); + errorType = AuditLogType.GLUSTER_SERVER_REMOVE_FAILED; + return; + } VDSReturnValue returnValue = - runVdsCommand( - VDSCommandType.RemoveGlusterServer, - new RemoveGlusterServerVDSParameters(upServer.getId(), - getVds().getHostName(), - getParameters().isForceAction())); + runVdsCommand( + VDSCommandType.RemoveGlusterServer, + new RemoveGlusterServerVDSParameters(upServer.getId(), + getVds().getHostName(), + getParameters().isForceAction(), + glusterHostId)); setSucceeded(returnValue.getSucceeded()); if (!getSucceeded()) { - getReturnValue().getFault().setError(returnValue.getVdsError().getCode()); - getReturnValue().getFault().setMessage(returnValue.getVdsError().getMessage()); + handleVdsError(returnValue); errorType = AuditLogType.GLUSTER_SERVER_REMOVE_FAILED; return; } } } + private void handleError(int errorCode, String errorMsg) { + getReturnValue().getFault().setError(errorCode); + getReturnValue().getFault().setMessage(errorMsg); + getReturnValue().getExecuteFailedMessages().add(errorMsg); + } + + private GlusterServerDao getGlusterServerDao() { + return getDbFacade().getGlusterServerDao(); + } + private boolean clusterHasMultipleHosts() { return getClusterUtils().hasMultipleServers(getVdsGroupId()); } diff --git a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/vdscommands/gluster/RemoveGlusterServerVDSParameters.java b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/vdscommands/gluster/RemoveGlusterServerVDSParameters.java index 43d282f..bacd187 100644 --- a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/vdscommands/gluster/RemoveGlusterServerVDSParameters.java +++ b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/vdscommands/gluster/RemoveGlusterServerVDSParameters.java @@ -10,11 +10,17 @@ public class RemoveGlusterServerVDSParameters extends VdsIdVDSCommandParametersBase { private String hostnameOrIp; private boolean forceAction; + private Guid glusterHostId; public RemoveGlusterServerVDSParameters(Guid serverId, String hostnameOrIp, boolean forceAction) { super(serverId); this.hostnameOrIp = hostnameOrIp; setForceAction(forceAction); + } + + public RemoveGlusterServerVDSParameters(Guid serverId, String hostnameOrIp, boolean forceAction, Guid glusterHostId) { + this(serverId, hostnameOrIp, forceAction); + this.glusterHostId = glusterHostId; } public String getHostnameOrIp() { @@ -29,5 +35,8 @@ this.forceAction = forceAction; } + public Guid getGlusterHostId() { + return glusterHostId; + } } diff --git a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/gluster/RemoveGlusterServerVDSCommand.java b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/gluster/RemoveGlusterServerVDSCommand.java index 105fc5f..6296959 100644 --- a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/gluster/RemoveGlusterServerVDSCommand.java +++ b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/gluster/RemoveGlusterServerVDSCommand.java @@ -11,7 +11,7 @@ @Override protected void executeVdsBrokerCommand() { - status = getBroker().glusterHostRemove(getParameters().getHostnameOrIp(), getParameters().isForceAction()); + status = getBroker().glusterHostRemove(getParameters().getHostnameOrIp(), getParameters().isForceAction(), getParameters().getGlusterHostId()); proceedProxyReturnValue(); } diff --git a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/IVdsServer.java b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/IVdsServer.java index 94ab2ab..7c4bbd0 100644 --- a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/IVdsServer.java +++ b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/IVdsServer.java @@ -232,7 +232,7 @@ String existingBrickDir, String newBrickDir); - StatusOnlyReturnForXmlRpc glusterHostRemove(String hostName, Boolean force); + StatusOnlyReturnForXmlRpc glusterHostRemove(String hostName, Boolean force, Guid hostId); StatusOnlyReturnForXmlRpc glusterHostAdd(String hostName); diff --git a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/VdsServerConnector.java b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/VdsServerConnector.java index 39d88bb..7a7eeef 100644 --- a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/VdsServerConnector.java +++ b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/VdsServerConnector.java @@ -212,7 +212,7 @@ public Map<String, Object> replaceGlusterVolumeBrickStart(String volumeName, String existingBrickDir, String newBrickDir); - public Map<String, Object> glusterHostRemove(String hostName, Boolean force); + public Map<String, Object> glusterHostRemove(String hostName, Boolean force, Map<String, String> option); public Map<String, Object> glusterVolumeReplaceBrickStart(String volumeName, String existingBrickDir, String newBrickDir); diff --git a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/VdsServerWrapper.java b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/VdsServerWrapper.java index 613b17b..7faaddf 100644 --- a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/VdsServerWrapper.java +++ b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/VdsServerWrapper.java @@ -1,6 +1,7 @@ package org.ovirt.engine.core.vdsbroker.vdsbroker; import java.lang.reflect.UndeclaredThrowableException; +import java.util.HashMap; import java.util.Map; import java.util.concurrent.Future; import java.util.concurrent.FutureTask; @@ -1044,9 +1045,12 @@ } @Override - public StatusOnlyReturnForXmlRpc glusterHostRemove(String hostName, Boolean force) { + public StatusOnlyReturnForXmlRpc glusterHostRemove(String hostName, Boolean force, Guid hostId) { try { - return new StatusOnlyReturnForXmlRpc(vdsServer.glusterHostRemove(hostName, force)); + Map<String, String> options = new HashMap<String, String>(); + options.put("hostUuid", hostId.toString()); + Map<String, Object> xmlRpcReturnValue = vdsServer.glusterHostRemove(hostName, force, options); + return new StatusOnlyReturnForXmlRpc(xmlRpcReturnValue); } catch (UndeclaredThrowableException ute) { throw new XmlRpcRunTimeException(ute); } -- To view, visit http://gerrit.ovirt.org/20731 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I799333a16dfffaa6125aa6d498e4292cbb97cf48 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Timothy Asir <[email protected]> _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
