Alon Bar-Lev has uploaded a new change for review.

Change subject: host-deploy: cleanup: remove depreciated otp usage
......................................................................

host-deploy: cleanup: remove depreciated otp usage

Change-Id: I68287641c891228ea1250feaa336359bc46eb7e0
Signed-off-by: Alon Bar-Lev <[email protected]>
---
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RegisterVdsQuery.java
M 
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/queries/RegisterVdsParameters.java
M 
backend/manager/modules/root/src/main/java/org/ovirt/engine/core/register/RegisterServlet.java
3 files changed, 3 insertions(+), 53 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/97/20597/1

diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RegisterVdsQuery.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RegisterVdsQuery.java
index 6595bfd..2c880cd 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RegisterVdsQuery.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RegisterVdsQuery.java
@@ -20,7 +20,6 @@
 import org.ovirt.engine.core.common.errors.VdcBllMessages;
 import org.ovirt.engine.core.common.queries.RegisterVdsParameters;
 import org.ovirt.engine.core.common.queries.VdcQueryReturnValue;
-import org.ovirt.engine.core.compat.DateTime;
 import org.ovirt.engine.core.compat.Guid;
 import org.ovirt.engine.core.compat.RefObject;
 import org.ovirt.engine.core.compat.Regex;
@@ -126,12 +125,6 @@
                     
returnValue.setExceptionString(VdcBllMessages.VDS_STATUS_NOT_VALID_FOR_UPDATE.name());
                     return false;
                 }
-                Long otp = getParameters().getOtp();
-                if (!isValidOtp(vds, otp)) {
-                    returnValue.setExceptionString(String.format("Invalid OTP 
for host %s", hostName));
-                    return false;
-                }
-
             }
 
         } catch (RuntimeException ex) {
@@ -142,24 +135,6 @@
         }
 
         return true;
-    }
-
-    /**
-     * the method checks if the given otp is valid, will return false for null 
as well
-     * @param vds
-     * @param otp
-     * @return boolean indicating whether the given otp is valid or not
-     */
-    private boolean isValidOtp(VDS vds, Long otp) {
-        if (otp != null && otp.longValue() == vds.getOtpValidity()) {
-            Integer otpExpiration = Config.<Integer> 
GetValue(ConfigValues.OtpExpirationInSeconds);
-            DateTime otpValidity = new DateTime(otp);
-            otpValidity.AddSeconds(otpExpiration);
-            if (otpValidity.before(DateTime.getUtcNow())) {
-                return true;
-            }
-        }
-        return false;
     }
 
     @Override
@@ -182,8 +157,7 @@
 
             // in case oVirt host was added for the second time - perform 
approval
             if (vdsByUniqueId != null && vdsByUniqueId.getStatus() == 
VDSStatus.PendingApproval
-                    && getParameters().getVdsType() == VDSType.oVirtNode
-                    && getParameters().getOtp() != null) {
+                    && getParameters().getVdsType() == VDSType.oVirtNode) {
 
                 
getQueryReturnValue().setSucceeded(dispatchOvirtApprovalCommand(vdsByUniqueId.getId()));
                 return;
diff --git 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/queries/RegisterVdsParameters.java
 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/queries/RegisterVdsParameters.java
index 9819deb..02f3df6 100644
--- 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/queries/RegisterVdsParameters.java
+++ 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/queries/RegisterVdsParameters.java
@@ -78,16 +78,6 @@
         privateVdsType = value;
     }
 
-    private Long otp;
-
-    public Long getOtp() {
-        return otp;
-    }
-
-    public void setOtp(Long otp) {
-        this.otp = otp;
-    }
-
     public RegisterVdsParameters(Guid vdsId, String vds_host_name, String 
vds_name, String vds_unique_id, int port,
             Guid vds_group_id, VDSType vds_type) {
         setVdsId(vdsId);
diff --git 
a/backend/manager/modules/root/src/main/java/org/ovirt/engine/core/register/RegisterServlet.java
 
b/backend/manager/modules/root/src/main/java/org/ovirt/engine/core/register/RegisterServlet.java
index 49be41b..844816e 100644
--- 
a/backend/manager/modules/root/src/main/java/org/ovirt/engine/core/register/RegisterServlet.java
+++ 
b/backend/manager/modules/root/src/main/java/org/ovirt/engine/core/register/RegisterServlet.java
@@ -11,7 +11,6 @@
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
-import org.apache.commons.lang.StringUtils;
 import org.ovirt.engine.core.bll.interfaces.BackendInternal;
 import org.ovirt.engine.core.common.businessentities.VDSType;
 import org.ovirt.engine.core.common.queries.RegisterVdsParameters;
@@ -32,7 +31,6 @@
     public static final String VDS_NAME = "vds_name";
     public static final String VDS_ID = "vds_unique_id";
     public static final String PORT = "port";
-    public static final String OTP = "ticket";
 
     private SimpleDateFormat m_sdfFormatter;
     private static Log log = LogFactory.getLog(RegisterServlet.class);
@@ -55,7 +53,6 @@
         String strName = "";
         String strID = "";
         int nPort = -1;
-        String otpMessage = "";
 
         try {
             backend = (BackendInternal) EjbUtils.findBean(BeanType.BACKEND, 
BeanProxyType.LOCAL);
@@ -63,18 +60,9 @@
             strName = request.getParameterValues(VDS_NAME)[0];
             strID = request.getParameterValues(VDS_ID)[0];
             nPort = Integer.parseInt(request.getParameterValues(PORT)[0]);
-            String[] otpValues = request.getParameterValues(OTP);
-            String otpString = (otpValues != null && otpValues.length > 0) ? 
otpValues[0] : null;
-            Long otp = null;
-
-            // if OTP was provided, assume registering oVirt host
-            if (StringUtils.isNotBlank(otpString)) {
-                otp = Long.parseLong(otpString);
-                otpMessage = ", OTP is set.";
-            }
 
             log.debug("Using the following parameters to call query:\nIP: " + 
strIP + ", Name: "
-                    + strName + ", UUID: " + strID + ", Port: " + nPort + 
otpMessage);
+                    + strName + ", UUID: " + strID + ", Port: " + nPort);
 
             /*
              * Ignore MAC if exists (old format)
@@ -83,8 +71,6 @@
             params = new RegisterVdsParameters(Guid.Empty, strIP, strName, 
strIDNoMAC, nPort,
                     Guid.Empty, VDSType.oVirtNode);
 
-            params.setOtp(otp);
-
             fReturn = backend.runInternalQuery(VdcQueryType.RegisterVds, 
params);
             if (fReturn == null) {
                 log.error("Got NULL from backend.RunQuery!");
@@ -92,7 +78,7 @@
         } catch (Throwable t) {
             log.error("Caught exception while trying to run query: ", t);
             log.error("Parameters used to call query:\nIP: " + strIP + ", 
Name: " + strName
-                    + ", UUID: " + strID + ", Port: " + nPort + otpMessage);
+                    + ", UUID: " + strID + ", Port: " + nPort);
             fReturn = null;
         }
 


-- 
To view, visit http://gerrit.ovirt.org/20597
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I68287641c891228ea1250feaa336359bc46eb7e0
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Alon Bar-Lev <[email protected]>
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to