Oved Ourfali has uploaded a new change for review. Change subject: core: get cd path only when the VM isn't the hosted engine ......................................................................
core: get cd path only when the VM isn't the hosted engine When the VM we wish to change disk to is the hosted engine VM, getting the CD path fails, as this VM isn't managed by the engine. For that reason, this patch moves this logic to after we know it is not the hosted engine. In addition, it is good to do that not in the constructor but after some validation is done, as it is less error prone. Change-Id: Ie94993f2f43b5c3d2658542f38292b0d8c5503b3 Bug-Url: https://bugzilla.redhat.com/1014030 Signed-off-by: Oved Ourfali <[email protected]> --- M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/ChangeDiskCommand.java 1 file changed, 9 insertions(+), 8 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/64/22164/1 diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/ChangeDiskCommand.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/ChangeDiskCommand.java index 120ab92..f75a4c9 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/ChangeDiskCommand.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/ChangeDiskCommand.java @@ -11,15 +11,14 @@ import org.ovirt.engine.core.common.vdscommands.VDSCommandType; public class ChangeDiskCommand<T extends ChangeDiskCommandParameters> extends VmOperationCommandBase<T> { - private String mCdImagePath; + private String cdImagePath; public ChangeDiskCommand(T parameters) { super(parameters); - mCdImagePath = ImagesHandler.cdPathWindowsToLinux(parameters.getCdImagePath(), getVm().getStoragePoolId(), getVm().getRunOnVds()); } public String getDiskName() { - return new File(mCdImagePath).getName(); + return new File(cdImagePath).getName(); } @Override @@ -38,6 +37,8 @@ if (retValue && !canRunActionOnNonManagedVm()) { retValue = false; + } else { + cdImagePath = ImagesHandler.cdPathWindowsToLinux(getParameters().getCdImagePath(), getVm().getStoragePoolId(), getVm().getRunOnVds()); } if (retValue && !getVm().isRunningOrPaused()) { @@ -45,15 +46,15 @@ retValue = false; addCanDoActionMessage(VdcBllMessages.VAR__TYPE__VM); - // An empty 'mCdImagePath' means eject CD - if (!StringUtils.isEmpty(mCdImagePath)) { + // An empty 'cdImagePath' means eject CD + if (!StringUtils.isEmpty(cdImagePath)) { addCanDoActionMessage(VdcBllMessages.VAR__ACTION__CHANGE_CD); } else { addCanDoActionMessage(VdcBllMessages.VAR__ACTION__EJECT_CD); } failCanDoAction(VdcBllMessages.ACTION_TYPE_FAILED_VM_STATUS_ILLEGAL, LocalizedVmStatus.from(getVm().getStatus())); } else if ((IsoDomainListSyncronizer.getInstance().findActiveISODomain(getVm().getStoragePoolId()) == null) - && !StringUtils.isEmpty(mCdImagePath)) { + && !StringUtils.isEmpty(cdImagePath)) { addCanDoActionMessage(VdcBllMessages.VAR__ACTION__CHANGE_CD); addCanDoActionMessage(VdcBllMessages.VM_CANNOT_WITHOUT_ACTIVE_STORAGE_DOMAIN_ISO); setSucceeded(false); @@ -68,7 +69,7 @@ .getInstance() .getResourceManager() .RunVdsCommand(VDSCommandType.ChangeDisk, - new ChangeDiskVDSCommandParameters(getVdsId(), getVm().getId(), mCdImagePath)) + new ChangeDiskVDSCommandParameters(getVdsId(), getVm().getId(), cdImagePath)) .getReturnValue()); setSucceeded(true); @@ -76,7 +77,7 @@ @Override public AuditLogType getAuditLogTypeValue() { - return getSucceeded() ? "".equals(mCdImagePath) ? AuditLogType.USER_EJECT_VM_DISK + return getSucceeded() ? "".equals(cdImagePath) ? AuditLogType.USER_EJECT_VM_DISK : AuditLogType.USER_CHANGE_DISK_VM : AuditLogType.USER_FAILED_CHANGE_DISK_VM; } } -- To view, visit http://gerrit.ovirt.org/22164 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ie94993f2f43b5c3d2658542f38292b0d8c5503b3 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: ovirt-engine-3.3 Gerrit-Owner: Oved Ourfali <[email protected]> _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
