Selvasundaram has uploaded a new change for review. Change subject: engine: Gluster server peer list command ......................................................................
engine: Gluster server peer list command Vds command to fetch the gluster server peer list Change-Id: Icfacfdc5847e5d871da38d22b6b5efe86ea4d579 Signed-off-by: Selvasundaram <sesub...@redhat.com> --- M backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/AuditLogType.java A backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/gluster/GlusterHostEntity.java M backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/errors/VdcBllErrors.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/GlusterHostsListVDSCommand.java A backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/irsbroker/GlusterHostsListReturnForXmlRpc.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, 161 insertions(+), 2 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/42/7242/1 diff --git a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/AuditLogType.java b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/AuditLogType.java index 1254232..c2b436c 100644 --- a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/AuditLogType.java +++ b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/AuditLogType.java @@ -199,7 +199,7 @@ GLUSTER_VOLUME_ADD_BRICK_FAILED(4020), GLUSTER_HOST_REMOVE_FAILED(4021), GLUSTER_HOST_ADD_FAILED(4404), - + GLUSTER_HOST_LIST_FAILED(4405), USER_VDS_RESTART(41), USER_FAILED_VDS_RESTART(107), diff --git a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/gluster/GlusterHostEntity.java b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/gluster/GlusterHostEntity.java new file mode 100644 index 0000000..949d813 --- /dev/null +++ b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/gluster/GlusterHostEntity.java @@ -0,0 +1,72 @@ +package org.ovirt.engine.core.common.businessentities.gluster; + +import org.ovirt.engine.core.common.businessentities.IVdcQueryable; +import org.ovirt.engine.core.common.businessentities.VDSStatus; +import org.ovirt.engine.core.common.utils.gluster.GlusterCoreUtil; +import org.ovirt.engine.core.compat.Guid; + +public class GlusterHostEntity extends IVdcQueryable { + + private Guid uuid; + + private String hostName; + + private VDSStatus status; + + public GlusterHostEntity() { + } + + public GlusterHostEntity(Guid uuid, String hostName, String fingerPrint, VDSStatus status) { + setUuid(uuid); + setHostName(hostName); + setStatus(status); + } + + public Guid getUuid() { + return uuid; + } + + public void setUuid(Guid uuid) { + this.uuid = uuid; + } + + public String getHostName() { + return hostName; + } + + public void setHostName(String hostName) { + this.hostName = hostName; + } + + public VDSStatus getStatus() { + return status; + } + + public void setStatus(VDSStatus status) { + this.status = status; + } + + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + getUuid().hashCode(); + result = prime * result + ((hostName == null) ? 0 : hostName.hashCode()); + result = prime * result + ((status == null) ? 0 : status.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (!(obj instanceof GlusterHostEntity)) { + return false; + } + + GlusterHostEntity host = (GlusterHostEntity) obj; + return (getUuid().equals(host.getUuid()) + && (GlusterCoreUtil.objectsEqual(hostName, host.getHostName())) + && (GlusterCoreUtil.objectsEqual(status, host.getStatus()))); + } + +} 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 54ad466..e05c6fb 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 @@ -336,6 +336,7 @@ GlusterVolumeReplaceBrickStartFailed(4142), GlusterHostRemoveFailed(4406), GlusterAddHostFailed(4404), + GlusterPeerListFailed(4405), UnicodeArgumentException(4900), 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 86ae3d2..1cf9963 100644 --- a/backend/manager/modules/dal/src/main/resources/bundles/VdsmErrors.properties +++ b/backend/manager/modules/dal/src/main/resources/bundles/VdsmErrors.properties @@ -318,7 +318,8 @@ GlusterVolumeRebalanceStartFailed=Gluster Volume Rebalance Start Failed GlusterVolumeReplaceBrickStartFailed=Gluster Volume Replace Brick Start Failed GlusterHostRemoveFailed=Gluster Server Remove Failed -GlusterAddHostFailed=Gluster Server Add Failed +GlusterAddHostFailed=Gluster Server Add Failed +GlusterPeerListFailed=Gluster Peer List 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 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 ab2214f..b4b909e 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 @@ -30,6 +30,7 @@ case GlusterVolumeReplaceBrickStartFailed: case GlusterHostRemoveFailed: case GlusterAddHostFailed: + case GlusterPeerListFailed: // 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/GlusterHostsListVDSCommand.java b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/gluster/GlusterHostsListVDSCommand.java new file mode 100644 index 0000000..a2610a2 --- /dev/null +++ b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/gluster/GlusterHostsListVDSCommand.java @@ -0,0 +1,24 @@ +package org.ovirt.engine.core.vdsbroker.gluster; + +import org.ovirt.engine.core.common.vdscommands.VdsIdVDSCommandParametersBase; +import org.ovirt.engine.core.vdsbroker.irsbroker.GlusterHostsListReturnForXmlRpc; + +public class GlusterHostsListVDSCommand<P extends VdsIdVDSCommandParametersBase> extends AbstractGlusterBrokerCommand<P> { + + private GlusterHostsListReturnForXmlRpc glusterHosts; + + public GlusterHostsListVDSCommand(P parameters) { + super(parameters); + } + + @Override + protected void ExecuteVdsBrokerCommand() { + glusterHosts = getBroker().glusterHostsList(); + ProceedProxyReturnValue(); + + if (getVDSReturnValue().getSucceeded()) { + setReturnValue(glusterHosts.hostsList); + } + } + +} diff --git a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/irsbroker/GlusterHostsListReturnForXmlRpc.java b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/irsbroker/GlusterHostsListReturnForXmlRpc.java new file mode 100644 index 0000000..166cd02 --- /dev/null +++ b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/irsbroker/GlusterHostsListReturnForXmlRpc.java @@ -0,0 +1,42 @@ +package org.ovirt.engine.core.vdsbroker.irsbroker; + +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + +import org.ovirt.engine.core.common.businessentities.VDSStatus; +import org.ovirt.engine.core.common.businessentities.gluster.GlusterHostEntity; +import org.ovirt.engine.core.compat.Guid; + +public final class GlusterHostsListReturnForXmlRpc extends StatusReturnForXmlRpc { + + private static final String GLUSTER_HOSTS = "hosts"; + + private static final String HOST_NAME = "hostname"; + + private static final String UUID = "uuid"; + + private static final String PEER_STATUS = "status"; + + public Set<GlusterHostEntity> hostsList = new HashSet<GlusterHostEntity>(); + + public GlusterHostsListReturnForXmlRpc(Map<String, Object> innerMap) { + super(innerMap); + Object[] temp = (Object[]) innerMap.get(GLUSTER_HOSTS); + + if (temp != null) { + for (int i = 0; i < temp.length; i++) { + hostsList.add(prepareHostsEntity((Map<String, Object>) temp[i])); + } + } + } + + private GlusterHostEntity prepareHostsEntity(Map<String, Object> map) { + GlusterHostEntity entity = new GlusterHostEntity(); + entity.setHostName(map.get(HOST_NAME).toString()); + entity.setUuid(new Guid(map.get(UUID).toString())); + entity.setStatus(map.get(PEER_STATUS).toString().equals("CONNECTED") ? VDSStatus.Up : VDSStatus.Down); + return entity; + } + +} 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 1bc410a..23f537b 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.vdsbroker.irsbroker.GlusterHostsListReturnForXmlRpc; import org.ovirt.engine.core.vdsbroker.irsbroker.GlusterVolumeOptionsInfoReturnForXmlRpc; import org.ovirt.engine.core.vdsbroker.irsbroker.IsoListReturnForXmlRpc; import org.ovirt.engine.core.vdsbroker.irsbroker.OneUuidReturnForXmlRpc; @@ -233,4 +234,6 @@ StatusOnlyReturnForXmlRpc glusterHostAdd(String hostName); + GlusterHostsListReturnForXmlRpc glusterHostsList(); + } 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 d928caf..246da01 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 @@ -224,6 +224,8 @@ public Map<String, Object> glusterHostAdd(String hostName); + public Map<String, Object> glusterHostsList(); + public Map<String, Object> ping(); @FutureCall(delegeteTo = "ping") 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 b3cf60b..def630d 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.vdsbroker.irsbroker.GlusterHostsListReturnForXmlRpc; import org.ovirt.engine.core.vdsbroker.irsbroker.GlusterVolumeOptionsInfoReturnForXmlRpc; import org.ovirt.engine.core.vdsbroker.irsbroker.IsoListReturnForXmlRpc; import org.ovirt.engine.core.vdsbroker.irsbroker.OneUuidReturnForXmlRpc; @@ -1136,4 +1137,16 @@ throw new XmlRpcRunTimeException(ute); } } + + @Override + public GlusterHostsListReturnForXmlRpc glusterHostsList() { + try { + Map<String, Object> xmlRpcReturnValue = vdsServer.glusterHostsList(); + GlusterHostsListReturnForXmlRpc wrapper = new GlusterHostsListReturnForXmlRpc(xmlRpcReturnValue); + return wrapper; + } catch (UndeclaredThrowableException ute) { + throw new XmlRpcRunTimeException(ute); + } + } + } -- To view, visit http://gerrit.ovirt.org/7242 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Icfacfdc5847e5d871da38d22b6b5efe86ea4d579 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Selvasundaram <sesub...@redhat.com> _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches