Martin Peřina has uploaded a new change for review. Change subject: core: Introducing VdsValidator class ......................................................................
core: Introducing VdsValidator class Created VdsValidator class that should contain methods used to validate VDS status before executing some actions on it. Change-Id: I6f8d22a148513bdbfa46b195e92bc90d66a962ba Signed-off-by: Martin Perina <[email protected]> --- M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/VdsNotRespondingTreatmentCommand.java A backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/VdsValidator.java 2 files changed, 60 insertions(+), 23 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/19/16319/1 diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/VdsNotRespondingTreatmentCommand.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/VdsNotRespondingTreatmentCommand.java index b4a6140..462453e 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/VdsNotRespondingTreatmentCommand.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/VdsNotRespondingTreatmentCommand.java @@ -46,8 +46,16 @@ */ @Override protected void executeCommand() { + VdsValidator validator; setVds(null); - if (getVds() != null && shouldVdsBeFenced()) { + if (getVds() == null) { + setCommandShouldBeLogged(false); + log.infoFormat("Host {0}({1}) not fenced since it doesn't exist anymore.", getVdsName(), getVdsId()); + return; + } + + validator = new VdsValidator(getVds()); + if (validator.shouldVdsBeFenced()) { super.executeCommand(); } else { setCommandShouldBeLogged(false); @@ -81,28 +89,6 @@ public AuditLogType getAuditLogTypeValue() { return getSucceeded() ? _vmsMovedToUnknown ? AuditLogType.VDS_RECOVER_FAILED_VMS_UNKNOWN : AuditLogType.VDS_RECOVER : AuditLogType.VDS_RECOVER_FAILED; - } - - /** - * Determine if the status is legal for actually fence the VDS. - * - * @return <c>true</c> if the VDS should be fenced, otherwise <c>false</c>. - */ - private boolean shouldVdsBeFenced() { - boolean result; - switch (getVds().getStatus()) { - case Down: - case InstallFailed: - case Maintenance: - case NonOperational: - case NonResponsive: - result = true; - break; - default: - result = false; - break; - } - return result; } private void MoveVMsToUnknown() { diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/VdsValidator.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/VdsValidator.java new file mode 100644 index 0000000..ed9f02e --- /dev/null +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/VdsValidator.java @@ -0,0 +1,51 @@ +package org.ovirt.engine.core.bll; + +import org.ovirt.engine.core.common.businessentities.VDS; + +/** + * Contains methods used to validate VDS status to execute some operation on it + */ +public class VdsValidator { + /** + * Vds instance + */ + private VDS vds; + + /** + * Creates an instance with specified VDS + * + * @param vds + * specified VDS + * @exception IllegalArgumentException if {@code vds} is {@code null} + */ + public VdsValidator(VDS vds) { + if (vds == null) { + throw new IllegalArgumentException(); + } + this.vds = vds; + } + + /** + * Determines if the VDS status is legal for execute fencing on host (either SSH Soft Fencing or real one) + * + * @return {@code true}, if fencing should be executed, otherwise {@code false} + */ + public boolean shouldVdsBeFenced() { + boolean result = false; + + switch (vds.getStatus()) { + case Down: + case InstallFailed: + case Maintenance: + case NonOperational: + case NonResponsive: + result = true; + break; + + default: + break; + } + + return result; + } +} -- To view, visit http://gerrit.ovirt.org/16319 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I6f8d22a148513bdbfa46b195e92bc90d66a962ba 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
