Lior Vernia has uploaded a new change for review.

Change subject: engine: Support interface QoS override in Setup Networks
......................................................................

engine: Support interface QoS override in Setup Networks

Modified the Setup Networks command to also account for QoS override
on the host interface level. If the feature is supported and the QoS
entities are valid, the overridden QoS is persisted and passed to
VDSM.

Change-Id: I22a4fefac1c5e80c98a72507623152ea4d30ef07
Signed-off-by: Lior Vernia <lver...@redhat.com>
---
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/network/host/SetupNetworksCommand.java
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
M 
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/errors/VdcBllMessages.java
M backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties
M 
backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/NetworkUtils.java
M 
backend/manager/modules/utils/src/test/java/org/ovirt/engine/core/utils/NetworkUtilsTest.java
M 
backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/SetupNetworksVDSCommand.java
M 
backend/manager/modules/vdsbroker/src/test/java/org/ovirt/engine/core/vdsbroker/vdsbroker/SetupNetworksVDSCommandTest.java
M 
frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/AppErrors.java
M 
frontend/webadmin/modules/webadmin/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties
11 files changed, 193 insertions(+), 16 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/66/22766/1

diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/network/host/SetupNetworksCommand.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/network/host/SetupNetworksCommand.java
index 729abc3..4cdba1f 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/network/host/SetupNetworksCommand.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/network/host/SetupNetworksCommand.java
@@ -1,6 +1,7 @@
 package org.ovirt.engine.core.bll.network.host;
 
 import java.util.Arrays;
+import java.util.Collection;
 import java.util.List;
 import java.util.Set;
 import java.util.concurrent.TimeUnit;
@@ -148,6 +149,10 @@
         return helper.getNetworks();
     }
 
+    private Collection<VdsNetworkInterface> getModifiedInterfaces() {
+        return helper.getModifiedInterfaces();
+    }
+
     /**
      * use FutureTask to poll the vdsm (with getCapabilities) while 
setupNetworks task is not done. during the poll task
      * try to fetch the setupNetwork task answer with a timeout equal to 
getConnectitivtyTimeout defined in the command
@@ -172,6 +177,9 @@
 
             @Override
             public Boolean runInTransaction() {
+                // update the interfaces whose qosOverridden field has changed
+                
getDbFacade().getInterfaceDao().updateQosOverridden(getModifiedInterfaces());
+
                 // save the new network topology to DB
                 Backend.getInstance().getResourceManager()
                         .RunVdsCommand(VDSCommandType.CollectVdsNetworkData,
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 bc2320d..a43bd9c 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
@@ -2,6 +2,7 @@
 
 import java.text.MessageFormat;
 import java.util.ArrayList;
+import java.util.Collection;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.List;
@@ -10,7 +11,9 @@
 
 import org.apache.commons.lang.ObjectUtils;
 import org.apache.commons.lang.StringUtils;
+import org.ovirt.engine.core.bll.ValidationResult;
 import org.ovirt.engine.core.bll.network.VmInterfaceManager;
+import org.ovirt.engine.core.bll.validator.NetworkQosValidator;
 import org.ovirt.engine.core.common.FeatureSupported;
 import org.ovirt.engine.core.common.action.SetupNetworksParameters;
 import org.ovirt.engine.core.common.businessentities.Entities;
@@ -35,6 +38,7 @@
     private List<String> removedNetworks = new ArrayList<String>();
     private Map<String, VdsNetworkInterface> modifiedBonds = new 
HashMap<String, VdsNetworkInterface>();
     private Set<String> removedBonds = new HashSet<String>();
+    private Collection<VdsNetworkInterface> modifiedInterfaces = new 
ArrayList<VdsNetworkInterface>();
 
     /** All interface`s names that were processed by the helper. */
     private Set<String> ifaceNames = new HashSet<String>();
@@ -90,6 +94,7 @@
         extractRemovedBonds();
         detectSlaveChanges();
         validateMTU();
+        validateNetworkQos();
 
         return translateViolations();
     }
@@ -141,6 +146,29 @@
         }
         addViolation(VdcBllMessages.NETWORK_MTU_DIFFERENCES,
                 String.format("[%s]", StringUtils.join(mtuDiffNetworks, ", 
")));
+    }
+
+    /**
+     * Validates that the feature is supported if any QoS configuration was 
specified, and that the values associated
+     * with it are valid.
+     */
+    private void validateNetworkQos() {
+        boolean featureSupported = 
FeatureSupported.HostNetworkQos(vds.getVdsGroupCompatibilityVersion());
+        for (VdsNetworkInterface iface : params.getInterfaces()) {
+            if (iface.isQosOverridden()) {
+                if (!featureSupported) {
+                    
addViolation(VdcBllMessages.ACTION_TYPE_FAILED_HOST_NETWORK_QOS_NOT_SUPPORTED, 
iface.getNetworkName());
+                }
+
+                NetworkQosValidator qosValidator = new 
NetworkQosValidator(iface.getQos());
+                if (qosValidator.allValuesPresent() != ValidationResult.VALID) 
{
+                    
addViolation(VdcBllMessages.ACTION_TYPE_FAILED_HOST_NETWORK_QOS_MISSING_VALUES, 
iface.getNetworkName());
+                }
+                if (qosValidator.peakConsistentWithAverage() != 
ValidationResult.VALID) {
+                    
addViolation(VdcBllMessages.ACTION_TYPE_FAILED_HOST_NETWORK_QOS_PEAK_LOWER_THAN_AVERAGE,
 iface.getNetworkName());
+                }
+            }
+        }
     }
 
     /**
@@ -306,11 +334,17 @@
                     } else if (networkWasModified(iface)) {
                         addViolation(VdcBllMessages.NETWORKS_NOT_IN_SYNC, 
networkName);
                     }
-                } else if (networkWasModified(iface)) {
-                    if (networkIpAddressWasSameAsHostnameAndChanged(iface)) {
-                        
addViolation(VdcBllMessages.ACTION_TYPE_FAILED_NETWORK_ADDRESS_CANNOT_BE_CHANGED,
 networkName);
+                } else {
+                    if (networkWasModified(iface)) {
+                        if 
(networkIpAddressWasSameAsHostnameAndChanged(iface)) {
+                            
addViolation(VdcBllMessages.ACTION_TYPE_FAILED_NETWORK_ADDRESS_CANNOT_BE_CHANGED,
 networkName);
+                        }
+                        modifiedNetworks.add(network);
                     }
-                    modifiedNetworks.add(network);
+                    if ((existingIface == null && iface.isQosOverridden())
+                            || existingIface != null && 
(iface.isQosOverridden() != existingIface.isQosOverridden())) {
+                        modifiedInterfaces.add(iface);
+                    }
                 }
             } else {
                 VdsNetworkInterface existingIface = 
getExistingIfaces().get(iface.getName());
@@ -426,7 +460,8 @@
 
         return !ObjectUtils.equals(iface.getNetworkName(), 
existingIface.getNetworkName())
                 || iface.getBootProtocol() != existingIface.getBootProtocol()
-                || staticBootProtoPropertiesChanged(iface, existingIface);
+                || staticBootProtoPropertiesChanged(iface, existingIface)
+                || !ObjectUtils.equals(iface.getQos(), existingIface.getQos());
     }
 
     /**
@@ -590,6 +625,10 @@
         return removedBonds;
     }
 
+    public Collection<VdsNetworkInterface> getModifiedInterfaces() {
+        return modifiedInterfaces;
+    }
+
     public VmInterfaceManager getVmInterfaceManager() {
         return new VmInterfaceManager();
     }
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 486c66a..605fe26 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
@@ -26,6 +26,7 @@
 import org.ovirt.engine.core.common.businessentities.VDS;
 import org.ovirt.engine.core.common.businessentities.network.Network;
 import 
org.ovirt.engine.core.common.businessentities.network.NetworkBootProtocol;
+import org.ovirt.engine.core.common.businessentities.network.NetworkQoS;
 import org.ovirt.engine.core.common.businessentities.network.ProviderNetwork;
 import 
org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface;
 import org.ovirt.engine.core.common.config.ConfigValues;
@@ -50,7 +51,10 @@
     public static MockConfigRule mcr = new 
MockConfigRule(mockConfig(ConfigValues.ManagementNetwork,
             MANAGEMENT_NETWORK_NAME),
             mockConfig(ConfigValues.MultipleGatewaysSupported, 
Version.v3_3.toString(), true),
-            mockConfig(ConfigValues.MultipleGatewaysSupported, 
Version.v3_2.toString(), false));
+            mockConfig(ConfigValues.MultipleGatewaysSupported, 
Version.v3_2.toString(), false),
+            mockConfig(ConfigValues.HostNetworkQosSupported, 
Version.v3_2.toString(), false),
+            mockConfig(ConfigValues.HostNetworkQosSupported, 
Version.v3_3.toString(), false),
+            mockConfig(ConfigValues.HostNetworkQosSupported, new Version(3, 
4).toString(), true));
 
     @Mock
     private NetworkDao networkDAO;
@@ -202,9 +206,9 @@
 
         VDS vds = mock(VDS.class);
         when(vds.getId()).thenReturn(Guid.Empty);
-        when(vds.getVdsGroupCompatibilityVersion()).thenReturn(Version.v3_2);
 
         SetupNetworksHelper helper = 
createHelper(createParametersForNics(nic), vds);
+        when(vds.getVdsGroupCompatibilityVersion()).thenReturn(Version.v3_2);
 
         validateAndExpectViolation(helper, 
VdcBllMessages.NETWORK_ATTACH_ILLEGAL_GATEWAY, nic.getNetworkName());
     }
@@ -338,6 +342,58 @@
 
         validateAndExpectViolation(helper,
                 
VdcBllMessages.ACTION_TYPE_FAILED_NETWORK_ADDRESS_CANNOT_BE_CHANGED);
+    }
+
+    @Test
+    public void qosNotSupported() {
+        Network network = createNetwork(MANAGEMENT_NETWORK_NAME);
+        mockExistingNetworks(network);
+        VdsNetworkInterface iface = createNicSyncedWithNetwork("eth0", 
network);
+        mockExistingIfaces(iface);
+        iface.setQosOverridden(true);
+
+        VDS host = mock(VDS.class);
+        SetupNetworksHelper helper = 
createHelper(createParametersForNics(iface), host);
+
+        validateAndExpectViolation(helper,
+                
VdcBllMessages.ACTION_TYPE_FAILED_HOST_NETWORK_QOS_NOT_SUPPORTED,
+                MANAGEMENT_NETWORK_NAME);
+    }
+
+    @Test
+    public void qosOverridden() {
+        Network network = createNetwork(MANAGEMENT_NETWORK_NAME);
+        mockExistingNetworks(network);
+        VdsNetworkInterface iface = createNicSyncedWithNetwork("eth0", 
network);
+        mockExistingIfaces(iface);
+        iface.setQosOverridden(true);
+
+        VDS host = mock(VDS.class);
+        SetupNetworksHelper helper = 
createHelper(createParametersForNics(iface), host);
+        when(host.getVdsGroupCompatibilityVersion()).thenReturn(new Version(3, 
4));
+
+        validateAndAssertQosOverridden(helper, iface);
+    }
+
+    @Test
+    public void qosValuesModified() {
+        Network network = createNetwork(MANAGEMENT_NETWORK_NAME);
+        mockExistingNetworks(network);
+        VdsNetworkInterface iface = createNicSyncedWithNetwork("eth0", 
network);
+        iface.setQosOverridden(true);
+        mockExistingIfaces(iface);
+
+        NetworkQoS qos = new NetworkQoS();
+        qos.setInboundAverage(30);
+        qos.setInboundPeak(30);
+        qos.setInboundBurst(30);
+        iface.setQos(qos);
+
+        VDS host = mock(VDS.class);
+        SetupNetworksHelper helper = 
createHelper(createParametersForNics(iface), host);
+        when(host.getVdsGroupCompatibilityVersion()).thenReturn(new Version(3, 
4));
+
+        validateAndAssertNetworkModified(helper, network);
     }
 
     /* --- Tests for external networks --- */
@@ -1278,6 +1334,7 @@
         assertNoNetworksModified(helper);
         assertNoNetworksRemoved(helper);
         assertNoBondsRemoved(helper);
+        assertNoInterfacesModified(helper);
     }
 
     private void validateAndAssertNetworkModified(SetupNetworksHelper helper, 
Network net) {
@@ -1286,6 +1343,16 @@
         assertNetworkModified(helper, net);
         assertNoNetworksRemoved(helper);
         assertNoBondsRemoved(helper);
+        assertNoInterfacesModified(helper);
+    }
+
+    private void validateAndAssertQosOverridden(SetupNetworksHelper helper, 
VdsNetworkInterface iface) {
+        validateAndExpectNoViolations(helper);
+        assertNoBondsModified(helper);
+        assertNoNetworksModified(helper);
+        assertNoNetworksRemoved(helper);
+        assertNoBondsRemoved(helper);
+        assertInterfaceModified(helper, iface);
     }
 
     private void assertBondRemoved(SetupNetworksHelper helper, String 
expectedBondName) {
@@ -1344,6 +1411,19 @@
                 0, helper.getBonds().size());
     }
 
+    private void assertInterfaceModified(SetupNetworksHelper helper, 
VdsNetworkInterface iface) {
+        assertTrue(MessageFormat.format("Expected interface ''{0}'' to be 
modified but it wasn''t. Modified interfaces: {1}",
+                iface, helper.getModifiedInterfaces()),
+                helper.getModifiedInterfaces().contains(iface));
+    }
+
+    private void assertNoInterfacesModified(SetupNetworksHelper helper) {
+        assertEquals(MessageFormat.format("Expected no interfaces to be 
modified, but the following interfaces were: {0}",
+                helper.getModifiedInterfaces()),
+                0,
+                helper.getModifiedInterfaces().size());
+    }
+
     /**
      * @param networkName
      *            The network's name.
@@ -1373,7 +1453,8 @@
             Integer vlanId,
             String networkName,
             boolean bridged,
-            String address) {
+            String address,
+            boolean qosOverridden) {
         VdsNetworkInterface iface = new VdsNetworkInterface();
         iface.setId(id);
         iface.setName(name);
@@ -1383,6 +1464,7 @@
         iface.setNetworkName(networkName);
         iface.setBridged(bridged);
         iface.setAddress(address);
+        iface.setQosOverridden(qosOverridden);
         return iface;
     }
 
@@ -1394,7 +1476,7 @@
      * @return {@link VdsNetworkInterface} representing a regular NIC with the 
given parameters.
      */
     private VdsNetworkInterface createNic(String nicName, String networkName) {
-        return createVdsInterface(Guid.newGuid(), nicName, false, null, null, 
networkName, true, null);
+        return createVdsInterface(Guid.newGuid(), nicName, false, null, null, 
networkName, true, null, false);
     }
 
     /**
@@ -1412,7 +1494,8 @@
                 network.getVlanId(),
                 network.getName(),
                 network.isVmNetwork(),
-                network.getAddr());
+                network.getAddr(),
+                false);
         return nic;
     }
 
@@ -1438,7 +1521,7 @@
      * @return Bond with the given parameters.
      */
     private VdsNetworkInterface createBond(String name, String networkName) {
-        return createVdsInterface(Guid.newGuid(), name, true, null, null, 
networkName, true, null);
+        return createVdsInterface(Guid.newGuid(), name, true, null, null, 
networkName, true, null, false);
     }
 
     /**
@@ -1458,7 +1541,8 @@
                 vlanId,
                 networkName,
                 true,
-                null);
+                null,
+                false);
     }
 
     /**
@@ -1471,7 +1555,7 @@
      * @return NIC from given NIC which is either enslaved or freed.
      */
     private VdsNetworkInterface enslaveOrReleaseNIC(VdsNetworkInterface iface, 
String bondName) {
-        return createVdsInterface(iface.getId(), iface.getName(), false, 
bondName, null, null, true, null);
+        return createVdsInterface(iface.getId(), iface.getName(), false, 
bondName, null, null, true, null, false);
     }
 
     /**
@@ -1588,7 +1672,8 @@
                     nics[i].getVlanId(),
                     nics[i].getNetworkName(),
                     nics[i].isBridged(),
-                    nics[i].getAddress()));
+                    nics[i].getAddress(),
+                    nics[i].isQosOverridden()));
         }
         
when(interfaceDAO.getAllInterfacesForVds(any(Guid.class))).thenReturn(existingIfaces);
     }
@@ -1600,6 +1685,8 @@
     }
 
     private SetupNetworksHelper createHelper(SetupNetworksParameters params, 
VDS vds) {
+        when(vds.getVdsGroupCompatibilityVersion()).thenReturn(Version.v3_3);
+
         SetupNetworksHelper helper = spy(new SetupNetworksHelper(params, vds));
 
         when(helper.getVmInterfaceManager()).thenReturn(vmInterfaceManager);
diff --git 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/errors/VdcBllMessages.java
 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/errors/VdcBllMessages.java
index 1dc5a57..aefeea6 100644
--- 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/errors/VdcBllMessages.java
+++ 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/errors/VdcBllMessages.java
@@ -683,6 +683,7 @@
     HOT_PLUG_DISK_SNAPSHOT_IS_NOT_SUPPORTED(ErrorType.NOT_SUPPORTED),
     NULL_NETWORK_IS_NOT_SUPPORTED(ErrorType.NOT_SUPPORTED),
     ACTION_TYPE_FAILED_NETWORK_QOS_IS_NOT_SUPPORTED(ErrorType.NOT_SUPPORTED),
+    ACTION_TYPE_FAILED_HOST_NETWORK_QOS_NOT_SUPPORTED(ErrorType.NOT_SUPPORTED),
     HOT_VM_INTERFACE_UPDATE_IS_NOT_SUPPORTED(ErrorType.NOT_SUPPORTED),
     
ACTION_TYPE_FAILED_VM_INTERFACE_TYPE_IS_NOT_SUPPORTED_BY_OS(ErrorType.INCOMPATIBLE_VERSION),
     CANNOT_PERFORM_HOT_UPDATE(ErrorType.CONFLICT),
@@ -864,6 +865,8 @@
     ACTION_TYPE_FAILED_NETWORK_QOS_NOT_FOUND(ErrorType.BAD_PARAMETERS),
     ACTION_TYPE_FAILED_NETWORK_QOS_INVALID_DC_ID(ErrorType.BAD_PARAMETERS),
     
ACTION_TYPE_FAILED_NETWORK_QOS_PEAK_LOWER_THAN_AVERAGE(ErrorType.BAD_PARAMETERS),
+    
ACTION_TYPE_FAILED_HOST_NETWORK_QOS_MISSING_VALUES(ErrorType.BAD_PARAMETERS),
+    
ACTION_TYPE_FAILED_HOST_NETWORK_QOS_PEAK_LOWER_THAN_AVERAGE(ErrorType.BAD_PARAMETERS),
 
     // Alignment scan
     ERROR_CANNOT_RUN_ALIGNMENT_SCAN_VM_IS_RUNNING(ErrorType.CONFLICT),
diff --git 
a/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties 
b/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties
index 6ea7c89..c1245b8 100644
--- 
a/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties
+++ 
b/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties
@@ -874,6 +874,7 @@
 UNLINKING_IS_NOT_SUPPORTED=Cannot ${action} ${type}. Link state is set to 
'Down' on the virtual machine's interface, this is not supported for clusters 
of version ${clusterVersion}.
 NULL_NETWORK_IS_NOT_SUPPORTED=Cannot ${action} ${type}. There is no network on 
the virtual machine's interface, this is not supported for clusters of version 
${clusterVersion}.
 ACTION_TYPE_FAILED_NETWORK_QOS_IS_NOT_SUPPORTED=Cannot ${action} ${type}. 
There is Network QoS on the profile, this is not supported for clusters of 
version ${clusterVersion}.
+ACTION_TYPE_FAILED_HOST_NETWORK_QOS_NOT_SUPPORTED=Cannot ${action} ${type}. 
Host Network QoS is not supported in this host's cluster compatibility version, 
but QoS was configured on the following network(s): 
${ACTION_TYPE_FAILED_HOST_NETWORK_QOS_NOT_SUPPORTED_LIST}.
 HOT_VM_INTERFACE_UPDATE_IS_NOT_SUPPORTED=Cannot ${action} ${type}. Updating 
the virtual machine interface while the virtual machine is running is not 
supported for clusters of version ${clusterVersion}.
 ACTION_TYPE_FAILED_VM_INTERFACE_TYPE_IS_NOT_SUPPORTED_BY_OS=Cannot ${action} 
${type}. The network interface type is not compatible with the selected 
operating system.
 CANNOT_PERFORM_HOT_UPDATE=Cannot ${action} ${type}. Updating some of the 
properties is not supported while the interface is plugged into a running 
virtual machine. Please un-plug the interface, update the properties, and then 
plug it back.
@@ -1031,6 +1032,8 @@
 ACTION_TYPE_FAILED_NETWORK_QOS_NOT_FOUND=Cannot ${action} ${type}. QoS entity 
not found.
 ACTION_TYPE_FAILED_NETWORK_QOS_INVALID_DC_ID=Cannot ${action} ${type}. Data 
Center does not contain the specific QoS entity.
 ACTION_TYPE_FAILED_NETWORK_QOS_PEAK_LOWER_THAN_AVERAGE=Cannot ${action} 
${type}. Peak cannot be set lower than Average.
+ACTION_TYPE_FAILED_HOST_NETWORK_QOS_MISSING_VALUES=Cannot ${action} ${type}. 
All three QoS parameters are required to configure QoS in a certain direction, 
but the following network(s) are missing some of them: 
${ACTION_TYPE_FAILED_HOST_NETWORK_QOS_MISSING_VALUES_LIST}.
+ACTION_TYPE_FAILED_HOST_NETWORK_QOS_PEAK_LOWER_THAN_AVERAGE=Cannot ${action} 
${type}. QoS cannot be configured such that Peak is set lower than Average, but 
it was configured so on the following network(s): 
${ACTION_TYPE_FAILED_HOST_NETWORK_QOS_PEAK_LOWER_THAN_AVERAGE_LIST}.
 QOS_NAME_NOT_NULL=QoS name cannot be empty.
 QOS_NAME_INVALID=Invalid QoS name (name must be formed of "a-z0-9A-Z" or "-_ ")
 QOS_NAME_TOO_LONG=QoS name length must be under 255 characters.
diff --git 
a/backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/NetworkUtils.java
 
b/backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/NetworkUtils.java
index 0ddb71a..1897b4a 100644
--- 
a/backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/NetworkUtils.java
+++ 
b/backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/NetworkUtils.java
@@ -172,7 +172,7 @@
         return (network.getMtu() == 0 || iface.getMtu() == network.getMtu())
                 && Objects.equals(iface.getVlanId(), network.getVlanId())
                 && iface.isBridged() == network.isVmNetwork()
-                && Objects.equals(iface.getQos(), qos);
+                && (Objects.equals(iface.getQos(), qos) || 
iface.isQosOverridden());
     }
 
     /**
diff --git 
a/backend/manager/modules/utils/src/test/java/org/ovirt/engine/core/utils/NetworkUtilsTest.java
 
b/backend/manager/modules/utils/src/test/java/org/ovirt/engine/core/utils/NetworkUtilsTest.java
index 4d22e42..524d883 100644
--- 
a/backend/manager/modules/utils/src/test/java/org/ovirt/engine/core/utils/NetworkUtilsTest.java
+++ 
b/backend/manager/modules/utils/src/test/java/org/ovirt/engine/core/utils/NetworkUtilsTest.java
@@ -147,6 +147,19 @@
     }
 
     @Test
+    public void calculateNetworkImplementationDetailsNetworkQosOverridden() 
throws Exception {
+        VdsNetworkInterface iface = createNetworkDevice();
+        iface.setQosOverridden(true);
+        calculateNetworkImplementationDetailsAndAssertSync(iface,
+                true,
+                iface.getNetworkName(),
+                iface.isBridged(),
+                iface.getMtu(),
+                iface.getVlanId(),
+                new NetworkQoS());
+    }
+
+    @Test
     public void interfaceBasedOn() {
         assertTrue(NetworkUtils.interfaceBasedOn(generateVlanName(IFACE_NAME), 
IFACE_NAME));
     }
diff --git 
a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/SetupNetworksVDSCommand.java
 
b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/SetupNetworksVDSCommand.java
index 061a653..15b07c8 100644
--- 
a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/SetupNetworksVDSCommand.java
+++ 
b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/SetupNetworksVDSCommand.java
@@ -62,7 +62,7 @@
             if 
(FeatureSupported.HostNetworkQos(getVds().getVdsGroupCompatibilityVersion())) {
                 NetworkQosMapper qosMapper =
                         new NetworkQosMapper(opts, 
VdsProperties.HOST_QOS_INBOUND, VdsProperties.HOST_QOS_OUTBOUND);
-                qosMapper.serialize(qosDao.get(network.getQosId()));
+                qosMapper.serialize(iface.isQosOverridden() ? iface.getQos() : 
qosDao.get(network.getQosId()));
             }
 
             networks.put(network.getName(), opts);
diff --git 
a/backend/manager/modules/vdsbroker/src/test/java/org/ovirt/engine/core/vdsbroker/vdsbroker/SetupNetworksVDSCommandTest.java
 
b/backend/manager/modules/vdsbroker/src/test/java/org/ovirt/engine/core/vdsbroker/vdsbroker/SetupNetworksVDSCommandTest.java
index 97985ad..c79e8e6 100644
--- 
a/backend/manager/modules/vdsbroker/src/test/java/org/ovirt/engine/core/vdsbroker/vdsbroker/SetupNetworksVDSCommandTest.java
+++ 
b/backend/manager/modules/vdsbroker/src/test/java/org/ovirt/engine/core/vdsbroker/vdsbroker/SetupNetworksVDSCommandTest.java
@@ -198,6 +198,18 @@
         qos(network, iface, qos, new Version(3, 4));
     }
 
+    @Test
+    public void qosOnInterface() {
+        Network network = createNetwork(null);
+        VdsNetworkInterface iface = createNic("eth0", null, null, 
network.getName());
+
+        NetworkQoS qos = createQos();
+        when(qosDao.get(any(Guid.class))).thenReturn(qos);
+        iface.setQosOverridden(true);
+
+        qos(network, iface, null, new Version(3, 4));
+    }
+
     /**
      * Verify that the method on the host was called, capturing the sent 
arguments for tests done later.
      */
diff --git 
a/frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/AppErrors.java
 
b/frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/AppErrors.java
index 09be69f..6107bd4 100644
--- 
a/frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/AppErrors.java
+++ 
b/frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/AppErrors.java
@@ -2366,6 +2366,9 @@
     @DefaultStringValue("Cannot ${action} ${type}. There is Network QoS on the 
profile, this is not supported for clusters of version ${clusterVersion}.")
     String ACTION_TYPE_FAILED_NETWORK_QOS_IS_NOT_SUPPORTED();
 
+    @DefaultStringValue("Cannot ${action} ${type}. Host Network QoS is not 
supported in this host's cluster compatibility version, but QoS was configured 
on the following network(s): 
${ACTION_TYPE_FAILED_HOST_NETWORK_QOS_NOT_SUPPORTED_LIST}.")
+    String ACTION_TYPE_FAILED_HOST_NETWORK_QOS_NOT_SUPPORTED();
+
     @DefaultStringValue("Cannot ${action} ${type}. Updating the virtual 
machine interface while the virtual machine is running is not supported for 
clusters of version ${clusterVersion}.")
     String HOT_VM_INTERFACE_UPDATE_IS_NOT_SUPPORTED();
 
@@ -2793,6 +2796,12 @@
     @DefaultStringValue("Cannot ${action} ${type}. Peak cannot be set lower 
than Average.")
     String ACTION_TYPE_FAILED_NETWORK_QOS_PEAK_LOWER_THAN_AVERAGE();
 
+    @DefaultStringValue("Cannot ${action} ${type}. All three QoS parameters 
are required to configure QoS in a certain direction, but the following 
network(s) are missing some of them: 
${ACTION_TYPE_FAILED_HOST_NETWORK_QOS_MISSING_VALUES_LIST}.")
+    String ACTION_TYPE_FAILED_HOST_NETWORK_QOS_MISSING_VALUES();
+
+    @DefaultStringValue("Cannot ${action} ${type}. QoS cannot be configured 
such that Peak is set lower than Average, but it was configured so on the 
following network(s): 
${ACTION_TYPE_FAILED_HOST_NETWORK_QOS_PEAK_LOWER_THAN_AVERAGE_LIST}.")
+    String ACTION_TYPE_FAILED_HOST_NETWORK_QOS_PEAK_LOWER_THAN_AVERAGE();
+
     @DefaultStringValue("QoS name cannot be empty.")
     String QOS_NAME_NOT_NULL();
 
diff --git 
a/frontend/webadmin/modules/webadmin/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties
 
b/frontend/webadmin/modules/webadmin/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties
index 181525c..e7af6ae 100644
--- 
a/frontend/webadmin/modules/webadmin/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties
+++ 
b/frontend/webadmin/modules/webadmin/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties
@@ -874,6 +874,7 @@
 UNLINKING_IS_NOT_SUPPORTED=Cannot ${action} ${type}. Link state is set to 
'Down' on the virtual machine's interface, this is not supported for clusters 
of version ${clusterVersion}.
 NULL_NETWORK_IS_NOT_SUPPORTED=Cannot ${action} ${type}. There is no network on 
the virtual machine's interface, this is not supported for clusters of version 
${clusterVersion}.
 ACTION_TYPE_FAILED_NETWORK_QOS_IS_NOT_SUPPORTED=Cannot ${action} ${type}. 
There is Network QoS on the profile, this is not supported for clusters of 
version ${clusterVersion}.
+ACTION_TYPE_FAILED_HOST_NETWORK_QOS_NOT_SUPPORTED=Cannot ${action} ${type}. 
Host Network QoS is not supported in this host's cluster compatibility version, 
but QoS was configured on the following network(s): 
${ACTION_TYPE_FAILED_HOST_NETWORK_QOS_NOT_SUPPORTED_LIST}.
 HOT_VM_INTERFACE_UPDATE_IS_NOT_SUPPORTED=Cannot ${action} ${type}. Updating 
the virtual machine interface while the virtual machine is running is not 
supported for clusters of version ${clusterVersion}.
 ACTION_TYPE_FAILED_VM_INTERFACE_TYPE_IS_NOT_SUPPORTED_BY_OS=Cannot ${action} 
${type}. The network interface type is not compatible with the selected 
operating system.
 CANNOT_PERFORM_HOT_UPDATE=Cannot ${action} ${type}. Updating some of the 
properties is not supported while the interface is plugged into a running 
virtual machine. Please un-plug the interface, update the properties, and then 
plug it back.
@@ -1010,6 +1011,8 @@
 ACTION_TYPE_FAILED_NETWORK_QOS_NOT_FOUND=Cannot ${action} ${type}. QoS entity 
not found.
 ACTION_TYPE_FAILED_NETWORK_QOS_INVALID_DC_ID=Cannot ${action} ${type}. Data 
Center does not contain the specific QoS entity.
 ACTION_TYPE_FAILED_NETWORK_QOS_PEAK_LOWER_THAN_AVERAGE=Cannot ${action} 
${type}. Peak cannot be set lower than Average.
+ACTION_TYPE_FAILED_HOST_NETWORK_QOS_MISSING_VALUES=Cannot ${action} ${type}. 
All three QoS parameters are required to configure QoS in a certain direction, 
but the following network(s) are missing some of them: 
${ACTION_TYPE_FAILED_HOST_NETWORK_QOS_MISSING_VALUES_LIST}.
+ACTION_TYPE_FAILED_HOST_NETWORK_QOS_PEAK_LOWER_THAN_AVERAGE=Cannot ${action} 
${type}. QoS cannot be configured such that Peak is set lower than Average, but 
it was configured so on the following network(s): 
${ACTION_TYPE_FAILED_HOST_NETWORK_QOS_PEAK_LOWER_THAN_AVERAGE_LIST}.
 QOS_NAME_NOT_NULL=QoS name cannot be empty.
 QOS_NAME_INVALID=Invalid QoS name (name must be formed of "a-z0-9A-Z" or "-_ ")
 QOS_NAME_TOO_LONG=QoS name length must be under 255 characters.


-- 
To view, visit http://gerrit.ovirt.org/22766
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I22a4fefac1c5e80c98a72507623152ea4d30ef07
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Lior Vernia <lver...@redhat.com>
_______________________________________________
Engine-patches mailing list
Engine-patches@ovirt.org
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to