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
the adding new record as waiting for approval. This is wrong approach
which cause loose 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, 7 insertions(+), 18 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/07/35207/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 404f470..134450a 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
@@ -29,8 +29,6 @@
 import org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogableBase;
 import org.ovirt.engine.core.dao.VdsDAO;
 import org.ovirt.engine.core.utils.threadpool.ThreadPoolUtil;
-import org.ovirt.engine.core.utils.transaction.TransactionMethod;
-import org.ovirt.engine.core.utils.transaction.TransactionSupport;
 
 @DisableInMaintenanceMode
 public class RegisterVdsQuery<P extends RegisterVdsParameters> extends 
QueriesCommandBase<P> {
@@ -339,7 +337,12 @@
                 /**
                  * looping foreach VDS found with similar hostnames and change 
to each one to available hostname
                  */
-                if (
+                if (vds_byHostName.getStatus() == VDSStatus.InstallingOS) {
+                    log.info(
+                            "RegisterVdsQuery::HandleOldVdssWithSameHostName - 
No Change required for VDS '{}' during provision.",
+                            vds_byHostName.getId());
+                }
+                else if (
                     vdsByUniqueId == null ||
                     !vds_byHostName.getId().equals(vdsByUniqueId.getId())
                 ) {
@@ -360,20 +363,6 @@
                                 vds_byHostName.getStaticData(), "" , false);
                         parameters.setShouldBeLogged(false);
                         
parameters.setTransactionScopeOption(TransactionScopeOption.RequiresNew);
-
-                        // If host exists in InstallingOs status, remove it 
from DB and move on
-                        final VDS foundVds = 
DbFacade.getInstance().getVdsDao().getByName(parameters.getVdsStaticData().getName());
-                        if ((foundVds != null) && 
(foundVds.getDynamicData().getStatus() == VDSStatus.InstallingOS)) {
-                            
TransactionSupport.executeInScope(TransactionScopeOption.Required, new 
TransactionMethod<Void>() {
-                                @Override
-                                public Void runInTransaction() {
-                                    
getDbFacade().getVdsStatisticsDao().remove(foundVds.getId());
-                                    
getDbFacade().getVdsDynamicDao().remove(foundVds.getId());
-                                    
getDbFacade().getVdsStaticDao().remove(foundVds.getId());
-                                    return null;
-                                }
-                            });
-                        }
 
                         VdcReturnValueBase ret = 
Backend.getInstance().runInternalAction(VdcActionType.UpdateVds, parameters);
 
@@ -427,7 +416,7 @@
         List<String> allHostNames = getAllHostNames(vdsDAO.getAll());
         boolean hostExistInDB = hostToRegister != null;
 
-        if (storedHost != null) {
+        if (storedHost != null && storedHost.getStatus() != 
VDSStatus.InstallingOS) {
             log.debug(
                     "found VDS with the same name {0}.  Will try to register 
with a new name",
                     getParameters().getVdsName());


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

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

Reply via email to