summaryrefslogtreecommitdiffstats
path: root/v3po/data-impl/src/main/java/io
diff options
context:
space:
mode:
authorMaros Marsalek <mmarsale@cisco.com>2016-04-12 16:19:31 +0200
committerMaros Marsalek <mmarsale@cisco.com>2016-04-13 08:19:15 +0200
commit152ec1037001b867890aaaffe8a9e38a85b501b2 (patch)
treed94ccb141cb2f83020253390d90a2578c67a9386 /v3po/data-impl/src/main/java/io
parentc4c4334ef4db37af07025523de4c2e2e25763599 (diff)
HONEYCOMB-8: Fix netconf monitoring operational data provisioning
Local storage for netconf monitoring was not wired with netconf northbound for vpp. Change-Id: I864614ffcbf7acf16eccc65ab58b9821b2682f93 Signed-off-by: Maros Marsalek <mmarsale@cisco.com>
Diffstat (limited to 'v3po/data-impl/src/main/java/io')
-rw-r--r--v3po/data-impl/src/main/java/io/fd/honeycomb/v3po/data/impl/OperationalDataTree.java43
1 files changed, 38 insertions, 5 deletions
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 de737c729..5d3b00646 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,6 +35,10 @@ import java.util.Collection;
import java.util.Map;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
+import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker;
+import org.opendaylight.controller.md.sal.dom.api.DOMDataReadOnlyTransaction;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.monitoring.rev101004.NetconfState;
import org.opendaylight.yangtools.binding.data.codec.api.BindingNormalizedNodeSerializer;
import org.opendaylight.yangtools.yang.binding.DataObject;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
@@ -64,17 +68,20 @@ public final class OperationalDataTree implements ReadableDataTree {
private final BindingNormalizedNodeSerializer serializer;
private final ReaderRegistry readerRegistry;
private final SchemaContext globalContext;
+ private final DOMDataBroker netconfMonitoringDomDataBrokerDependency;
/**
* Creates operational data tree instance.
- *
- * @param serializer service for serialization between Java Binding Data representation and NormalizedNode
+ * @param serializer service for serialization between Java Binding Data representation and NormalizedNode
* representation.
* @param globalContext service for obtaining top level context data from all yang modules.
* @param readerRegistry service responsible for translation between DataObjects and data provider.
+ * @param netconfMonitoringDomDataBrokerDependency
*/
public OperationalDataTree(@Nonnull BindingNormalizedNodeSerializer serializer,
- @Nonnull final SchemaContext globalContext, @Nonnull ReaderRegistry readerRegistry) {
+ @Nonnull final SchemaContext globalContext, @Nonnull ReaderRegistry readerRegistry,
+ final DOMDataBroker netconfMonitoringDomDataBrokerDependency) {
+ this.netconfMonitoringDomDataBrokerDependency = netconfMonitoringDomDataBrokerDependency;
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");
@@ -99,8 +106,14 @@ public final class OperationalDataTree implements ReadableDataTree {
}
private Optional<NormalizedNode<?, ?>> readNode(final YangInstanceIdentifier yangInstanceIdentifier,
- final ReadContext ctx)
- throws ReadFailedException {
+ final ReadContext ctx) throws ReadFailedException {
+
+ // FIXME workaround for: https://git.opendaylight.org/gerrit/#/c/37499/
+ if(yangInstanceIdentifier.getPathArguments().size() > 0 &&
+ yangInstanceIdentifier.getPathArguments().get(0).getNodeType().equals(NetconfState.QNAME)) {
+ return readFromNetconfDs(yangInstanceIdentifier);
+ }
+
LOG.debug("OperationalDataTree.readNode(), yangInstanceIdentifier={}", yangInstanceIdentifier);
final InstanceIdentifier<?> path = serializer.fromYangInstanceIdentifier(yangInstanceIdentifier);
checkNotNull(path, "Invalid instance identifier %s. Cannot create BA equivalent.", yangInstanceIdentifier);
@@ -117,6 +130,19 @@ public final class OperationalDataTree implements ReadableDataTree {
}
}
+ // FIXME workaround for: https://git.opendaylight.org/gerrit/#/c/37499/
+ private Optional<NormalizedNode<?, ?>> readFromNetconfDs(final YangInstanceIdentifier yangInstanceIdentifier)
+ throws ReadFailedException {
+ try(final DOMDataReadOnlyTransaction domDataReadOnlyTransaction =
+ netconfMonitoringDomDataBrokerDependency.newReadOnlyTransaction()) {
+ try {
+ return domDataReadOnlyTransaction.read(LogicalDatastoreType.OPERATIONAL, yangInstanceIdentifier).checkedGet();
+ } catch (org.opendaylight.controller.md.sal.common.api.data.ReadFailedException e) {
+ throw new ReadFailedException(InstanceIdentifier.create(NetconfState.class), e);
+ }
+ }
+ }
+
private Optional<NormalizedNode<?, ?>> readRoot(final ReadContext ctx) throws ReadFailedException {
LOG.debug("OperationalDataTree.readRoot()");
@@ -134,6 +160,13 @@ public final class OperationalDataTree implements ReadableDataTree {
dataNodeBuilder.withChild((DataContainerChild<?, ?>) node);
}
+ // FIXME workaround for: https://git.opendaylight.org/gerrit/#/c/37499/
+ final Optional<NormalizedNode<?, ?>> normalizedNodeOptional =
+ readFromNetconfDs(YangInstanceIdentifier.builder().node(NetconfState.QNAME).build());
+ if(normalizedNodeOptional.isPresent()) {
+ dataNodeBuilder.withChild((DataContainerChild<?, ?>) normalizedNodeOptional.get());
+ }
+
return Optional.<NormalizedNode<?, ?>>of(dataNodeBuilder.build());
}