Tomas Jelinek has uploaded a new change for review. Change subject: webadmin,userportal: do not add default nic on edit vm ......................................................................
webadmin,userportal: do not add default nic on edit vm If the VM had no nics the edit VM added a default one and tried to edit it. It was not correct - if the VM has no nics than the edit should not add any. Change-Id: I21724b30dc1ad6ccbbe40448ad77c47c22123c06 Bug-Url: https://bugzilla.redhat.com/987930 Signed-off-by: Tomas Jelinek <[email protected]> --- M frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/ExistingVmModelBehavior.java M frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/UnitVmModelNetworkAsyncCallbacks.java M frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/VmNetworkCreatingManager.java 3 files changed, 20 insertions(+), 9 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/15/17315/1 diff --git a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/ExistingVmModelBehavior.java b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/ExistingVmModelBehavior.java index 9b88129..e65e47e 100644 --- a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/ExistingVmModelBehavior.java +++ b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/ExistingVmModelBehavior.java @@ -252,7 +252,10 @@ @Override public void onSuccess(Object model, Object result) { List<VmNetworkInterface> nics = (List<VmNetworkInterface>) result; - initNetworkInterfaces(networkBehavior, nics); + // do not create the default nic if the VM has no nics and you edit it + if (nics != null && nics.size() > 0) { + initNetworkInterfaces(networkBehavior, nics); + } networkInterfacesInited = true; } }; diff --git a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/UnitVmModelNetworkAsyncCallbacks.java b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/UnitVmModelNetworkAsyncCallbacks.java index 09e56b5..81c6ca2 100644 --- a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/UnitVmModelNetworkAsyncCallbacks.java +++ b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/UnitVmModelNetworkAsyncCallbacks.java @@ -1,5 +1,6 @@ package org.ovirt.engine.ui.uicommonweb.models.vms; +import java.util.ArrayList; import java.util.List; import org.ovirt.engine.core.common.action.VdcReturnValueBase; import org.ovirt.engine.core.compat.Guid; @@ -23,9 +24,12 @@ public void executed(FrontendActionAsyncResult result) { VdcReturnValueBase returnValue = result.getReturnValue(); if (returnValue != null && returnValue.getSucceeded()) { - doNetworkOperation(returnValue, - (List<NicWithLogicalNetworks>) unitVmModel.getNicsWithLogicalNetworks().getItems() - ); + List<NicWithLogicalNetworks> nicWithLogicalNetworks = (List<NicWithLogicalNetworks>) unitVmModel.getNicsWithLogicalNetworks().getItems(); + if (nicWithLogicalNetworks == null) { + // enter the opertation with null object if nothing has been edited by the user + nicWithLogicalNetworks = new ArrayList<NicWithLogicalNetworks>(); + } + doNetworkOperation(returnValue, nicWithLogicalNetworks); } else { networkCreatingManager.getCallback().queryFailed(); } diff --git a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/VmNetworkCreatingManager.java b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/VmNetworkCreatingManager.java index a232c82..9dd8ba1 100644 --- a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/VmNetworkCreatingManager.java +++ b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/VmNetworkCreatingManager.java @@ -68,7 +68,13 @@ * @param nicsWithLogicalNetworks list of nics as edited in the window */ public void updateNetworks(final Guid vmId, final List<NicWithLogicalNetworks> nicsWithLogicalNetworks) { - new UpdatedNicsUpdater().execute(vmId, nicsWithLogicalNetworks); + new UpdatedNicsUpdater() { + @Override + protected void onNoNicsDefinedOnVm() { + // nothing to do + callback.networkCreated(vmId); + } + }.execute(vmId, nicsWithLogicalNetworks); } /** @@ -122,7 +128,7 @@ void queryFailed(); } - class UpdatedNicsUpdater { + abstract class UpdatedNicsUpdater { public void execute(final Guid vmId, final List<NicWithLogicalNetworks> nicsWithLogicalNetworks) { AsyncQuery getVmNicsQuery = new AsyncQuery(); @@ -165,9 +171,7 @@ AsyncDataProvider.getVmNicList(getVmNicsQuery, vmId); } - protected void onNoNicsDefinedOnVm() { - // do nothing by default - } + protected abstract void onNoNicsDefinedOnVm(); } } -- To view, visit http://gerrit.ovirt.org/17315 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I21724b30dc1ad6ccbbe40448ad77c47c22123c06 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Tomas Jelinek <[email protected]> _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
