Yaniv Bronhaim has uploaded a new change for review.

Change subject: foreman-integration: Remove domain from hostname to allow rhevh 
registration
......................................................................

foreman-integration: Remove domain from hostname to allow rhevh registration

After RHEVH provisioning installation the provisioned host sends registration
request which includes and name added to the domain url as the vds name.

oVirt adds the host only with the name, therefore we need to remove the
domain url from the request to find out if the request comes after
provision. In such case we will update the vds record as it is without
relying on the request parameters.

Change-Id: Ie95c258def25d2e484d4094784eb0b15d62c7ef3
Signed-off-by: Yaniv Bronhaim <[email protected]>
---
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RegisterVdsQuery.java
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/UpdateVdsCommand.java
2 files changed, 9 insertions(+), 7 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/50/35450/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 ff27ccc..0c64ec2 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,7 +156,8 @@
             // 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());
+            String registeredVdsName = 
getParameters().getVdsName().split("\\.")[0];
+            VDS provisionedVds = 
DbFacade.getInstance().getVdsDao().getByName(registeredVdsName);
             if (provisionedVds != null && provisionedVds.getStatus() != 
VDSStatus.InstallingOS) {
                 // if not in InstallingOS status, this host is not provisioned.
                 provisionedVds = null;
@@ -246,10 +247,10 @@
         return returnValue;
     }
 
-    private boolean updateExistingHost(VDS vdsByUniqueId, boolean IsPending) {
+    private boolean updateExistingHost(VDS vds, boolean IsPending) {
         boolean returnValue = true;
-        vdsByUniqueId.setHostName(getParameters().getVdsHostName());
-        vdsByUniqueId.setPort(getParameters().getVdsPort());
+        vds.setHostName(vds.getHostName());
+        vds.setPort(getParameters().getVdsPort());
         log.debug(
                 "RegisterVdsQuery::Register - Will try now to update VDS with 
existing unique id; Name: '{}', Hostname: '{}', Unique: '{}', VdsPort: '{}', 
IsPending: '{}' with force synchronize",
                 getParameters().getVdsHostName(),
@@ -258,7 +259,7 @@
                 getParameters().getVdsPort(),
                 IsPending);
 
-        UpdateVdsActionParameters p = new 
UpdateVdsActionParameters(vdsByUniqueId.getStaticData(), "", false);
+        UpdateVdsActionParameters p = new 
UpdateVdsActionParameters(vds.getStaticData(), "", false);
         p.setTransactionScopeOption(TransactionScopeOption.RequiresNew);
         VdcReturnValueBase rc = 
Backend.getInstance().runInternalAction(VdcActionType.UpdateVds, p);
 
@@ -277,7 +278,7 @@
         } else {
             log.info(
                     "RegisterVdsQuery::Register - Updated a '{}' registered 
VDS - Name: '{}', Hostname: '{}', UniqueID: '{}'",
-                    vdsByUniqueId.getStatus() == VDSStatus.PendingApproval ? 
"Pending " : "",
+                    vds.getStatus() == VDSStatus.PendingApproval ? "Pending " 
: "",
                     getParameters().getVdsName(),
                     getParameters().getVdsHostName(),
                     getStrippedVdsUniqueId());
diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/UpdateVdsCommand.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/UpdateVdsCommand.java
index f78a69d..a695f3f 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/UpdateVdsCommand.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/UpdateVdsCommand.java
@@ -121,7 +121,8 @@
                             
validateNetworkProviderProperties(getParameters().getNetworkProviderId(),
                                     getParameters().getNetworkMappings());
                 } else if (getParameters().getVdsStaticData().getProtocol() != 
_oldVds.getProtocol()
-                        && _oldVds.getStatus() != VDSStatus.Maintenance) {
+                        && _oldVds.getStatus() != VDSStatus.Maintenance &&
+                        _oldVds.getStatus() != VDSStatus.InstallingOS) {
                     
addCanDoActionMessage(VdcBllMessages.VDS_STATUS_NOT_VALID_FOR_UPDATE);
                 } else {
                     returnValue = true;


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie95c258def25d2e484d4094784eb0b15d62c7ef3
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