summaryrefslogtreecommitdiffstats
path: root/v3po/impl
diff options
context:
space:
mode:
authorMarek Gradzki <mgradzki@cisco.com>2016-04-10 22:06:36 +0200
committerMarek Gradzki <mgradzki@cisco.com>2016-04-12 10:59:14 +0200
commit6dcea1de979536dbe0478e31f17191bcfae92f3c (patch)
treea5070e77f1de0c17476a33aeaaa68fc21ba4315a /v3po/impl
parent4ebc67b58e0172bd4f5704e52a10714ee64d7d07 (diff)
HONEYCOMB-34: Configurable serializer dependency
Change-Id: I05cb7836ec4a379f7617710a6c6f64c3541ff0c9 Signed-off-by: Marek Gradzki <mgradzki@cisco.com>
Diffstat (limited to 'v3po/impl')
-rw-r--r--v3po/impl/src/main/config/default-config.xml87
-rw-r--r--v3po/impl/src/main/config/netconf-north-config.xml2
-rw-r--r--v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/V3poProvider.java18
-rw-r--r--v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/VppDataBrokerInitializationProvider.java151
-rw-r--r--v3po/impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/v3po/impl/rev141210/V3poModule.java8
-rw-r--r--v3po/impl/src/main/yang/v3po-impl.yang10
-rw-r--r--v3po/impl/src/test/java/io/fd/honeycomb/v3po/impl/data/VppDataBrokerInitializationProviderTest.java5
-rw-r--r--v3po/impl/src/test/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/v3po/impl/rev141210/V3poModuleTest.java9
8 files changed, 242 insertions, 48 deletions
diff --git a/v3po/impl/src/main/config/default-config.xml b/v3po/impl/src/main/config/default-config.xml
index 5b8ef15da..13ab70211 100644
--- a/v3po/impl/src/main/config/default-config.xml
+++ b/v3po/impl/src/main/config/default-config.xml
@@ -27,6 +27,54 @@
<data xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
<modules xmlns="urn:opendaylight:params:xml:ns:yang:controller:config">
+ <!--<module>-->
+ <!--<type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:impl">prefix:dom-inmemory-data-broker</type>-->
+ <!--<name>netconf-inmemory-data-broker</name>-->
+
+ <!--<schema-service>-->
+ <!--<type xmlns:dom="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom">dom:schema-service</type>-->
+ <!--<name>yang-schema-service</name>-->
+ <!--</schema-service>-->
+
+ <!--<config-data-store>-->
+ <!--<type xmlns:config-dom-store-spi="urn:opendaylight:params:xml:ns:yang:controller:md:sal:core:spi:config-dom-store">config-dom-store-spi:config-dom-datastore</type>-->
+ <!--<name>netconf-config-store-service</name>-->
+ <!--</config-data-store>-->
+
+ <!--<operational-data-store>-->
+ <!--<type xmlns:operational-dom-store-spi="urn:opendaylight:params:xml:ns:yang:controller:md:sal:core:spi:operational-dom-store">operational-dom-store-spi:operational-dom-datastore</type>-->
+ <!--<name>netconf-operational-store-service</name>-->
+ <!--</operational-data-store>-->
+ <!--</module>-->
+
+ <!--<module>-->
+ <!--<type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">prefix:binding-forwarded-data-broker</type>-->
+ <!--<name>honeycomb-binding-data-broker</name>-->
+ <!--<binding-forwarded-data-broker xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">-->
+
+ <!--&lt;!&ndash;TODO &ndash;&gt;-->
+ <!--&lt;!&ndash;<dom-async-broker>&ndash;&gt;-->
+ <!--&lt;!&ndash;<type xmlns:dom="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom">dom:dom-async-data-broker</type>&ndash;&gt;-->
+ <!--&lt;!&ndash;<name>honeycomb-dom-data-broker</name>&ndash;&gt;-->
+ <!--&lt;!&ndash;</dom-async-broker>&ndash;&gt;-->
+
+ <!--<dom-async-broker>-->
+ <!--<type xmlns:dom="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom">dom:dom-async-data-broker</type>-->
+ <!--<name>netconf-inmemory-data-broker</name>-->
+ <!--</dom-async-broker>-->
+
+ <!--<schema-service>-->
+ <!--<type xmlns:dom="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom">dom:schema-service</type>-->
+ <!--<name>yang-schema-service</name>-->
+ <!--</schema-service>-->
+ <!--<binding-mapping-service>-->
+ <!--<type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">binding:binding-dom-mapping-service</type>-->
+ <!--<name>runtime-mapping-singleton</name>-->
+ <!--</binding-mapping-service>-->
+ <!--</binding-forwarded-data-broker>-->
+ <!--</module>-->
+
+
<module>
<type xmlns:prefix="urn:honeycomb:params:xml:ns:yang:translate:utils">prefix:delegating-reader-registry</type>
<name>read-registry</name>
@@ -59,6 +107,17 @@
<type xmlns:prefix="urn:honeycomb:params:xml:ns:yang:translate:api">prefix:honeycomb-writer-registry</type>
<name>write-registry</name>
</writer-registry>
+
+
+ <!--<binding-mapping-service>-->
+ <!--<type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">binding:binding-dom-mapping-service</type>-->
+ <!--<name>runtime-mapping-singleton</name>-->
+ <!--</binding-mapping-service>-->
+
+ <binding-normalized-node-serializer>
+ <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">prefix:binding-dom-mapping-service</type>
+ <name>runtime-mapping-singleton</name>
+ </binding-normalized-node-serializer>
</module>
<module>
@@ -73,6 +132,24 @@
</modules>
<services xmlns="urn:opendaylight:params:xml:ns:yang:controller:config">
+
+ <!--<service>-->
+ <!--<type xmlns:dom="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom">dom:dom-async-data-broker</type>-->
+ <!--<instance>-->
+ <!--<name>netconf-inmemory-data-broker</name>-->
+ <!--<provider>/modules/module[type='dom-inmemory-data-broker'][name='netconf-inmemory-data-broker']</provider>-->
+ <!--</instance>-->
+ <!--</service>-->
+
+ <!--<service>-->
+ <!--<type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">binding:binding-async-data-broker</type>-->
+ <!--<instance>-->
+ <!--<name>honeycomb-binding-data-broker</name>-->
+ <!--<provider>/modules/module[type='binding-forwarded-data-broker'][name='honeycomb-binding-data-broker']</provider>-->
+ <!--</instance>-->
+ <!--</service>-->
+
+
<service>
<type xmlns:prefix="urn:honeycomb:params:xml:ns:yang:translate:api">prefix:honeycomb-reader-registry</type>
<instance>
@@ -104,6 +181,16 @@
<provider>/modules/module[type='v3po'][name='v3po-default']</provider>
</instance>
</service>
+
+
+ <!--<service>-->
+ <!--<type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">prefix:runtime-generated-mapping</type>-->
+ <!--<instance>-->
+ <!--<name>runtime-generated-mappingy</name>-->
+ <!--<provider>/modules/module[type='runtime-generated-mapping'][name='runtime-generated-mapping']</provider>-->
+ <!--</instance>-->
+ <!--</service>-->
+
</services>
</data>
</configuration>
diff --git a/v3po/impl/src/main/config/netconf-north-config.xml b/v3po/impl/src/main/config/netconf-north-config.xml
index fb89a17e6..fc913fcb1 100644
--- a/v3po/impl/src/main/config/netconf-north-config.xml
+++ b/v3po/impl/src/main/config/netconf-north-config.xml
@@ -62,6 +62,8 @@
<name>netconf-operational-store-service</name>
</operational-data-store>
</module>
+
+
<module>
<type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">prefix:binding-forwarded-data-broker</type>
<name>netconf-binding-data-broker</name>
diff --git a/v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/V3poProvider.java b/v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/V3poProvider.java
index 973d34585..d07c0ffca 100644
--- a/v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/V3poProvider.java
+++ b/v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/V3poProvider.java
@@ -56,6 +56,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.Vpp;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.VppBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.VxlanTunnel;
+import org.opendaylight.yangtools.binding.data.codec.api.BindingNormalizedNodeSerializer;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.openvpp.vppjapi.vppApi;
import org.openvpp.vppjapi.vppInterfaceDetails;
@@ -67,6 +68,7 @@ public class V3poProvider implements BindingAwareProvider, AutoCloseable, Broker
private static final Logger LOG = LoggerFactory.getLogger(V3poProvider.class);
private final Broker domBroker;
+ private final BindingNormalizedNodeSerializer serializer;
private RpcRegistration<V3poService> v3poService;
private VppIetfInterfaceListener vppInterfaceListener;
private VppBridgeDomainListener vppBridgeDomainListener;
@@ -77,13 +79,15 @@ public class V3poProvider implements BindingAwareProvider, AutoCloseable, Broker
VppPollOperDataImpl vppPollOperData;
private VppDataBrokerInitializationProvider vppDataBrokerInitializationProvider;
- public V3poProvider(@Nonnull final Broker domBroker, final vppApi vppJapiDependency,
- final ReaderRegistry readerRegistry,
- final WriterRegistry writerRegistry) {
- api = vppJapiDependency;
- this.readerRegistry = readerRegistry;
- this.writerRegistry = writerRegistry;
+ public V3poProvider(@Nonnull final Broker domBroker, final vppApi vppJapi,
+ @Nonnull final ReaderRegistry readerRegistry,
+ @Nonnull final WriterRegistry writerRegistry,
+ @Nonnull final BindingNormalizedNodeSerializer serializer) {
+ api = vppJapi;
+ this.readerRegistry = Preconditions.checkNotNull(readerRegistry, "readerRegistry should not be null");
+ this.writerRegistry = Preconditions.checkNotNull(writerRegistry, "writerRegistry should not be null");
this.domBroker = Preconditions.checkNotNull(domBroker, "domBroker should not be null");
+ this.serializer = Preconditions.checkNotNull(serializer, "serializer should not be null");
}
private void initializeVppConfig() {
@@ -194,7 +198,7 @@ public class V3poProvider implements BindingAwareProvider, AutoCloseable, Broker
startOperationalUpdateTimer();
// TODO make configurable:
- vppDataBrokerInitializationProvider = new VppDataBrokerInitializationProvider(db, readerRegistry, writerRegistry);
+ vppDataBrokerInitializationProvider = new VppDataBrokerInitializationProvider(db, readerRegistry, writerRegistry, serializer);
// TODO pull the registration into Module
domBroker.registerProvider(vppDataBrokerInitializationProvider);
}
diff --git a/v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/VppDataBrokerInitializationProvider.java b/v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/VppDataBrokerInitializationProvider.java
index 58195ba3f..b0ee447ba 100644
--- a/v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/VppDataBrokerInitializationProvider.java
+++ b/v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/VppDataBrokerInitializationProvider.java
@@ -26,13 +26,18 @@ import com.google.common.util.concurrent.ListenableFuture;
import io.fd.honeycomb.v3po.data.ModifiableDataTree;
import io.fd.honeycomb.v3po.data.ReadableDataTree;
import io.fd.honeycomb.v3po.data.impl.ConfigDataTree;
-import io.fd.honeycomb.v3po.data.impl.OperationalDataTree;
import io.fd.honeycomb.v3po.data.impl.DataBroker;
+import io.fd.honeycomb.v3po.data.impl.OperationalDataTree;
+import io.fd.honeycomb.v3po.translate.Context;
+import io.fd.honeycomb.v3po.translate.TranslationException;
+import io.fd.honeycomb.v3po.translate.read.ReadContext;
import io.fd.honeycomb.v3po.translate.read.ReaderRegistry;
import io.fd.honeycomb.v3po.translate.write.WriterRegistry;
+import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
-import javassist.ClassPool;
+import java.util.List;
+import java.util.Map;
import javax.annotation.Nonnull;
import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction;
import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
@@ -47,9 +52,12 @@ import org.opendaylight.controller.md.sal.dom.api.DOMMountPointService;
import org.opendaylight.controller.sal.core.api.Broker;
import org.opendaylight.controller.sal.core.api.Provider;
import org.opendaylight.controller.sal.core.api.model.SchemaService;
-import org.opendaylight.mdsal.binding.dom.codec.api.BindingNormalizedNodeSerializer;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.Vpp;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.VppBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.VppState;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.vpp.bridge.domains.BridgeDomainKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.vpp.state.BridgeDomains;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.vpp.state.bridge.domains.BridgeDomain;
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NetworkTopology;
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId;
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.TopologyId;
@@ -58,18 +66,16 @@ import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node;
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeBuilder;
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeKey;
-import org.opendaylight.yangtools.binding.data.codec.gen.impl.DataObjectSerializerGenerator;
-import org.opendaylight.yangtools.binding.data.codec.gen.impl.StreamWriterGenerator;
-import org.opendaylight.yangtools.binding.data.codec.impl.BindingNormalizedNodeCodecRegistry;
+import org.opendaylight.yangtools.binding.data.codec.api.BindingNormalizedNodeSerializer;
import org.opendaylight.yangtools.concepts.ObjectRegistration;
-import org.opendaylight.yangtools.sal.binding.generator.impl.GeneratedClassLoadingStrategy;
-import org.opendaylight.yangtools.sal.binding.generator.util.BindingRuntimeContext;
-import org.opendaylight.yangtools.sal.binding.generator.util.JavassistUtils;
+import org.opendaylight.yangtools.yang.binding.DataObject;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTree;
+import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeModification;
+import org.opendaylight.yangtools.yang.data.api.schema.tree.DataValidationFailedException;
import org.opendaylight.yangtools.yang.data.api.schema.tree.TreeType;
import org.opendaylight.yangtools.yang.data.impl.schema.tree.InMemoryDataTreeFactory;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
@@ -90,15 +96,19 @@ public final class VppDataBrokerInitializationProvider implements Provider, Auto
private final ReaderRegistry readerRegistry;
private final InstanceIdentifier<Node> mountPointPath;
private final WriterRegistry writerRegistry;
+ private final BindingNormalizedNodeSerializer serializer;
private ObjectRegistration<DOMMountPoint> mountPointRegistration;
private DOMDataBroker broker;
- public VppDataBrokerInitializationProvider(@Nonnull final org.opendaylight.controller.md.sal.binding.api.DataBroker bindingBroker,
- final ReaderRegistry readerRegistry,
- final WriterRegistry writerRegistry) {
+ public VppDataBrokerInitializationProvider(
+ @Nonnull final org.opendaylight.controller.md.sal.binding.api.DataBroker bindingBroker,
+ final ReaderRegistry readerRegistry,
+ final WriterRegistry writerRegistry,
+ final BindingNormalizedNodeSerializer serializer) {
this.bindingBroker = checkNotNull(bindingBroker, "bindingBroker should not be null");
this.readerRegistry = checkNotNull(readerRegistry, "readerRegistry should not be null");
this.writerRegistry = checkNotNull(writerRegistry, "writerRegistry should not be null");
+ this.serializer = checkNotNull(serializer, "serializer should not be null");
this.mountPointPath = getMountPointPath();
}
@@ -120,7 +130,7 @@ public final class VppDataBrokerInitializationProvider implements Provider, Auto
final SchemaService schemaService = providerSession.getService(SchemaService.class);
final SchemaContext globalContext = schemaService.getGlobalContext();
- final BindingNormalizedNodeSerializer serializer = initSerializer(globalContext);
+ // final BindingNormalizedNodeSerializer serializer = initSerializer(globalContext);
final YangInstanceIdentifier path = serializer.toYangInstanceIdentifier(mountPointPath);
final DOMMountPointService.DOMMountPointBuilder mountPointBuilder = mountPointService.createMountPoint(path);
@@ -158,43 +168,106 @@ public final class VppDataBrokerInitializationProvider implements Provider, Auto
}
}
- private BindingNormalizedNodeSerializer initSerializer(final SchemaContext globalContext) {
- final JavassistUtils utils = JavassistUtils.forClassPool(ClassPool.getDefault());
- // TODO this produces ClassNotFoundException
- //final GeneratedClassLoadingStrategy loading = GeneratedClassLoadingStrategy.getTCCLClassLoadingStrategy();
-
- // FIXME get global class loader instance
- final GeneratedClassLoadingStrategy loadingStrategy =
- new GeneratedClassLoadingStrategy() {
- @Override
- public Class<?> loadClass(final String fullyQualifiedName)
- throws ClassNotFoundException {
- return Class.forName(fullyQualifiedName);
- }
- };
- final DataObjectSerializerGenerator generator = StreamWriterGenerator.create(utils);
-
- // TODO make configurable:
- final BindingNormalizedNodeCodecRegistry serializer = new BindingNormalizedNodeCodecRegistry(generator);
- final BindingRuntimeContext context = BindingRuntimeContext.create(loadingStrategy, globalContext);
- serializer.onBindingRuntimeContextUpdated(context);
- return serializer;
- }
-
private DOMDataBroker initVppDataBroker(final SchemaContext globalContext,
final BindingNormalizedNodeSerializer serializer) {
- final ReadableDataTree operationalData =
+ final ReadableDataTree operationalDataTree =
new OperationalDataTree(serializer, globalContext, readerRegistry); // TODO make configurable
final DataTree dataTree =
InMemoryDataTreeFactory.getInstance().create(TreeType.CONFIGURATION); // TODO make configurable
dataTree.setSchemaContext(globalContext);
- final ModifiableDataTree configDataProxy =
+ final ModifiableDataTree configDataTree =
new ConfigDataTree(serializer, dataTree, writerRegistry); // TODO make configurable
- return new DataBroker(operationalData, configDataProxy);
+
+ // init operational data tree before data broker is initialized
+
+ try {
+ initConfig(serializer, configDataTree);
+ } catch (Exception e) {
+ LOG.warn("Failed to initialize config", e);
+ }
+
+ return new DataBroker(operationalDataTree, configDataTree);
}
+ private void initConfig(final BindingNormalizedNodeSerializer serializer, final ModifiableDataTree configDataTree)
+ throws TranslationException, DataValidationFailedException {
+ LOG.info("Config initialization");
+
+ final Optional<? extends DataObject> data = readerRegistry.read(InstanceIdentifier.create(VppState.class), new ReadContextImpl());
+ LOG.info("Config initialization data={}", data);
+
+ if (data.isPresent()) {
+ // conversion
+ VppState vppOperationalData = (VppState) data.get();
+ final Vpp vppConfigData = convert(vppOperationalData);
+
+ final Map.Entry<YangInstanceIdentifier, NormalizedNode<?, ?>> normalizedData =
+ serializer.toNormalizedNode(InstanceIdentifier.create(Vpp.class), vppConfigData);
+
+ final DataTreeModification modification = configDataTree.takeSnapshot().newModification();
+ final YangInstanceIdentifier biPath = normalizedData.getKey();
+ final NormalizedNode<?, ?> biData = normalizedData.getValue();
+ LOG.info("Config initialization biPath={}, biData={}", biPath, biData);
+ modification.write(biPath, biData);
+ modification.ready();
+
+ LOG.info("Config writing modification ...");
+ configDataTree.modify(modification); // TODO do not write to VPP
+ LOG.info("Config writing modification written successfully.");
+ } else {
+ LOG.info("Data is not present");
+ }
+ }
+
+ private Vpp convert(final VppState vppState) {
+ final BridgeDomains bridgeDomains = vppState.getBridgeDomains();
+ final List<BridgeDomain> bridgeDomainList = bridgeDomains.getBridgeDomain();
+
+ VppBuilder vppBuilder = new VppBuilder();
+ org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.vpp.BridgeDomainsBuilder bdsBuilder = new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.vpp.BridgeDomainsBuilder();
+ final List<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.vpp.bridge.domains.BridgeDomain>
+ listOfBDs = new ArrayList<>();
+
+ // TODO use reflexions
+ for (BridgeDomain bd : bridgeDomainList) {
+ org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.vpp.bridge.domains.BridgeDomainBuilder bdBuilder = new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.vpp.bridge.domains.BridgeDomainBuilder();
+ bdBuilder.setLearn(bd.isLearn());
+ bdBuilder.setUnknownUnicastFlood(bd.isUnknownUnicastFlood());
+ bdBuilder.setArpTermination(bd.isArpTermination());
+ bdBuilder.setFlood(bd.isFlood());
+ bdBuilder.setForward(bd.isForward());
+ bdBuilder.setKey(new BridgeDomainKey(bd.getKey().getName()));
+ // TODO bdBuilder.setL2Fib(bd.getL2Fib());
+ bdBuilder.setName(bd.getName());
+ listOfBDs.add(bdBuilder.build());
+ }
+
+ bdsBuilder.setBridgeDomain(listOfBDs);
+ vppBuilder.setBridgeDomains(bdsBuilder.build());
+ return vppBuilder.build();
+ }
+
+
+ // TODO move to utility module
+ private static final class ReadContextImpl implements ReadContext {
+ public final Context ctx = new Context();
+
+ @Nonnull
+ @Override
+ public Context getContext() {
+ return ctx;
+ }
+
+ @Override
+ public void close() {
+ // Make sure to clear the storage in case some customizer stored it to prevent memory leaks
+ ctx.close();
+ }
+ }
+
+
/**
* Writes placeholder data into MD-SAL's global datastore to indicate the presence of VPP mountpoint.
*/
diff --git a/v3po/impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/v3po/impl/rev141210/V3poModule.java b/v3po/impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/v3po/impl/rev141210/V3poModule.java
index 3b77418ad..406525c19 100644
--- a/v3po/impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/v3po/impl/rev141210/V3poModule.java
+++ b/v3po/impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/v3po/impl/rev141210/V3poModule.java
@@ -30,6 +30,7 @@ import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.vpp.BridgeDomains;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.vpp.bridge.domains.BridgeDomain;
+import org.opendaylight.yangtools.binding.data.codec.api.BindingNormalizedNodeSerializer;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
@@ -61,7 +62,12 @@ public class V3poModule extends
final Broker domBroker = getDomBrokerDependency();
domBroker.registerProvider(new InitializationProvider());
- final V3poProvider provider = new V3poProvider(domBroker, getVppJapiDependency(), readerRegistry, writerRegistry);
+
+ final BindingNormalizedNodeSerializer serializer =
+ getBindingNormalizedNodeSerializerDependency();
+
+ final V3poProvider provider =
+ new V3poProvider(domBroker, getVppJapiDependency(), readerRegistry, writerRegistry, serializer);
getBrokerDependency().registerProvider(provider);
return provider;
}
diff --git a/v3po/impl/src/main/yang/v3po-impl.yang b/v3po/impl/src/main/yang/v3po-impl.yang
index 32696125b..589148f28 100644
--- a/v3po/impl/src/main/yang/v3po-impl.yang
+++ b/v3po/impl/src/main/yang/v3po-impl.yang
@@ -70,6 +70,16 @@ module v3po-impl {
}
}
}
+
+ container binding-normalized-node-serializer {
+ uses config:service-ref {
+ refine type {
+ mandatory true;
+ config:required-identity md-sal-binding:binding-normalized-node-serializer;
+ }
+ }
+ }
+
}
}
diff --git a/v3po/impl/src/test/java/io/fd/honeycomb/v3po/impl/data/VppDataBrokerInitializationProviderTest.java b/v3po/impl/src/test/java/io/fd/honeycomb/v3po/impl/data/VppDataBrokerInitializationProviderTest.java
index d8628f2bf..eb2349fb2 100644
--- a/v3po/impl/src/test/java/io/fd/honeycomb/v3po/impl/data/VppDataBrokerInitializationProviderTest.java
+++ b/v3po/impl/src/test/java/io/fd/honeycomb/v3po/impl/data/VppDataBrokerInitializationProviderTest.java
@@ -36,6 +36,7 @@ import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
+import org.opendaylight.yangtools.binding.data.codec.api.BindingNormalizedNodeSerializer;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
public class VppDataBrokerInitializationProviderTest {
@@ -48,6 +49,8 @@ public class VppDataBrokerInitializationProviderTest {
private ReaderRegistry readerRegistry;
@Mock
private WriterRegistry writerRegistry;
+ @Mock
+ private BindingNormalizedNodeSerializer serializer;
private VppDataBrokerInitializationProvider provider;
@@ -56,7 +59,7 @@ public class VppDataBrokerInitializationProviderTest {
public void setUp() throws Exception {
initMocks(this);
doReturn(writeTx).when(bindingBroker).newWriteOnlyTransaction();
- provider = new VppDataBrokerInitializationProvider(bindingBroker, readerRegistry, writerRegistry);
+ provider = new VppDataBrokerInitializationProvider(bindingBroker, readerRegistry, writerRegistry, serializer);
}
@Test
diff --git a/v3po/impl/src/test/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/v3po/impl/rev141210/V3poModuleTest.java b/v3po/impl/src/test/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/v3po/impl/rev141210/V3poModuleTest.java
index 74d36bb9d..6eef488cc 100644
--- a/v3po/impl/src/test/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/v3po/impl/rev141210/V3poModuleTest.java
+++ b/v3po/impl/src/test/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/v3po/impl/rev141210/V3poModuleTest.java
@@ -22,12 +22,15 @@ import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import io.fd.honeycomb.v3po.impl.V3poProvider;
+import io.fd.honeycomb.v3po.translate.read.ReaderRegistry;
+import io.fd.honeycomb.v3po.translate.write.WriterRegistry;
import javax.management.ObjectName;
import org.junit.Test;
import org.opendaylight.controller.config.api.DependencyResolver;
import org.opendaylight.controller.config.api.JmxAttribute;
import org.opendaylight.controller.config.api.ModuleIdentifier;
import org.opendaylight.controller.sal.binding.api.BindingAwareBroker;
+import org.opendaylight.yangtools.binding.data.codec.api.BindingNormalizedNodeSerializer;
public class V3poModuleTest {
@Test
@@ -50,6 +53,12 @@ public class V3poModuleTest {
final org.opendaylight.controller.sal.core.api.Broker domBroker = mock(org.opendaylight.controller.sal.core.api.Broker.class);
when(dependencyResolver.resolveInstance(eq(org.opendaylight.controller.sal.core.api.Broker.class), any(ObjectName.class), any(JmxAttribute.class)))
.thenReturn(domBroker);
+ when(dependencyResolver.resolveInstance(eq(ReaderRegistry.class), any(ObjectName.class), any(JmxAttribute.class)))
+ .thenReturn(mock(ReaderRegistry.class));
+ when(dependencyResolver.resolveInstance(eq(WriterRegistry.class), any(ObjectName.class), any(JmxAttribute.class)))
+ .thenReturn(mock(WriterRegistry.class));
+ when(dependencyResolver.resolveInstance(eq(BindingNormalizedNodeSerializer.class), any(ObjectName.class), any(JmxAttribute.class)))
+ .thenReturn(mock(BindingNormalizedNodeSerializer.class));
// create instance of module with injected mocks
V3poModule module = new V3poModule(mock(ModuleIdentifier.class), dependencyResolver);