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. Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=1115343 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, 12 insertions(+), 6 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/18/35718/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 2d19cf2..01a1157 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 @@ -11,6 +11,7 @@ import org.ovirt.engine.core.common.action.UpdateVdsActionParameters; import org.ovirt.engine.core.common.action.VdcActionType; import org.ovirt.engine.core.common.action.VdcReturnValueBase; +import org.ovirt.engine.core.common.action.VdsOperationActionParameters; import org.ovirt.engine.core.common.businessentities.VDS; import org.ovirt.engine.core.common.businessentities.VDSStatus; import org.ovirt.engine.core.common.businessentities.VDSType; @@ -156,7 +157,7 @@ // 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()); + VDS provisionedVds = DbFacade.getInstance().getVdsDao().getAllForHostname(getParameters().getVdsName()).get(0); if (provisionedVds != null && provisionedVds.getStatus() != VDSStatus.InstallingOS) { // if not in InstallingOS status, this host is not provisioned. provisionedVds = null; @@ -188,6 +189,7 @@ vdsGroupId = getParameters().getVdsGroupId(); } if (provisionedVds != null) { + // In provision don't set host on pending - isPending = false getQueryReturnValue().setSucceeded(Register(provisionedVds, vdsGroupId, false)); } else { // TODO: always add in pending state, and if auto approve call @@ -246,10 +248,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.debugFormat( "RegisterVdsQuery::Register - Will try now to update VDS with existing unique id; Name: {0}, Hostname: {1}, Unique: {2}, VdsPort: {3}, IsPending: {4} with force synchronize", getParameters().getVdsHostName(), @@ -258,7 +260,10 @@ getParameters().getVdsPort(), IsPending); - UpdateVdsActionParameters p = new UpdateVdsActionParameters(vdsByUniqueId.getStaticData(), "", false); + UpdateVdsActionParameters p = new UpdateVdsActionParameters(vds.getStaticData(), "", false); + p.setInstallVds(!IsPending); + p.setIsReinstallOrUpgrade(!IsPending); + p.setAuthMethod(VdsOperationActionParameters.AuthenticationMethod.PublicKey); p.setTransactionScopeOption(TransactionScopeOption.RequiresNew); VdcReturnValueBase rc = Backend.getInstance().runInternalAction(VdcActionType.UpdateVds, p); 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 44eec7d..a693263 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/35718 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ie95c258def25d2e484d4094784eb0b15d62c7ef3 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
