Yaniv Bronhaim has uploaded a new change for review.

Change subject: Allow registerVds with same name and hostname if provisioned
......................................................................

Allow registerVds with same name and hostname if provisioned

Currently we delete the old vds record with InstallingOS status to allow
adding new record as waiting for approval. This is wrong approach
which causes lose of all the initial information that set on the vds record.

With this fix we don't delete the record and skip the duplication check

Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=1115343
Change-Id: I157b567b2c868b12a89a394e909e97895338380d
Signed-off-by: Yaniv Bronhaim <[email protected]>
---
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RegisterVdsQuery.java
1 file changed, 24 insertions(+), 10 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/43/35343/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 adc90ad..55991ea 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
@@ -156,6 +156,11 @@
             // force to reload vdss by unique ID used later on
             _vdssByUniqueId = null;
             VDS vdsByUniqueId = getVdssByUniqueId().size() != 0 ? 
getVdssByUniqueId().get(0) : null;
+            VDS provisionedVds = 
DbFacade.getInstance().getVdsDao().getByName(getParameters().getVdsName());
+            if (provisionedVds != null && provisionedVds.getStatus() != 
VDSStatus.InstallingOS) {
+                // if not in InstallingOS status, this host is not provisioned.
+                provisionedVds = null;
+            }
 
             // in case oVirt host was added for the second time - perform 
approval
             if (vdsByUniqueId != null && vdsByUniqueId.getStatus() == 
VDSStatus.PendingApproval) {
@@ -182,14 +187,18 @@
             } else {
                 vdsGroupId = getParameters().getVdsGroupId();
             }
-            // TODO: always add in pending state, and if auto approve call
-            // approve command action after registration
-            RefObject<Boolean> isPending = new 
RefObject<Boolean>(Boolean.FALSE);
-            getQueryReturnValue().setSucceeded(
-                    HandleOldVdssWithSameHostName(vdsByUniqueId) && 
HandleOldVdssWithSameName(vdsByUniqueId)
-                            && CheckAutoApprovalDefinitions(isPending)
-                            && Register(vdsByUniqueId, vdsGroupId, 
isPending.argvalue.booleanValue()));
-            log.debugFormat("RegisterVdsQuery::ExecuteCommand - Leaving 
Succeded value is {0}",
+            if (provisionedVds != null) {
+                getQueryReturnValue().setSucceeded(Register(provisionedVds, 
vdsGroupId, false));
+            } else {
+                // TODO: always add in pending state, and if auto approve call
+                // approve command action after registration
+                RefObject<Boolean> isPending = new 
RefObject<Boolean>(Boolean.FALSE);
+                getQueryReturnValue().setSucceeded(
+                        HandleOldVdssWithSameHostName(vdsByUniqueId) && 
HandleOldVdssWithSameName(vdsByUniqueId)
+                                && CheckAutoApprovalDefinitions(isPending)
+                                && Register(vdsByUniqueId, vdsGroupId, 
isPending.argvalue.booleanValue()));
+            }
+            log.debug("RegisterVdsQuery::ExecuteCommand - Leaving Succeded 
value is {0}",
                     getQueryReturnValue().getSucceeded());
         }
     }
@@ -224,13 +233,18 @@
         return isApprovalDispatched;
     }
 
-    private boolean Register(VDS vdsByUniqueId, Guid vdsGroupId, boolean 
IsPending) {
+    private boolean Register(VDS vds, Guid vdsGroupId, boolean IsPending) {
         boolean returnValue = true;
+<<<<<<< HEAD
         log.debugFormat("RegisterVdsQuery::Register - Entering");
         if (vdsByUniqueId == null) {
+=======
+        log.debug("RegisterVdsQuery::Register - Entering");
+        if (vds == null) {
+>>>>>>> 1f22023... Allow registerVds with same name and hostname if provisioned
             returnValue = registerNewHost(vdsGroupId, IsPending);
         } else {
-            returnValue = updateExistingHost(vdsByUniqueId, IsPending);
+            returnValue = updateExistingHost(vds, IsPending);
         }
         log.debugFormat("RegisterVdsQuery::Register - Leaving with value {0}", 
returnValue);
 


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I157b567b2c868b12a89a394e909e97895338380d
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: ovirt-engine-3.5
Gerrit-Owner: Yaniv Bronhaim <[email protected]>
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to