Arik Hadas has uploaded a new change for review. Change subject: core: move cd rom path setting to be set after vds is selected ......................................................................
core: move cd rom path setting to be set after vds is selected Change-Id: Ic7919e224c093d86a2b1ebf564f0307d5dd813a7 Signed-off-by: Arik Hadas <aha...@redhat.com> --- M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RunVmCommand.java 1 file changed, 33 insertions(+), 27 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/46/17746/1 diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RunVmCommand.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RunVmCommand.java index b43dca2..73d1224 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RunVmCommand.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RunVmCommand.java @@ -85,7 +85,6 @@ implements QuotaVdsDependent { private static final RunVmValidator runVmValidator = new RunVmValidator(); - private String cdImagePath = ""; private boolean mResume; /** Note: this field should not be used directly, use {@link #isVmRunningStateless()} instead */ private Boolean cachedVmIsRunningStateless; @@ -128,9 +127,6 @@ private void initRunVmCommand() { RunVmParams runVmParameters = getParameters(); - if (!StringUtils.isEmpty(runVmParameters.getDiskPath())) { - cdImagePath = cdPathWindowsToLinux(runVmParameters.getDiskPath()); - } if (getVm() != null) { refreshBootParameters(runVmParameters); @@ -306,31 +302,42 @@ return getSnapshotDao().exists(getVm().getId(), SnapshotType.STATELESS); } - /** - * Handles the cd attachment. Set the VM CDPath to the ISO Path stored in the database (default) Call - * GuestToolsVersionTreatment to override CDPath by guest tools if needed. If the CD symbol ('D') is contained in - * the Boot Sequence (at any place) set again the CDPath to the ISO Path that was stored in the database, and we - * assume that this CD is bootable. So , priorities are (from low to high) : 1)Default 2)Tools 3)Boot Sequence - */ private void attachCd() { - Guid storagePoolId = getVm().getStoragePoolId(); - // if iso domain found - if (getIsoDomainListSyncronizer().findActiveISODomain(storagePoolId) != null) { - if (StringUtils.isEmpty(getVm().getCdPath())) { - getVm().setCdPath(getVm().getIsoPath()); - guestToolsVersionTreatment(); - if (getVm().getBootSequence() != null && getVm().getBootSequence().containsSubsequence(BootSequence.D)) { - getVm().setCdPath(getVm().getIsoPath()); - } - getVm().setCdPath(cdPathWindowsToLinux(getVm().getCdPath())); - } - } else if (!StringUtils.isEmpty(getVm().getIsoPath())) { + if (getIsoDomainListSyncronizer().findActiveISODomain(getVm().getStoragePoolId()) != null) { + getVm().setCdPath(cdPathWindowsToLinux(chooseCd())); + } + else if (!StringUtils.isEmpty(getVm().getIsoPath())) { getVm().setCdPath(""); setSucceeded(false); throw new VdcBLLException(VdcBllErrors.NO_ACTIVE_ISO_DOMAIN_IN_DATA_CENTER); } + } + /** + * Returns the CD path in the following order (from high to low): + * (1) The path given in the parameters + * (2) The ISO path stored in the database if the boot sequence contains CD ROM + * (3) Guest agent tools iso + * (4) The ISO path stored in the database + * + * Note that in (2) we assume that the CD is bootable + */ + private String chooseCd() { + if (!StringUtils.isEmpty(getParameters().getDiskPath())) { + return getParameters().getDiskPath(); + } + + if (getVm().getBootSequence() != null && getVm().getBootSequence().containsSubsequence(BootSequence.D)) { + return getVm().getIsoPath(); + } + + String guestToolPath = guestToolsVersionTreatment(); + if (guestToolPath != null) { + return guestToolPath; + } + + return getVm().getIsoPath(); } protected IsoDomainListSyncronizer getIsoDomainListSyncronizer() { @@ -595,7 +602,6 @@ } else { handleMemoryAdjustments(); VmHandler.updateDisksFromDb(getVm()); - getVm().setCdPath(cdImagePath); getVm().setKvmEnable(getParameters().getKvmEnable()); getVm().setRunAndPause(getParameters().getRunAndPause() == null ? getVm().isRunAndPause() : getParameters().getRunAndPause()); getVm().setAcpiEnable(getParameters().getAcpiEnable()); @@ -665,13 +671,12 @@ * If vds version greater then vm's and vm not running with cd and there is appropriate RhevAgentTools image - * add it to vm as cd. */ - private void guestToolsVersionTreatment() { + private String guestToolsVersionTreatment() { boolean attachCd = false; String selectedToolsVersion = ""; String selectedToolsClusterVersion = ""; Guid isoDomainId = getIsoDomainListSyncronizer().findActiveISODomain(getVm().getStoragePoolId()); - if (OsRepositoryImpl.INSTANCE.isWindows(getVm().getVmOsId()) - && null != isoDomainId && StringUtils.isEmpty(cdImagePath)) { + if (OsRepositoryImpl.INSTANCE.isWindows(getVm().getVmOsId()) && null != isoDomainId) { // get cluster version of the vm tools Version vmToolsClusterVersion = null; @@ -733,8 +738,9 @@ new IrsBaseVDSCommandParameters(getVm().getStoragePoolId())).getReturnValue(); rhevToolsPath = isoDir + File.separator + rhevToolsPath; - getVm().setCdPath(cdPathWindowsToLinux(rhevToolsPath)); + return rhevToolsPath; } + return null; } @Override -- To view, visit http://gerrit.ovirt.org/17746 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ic7919e224c093d86a2b1ebf564f0307d5dd813a7 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Arik Hadas <aha...@redhat.com> _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches