Moti Asayag has uploaded a new change for review.

Change subject: engine: Provide defaultRoute property for management network
......................................................................

engine: Provide defaultRoute property for management network

The engine should pass for setup networks requests a new
property for the management network if it was configured
as DHCP or with a static IP and a gateway was set for it.
The new property will be supported from cluster levels 3.4
and above.

This will allow vdsm to be name-agnostic in regards to the
management network.

Change-Id: Id7bc20065ce28926ceb977c09f0480b345c66da5
Bug-Url: https://bugzilla.redhat.com/1015009
Signed-off-by: Moti Asayag <masa...@redhat.com>
---
M 
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/FeatureSupported.java
M 
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/config/ConfigValues.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 packaging/dbscripts/upgrade/pre_upgrade/0000_config.sql
5 files changed, 43 insertions(+), 8 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/92/24892/1

diff --git 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/FeatureSupported.java
 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/FeatureSupported.java
index cccdaa6..7e97072 100644
--- 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/FeatureSupported.java
+++ 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/FeatureSupported.java
@@ -1,11 +1,11 @@
 package org.ovirt.engine.core.common;
 
+import java.util.Map;
+
 import org.ovirt.engine.core.common.businessentities.ArchitectureType;
 import org.ovirt.engine.core.common.config.Config;
 import org.ovirt.engine.core.common.config.ConfigValues;
 import org.ovirt.engine.core.compat.Version;
-
-import java.util.Map;
 
 /**
  * Convenience class to check if a feature is supported or not in any given 
version.<br>
@@ -220,4 +220,13 @@
     public static boolean getFileStats(Version version) {
         return supportedInConfig(ConfigValues.GetFileStats, version);
     }
+
+    /**
+     * @param version
+     *            Compatibility version to check for.
+     * @return <code>true</code> if default route is supported for the given 
version.
+     */
+    public static boolean defaultRoute(Version version) {
+        return supportedInConfig(ConfigValues.DefaultRouteSupported, version);
+    }
 }
diff --git 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/config/ConfigValues.java
 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/config/ConfigValues.java
index 757c36b..e9b5dfb 100644
--- 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/config/ConfigValues.java
+++ 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/config/ConfigValues.java
@@ -1543,6 +1543,10 @@
 
     @TypeConverterAttribute(Boolean.class)
     @DefaultValueAttribute("true")
+    DefaultRouteSupported,
+
+    @TypeConverterAttribute(Boolean.class)
+    @DefaultValueAttribute("true")
     CloudInitSupported,
 
     @TypeConverterAttribute(Boolean.class)
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 f84a859..7b3fbdb 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
@@ -9,8 +9,10 @@
 import org.apache.commons.lang.StringUtils;
 import org.ovirt.engine.core.common.FeatureSupported;
 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.VdsNetworkInterface;
 import 
org.ovirt.engine.core.common.vdscommands.SetupNetworksVdsCommandParameters;
+import org.ovirt.engine.core.compat.Version;
 import org.ovirt.engine.core.dao.network.NetworkQoSDao;
 import org.ovirt.engine.core.utils.NetworkUtils;
 
@@ -20,6 +22,7 @@
     protected static final String BOOT_PROTOCOL = "bootproto";
     protected static final String BONDING_OPTIONS = "options";
     protected static final String SLAVES = "nics";
+    private static final String DEFAULT_ROUTE = "defaultRoute";
     private static final Map<String, String> REMOVE_OBJ = 
Collections.singletonMap("remove", Boolean.TRUE.toString());
 
     public SetupNetworksVDSCommand(T parameters) {
@@ -59,15 +62,23 @@
                 opts.put(VdsProperties.STP, network.getStp() ? "yes" : "no");
             }
 
+            Version version =
+                    
getDbFacade().getVdsDao().get(getParameters().getVdsId()).getVdsGroupCompatibilityVersion();
             if (qosConfiguredOnInterface(iface, network)
-                    && 
FeatureSupported.hostNetworkQos(getDbFacade().getVdsDao()
-                            .get(getParameters().getVdsId())
-                            .getVdsGroupCompatibilityVersion())) {
+                    && FeatureSupported.hostNetworkQos(version)) {
                 NetworkQosMapper qosMapper =
                         new NetworkQosMapper(opts, 
VdsProperties.HOST_QOS_INBOUND, VdsProperties.HOST_QOS_OUTBOUND);
                 qosMapper.serialize(iface.isQosOverridden() ? iface.getQos() : 
qosDao.get(network.getQosId()));
             }
 
+            if (FeatureSupported.defaultRoute(version)
+                    && NetworkUtils.isManagementNetwork(network)
+                    && (iface.getBootProtocol() == NetworkBootProtocol.DHCP
+                    || (iface.getBootProtocol() == 
NetworkBootProtocol.STATIC_IP
+                    && StringUtils.isNotEmpty(iface.getGateway())))) {
+                opts.put(DEFAULT_ROUTE, Boolean.TRUE);
+            }
+
             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 dde63c3..ae2aa7f 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
@@ -15,6 +15,7 @@
 import java.util.List;
 import java.util.Map;
 
+import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -51,6 +52,9 @@
     @Mock
     private VDS host;
 
+    @Mock
+    private Version version;
+
     @Rule
     public MockConfigRule configRule = new MockConfigRule();
 
@@ -59,6 +63,12 @@
 
     @Captor
     private ArgumentCaptor<Map> networksCaptor;
+
+    @Before
+    public void mockConfig() {
+        when(host.getVdsGroupCompatibilityVersion()).thenReturn(version);
+        configRule.mockConfigValue(ConfigValues.DefaultRouteSupported, 
version, Boolean.FALSE);
+    }
 
     @Test
     public void vlanOverNic() {
@@ -156,9 +166,6 @@
             VdsNetworkInterface iface,
             NetworkQoS expectedQos,
             boolean hostNetworkQosSupported) {
-
-        Version version = mock(Version.class);
-        when(host.getVdsGroupCompatibilityVersion()).thenReturn(version);
         configRule.mockConfigValue(ConfigValues.HostNetworkQosSupported, 
version, hostNetworkQosSupported);
 
         SetupNetworksVdsCommandParameters parameters =
diff --git a/packaging/dbscripts/upgrade/pre_upgrade/0000_config.sql 
b/packaging/dbscripts/upgrade/pre_upgrade/0000_config.sql
index 85c7d9a..f974807 100644
--- a/packaging/dbscripts/upgrade/pre_upgrade/0000_config.sql
+++ b/packaging/dbscripts/upgrade/pre_upgrade/0000_config.sql
@@ -210,6 +210,10 @@
 select fn_db_add_config_value('GetFileStats','false','3.1');
 select fn_db_add_config_value('GetFileStats','false','3.2');
 select fn_db_add_config_value('GetFileStats','false','3.3');
+select fn_db_add_config_value('DefaultRouteSupported','false','3.0');
+select fn_db_add_config_value('DefaultRouteSupported','false','3.1');
+select fn_db_add_config_value('DefaultRouteSupported','false','3.2');
+select fn_db_add_config_value('DefaultRouteSupported','false','3.3');
 
 -- by default use no proxy
 select fn_db_add_config_value('SpiceProxyDefault','','general');


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Id7bc20065ce28926ceb977c09f0480b345c66da5
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: ovirt-engine-3.4
Gerrit-Owner: Moti Asayag <masa...@redhat.com>
_______________________________________________
Engine-patches mailing list
Engine-patches@ovirt.org
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to