Lior Vernia has uploaded a new change for review. Change subject: engine: Allowed creation of bonds in SetupNetworksHelper ......................................................................
engine: Allowed creation of bonds in SetupNetworksHelper The validation used to check that any NIC to which VLAN-tagged networks were attached existed on the host; this no longer must be true since we've enabled adding new bonds that hadn't before existed on the host. Change-Id: I167758e86b32bd90f09203321f89bf1a5adc7bf6 Bug-Url: https://bugzilla.redhat.com/968190 Signed-off-by: Lior Vernia <[email protected]> --- M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/network/host/SetupNetworksHelper.java M backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/network/host/SetupNetworksHelperTest.java 2 files changed, 31 insertions(+), 10 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/31/18031/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 dcfd07f..4746004 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 @@ -72,16 +72,8 @@ if (addInterfaceToProcessedList(iface)) { if (isBond(iface)) { extractBondIfModified(iface, name); - } else { - if (StringUtils.isNotBlank(iface.getBondName())) { - extractBondSlave(iface); - } - - // validate the nic exists on host - String nameWithoutVlanId = NetworkUtils.StripVlan(name); - if (!getExistingIfaces().containsKey(nameWithoutVlanId)) { - addViolation(VdcBllMessages.NETWORK_INTERFACES_DONT_EXIST, nameWithoutVlanId); - } + } else if (StringUtils.isNotBlank(iface.getBondName())) { + extractBondSlave(iface); } // validate and extract to network map @@ -92,6 +84,7 @@ } } + validateInterfacesExist(); validateBondSlavesCount(); extractRemovedNetworks(); extractRemovedBonds(); @@ -102,6 +95,18 @@ } /** + * Validates that all interfaces exist on the host, except bonds that may be created. + */ + private void validateInterfacesExist() { + for (VdsNetworkInterface iface : params.getInterfaces()) { + String nameWithoutVlanId = NetworkUtils.StripVlan(iface.getName()); + if (!getExistingIfaces().containsKey(nameWithoutVlanId) && !bonds.containsKey(nameWithoutVlanId)) { + addViolation(VdcBllMessages.NETWORK_INTERFACES_DONT_EXIST, nameWithoutVlanId); + } + } + } + + /** * Validates there is no differences on MTU value between non-VM network to Vlans over the same interface/bond */ private void validateMTU() { diff --git a/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/network/host/SetupNetworksHelperTest.java b/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/network/host/SetupNetworksHelperTest.java index 793aeeb..6c9295f 100644 --- a/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/network/host/SetupNetworksHelperTest.java +++ b/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/network/host/SetupNetworksHelperTest.java @@ -1178,6 +1178,22 @@ nic2.getName()); } + @Test + public void nicDoesntExist() { + VdsNetworkInterface nic = createNic("eth0", null); + SetupNetworksHelper helper = createHelper(createParametersForNics(nic)); + validateAndExpectViolation(helper, VdcBllMessages.NETWORK_INTERFACES_DONT_EXIST, nic.getName()); + } + + @Test + public void bondDoesntExist() { + VdsNetworkInterface bond = createBond(BOND_NAME, null); + List<VdsNetworkInterface> ifacesToBond = createNics(null); + mockExistingIfaces(ifacesToBond.toArray(new VdsNetworkInterface[ifacesToBond.size()])); + SetupNetworksHelper helper = createHelper(createParametersForBond(bond, ifacesToBond)); + validateAndExpectNoViolations(helper); + } + /* --- Helper methods for tests --- */ private void validateAndExpectNoViolations(SetupNetworksHelper helper) { -- To view, visit http://gerrit.ovirt.org/18031 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I167758e86b32bd90f09203321f89bf1a5adc7bf6 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: ovirt-engine-3.3 Gerrit-Owner: Lior Vernia <[email protected]> _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
