Selvasundaram has uploaded a new change for review. Change subject: engine: [WIP] Geo-replication status VDS command ......................................................................
engine: [WIP] Geo-replication status VDS command - Get All Geo-replication sessions status Change-Id: I7a5631ecb1a623e72340bff34b1b99829e4716d1 Signed-off-by: Selvasundaram <[email protected]> --- M backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/errors/VdcBllErrors.java M backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/vdscommands/VDSCommandType.java M backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/vdscommands/gluster/GlusterVolumeGeoreplicationVDSParameters.java M backend/manager/modules/dal/src/main/resources/bundles/VdsmErrors.properties M backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/gluster/AbstractGlusterBrokerCommand.java A backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/gluster/GetGlusterGeoreplicationStatusVDSCommand.java A backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/GeoreplicationStatusListReturnForXmlRpc.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 10 files changed, 145 insertions(+), 2 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/50/8950/1 diff --git a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/errors/VdcBllErrors.java b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/errors/VdcBllErrors.java index 3d02f9d..a2ccaa0 100644 --- a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/errors/VdcBllErrors.java +++ b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/errors/VdcBllErrors.java @@ -349,7 +349,7 @@ SshSetupFailed(4506), GlusterVolumeGeoReplicationStartFailed(4160), GlusterVolumeGeoReplicationStopFailed(4161), - + GlusterVolumeGeoReplicationStatusFailed(4162), UnicodeArgumentException(4900), // oVirt errors diff --git a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/vdscommands/VDSCommandType.java b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/vdscommands/VDSCommandType.java index 6857bf5..f7dc1d5 100644 --- a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/vdscommands/VDSCommandType.java +++ b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/vdscommands/VDSCommandType.java @@ -142,6 +142,7 @@ ConfigPasswordlessSsh("org.ovirt.engine.core.vdsbroker.gluster"), GlusterVolumeGeoReplicationStart("org.ovirt.engine.core.vdsbroker.gluster"), GlusterVolumeGeoReplicationStop("org.ovirt.engine.core.vdsbroker.gluster"), + GlusterVolumeGeoReplicationStatus("org.ovirt.engine.core.vdsbroker.gluster"), ; String packageName; diff --git a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/vdscommands/gluster/GlusterVolumeGeoreplicationVDSParameters.java b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/vdscommands/gluster/GlusterVolumeGeoreplicationVDSParameters.java index cb0d792..47a121b 100644 --- a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/vdscommands/gluster/GlusterVolumeGeoreplicationVDSParameters.java +++ b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/vdscommands/gluster/GlusterVolumeGeoreplicationVDSParameters.java @@ -12,6 +12,12 @@ private String remoteServer; private String remoteDir; + public GlusterVolumeGeoreplicationVDSParameters(Guid serverId) { + super(serverId, ""); + setRemoteServer(""); + setRemoteDir(""); + } + public GlusterVolumeGeoreplicationVDSParameters(Guid serverId, String volumeName, String remoteUser, diff --git a/backend/manager/modules/dal/src/main/resources/bundles/VdsmErrors.properties b/backend/manager/modules/dal/src/main/resources/bundles/VdsmErrors.properties index 2c123d0..fdc799b 100644 --- a/backend/manager/modules/dal/src/main/resources/bundles/VdsmErrors.properties +++ b/backend/manager/modules/dal/src/main/resources/bundles/VdsmErrors.properties @@ -324,7 +324,7 @@ GlusterPeerListFailed=Gluster Peer List Failed GlusterVolumeGeoReplicationStartFailed=Gluster Volume Geo-replication Start Failed GlusterVolumeGeoReplicationStopFailed=Gluster Volume Geo-replication Stop Failed - +GlusterVolumeGeoReplicationStatusFailed=Gluster Volume Geo-replication Status Failed CANT_RECONSTRUCT_WHEN_A_DOMAIN_IN_POOL_IS_LOCKED=Can't reconstruct the Master Domain when the Data Center contains Domains in Locked state.\nPlease wait until the operation for these Domains ends before trying to reconstruct the Master Domain again. NO_IMPLEMENTATION=Not implemented FailedToPlugDisk=Failed to hot-plug disk diff --git a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/gluster/AbstractGlusterBrokerCommand.java b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/gluster/AbstractGlusterBrokerCommand.java index 700c094..2578a1c 100644 --- a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/gluster/AbstractGlusterBrokerCommand.java +++ b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/gluster/AbstractGlusterBrokerCommand.java @@ -38,6 +38,7 @@ case SshSetupFailed: case GlusterVolumeGeoReplicationStartFailed: case GlusterVolumeGeoReplicationStopFailed: + case GlusterVolumeGeoReplicationStatusFailed: // Capture error from gluster command and record failure getVDSReturnValue().setVdsError(new VDSError(returnStatus, getReturnStatus().mMessage)); getVDSReturnValue().setSucceeded(false); diff --git a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/gluster/GetGlusterGeoreplicationStatusVDSCommand.java b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/gluster/GetGlusterGeoreplicationStatusVDSCommand.java new file mode 100644 index 0000000..df61776 --- /dev/null +++ b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/gluster/GetGlusterGeoreplicationStatusVDSCommand.java @@ -0,0 +1,31 @@ +package org.ovirt.engine.core.vdsbroker.gluster; + +import org.ovirt.engine.core.common.vdscommands.gluster.GlusterVolumeGeoreplicationVDSParameters; +import org.ovirt.engine.core.vdsbroker.vdsbroker.GeoreplicationStatusListReturnForXmlRpc; +import org.ovirt.engine.core.vdsbroker.vdsbroker.StatusForXmlRpc; + +public class GetGlusterGeoreplicationStatusVDSCommand<P extends GlusterVolumeGeoreplicationVDSParameters> extends AbstractGlusterBrokerCommand<P> { + + private GeoreplicationStatusListReturnForXmlRpc result; + + public GetGlusterGeoreplicationStatusVDSCommand(P parameters) { + super(parameters); + } + + @Override + protected StatusForXmlRpc getReturnStatus() { + return result.mStatus; + } + + @Override + protected void ExecuteVdsBrokerCommand() { + result = + getBroker().glusterVolumeGeoReplicationStatus(getVds().getvds_group_id(), + getParameters().getVolumeName(), + getParameters().getRemoteServer(), + getParameters().getRemoteDir()); + + ProceedProxyReturnValue(); + setReturnValue(result.getGeoreplicationStatusList()); + } +} diff --git a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/GeoreplicationStatusListReturnForXmlRpc.java b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/GeoreplicationStatusListReturnForXmlRpc.java new file mode 100644 index 0000000..a77c7dc --- /dev/null +++ b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/GeoreplicationStatusListReturnForXmlRpc.java @@ -0,0 +1,80 @@ +package org.ovirt.engine.core.vdsbroker.vdsbroker; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +import org.ovirt.engine.core.common.businessentities.VDS; +import org.ovirt.engine.core.common.businessentities.gluster.GlusterGeoreplicationEntity; +import org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity; +import org.ovirt.engine.core.compat.Guid; +import org.ovirt.engine.core.dal.dbbroker.DbFacade; +import org.ovirt.engine.core.vdsbroker.irsbroker.StatusReturnForXmlRpc; + +public final class GeoreplicationStatusListReturnForXmlRpc extends StatusReturnForXmlRpc { + + private static final String GEOREP_STATUSES = "GeorepStatuses"; + private static final String VOLUME = "volume"; + private static final String SERVER = "server"; + private static final String REMOTE_SERVER = "remoteServer"; + private static final String REMOTE_USER = "remoteUser"; + private static final String REMOTE_VOL_DIR = "remoteVolDir"; + private static final String GEOREP_STATUS = "georepStatus"; + + private List<GlusterGeoreplicationEntity> georepStatusList = new ArrayList<GlusterGeoreplicationEntity>(); + + @SuppressWarnings("unchecked") + public GeoreplicationStatusListReturnForXmlRpc(Map<String, Object> innerMap, Guid clusterId) { + super(innerMap); + Object[] georepArr = (Object[]) innerMap.get(GEOREP_STATUSES); + + if (georepArr != null) { + for (int i = 0; i < georepArr.length; i++) { + this.georepStatusList.add(prepareGeorepStatus((Map<String, Object>) georepArr[i], clusterId)); + } + } + } + + public GlusterGeoreplicationEntity prepareGeorepStatus(Map<String, Object> map, Guid clusterId) { + GlusterGeoreplicationEntity entity = new GlusterGeoreplicationEntity(); + + entity.setVolumeId(getVolumeId(clusterId, map.get(VOLUME).toString().trim())); + entity.setServerId(getServerId(map.get(SERVER).toString().trim())); + entity.setRemoteServerIpOrHostname(map.get(REMOTE_SERVER).toString()); + entity.setRemoteServerIpOrHostname(map.get(REMOTE_USER).toString()); + entity.setRemoteVolumeOrDir(map.get(REMOTE_VOL_DIR).toString()); + entity.setFingerprint(""); + entity.setStatus(map.get(GEOREP_STATUS).toString()); + return entity; + } + + private Guid getServerId(String hostnameOrIp) { + Guid serverId; + + try { + VDS server = DbFacade.getInstance().getVdsDao().getAllForHostname(hostnameOrIp).get(0); + serverId = server.getId(); + } catch (Exception e) { + serverId = null; + } + return serverId; + } + + private Guid getVolumeId(Guid clusterId, String volumeName) { + Guid volumeId; + + try { + GlusterVolumeEntity volume = + DbFacade.getInstance().getGlusterVolumeDao().getByName(clusterId, volumeName); + volumeId = volume.getId(); + } catch (Exception e) { + volumeId = null; + } + return volumeId; + } + + public List<GlusterGeoreplicationEntity> getGeoreplicationStatusList() { + return georepStatusList; + } + +} 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 870c4e6..81f0a9d 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 @@ -4,6 +4,7 @@ import java.util.concurrent.Future; import java.util.concurrent.FutureTask; +import org.ovirt.engine.core.compat.Guid; import org.ovirt.engine.core.vdsbroker.irsbroker.GlusterServersListReturnForXmlRpc; import org.ovirt.engine.core.vdsbroker.irsbroker.GlusterVolumeOptionsInfoReturnForXmlRpc; import org.ovirt.engine.core.vdsbroker.irsbroker.IsoListReturnForXmlRpc; @@ -255,4 +256,8 @@ String remoteServer, String remoteDir); + GeoreplicationStatusListReturnForXmlRpc glusterVolumeGeoReplicationStatus(Guid clusterId, String volumeName, + String remoteServer, + String remoteDir); + } 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 9e564c6..644f742 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 @@ -249,4 +249,8 @@ String userName, String remoteServer, String remoteDir); + + public Map<String, Object> glusterVolumeGeoReplicationStatus(String volumeName, + String remoteServer, + String remoteDir); } 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 776665a..72a6d01 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 @@ -6,6 +6,7 @@ import java.util.concurrent.FutureTask; import org.apache.commons.httpclient.HttpClient; +import org.ovirt.engine.core.compat.Guid; import org.ovirt.engine.core.vdsbroker.irsbroker.GlusterServersListReturnForXmlRpc; import org.ovirt.engine.core.vdsbroker.irsbroker.GlusterVolumeOptionsInfoReturnForXmlRpc; import org.ovirt.engine.core.vdsbroker.irsbroker.IsoListReturnForXmlRpc; @@ -1207,4 +1208,18 @@ throw new XmlRpcRunTimeException(ute); } } + + @Override + public GeoreplicationStatusListReturnForXmlRpc glusterVolumeGeoReplicationStatus(Guid clusterId, String volumeName, + String remoteServer, + String remoteDir) { + try { + return new GeoreplicationStatusListReturnForXmlRpc(vdsServer.glusterVolumeGeoReplicationStatus(volumeName, + remoteServer, + remoteDir), clusterId); + } catch (UndeclaredThrowableException ute) { + throw new XmlRpcRunTimeException(ute); + } + } + } -- To view, visit http://gerrit.ovirt.org/8950 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I7a5631ecb1a623e72340bff34b1b99829e4716d1 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Selvasundaram <[email protected]> _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
