replace hard-coded ForwardingRulesManagerConfig with XML configuration
authorMichael Vorburger <mike@vorburger.ch>
Wed, 19 Dec 2018 00:27:57 +0000 (01:27 +0100)
committerMichael Vorburger <mike@vorburger.ch>
Wed, 1 Jul 2020 23:37:50 +0000 (01:37 +0200)
Note how the test proves that the default (5) from the YANG is used!

Signed-off-by: Michael Vorburger <mike@vorburger.ch>
src/main/java/org/opendaylight/openflowplugin/simple/OpenFlowPluginWiring.java
src/main/resources/initial/openflow-frm-config.xml [new file with mode: 0644]
src/test/java/org/opendaylight/openflowplugin/simple/test/OpenFlowPluginWiringTest.java

index b391b5d8b866cbeb87e93186f7dd75150ada3b76..e65a3d33289683784fea740cab4509538a065f11 100644 (file)
@@ -28,7 +28,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.Tr
 import org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.TransmitPacketOutput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow.provider.config.rev160510.OpenflowProviderConfig;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflowplugin.app.forwardingrules.manager.config.rev160511.ForwardingRulesManagerConfig;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflowplugin.app.forwardingrules.manager.config.rev160511.ForwardingRulesManagerConfigBuilder;
 import org.opendaylight.yangtools.yang.common.RpcResult;
 
 public class OpenFlowPluginWiring extends AutoWiringModule {
@@ -46,13 +45,6 @@ public class OpenFlowPluginWiring extends AutoWiringModule {
 
         // TODO curious that this is needed despite SwitchConnectionProviderFactoryImpl being annotated?!
         bind(SwitchConnectionProviderFactory.class).to(SwitchConnectionProviderFactoryImpl.class);
-
-        // Configurations:
-        // TODO ConfigReader for ForwardingRulesManagerConfig XML - but there is none?  Hard-code defaults, for now:
-        // perhaps we can just replace it with an empty XML??
-        bind(ForwardingRulesManagerConfig.class).toInstance(
-                new ForwardingRulesManagerConfigBuilder().setDisableReconciliation(false).setStaleMarkingEnabled(false)
-                        .setReconciliationRetryCount(5).setBundleBasedReconciliationEnabled(false).build());
     }
 
     @Provides
@@ -76,6 +68,11 @@ public class OpenFlowPluginWiring extends AutoWiringModule {
         return configReader.read("/initial/openflow-provider-config", OpenflowProviderConfig.class);
     }
 
+    @Provides
+    @Singleton ForwardingRulesManagerConfig getForwardingRulesManagerConfig(ConfigReader configReader) {
+        return configReader.read("/initial/openflow-frm-config", ForwardingRulesManagerConfig.class);
+    }
+
     private static class NoPacketProcessingService implements PacketProcessingService {
 
         // TODO <odl:action-provider
diff --git a/src/main/resources/initial/openflow-frm-config.xml b/src/main/resources/initial/openflow-frm-config.xml
new file mode 100644 (file)
index 0000000..89d47b4
--- /dev/null
@@ -0,0 +1,2 @@
+<forwarding-rules-manager-config xmlns="urn:opendaylight:params:xml:ns:yang:openflowplugin:app:forwardingrules-manager:config">
+</forwarding-rules-manager-config>
index 390182c35af0abe42f03c0f6fb1cf7c0a677ab96..d30b5c7997aeb8e7a037282785e38735968bbd14 100644 (file)
@@ -23,6 +23,7 @@ import org.opendaylight.infrautils.web.WebWiring;
 import org.opendaylight.openflowplugin.simple.OpenFlowPluginWiring;
 import org.opendaylight.serviceutils.simple.ServiceUtilsWiring;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow.provider.config.rev160510.OpenflowProviderConfig;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflowplugin.app.forwardingrules.manager.config.rev160511.ForwardingRulesManagerConfig;
 
 public class OpenFlowPluginWiringTest extends AbstractSimpleDistributionTest {
 
@@ -33,9 +34,11 @@ public class OpenFlowPluginWiringTest extends AbstractSimpleDistributionTest {
             new AnnotationsModule());
 
     @Inject OpenflowProviderConfig ofpConfig;
+    @Inject ForwardingRulesManagerConfig frmConfig;
 
     @Test public void testConfig() {
         assertThat(ofpConfig.getGlobalNotificationQuota()).named("globalNotificationQuota").isEqualTo(64000L);
+        assertThat(frmConfig.getReconciliationRetryCount()).named("reconciliationRetryCount").isEqualTo(5);
     }
 
 }