Martin Peřina has uploaded a new change for review. Change subject: core: webadmin: Replace FenceExecutor in GetFenceAgentStatusQuery ......................................................................
core: webadmin: Replace FenceExecutor in GetFenceAgentStatusQuery Replaces FenceExecutor with HostFenceActionExecutor in GetFenceAgentStatusQuery and refactors displaying result of agent test. Change-Id: I509729eda00098ea63396c13fd3a6619e55c8c76 Bug-Url: https://bugzilla.redhat.com/1182510 Signed-off-by: Martin Perina <[email protected]> --- M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/GetFenceAgentStatusQuery.java M backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/queries/GetFenceAgentStatusParameters.java M frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/hosts/HostModel.java M frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/UIConstants.java 4 files changed, 71 insertions(+), 57 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/67/38967/1 diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/GetFenceAgentStatusQuery.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/GetFenceAgentStatusQuery.java index 1815cdc..36a5380 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/GetFenceAgentStatusQuery.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/GetFenceAgentStatusQuery.java @@ -1,16 +1,14 @@ package org.ovirt.engine.core.bll; -import org.ovirt.engine.core.common.AuditLogType; -import org.ovirt.engine.core.common.businessentities.FenceStatusReturnValue; +import org.ovirt.engine.core.bll.pm.HostFenceActionExecutor; import org.ovirt.engine.core.common.businessentities.VDS; +import org.ovirt.engine.core.common.businessentities.pm.FenceActionType; +import org.ovirt.engine.core.common.businessentities.pm.FenceOperationResult; +import org.ovirt.engine.core.common.businessentities.pm.FenceOperationResult.Status; import org.ovirt.engine.core.common.queries.GetFenceAgentStatusParameters; -import org.ovirt.engine.core.common.vdscommands.VDSFenceReturnValue; import org.ovirt.engine.core.compat.Guid; -import org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogDirector; public class GetFenceAgentStatusQuery<P extends GetFenceAgentStatusParameters> extends FenceQueryBase<P> { - - private static final String UNKNOWN = "unknown"; public GetFenceAgentStatusQuery(P parameters) { super(parameters); @@ -18,33 +16,20 @@ @Override protected void executeQueryCommand() { - FenceExecutor executor = new FenceExecutor(getHost()); - VDSFenceReturnValue result = executor.checkAgentStatus(getParameters().getAgent()); - if (result.getSucceeded()) { - getQueryReturnValue().setReturnValue(result.getReturnValue()); - } else { - handleError(result); - } + HostFenceActionExecutor executor = new HostFenceActionExecutor(getHost()); + FenceOperationResult result = executor.fence(FenceActionType.STATUS, getParameters().getAgent()); + getQueryReturnValue().setSucceeded(result.getStatus() == Status.SUCCESS); + getQueryReturnValue().setReturnValue(result.getMessage()); } private VDS getHost() { Guid id = getParameters().getVdsId(); VDS vds = new VDS(); - vds.setId((Guid) ((id != null) ? id : Guid.Empty)); + vds.setId(id != null ? id : Guid.Empty); + vds.setHostName(getParameters().getHostName()); vds.setStoragePoolId(getParameters().getStoragePoolId()); + vds.setVdsGroupId(getParameters().getVdsGroupId()); vds.setPmProxyPreferences(getParameters().getPmProxyPreferences()); return vds; - } - - private void handleError(VDSFenceReturnValue result) { - if (!result.isProxyHostFound()) { - getQueryReturnValue().setSucceeded(false); - getQueryReturnValue().setReturnValue(new FenceStatusReturnValue(UNKNOWN, - AuditLogDirector.getMessage(AuditLogType.VDS_ALERT_FENCE_NO_PROXY_HOST))); - } else { - getQueryReturnValue().setSucceeded(false); - getQueryReturnValue().setReturnValue(new FenceStatusReturnValue(UNKNOWN, - AuditLogDirector.getMessage(AuditLogType.VDS_ALERT_FENCE_STATUS_VERIFICATION_FAILED))); - } } } diff --git a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/queries/GetFenceAgentStatusParameters.java b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/queries/GetFenceAgentStatusParameters.java index 90db76d..0cc62d2 100644 --- a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/queries/GetFenceAgentStatusParameters.java +++ b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/queries/GetFenceAgentStatusParameters.java @@ -6,12 +6,15 @@ public class GetFenceAgentStatusParameters extends VdcQueryParametersBase { private static final long serialVersionUID = -3663389765505476776L; - private Guid _vds_id; + private Guid vdsId; + private String hostName; private FenceAgent agent; private String pmProxyPreferences; + private Guid storagePoolId; + private Guid vdsGroupId; public GetFenceAgentStatusParameters() { - _storagePoolId = Guid.Empty; + storagePoolId = Guid.Empty; } public FenceAgent getAgent() { @@ -23,21 +26,35 @@ } public Guid getVdsId() { - return _vds_id; + return vdsId; } public void setVdsId(Guid value) { - _vds_id = value; + vdsId = value; } - private Guid _storagePoolId; + public String getHostName() { + return hostName; + } + + public void setHostName(String hostName) { + this.hostName = hostName; + } public Guid getStoragePoolId() { - return _storagePoolId; + return storagePoolId; } public void setStoragePoolId(Guid value) { - _storagePoolId = value; + storagePoolId = value; + } + + public Guid getVdsGroupId() { + return vdsGroupId; + } + + public void setVdsGroupId(Guid vdsGroupId) { + this.vdsGroupId = vdsGroupId; } public String getPmProxyPreferences() { diff --git a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/hosts/HostModel.java b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/hosts/HostModel.java index 08fb179..1f63337 100644 --- a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/hosts/HostModel.java +++ b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/hosts/HostModel.java @@ -10,7 +10,6 @@ import org.ovirt.engine.core.common.action.VdsOperationActionParameters.AuthenticationMethod; import org.ovirt.engine.core.common.businessentities.ArchitectureType; import org.ovirt.engine.core.common.businessentities.ExternalEntityBase; -import org.ovirt.engine.core.common.businessentities.FenceStatusReturnValue; import org.ovirt.engine.core.common.businessentities.FenceAgent; import org.ovirt.engine.core.common.businessentities.Provider; import org.ovirt.engine.core.common.businessentities.StoragePool; @@ -1618,33 +1617,40 @@ agent.setUser(isPrimary ? getPmUserName().getEntity() : getPmSecondaryUserName().getEntity()); agent.setPassword(isPrimary ? getPmPassword().getEntity() : getPmSecondaryPassword().getEntity()); agent.setPort(isPrimary ? getPmPrimaryPortAsInteger() : getPmSecondaryPortAsIngeter()); + agent.setOptionsMap(isPrimary ? getPmOptionsMap() : getPmSecondaryOptionsMap()); + param.setAgent(agent); param.setStoragePoolId(cluster.getStoragePoolId() != null ? cluster.getStoragePoolId() : Guid.Empty); param.setPmProxyPreferences(getPmProxyPreferences()); - agent.setOptionsMap(isPrimary ? getPmOptionsMap() : getPmSecondaryOptionsMap()); + param.setHostName(getHost().getEntity()); + param.setVdsGroupId(cluster.getId()); - param.setAgent(agent); - Frontend.getInstance().runQuery(VdcQueryType.GetFenceAgentStatus, param, new AsyncQuery(this, new INewAsyncCallback() { - - @Override - public void onSuccess(Object model, Object returnValue) { - String message; - if (returnValue == null) { - message = ConstantsManager.getInstance().getConstants().testFailedUnknownErrorMsg(); - } else { - VdcQueryReturnValue response = (VdcQueryReturnValue) returnValue; - if (response.getReturnValue() == null) { - message = ConstantsManager.getInstance().getConstants().testFailedUnknownErrorMsg(); - } else { - FenceStatusReturnValue fenceStatusReturnValue = - (FenceStatusReturnValue) response.getReturnValue(); - message = fenceStatusReturnValue.toString(); + Frontend.getInstance().runQuery( + VdcQueryType.GetFenceAgentStatus, + param, + new AsyncQuery( + this, + new INewAsyncCallback() { + @Override + public void onSuccess(Object model, Object returnValue) { + VdcQueryReturnValue result = (VdcQueryReturnValue) returnValue; + if (result.getSucceeded()) { + setMessage(ConstantsManager.getInstance().getConstants().testSuccessful()); + } else { + if (result.getReturnValue() == null) { + setMessage( + ConstantsManager.getInstance().getConstants() + .testFailedUnknownErrorMsg()); + } else { + setMessage( + ConstantsManager.getInstance().getConstants() + .testFailedWithErrorMsg() + + result.getReturnValue()); + } + } + getTestCommand().setIsExecutionAllowed(true); } - } - setMessage(message); - getTestCommand().setIsExecutionAllowed(true); - } - } - , + + }, true)); } diff --git a/frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/UIConstants.java b/frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/UIConstants.java index 4d0cbce..d5520ee 100644 --- a/frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/UIConstants.java +++ b/frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/UIConstants.java @@ -1146,6 +1146,12 @@ @DefaultStringValue("Configuring local Storage is permitted only to Administrators with System-level permissions") String configuringLocalStoragePermittedOnlyAdministratorsWithSystemLevelPermissionsReason(); + @DefaultStringValue("Test was successful.") + String testSuccessful(); + + @DefaultStringValue("Test failed: ") + String testFailedWithErrorMsg(); + @DefaultStringValue("Test Failed (unknown error).") String testFailedUnknownErrorMsg(); -- To view, visit https://gerrit.ovirt.org/38967 To unsubscribe, visit https://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I509729eda00098ea63396c13fd3a6619e55c8c76 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Martin Peřina <[email protected]> _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
