Martin Mucha has uploaded a new change for review. Change subject: core: fail when trying to remove labeled VLAN network. ......................................................................
core: fail when trying to remove labeled VLAN network. Vlan related nics cannot have labels, but when I have VLAN enabled non vm network added to nic via label, then this nic will have associated label, and vlan related nic will have associated network. So I have to remove Vlan related nic when updating via setupnetworks, to remove network. So I have to check base interface for label presence when removing network with vlan enabled via removing of vlan related nic. Also it seemed to me like a bug, that if isVlan(nic) is true, but it's base interface nic is present in setupnetworks request(ie. vlan related nic was deleted but base interface was not), vlan related nic is checked for label presence, although it's base resource should have been validated. Change-Id: I132f4ae124e45144beee21f81f69e55ed25cd540 Bug-Url: https://bugzilla.redhat.com/1134380 Signed-off-by: Martin Mucha <mmu...@redhat.com> --- M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/network/host/SetupNetworksHelper.java 1 file changed, 14 insertions(+), 12 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/77/32477/1 diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/network/host/SetupNetworksHelper.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/network/host/SetupNetworksHelper.java index c747ce5..7ab9aeb 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/network/host/SetupNetworksHelper.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/network/host/SetupNetworksHelper.java @@ -127,9 +127,9 @@ } private void validateNotRemovingLabeledNetworks() { - Map<String, VdsNetworkInterface> nicsByName = Entities.entitiesByName(params.getInterfaces()); + Map<String, VdsNetworkInterface> existingIfaces = getExistingIfaces(); Map<String, VdsNetworkInterface> hostInterfacesByNetworkName = - Entities.hostInterfacesByNetworkName(getExistingIfaces().values()); + Entities.hostInterfacesByNetworkName(existingIfaces.values()); for (String network : removedNetworks) { VdsNetworkInterface nic = hostInterfacesByNetworkName.get(network); @@ -137,21 +137,23 @@ if (nic != null && !removedBonds.containsKey(baseInterfaceName)) { if (NetworkUtils.isVlan(nic)) { - nic = nicsByName.get(baseInterfaceName); - if (nic == null) { - continue; - } - } - - Network removedNetwork = getExistingClusterNetworks().get(network); - if (NetworkUtils.isLabeled(nic) && removedNetwork != null - && nic.getLabels().contains(removedNetwork.getLabel())) { - addViolation(VdcBllMessages.ACTION_TYPE_FAILED_CANNOT_REMOVE_LABELED_NETWORK_FROM_NIC, network); + final VdsNetworkInterface baseInterface = existingIfaces.get(baseInterfaceName); + validateNicForNotRemovingLabeledNetworks(network, baseInterface); + } else { + validateNicForNotRemovingLabeledNetworks(network, nic); } } } } + private void validateNicForNotRemovingLabeledNetworks(String network, VdsNetworkInterface nic) { + Network removedNetwork = getExistingClusterNetworks().get(network); + if (NetworkUtils.isLabeled(nic) && removedNetwork != null + && nic.getLabels().contains(removedNetwork.getLabel())) { + addViolation(VdcBllMessages.ACTION_TYPE_FAILED_CANNOT_REMOVE_LABELED_NETWORK_FROM_NIC, network); + } + } + private void extractModifiedInterfaces() { for (VdsNetworkInterface nic : params.getInterfaces()) { VdsNetworkInterface existingNic = getExistingIfaces().get(nic.getName()); -- To view, visit http://gerrit.ovirt.org/32477 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I132f4ae124e45144beee21f81f69e55ed25cd540 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: ovirt-engine-3.5 Gerrit-Owner: Martin Mucha <mmu...@redhat.com> _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches