Shireesh Anjal has uploaded a new change for review. Change subject: engine: Refactoring AddVdsCommand#canDoAction() ......................................................................
engine: Refactoring AddVdsCommand#canDoAction() to use failCanDoAction(), saving few lines of code. Also made sure that the gluster specific validation happens only if all previous validation was successful. Change-Id: Id2525aa9ce72654fea18eb60948a87d95a636602 Signed-off-by: Shireesh Anjal <anjalshire...@gmail.com> --- M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddVdsCommand.java 1 file changed, 10 insertions(+), 17 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/01/14401/1 diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddVdsCommand.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddVdsCommand.java index a398461..152e753 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddVdsCommand.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddVdsCommand.java @@ -302,35 +302,28 @@ int maxVdsNameLength = Config.<Integer> GetValue(ConfigValues.MaxVdsNameLength); // check that vds name is not null or empty if (vdsName == null || vdsName.isEmpty()) { - addCanDoActionMessage(VdcBllMessages.ACTION_TYPE_FAILED_NAME_MAY_NOT_BE_EMPTY); - returnValue = false; + returnValue = failCanDoAction(VdcBllMessages.ACTION_TYPE_FAILED_NAME_MAY_NOT_BE_EMPTY); // check that VDS name is not too long } else if (vdsName.length() > maxVdsNameLength) { - addCanDoActionMessage(VdcBllMessages.ACTION_TYPE_FAILED_NAME_LENGTH_IS_TOO_LONG); - returnValue = false; + returnValue = failCanDoAction(VdcBllMessages.ACTION_TYPE_FAILED_NAME_LENGTH_IS_TOO_LONG); // check that VDS hostname does not contain special characters. } else if (!ValidationUtils.validHostname(hostName)) { - addCanDoActionMessage(VdcBllMessages.ACTION_TYPE_FAILED_INVALID_VDS_HOSTNAME); - returnValue = false; + returnValue = failCanDoAction(VdcBllMessages.ACTION_TYPE_FAILED_INVALID_VDS_HOSTNAME); } else if (getVdsDAO().getByName(vdsName) != null) { - addCanDoActionMessage(VdcBllMessages.ACTION_TYPE_FAILED_NAME_ALREADY_USED); - returnValue = false; + returnValue = failCanDoAction(VdcBllMessages.ACTION_TYPE_FAILED_NAME_ALREADY_USED); } else if (getVdsDAO().getAllForHostname(hostName).size() != 0) { - addCanDoActionMessage(VdcBllMessages.ACTION_TYPE_FAILED_VDS_WITH_SAME_HOST_EXIST); - returnValue = false; + returnValue = failCanDoAction(VdcBllMessages.ACTION_TYPE_FAILED_VDS_WITH_SAME_HOST_EXIST); } else { returnValue = returnValue && validateSingleHostAttachedToLocalStorage(); if (Config.<Boolean> GetValue(ConfigValues.UseSecureConnectionWithServers) && !new File(Config.resolveCertificatePath()).exists()) { - addCanDoActionMessage(VdcBllMessages.VDS_TRY_CREATE_SECURE_CERTIFICATE_NOT_FOUND); - returnValue = false; + returnValue = failCanDoAction(VdcBllMessages.VDS_TRY_CREATE_SECURE_CERTIFICATE_NOT_FOUND); } else if (!getParameters().getAddPending() && StringUtils.isEmpty(getParameters().getRootPassword())) { // We block vds installations if it's not a RHEV-H and password is empty // Note that this may override local host SSH policy. See BZ#688718. - addCanDoActionMessage(VdcBllMessages.VDS_CANNOT_INSTALL_EMPTY_PASSWORD); - returnValue = false; + returnValue = failCanDoAction(VdcBllMessages.VDS_CANNOT_INSTALL_EMPTY_PASSWORD); } else if (!isPowerManagementLegal()) { returnValue = false; } else { @@ -338,12 +331,12 @@ } } } - if (isGlusterSupportEnabled()) { + + if (returnValue && isGlusterSupportEnabled()) { if (clusterHasServers()) { upServer = getClusterUtils().getUpServer(getVdsGroupId()); if (upServer == null) { - addCanDoActionMessage(VdcBllMessages.ACTION_TYPE_FAILED_NO_GLUSTER_HOST_TO_PEER_PROBE); - returnValue = false; + returnValue = failCanDoAction(VdcBllMessages.ACTION_TYPE_FAILED_NO_GLUSTER_HOST_TO_PEER_PROBE); } } } -- To view, visit http://gerrit.ovirt.org/14401 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Id2525aa9ce72654fea18eb60948a87d95a636602 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Shireesh Anjal <san...@redhat.com> _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches