BUG-5636: making table features configurable for the He plugin.
[openflowplugin.git] / openflowplugin / src / main / java / org / opendaylight / yang / gen / v1 / urn / opendaylight / params / xml / ns / yang / openflow / common / config / impl / rev140326 / ConfigurableOpenFlowProviderModule.java
index 0c31a5821a0b1aa0c354ccede34f711f4a51a1b7..1542d5444bacf717e81ed154717b3f9987528975 100644 (file)
@@ -11,15 +11,23 @@ package org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflo
 
 import com.google.common.base.MoreObjects;
 import javax.management.ObjectName;
+
+import org.opendaylight.openflowplugin.openflow.md.core.sal.OpenflowPluginConfig;
 import org.opendaylight.openflowplugin.openflow.md.core.sal.OpenflowPluginProvider;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
 *
 */
 public final class ConfigurableOpenFlowProviderModule extends org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow.common.config.impl.rev140326.AbstractConfigurableOpenFlowProviderModule {
 
+    private static final Logger LOG = LoggerFactory.getLogger(ConfigurableOpenFlowProviderModule.class);
+
     private OpenflowPluginProvider pluginProvider;
 
+    private static final boolean SKIP_TABLE_FEATURES = false;
+
     /**
      * @param identifier module identifier
      * @param dependencyResolver dependency resolver
@@ -54,6 +62,7 @@ public final class ConfigurableOpenFlowProviderModule extends org.opendaylight.y
         pluginProvider.setSwitchConnectionProviders(getOpenflowSwitchConnectionProviderDependency());
         pluginProvider.setEntityOwnershipService(getOwnershipServiceDependency());
         pluginProvider.setRole(getRole());
+        pluginProvider.setOpenflowPluginConfig(readConfig());
         pluginProvider.initialization();
         return pluginProvider;
     }
@@ -85,4 +94,18 @@ public final class ConfigurableOpenFlowProviderModule extends org.opendaylight.y
 
         return recycled;
     }
+
+    private OpenflowPluginConfig readConfig(){
+
+        final OpenflowPluginConfig.OpenflowPluginConfigBuilder openflowCfgBuilder = OpenflowPluginConfig.builder();
+
+        if(getSkipTableFeatures()!=null){
+            openflowCfgBuilder.setSkipTableFeatures(getSkipTableFeatures().booleanValue());
+        } else{
+            LOG.warn("Could not load XML configuration file via ConfigSubsystem! Fallback to default config value(s)");
+            openflowCfgBuilder.setSkipTableFeatures(SKIP_TABLE_FEATURES);
+        }
+
+        return openflowCfgBuilder.build();
+    }
 }