Arik Hadas has uploaded a new change for review. Change subject: core: change can-do checks for resume action ......................................................................
core: change can-do checks for resume action Currently resume is done as a special flow of run-vm command when the previous state of the VM is paused. the can-do-action checks in that case were the same as those that are made for regular run-vm action (for VM which are down). This patch changes the can-do-action checks in case of resume action such that they will only check that the VM exists. there is no need to do further checks as the VM was already created (thus was found to be valid before) if its state is paused. Change-Id: I772377045d5c6d694e00006c9b12e210c52ab353 Bug-Url: https://bugzilla.redhat.com/885994 Signed-off-by: Arik Hadas <[email protected]> --- M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RunVmCommand.java 1 file changed, 26 insertions(+), 13 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/69/12769/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 931cbf5..a78bc41 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 @@ -40,6 +40,7 @@ import org.ovirt.engine.core.common.businessentities.StorageDomainStatus; import org.ovirt.engine.core.common.businessentities.StorageDomainType; import org.ovirt.engine.core.common.businessentities.VDS; +import org.ovirt.engine.core.common.businessentities.VM; import org.ovirt.engine.core.common.businessentities.VMStatus; import org.ovirt.engine.core.common.businessentities.network.Network; import org.ovirt.engine.core.common.businessentities.network.VmNetworkInterface; @@ -653,22 +654,34 @@ // since canRunVm is static and can not call non-static method isInternalExecution getParameters().setIsInternal(isInternalExecution()); - boolean canDoAction = canRunVm(); + VM vm = getVm(); - canDoAction = canDoAction && validateNetworkInterfaces(); + if (vm == null) { + return failCanDoAction(VdcBllMessages.ACTION_TYPE_FAILED_VM_NOT_FOUND); + } - // check for Vm Payload - if (canDoAction && getParameters().getVmPayload() != null) { - canDoAction = checkPayload(getParameters().getVmPayload(), - getParameters().getDiskPath()); + boolean canDoAction; - if (canDoAction && !StringUtils.isEmpty(getParameters().getFloppyPath()) && - getParameters().getVmPayload().getType() == VmDeviceType.FLOPPY) { - addCanDoActionMessage(VdcBllMessages.VMPAYLOAD_FLOPPY_EXCEEDED); - canDoAction = false; - } - else { - getVm().setVmPayload(getParameters().getVmPayload()); + if (vm.getStatus() == VMStatus.Paused) { + // if VM is paused, it was already checked before that it is capable to run + canDoAction = true; + } + else { + canDoAction = canRunVm() && validateNetworkInterfaces(); + + // check for Vm Payload + if (canDoAction && getParameters().getVmPayload() != null) { + canDoAction = checkPayload(getParameters().getVmPayload(), + getParameters().getDiskPath()); + + if (canDoAction && !StringUtils.isEmpty(getParameters().getFloppyPath()) && + getParameters().getVmPayload().getType() == VmDeviceType.FLOPPY) { + addCanDoActionMessage(VdcBllMessages.VMPAYLOAD_FLOPPY_EXCEEDED); + canDoAction = false; + } + else { + getVm().setVmPayload(getParameters().getVmPayload()); + } } } return canDoAction; -- To view, visit http://gerrit.ovirt.org/12769 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I772377045d5c6d694e00006c9b12e210c52ab353 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Arik Hadas <[email protected]> _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
