Muli Salem has uploaded a new change for review. Change subject: core: Block Hotplug Nic in Certain Vm States (#826931) ......................................................................
core: Block Hotplug Nic in Certain Vm States (#826931) https://bugzilla.redhat.com/826931 This patch adds a canDoAction that makes sure the Vm is in a valid state for Hot plug / unplug Nic. Change-Id: Id759ca8152b455047c9c83447f526aaccdd77d6c Signed-off-by: Muli Salem <msa...@redhat.com> --- M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/HotPlugUnplugVmNicCommand.java 1 file changed, 13 insertions(+), 8 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/76/7176/1 diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/HotPlugUnplugVmNicCommand.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/HotPlugUnplugVmNicCommand.java index a38a164..dcc244f 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/HotPlugUnplugVmNicCommand.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/HotPlugUnplugVmNicCommand.java @@ -29,9 +29,12 @@ protected boolean canDoAction() { boolean returnValue = true; - if (getVm().getstatus() == VMStatus.Up) { + if (isVmUpDownOrPoweringUp(getVm().getstatus())) { setVdsId(getVm().getrun_on_vds().getValue()); returnValue = isHotPlugSupported() && isOSSupportingHotPlug(); + } else { + addCanDoActionMessage(VdcBllMessages.ACTION_TYPE_FAILED_VM_STATUS_ILLEGAL); + returnValue = false; } if (returnValue) { @@ -47,13 +50,11 @@ @Override protected void ExecuteVmCommand() { - if (getVm().getstatus() == VMStatus.Up) { - runVdsCommand(getParameters().getAction().getCommandType(), - new HotPlugUnplgNicVDSParameters(getVm().getrun_on_vds().getValue(), - getVm().getId(), - DbFacade.getInstance().getVmNetworkInterfaceDAO().get(getParameters().getNicId()), - vmDevice)); - } + runVdsCommand(getParameters().getAction().getCommandType(), + new HotPlugUnplgNicVDSParameters(getVm().getrun_on_vds().getValue(), + getVm().getId(), + DbFacade.getInstance().getVmNetworkInterfaceDAO().get(getParameters().getNicId()), + vmDevice)); TransactionSupport.executeInNewTransaction(updateDevice()); VmDeviceUtils.updateBootOrderInVmDevice(getVm().getStaticData()); setSucceeded(true); @@ -77,4 +78,8 @@ VdcBllMessages.VAR__ACTION__ACTIVATE : VdcBllMessages.VAR__ACTION__DEACTIVATE); addCanDoActionMessage(VdcBllMessages.VAR__TYPE__INTERFACE); } + + private boolean isVmUpDownOrPoweringUp(VMStatus vmStatus) { + return vmStatus == VMStatus.Up || vmStatus == VMStatus.Down || vmStatus == VMStatus.PoweringUp; + } } -- To view, visit http://gerrit.ovirt.org/7176 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Id759ca8152b455047c9c83447f526aaccdd77d6c Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Muli Salem <msa...@redhat.com> _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches