summaryrefslogtreecommitdiffstats
path: root/v3po
diff options
context:
space:
mode:
Diffstat (limited to 'v3po')
-rw-r--r--v3po/data-api/src/main/yang/data-api.yang37
-rw-r--r--v3po/data-impl/src/main/java/io/fd/honeycomb/v3po/data/impl/ConfigDataTree.java2
-rw-r--r--v3po/data-impl/src/main/java/io/fd/honeycomb/v3po/data/impl/DataBroker.java25
-rw-r--r--v3po/data-impl/src/main/java/io/fd/honeycomb/v3po/data/impl/DataTreeUtils.java2
-rw-r--r--v3po/data-impl/src/main/java/io/fd/honeycomb/v3po/data/impl/OperationalDataTree.java4
-rw-r--r--v3po/data-impl/src/main/yang/data-impl.yang61
-rw-r--r--v3po/data-impl/src/test/java/io/fd/honeycomb/v3po/data/impl/OperationalDataTreeTest.java2
-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
-rw-r--r--v3po/translate-utils/src/main/java/io/fd/honeycomb/v3po/translate/util/write/TransactionWriteContext.java4
-rw-r--r--v3po/translate-utils/src/test/java/io/fd/honeycomb/v3po/translate/impl/write/util/TransactionWriteContextTest.java2
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/vppstate/BridgeDomainCustomizer.java31
-rw-r--r--v3po/vpp-cfg-init/pom.xml5
-rw-r--r--v3po/vpp-cfg-init/src/main/java/io/fd/honeycomb/v3po/vpp/data/init/InitializerRegistryImpl.java2
20 files changed, 398 insertions, 69 deletions
diff --git a/v3po/data-api/src/main/yang/data-api.yang b/v3po/data-api/src/main/yang/data-api.yang
new file mode 100644
index 000000000..28d969378
--- /dev/null
+++ b/v3po/data-api/src/main/yang/data-api.yang
@@ -0,0 +1,37 @@
+module translate-api {
+ yang-version 1;
+ namespace "urn:honeycomb:params:xml:ns:yang:translate:api";
+ prefix "tapi";
+
+ import config { prefix config; revision-date 2013-04-05; }
+
+ description
+ "This module contains the base YANG definitions for
+ readers/writers plugged into a honeycomb";
+
+ revision "2016-04-06" {
+ description
+ "Initial revision.";
+ }
+
+ identity honeycomb-reader {
+ base "config:service-type";
+ config:java-class io.fd.honeycomb.v3po.translate.read.Reader;
+ }
+
+ identity honeycomb-reader-registry {
+ base "config:service-type";
+ config:java-class io.fd.honeycomb.v3po.translate.read.ReaderRegistry;
+ }
+
+ identity honeycomb-writer {
+ base "config:service-type";
+ config:java-class io.fd.honeycomb.v3po.translate.write.Writer;
+ }
+
+ identity honeycomb-writer-registry {
+ base "config:service-type";
+ config:java-class io.fd.honeycomb.v3po.translate.write.WriterRegistry;
+ }
+
+} \ No newline at end of file
diff --git a/v3po/data-impl/src/main/java/io/fd/honeycomb/v3po/data/impl/ConfigDataTree.java b/v3po/data-impl/src/main/java/io/fd/honeycomb/v3po/data/impl/ConfigDataTree.java
index 84a1d27e3..f636e6708 100644
--- a/v3po/data-impl/src/main/java/io/fd/honeycomb/v3po/data/impl/ConfigDataTree.java
+++ b/v3po/data-impl/src/main/java/io/fd/honeycomb/v3po/data/impl/ConfigDataTree.java
@@ -34,7 +34,7 @@ import java.util.Map;
import javax.annotation.Nonnull;
import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
import org.opendaylight.controller.md.sal.dom.api.DOMDataReadOnlyTransaction;
-import org.opendaylight.mdsal.binding.dom.codec.api.BindingNormalizedNodeSerializer;
+import org.opendaylight.yangtools.binding.data.codec.api.BindingNormalizedNodeSerializer;
import org.opendaylight.yangtools.yang.binding.DataObject;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
diff --git a/v3po/data-impl/src/main/java/io/fd/honeycomb/v3po/data/impl/DataBroker.java b/v3po/data-impl/src/main/java/io/fd/honeycomb/v3po/data/impl/DataBroker.java
index 7b4d93baa..47b27f707 100644
--- a/v3po/data-impl/src/main/java/io/fd/honeycomb/v3po/data/impl/DataBroker.java
+++ b/v3po/data-impl/src/main/java/io/fd/honeycomb/v3po/data/impl/DataBroker.java
@@ -17,9 +17,9 @@
package io.fd.honeycomb.v3po.data.impl;
import com.google.common.base.Preconditions;
-import io.fd.honeycomb.v3po.data.ReadableDataTree;
-import io.fd.honeycomb.v3po.data.ModifiableDataTree;
import io.fd.honeycomb.v3po.data.DataTreeSnapshot;
+import io.fd.honeycomb.v3po.data.ModifiableDataTree;
+import io.fd.honeycomb.v3po.data.ReadableDataTree;
import java.util.Collections;
import java.util.Map;
import javax.annotation.Nonnull;
@@ -37,36 +37,37 @@ import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
/**
- * Data Broker which provides data transaction functionality for YANG capable data provider
- * using {@link NormalizedNode} data format.
+ * Data Broker which provides data transaction functionality for YANG capable data provider using {@link NormalizedNode}
+ * data format.
*/
public class DataBroker implements DOMDataBroker {
- private final ReadableDataTree operationalData;
+ private final ReadableDataTree operationalDataTree;
private final ModifiableDataTree configDataTree;
/**
* Creates DataBroker instance.
*
- * @param operationalData operational data
- * @param configDataTree configuration data
+ * @param operationalDataTree operational data
+ * @param configDataTree configuration data
*/
- public DataBroker(@Nonnull final ReadableDataTree operationalData,
+ public DataBroker(@Nonnull final ReadableDataTree operationalDataTree,
@Nonnull final ModifiableDataTree configDataTree) {
- this.operationalData = Preconditions.checkNotNull(operationalData, "operationalData should not be null");
- this.configDataTree = Preconditions.checkNotNull(configDataTree, "configDataProxy should not be null");
+ this.operationalDataTree =
+ Preconditions.checkNotNull(operationalDataTree, "operationalDataTree should not be null");
+ this.configDataTree = Preconditions.checkNotNull(configDataTree, "configDataTree should not be null");
}
@Override
public DOMDataReadOnlyTransaction newReadOnlyTransaction() {
- return new ReadOnlyTransaction(operationalData, configDataTree.takeSnapshot());
+ return new ReadOnlyTransaction(operationalDataTree, configDataTree.takeSnapshot());
}
@Override
public DOMDataReadWriteTransaction newReadWriteTransaction() {
// todo use the same snapshot
final DataTreeSnapshot configSnapshot = configDataTree.takeSnapshot();
- final DOMDataReadOnlyTransaction readOnlyTx = new ReadOnlyTransaction(operationalData, configSnapshot);
+ final DOMDataReadOnlyTransaction readOnlyTx = new ReadOnlyTransaction(operationalDataTree, configSnapshot);
final DOMDataWriteTransaction writeOnlyTx = new WriteTransaction(configDataTree, configSnapshot);
return new ReadWriteTransaction(readOnlyTx, writeOnlyTx);
}
diff --git a/v3po/data-impl/src/main/java/io/fd/honeycomb/v3po/data/impl/DataTreeUtils.java b/v3po/data-impl/src/main/java/io/fd/honeycomb/v3po/data/impl/DataTreeUtils.java
index 39e841f9a..de83a198b 100644
--- a/v3po/data-impl/src/main/java/io/fd/honeycomb/v3po/data/impl/DataTreeUtils.java
+++ b/v3po/data-impl/src/main/java/io/fd/honeycomb/v3po/data/impl/DataTreeUtils.java
@@ -21,7 +21,7 @@ import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import javax.annotation.Nonnull;
-import org.opendaylight.mdsal.binding.dom.codec.api.BindingNormalizedNodeSerializer;
+import org.opendaylight.yangtools.binding.data.codec.api.BindingNormalizedNodeSerializer;
import org.opendaylight.yangtools.yang.binding.DataObject;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
diff --git a/v3po/data-impl/src/main/java/io/fd/honeycomb/v3po/data/impl/OperationalDataTree.java b/v3po/data-impl/src/main/java/io/fd/honeycomb/v3po/data/impl/OperationalDataTree.java
index 21672b48b..de737c729 100644
--- a/v3po/data-impl/src/main/java/io/fd/honeycomb/v3po/data/impl/OperationalDataTree.java
+++ b/v3po/data-impl/src/main/java/io/fd/honeycomb/v3po/data/impl/OperationalDataTree.java
@@ -35,7 +35,7 @@ import java.util.Collection;
import java.util.Map;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
-import org.opendaylight.mdsal.binding.dom.codec.api.BindingNormalizedNodeSerializer;
+import org.opendaylight.yangtools.binding.data.codec.api.BindingNormalizedNodeSerializer;
import org.opendaylight.yangtools.yang.binding.DataObject;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
@@ -75,7 +75,7 @@ public final class OperationalDataTree implements ReadableDataTree {
*/
public OperationalDataTree(@Nonnull BindingNormalizedNodeSerializer serializer,
@Nonnull final SchemaContext globalContext, @Nonnull ReaderRegistry readerRegistry) {
- this.globalContext = checkNotNull(globalContext, "serializer should not be null");
+ this.globalContext = checkNotNull(globalContext, "globalContext should not be null");
this.serializer = checkNotNull(serializer, "serializer should not be null");
this.readerRegistry = checkNotNull(readerRegistry, "reader should not be null");
}
diff --git a/v3po/data-impl/src/main/yang/data-impl.yang b/v3po/data-impl/src/main/yang/data-impl.yang
new file mode 100644
index 000000000..093e1725b
--- /dev/null
+++ b/v3po/data-impl/src/main/yang/data-impl.yang
@@ -0,0 +1,61 @@
+module translate-utils {
+ yang-version 1;
+ namespace "urn:honeycomb:params:xml:ns:yang:translate:utils";
+ prefix "tutils";
+
+ import config { prefix config; revision-date 2013-04-05; }
+ import translate-api { prefix tapi; revision-date 2016-04-06; }
+
+ description
+ "This module contains translation layer utilities";
+
+ revision "2016-04-06" {
+ description
+ "Initial revision.";
+ }
+
+ identity delegating-reader-registry {
+ base config:module-type;
+ config:provided-service tapi:honeycomb-reader-registry;
+ config:java-name-prefix DelegatingReaderRegistry;
+ }
+
+ augment "/config:modules/config:module/config:configuration" {
+ case delegating-reader-registry {
+ when "/config:modules/config:module/config:type = 'delegating-reader-registry'";
+
+ list root-readers {
+ uses config:service-ref {
+ refine type {
+ mandatory true;
+ config:required-identity tapi:honeycomb-reader;
+ }
+ }
+ }
+
+ }
+ }
+
+ identity delegating-writer-registry {
+ base config:module-type;
+ config:provided-service tapi:honeycomb-writer-registry;
+ config:java-name-prefix DelegatingWriterRegistry;
+ }
+
+ augment "/config:modules/config:module/config:configuration" {
+ case delegating-writer-registry {
+ when "/config:modules/config:module/config:type = 'delegating-writer-registry'";
+
+ list root-writers {
+ uses config:service-ref {
+ refine type {
+ mandatory true;
+ config:required-identity tapi:honeycomb-writer;
+ }
+ }
+ }
+
+ }
+ }
+
+} \ No newline at end of file
diff --git a/v3po/data-impl/src/test/java/io/fd/honeycomb/v3po/data/impl/OperationalDataTreeTest.java b/v3po/data-impl/src/test/java/io/fd/honeycomb/v3po/data/impl/OperationalDataTreeTest.java
index f4c2f1e5b..fbd512915 100644
--- a/v3po/data-impl/src/test/java/io/fd/honeycomb/v3po/data/impl/OperationalDataTreeTest.java
+++ b/v3po/data-impl/src/test/java/io/fd/honeycomb/v3po/data/impl/OperationalDataTreeTest.java
@@ -41,7 +41,7 @@ import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
-import org.opendaylight.mdsal.binding.dom.codec.api.BindingNormalizedNodeSerializer;
+import org.opendaylight.yangtools.binding.data.codec.api.BindingNormalizedNodeSerializer;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.VppState;
import org.opendaylight.yangtools.yang.binding.DataObject;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
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);
diff --git a/v3po/translate-utils/src/main/java/io/fd/honeycomb/v3po/translate/util/write/TransactionWriteContext.java b/v3po/translate-utils/src/main/java/io/fd/honeycomb/v3po/translate/util/write/TransactionWriteContext.java
index 0bb68e3b2..37756d5b8 100644
--- a/v3po/translate-utils/src/main/java/io/fd/honeycomb/v3po/translate/util/write/TransactionWriteContext.java
+++ b/v3po/translate-utils/src/main/java/io/fd/honeycomb/v3po/translate/util/write/TransactionWriteContext.java
@@ -18,14 +18,14 @@ package io.fd.honeycomb.v3po.translate.util.write;
import com.google.common.base.Optional;
import com.google.common.util.concurrent.CheckedFuture;
-import io.fd.honeycomb.v3po.translate.write.WriteContext;
import io.fd.honeycomb.v3po.translate.Context;
+import io.fd.honeycomb.v3po.translate.write.WriteContext;
import java.util.Map;
import javax.annotation.Nonnull;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
import org.opendaylight.controller.md.sal.dom.api.DOMDataReadOnlyTransaction;
-import org.opendaylight.mdsal.binding.dom.codec.api.BindingNormalizedNodeSerializer;
+import org.opendaylight.yangtools.binding.data.codec.api.BindingNormalizedNodeSerializer;
import org.opendaylight.yangtools.yang.binding.DataObject;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
diff --git a/v3po/translate-utils/src/test/java/io/fd/honeycomb/v3po/translate/impl/write/util/TransactionWriteContextTest.java b/v3po/translate-utils/src/test/java/io/fd/honeycomb/v3po/translate/impl/write/util/TransactionWriteContextTest.java
index 5a8740b2d..03dc0c200 100644
--- a/v3po/translate-utils/src/test/java/io/fd/honeycomb/v3po/translate/impl/write/util/TransactionWriteContextTest.java
+++ b/v3po/translate-utils/src/test/java/io/fd/honeycomb/v3po/translate/impl/write/util/TransactionWriteContextTest.java
@@ -38,11 +38,11 @@ import org.mockito.Mock;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
import org.opendaylight.controller.md.sal.dom.api.DOMDataReadOnlyTransaction;
-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.VppState;
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.binding.DataObject;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/vppstate/BridgeDomainCustomizer.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/vppstate/BridgeDomainCustomizer.java
index 36e1da366..39f164e4b 100644
--- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/vppstate/BridgeDomainCustomizer.java
+++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/vppstate/BridgeDomainCustomizer.java
@@ -39,10 +39,14 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.openvpp.vppjapi.vppBridgeDomainDetails;
import org.openvpp.vppjapi.vppBridgeDomainInterfaceDetails;
import org.openvpp.vppjapi.vppL2Fib;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public final class BridgeDomainCustomizer extends VppApiCustomizer
implements ListReaderCustomizer<BridgeDomain, BridgeDomainKey, BridgeDomainBuilder> {
+ private static final Logger LOG = LoggerFactory.getLogger(BridgeDomainCustomizer.class);
+
public BridgeDomainCustomizer(@Nonnull final org.openvpp.vppjapi.vppApi vppApi) {
super(vppApi);
}
@@ -50,11 +54,18 @@ public final class BridgeDomainCustomizer extends VppApiCustomizer
@Override
public void readCurrentAttributes(@Nonnull final InstanceIdentifier<BridgeDomain> id,
@Nonnull final BridgeDomainBuilder builder, @Nonnull final Context context) {
+ LOG.debug("vppstate.BridgeDomainCustomizer.readCurrentAttributes: id={}, builderbuilder={}, context={}",
+ id, builder, context);
+
final BridgeDomainKey key = id.firstKeyOf(id.getTargetType());
// TODO find out if bd exists based on name and if not return
+ LOG.debug("vppstate.BridgeDomainCustomizer.readCurrentAttributes: key={}", key);
final int bdId = getVppApi().bridgeDomainIdFromName(key.getName());
+ LOG.debug("vppstate.BridgeDomainCustomizer.readCurrentAttributes: bdId={}", bdId);
+
final vppBridgeDomainDetails bridgeDomainDetails = getVppApi().getBridgeDomainDetails(bdId);
+ logBridgeDomainDetails(bridgeDomainDetails);
builder.setName(key.getName());
// builder.setName(bridgeDomainDetails.name);
@@ -83,6 +94,21 @@ public final class BridgeDomainCustomizer extends VppApiCustomizer
builder.setL2Fib(l2Fibs);
}
+ private void logBridgeDomainDetails(final vppBridgeDomainDetails bridgeDomainDetails) {
+ LOG.debug("bridgeDomainDetails={}", bridgeDomainDetails);
+ if (bridgeDomainDetails != null) {
+ LOG.debug("bridgeDomainDetails.arpTerm={}", bridgeDomainDetails.arpTerm);
+ LOG.debug("bridgeDomainDetails.bdId={}", bridgeDomainDetails.bdId);
+ LOG.debug("bridgeDomainDetails.bviInterfaceName={}", bridgeDomainDetails.bviInterfaceName);
+ LOG.debug("bridgeDomainDetails.flood={}", bridgeDomainDetails.flood);
+ LOG.debug("bridgeDomainDetails.forward={}", bridgeDomainDetails.forward);
+ LOG.debug("bridgeDomainDetails.learn={}", bridgeDomainDetails.learn);
+ LOG.debug("bridgeDomainDetails.name={}", bridgeDomainDetails.name);
+ LOG.debug("bridgeDomainDetails.uuFlood={}", bridgeDomainDetails.uuFlood);
+ }
+ }
+
+
private static String getMacAddress(byte[] mac) {
StringBuilder sb = new StringBuilder(18);
for (byte b : mac) {
@@ -116,13 +142,18 @@ public final class BridgeDomainCustomizer extends VppApiCustomizer
@Override
public List<BridgeDomainKey> getAllIds(@Nonnull final InstanceIdentifier<BridgeDomain> id, @Nonnull final Context context) {
final int[] bIds = getVppApi().bridgeDomainDump(-1);
+ LOG.debug("vppstate.BridgeDomainCustomizer.getAllIds: bIds.length={}", bIds.length);
final List<BridgeDomainKey> allIds = new ArrayList<>(bIds.length);
for (int bId : bIds) {
+ LOG.debug("vppstate.BridgeDomainCustomizer.getAllIds: bId={}", bId);
// FIXME this is highly inefficient having to dump all of the bridge domain details
// Use context to store already read information
// TODO Or just remove the getAllIds method and replace with a simple readAll
final vppBridgeDomainDetails bridgeDomainDetails = getVppApi().getBridgeDomainDetails(bId);
+ logBridgeDomainDetails(bridgeDomainDetails);
+
final String bName = bridgeDomainDetails.name;
+ LOG.debug("vppstate.BridgeDomainCustomizer.getAllIds: bName={}", bName);
allIds.add(new BridgeDomainKey(bName));
}
diff --git a/v3po/vpp-cfg-init/pom.xml b/v3po/vpp-cfg-init/pom.xml
index a0c2dcb89..002a1c8d7 100644
--- a/v3po/vpp-cfg-init/pom.xml
+++ b/v3po/vpp-cfg-init/pom.xml
@@ -39,6 +39,11 @@
<artifactId>translate-impl</artifactId>
<version>${project.version}</version>
</dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>data-api</artifactId>
+ <version>${project.version}</version>
+ </dependency>
</dependencies>
</project>
diff --git a/v3po/vpp-cfg-init/src/main/java/io/fd/honeycomb/v3po/vpp/data/init/InitializerRegistryImpl.java b/v3po/vpp-cfg-init/src/main/java/io/fd/honeycomb/v3po/vpp/data/init/InitializerRegistryImpl.java
index 0feada4cb..eaf86a633 100644
--- a/v3po/vpp-cfg-init/src/main/java/io/fd/honeycomb/v3po/vpp/data/init/InitializerRegistryImpl.java
+++ b/v3po/vpp-cfg-init/src/main/java/io/fd/honeycomb/v3po/vpp/data/init/InitializerRegistryImpl.java
@@ -42,7 +42,7 @@ public class InitializerRegistryImpl implements InitializerRegistry, AutoCloseab
@Override
public void close() throws Exception {
- LOG.debug("Initializer.close()");
+ LOG.info("Initializer.close()");
// TODO remove data
}