Shahar Havivi has uploaded a new change for review. Change subject: engine: VmInit root-password not fetch from DB ......................................................................
engine: VmInit root-password not fetch from DB By default we don't fetch the password when getting VmInit for security reasons (we don't want to display the password in plain text via API or in the source code of the UI). For this reason the password was not copy when creating a Template, New Pool. Bug-Url: https://bugzilla.redhat.com/1051041 Change-Id: I9206906e3b61551023b21e4358663a4842018c7c Signed-off-by: Shahar Havivi <[email protected]> --- M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddVmTemplateCommand.java M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/CommonVmPoolWithVmsCommand.java M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RunVmOnceCommand.java 3 files changed, 28 insertions(+), 4 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/04/24504/1 diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddVmTemplateCommand.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddVmTemplateCommand.java index 0e6b1f6..a95e907 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddVmTemplateCommand.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddVmTemplateCommand.java @@ -519,7 +519,7 @@ getCompensationContext().snapshotNewEntity(getVmTemplate()); setActionReturnValue(getVmTemplate().getId()); // Load Vm Init from DB and set it to the template - VmHandler.updateVmInitFromDB(getParameters().getMasterVm(), true); + VmHandler.updateVmInitFromDB(getParameters().getMasterVm(), false); getVmTemplate().setVmInit(getParameters().getMasterVm().getVmInit()); VmHandler.addVmInitToDB(getVmTemplate()); } diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/CommonVmPoolWithVmsCommand.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/CommonVmPoolWithVmsCommand.java index 4e6490c..bb8260d 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/CommonVmPoolWithVmsCommand.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/CommonVmPoolWithVmsCommand.java @@ -24,6 +24,7 @@ import org.ovirt.engine.core.common.businessentities.DiskImage; import org.ovirt.engine.core.common.businessentities.StorageDomain; import org.ovirt.engine.core.common.businessentities.StorageDomainType; +import org.ovirt.engine.core.common.businessentities.VmBase; import org.ovirt.engine.core.common.businessentities.VmPool; import org.ovirt.engine.core.common.businessentities.VmStatic; import org.ovirt.engine.core.common.businessentities.VmTemplate; @@ -109,6 +110,7 @@ */ @Override protected void executeCommand() { + UpdateVmInitPassword(); VmHandler.warnMemorySizeLegal(getParameters().getVmStaticData(), getVdsGroup().getcompatibility_version()); Guid poolId = getPoolId(); @@ -175,6 +177,18 @@ getCompensationContext().resetCompensation(); } + private void UpdateVmInitPassword() { + // We are not passing the VmInit password to the UI, + // so we need to update the VmInit password from its template. + if (getParameters().getVmStaticData().getVmInit() != null && + getParameters().getVmStaticData().getVmInit().isPasswordAlreadyStored()) { + VmBase temp = new VmBase(); + temp.setId(getParameters().getVmStaticData().getVmtGuid()); + VmHandler.updateVmInitFromDB(temp, false); + getParameters().getVmStaticData().getVmInit().setRootPassword(temp.getVmInit().getRootPassword()); + } + } + private CommandContext createAddVmStepContext(String currentVmName) { CommandContext commandCtx = null; diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RunVmOnceCommand.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RunVmOnceCommand.java index 0d3c32d..7cd3b36 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RunVmOnceCommand.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RunVmOnceCommand.java @@ -16,6 +16,7 @@ import org.ovirt.engine.core.common.businessentities.DiskImage; import org.ovirt.engine.core.common.businessentities.VDS; import org.ovirt.engine.core.common.businessentities.VMStatus; +import org.ovirt.engine.core.common.businessentities.VmBase; import org.ovirt.engine.core.common.errors.VdcBllMessages; import org.ovirt.engine.core.common.vdscommands.CreateVmVDSCommandParameters; import org.ovirt.engine.core.compat.Guid; @@ -39,9 +40,18 @@ return failCanDoAction(VdcBllMessages.VM_CANNOT_RUN_ONCE_WITH_ILLEGAL_SYSPREP_PARAM); } - if ((getParameters().getVmInit() != null && !OsRepositoryImpl.INSTANCE.isWindows(getVm().getOs())) - && !FeatureSupported.cloudInit(getVm().getVdsGroupCompatibilityVersion())) { - return failCanDoAction(VdcBllMessages.ACTION_TYPE_FAILED_CLOUD_INIT_IS_NOT_SUPPORTED); + if (getParameters().getVmInit() != null) { + if (!OsRepositoryImpl.INSTANCE.isWindows(getVm().getOs()) && + !FeatureSupported.cloudInit(getVm().getVdsGroupCompatibilityVersion())) { + return failCanDoAction(VdcBllMessages.ACTION_TYPE_FAILED_CLOUD_INIT_IS_NOT_SUPPORTED); + } + + if (getParameters().getVmInit().isPasswordAlreadyStored()) { + VmBase temp = new VmBase(); + temp.setId(getParameters().getVmId()); + VmHandler.updateVmInitFromDB(temp, false); + getParameters().getVmInit().setRootPassword(temp.getVmInit().getRootPassword()); + } } return true; -- To view, visit http://gerrit.ovirt.org/24504 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I9206906e3b61551023b21e4358663a4842018c7c Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: ovirt-engine-3.4 Gerrit-Owner: Shahar Havivi <[email protected]> _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
