Lior Vernia has uploaded a new change for review.

Change subject: engine: Ignore 'cfg' entries for cluster version >= 3.6
......................................................................

engine: Ignore 'cfg' entries for cluster version >= 3.6

If we want to deprecate 'cfg' entries (specific to ifcfg files) in
4.0, we should stop using them in 3.6.

Change-Id: If434111561aefab3d5d358a97331bcf3159f3484
Bug-Url: https://bugzilla.redhat.com/1070613
Signed-off-by: Lior Vernia <lver...@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/VdsBrokerObjectsBuilder.java
M packaging/dbscripts/upgrade/pre_upgrade/0000_config.sql
4 files changed, 64 insertions(+), 33 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/43/36343/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 a85ab54..a9e03c7 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
@@ -80,6 +80,15 @@
 
     /**
      * @param version
+     * Compatibility version to check for.
+     * @return <code>true</code> iff VDSM doesn't depend on ifcfg files for 
reporting.
+     */
+    public static boolean cfgEntryDeprecated(Version version) {
+        return supportedInConfig(ConfigValues.CfgEntriesDeprecated, version);
+    }
+
+    /**
+     * @param version
      *            Compatibility version to check for.
      * @return <code>true</code> if anti MAC spoofing is supported for the 
version, <code>false</code> if it's not.
      */
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 f0adc8e..92ee843 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
@@ -1135,6 +1135,10 @@
     @DefaultValueAttribute("true")
     SupportBridgesReportByVDSM,
 
+    @TypeConverterAttribute(Boolean.class)
+    @DefaultValueAttribute("true")
+    CfgEntriesDeprecated,
+
     @Reloadable
     @TypeConverterAttribute(Map.class)
     @DefaultValueAttribute("{\"storage domains\":\"true\",\"hosts\":\"true\"}")
diff --git 
a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/VdsBrokerObjectsBuilder.java
 
b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/VdsBrokerObjectsBuilder.java
index f952227..358cbdf 100644
--- 
a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/VdsBrokerObjectsBuilder.java
+++ 
b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/VdsBrokerObjectsBuilder.java
@@ -1429,13 +1429,16 @@
                         iface.setMtu(Integer.parseInt((String) 
bond.get(VdsProperties.MTU)));
                     }
 
-                    Map<String, Object> config =
-                            (Map<String, Object>) bond.get("cfg");
-
-                    if (config != null && config.get("BONDING_OPTS") != null) {
-                        
iface.setBondOptions(config.get("BONDING_OPTS").toString());
+                    Object bondOptions = null;
+                    if 
(FeatureSupported.cfgEntryDeprecated(vds.getVdsGroupCompatibilityVersion())) {
+                        bondOptions = bond.get("opts");
+                    } else {
+                        Map<String, Object> config = (Map<String, Object>) 
bond.get("cfg");
+                        bondOptions = (config == null) ? null : 
config.get("BONDING_OPTS");
                     }
-                    addBootProtocol(config, vds, iface);
+                    iface.setBondOptions(bondOptions == null ? null : 
bondOptions.toString());
+ 
+                    addBootProtocol(bond, vds, iface);
                 }
             }
         }
@@ -1483,7 +1486,7 @@
                 }
 
                 iStats.setVdsId(vds.getId());
-                addBootProtocol((Map<String, Object>) vlan.get("cfg"), vds, 
iface);
+                addBootProtocol(vlan, vds, iface);
                 vds.getInterfaces().add(iface);
             }
         }
@@ -1545,7 +1548,7 @@
             if (StringUtils.isNotBlank((String) nic.get(VdsProperties.MTU))) {
                 iface.setMtu(Integer.parseInt((String) 
nic.get(VdsProperties.MTU)));
             }
-            addBootProtocol((Map<String, Object>) nic.get("cfg"), host, iface);
+            addBootProtocol(nic, host, iface);
         }
     }
 
@@ -1579,8 +1582,7 @@
             setGatewayIfNecessary(iface, host, net.getGateway());
 
             if (bridgedNetwork) {
-                Map<String, Object> networkConfig = (Map<String, Object>) 
network.get("cfg");
-                addBootProtocol(networkConfig, host, iface);
+                addBootProtocol(network, host, iface);
             }
 
             if 
(FeatureSupported.hostNetworkQos(Collections.max(host.getSupportedClusterVersionsSet())))
 {
@@ -1620,31 +1622,41 @@
         }
     }
 
-    private static void addBootProtocol(Map<String, Object> cfg, VDS host, 
VdsNetworkInterface iface) {
-        NetworkBootProtocol bootproto = NetworkBootProtocol.NONE;
-
-        if (cfg != null) {
-            String bootProtocol = (String) cfg.get("BOOTPROTO");
-
-            if (bootProtocol != null) {
-                if (bootProtocol.toLowerCase().equals("dhcp")) {
-                    bootproto = NetworkBootProtocol.DHCP;
-                } else if (bootProtocol.toLowerCase().equals("none") || 
bootProtocol.toLowerCase().equals("static")) {
-                    if (StringUtils.isNotEmpty((String) cfg.get("IPADDR"))) {
-                        bootproto = NetworkBootProtocol.STATIC_IP;
-                    }
-                }
-            } else if (StringUtils.isNotEmpty((String) cfg.get("IPADDR"))) {
-                bootproto = NetworkBootProtocol.STATIC_IP;
-            }
-
-            if (bootproto == NetworkBootProtocol.STATIC_IP) {
-                String gateway = (String) cfg.get(VdsProperties.GATEWAY);
-                if (StringUtils.isNotEmpty(gateway)) {
-                    setGatewayIfNecessary(iface, host, gateway.toString());
-                }
+    private static void addBootProtocol(Map<String, Object> entry, VDS host, 
VdsNetworkInterface iface) {
+        boolean cfgDeprecated = 
FeatureSupported.cfgEntryDeprecated(host.getVdsGroupCompatibilityVersion());
+        if (!cfgDeprecated) {
+            entry = (Map<String, Object>) entry.get("cfg");
+            if (entry == null) {
+                return;
             }
         }
+
+        String bootProtocolKey = cfgDeprecated ? "bootproto4" : "BOOTPROTO";
+        String ipAddressKey = cfgDeprecated ? "addr" : "IPADDR";
+        String gatewayKey = cfgDeprecated ? VdsProperties.GLOBAL_GATEWAY : 
VdsProperties.GATEWAY;
+
+        NetworkBootProtocol bootproto = NetworkBootProtocol.NONE;
+        String bootProtocol = (String) entry.get(bootProtocolKey);
+
+        if (bootProtocol != null) {
+            if (bootProtocol.toLowerCase().equals("dhcp")) {
+                bootproto = NetworkBootProtocol.DHCP;
+            } else if (bootProtocol.toLowerCase().equals("none") || 
bootProtocol.toLowerCase().equals("static")) {
+                if (StringUtils.isNotEmpty((String) entry.get(ipAddressKey))) {
+                    bootproto = NetworkBootProtocol.STATIC_IP;
+                }
+            }
+        } else if (StringUtils.isNotEmpty((String) entry.get(ipAddressKey))) {
+            bootproto = NetworkBootProtocol.STATIC_IP;
+        }
+
+        if (bootproto == NetworkBootProtocol.STATIC_IP) {
+            String gateway = (String) entry.get(gatewayKey);
+            if (StringUtils.isNotEmpty(gateway)) {
+                setGatewayIfNecessary(iface, host, gateway.toString());
+            }
+        }
+
         iface.setBootProtocol(bootproto);
     }
 
diff --git a/packaging/dbscripts/upgrade/pre_upgrade/0000_config.sql 
b/packaging/dbscripts/upgrade/pre_upgrade/0000_config.sql
index 9dd1ceb..dcf475b 100644
--- a/packaging/dbscripts/upgrade/pre_upgrade/0000_config.sql
+++ b/packaging/dbscripts/upgrade/pre_upgrade/0000_config.sql
@@ -396,6 +396,12 @@
 select fn_db_add_config_value('NumberVmRefreshesBeforeSave','5','general');
 select fn_db_add_config_value('SupportBridgesReportByVDSM','false','3.0');
 select fn_db_add_config_value('SupportBridgesReportByVDSM','false','3.1');
+select fn_db_add_config_value('CfgEntriesDeprecated', 'false', '3.0');
+select fn_db_add_config_value('CfgEntriesDeprecated', 'false', '3.1');
+select fn_db_add_config_value('CfgEntriesDeprecated', 'false', '3.2');
+select fn_db_add_config_value('CfgEntriesDeprecated', 'false', '3.3');
+select fn_db_add_config_value('CfgEntriesDeprecated', 'false', '3.4');
+select fn_db_add_config_value('CfgEntriesDeprecated', 'false', '3.5');
 select fn_db_add_config_value('MacAntiSpoofingFilterRulesSupported','false', 
'3.0');
 select fn_db_add_config_value('MacAntiSpoofingFilterRulesSupported','false', 
'3.1');
 select fn_db_add_config_value('EnableMACAntiSpoofingFilterRules','true', 
'general');


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: If434111561aefab3d5d358a97331bcf3159f3484
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