summaryrefslogtreecommitdiffstats
path: root/v3po/impl/src/main/java
diff options
context:
space:
mode:
authorMaros Marsalek <mmarsale@cisco.com>2016-02-18 17:02:26 +0100
committerMaros Marsalek <mmarsale@cisco.com>2016-02-18 17:30:40 +0100
commitcf37a5315e7d1961eabf6c4c5b91963b427ca66a (patch)
treefbcf90d1bbaf2b0c36c86095c12db00dd62544f3 /v3po/impl/src/main/java
parent7ed7491932e1181f6781883b5da1aabe799a87bb (diff)
Initialize v3po data structures
This is a workaround to avoid posible DataTree exception when submitting new interface configuration without pre-existing day0 configuration. Applies for all list nodes and a proper fix will follow in ODL. Change-Id: I6ee6e7ae189542d5ae2ad742f431b88745c42c4d Signed-off-by: Maros Marsalek <mmarsale@cisco.com>
Diffstat (limited to 'v3po/impl/src/main/java')
-rw-r--r--v3po/impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/v3po/impl/rev141210/V3poModule.java59
1 files changed, 59 insertions, 0 deletions
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 5a5fd1147..0805452c5 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
@@ -16,6 +16,21 @@
package org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.impl.rev141210;
import io.fd.honeycomb.v3po.impl.V3poProvider;
+import java.util.Collection;
+import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
+import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker;
+import org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction;
+import org.opendaylight.controller.sal.core.api.Broker;
+import org.opendaylight.controller.sal.core.api.Provider;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.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;
+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.yang.common.QName;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
+import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
public class V3poModule extends org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.impl.rev141210.AbstractV3poModule {
public V3poModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
@@ -33,9 +48,53 @@ public class V3poModule extends org.opendaylight.yang.gen.v1.urn.opendaylight.pa
@Override
public java.lang.AutoCloseable createInstance() {
+ getDomBrokerDependency().registerProvider(new InitializationProvider());
+
V3poProvider provider = new V3poProvider();
getBrokerDependency().registerProvider(provider);
return provider;
}
+ /**
+ * Writes list parents as a workaround for ODL issue
+ * TODO remove (also remove from yang model and cfg) and fix ODL bug-5382
+ */
+ private class InitializationProvider implements Provider {
+ @Override
+ public void onSessionInitiated(final Broker.ProviderSession providerSession) {
+ final DOMDataBroker service = providerSession.getService(DOMDataBroker.class);
+ final DOMDataWriteTransaction domDataWriteTransaction = service.newWriteOnlyTransaction();
+
+ // Initialize interfaces list
+ YangInstanceIdentifier.NodeIdentifier nodeId = getNodeId(Interfaces.QNAME);
+ YangInstanceIdentifier interfacesYid = YangInstanceIdentifier.create(nodeId);
+ domDataWriteTransaction.merge(LogicalDatastoreType.CONFIGURATION,
+ interfacesYid, Builders.containerBuilder().withNodeIdentifier(nodeId)
+ .withChild(Builders.mapBuilder().withNodeIdentifier(getNodeId(Interface.QNAME)).build())
+ .build());
+
+ // Initialize bridge domains list
+ nodeId = getNodeId(BridgeDomains.QNAME);
+ interfacesYid = YangInstanceIdentifier.create(getNodeId(Vpp.QNAME), nodeId);
+ domDataWriteTransaction.merge(LogicalDatastoreType.CONFIGURATION,
+ interfacesYid, Builders.containerBuilder().withNodeIdentifier(nodeId)
+ .withChild(Builders.mapBuilder().withNodeIdentifier(getNodeId(BridgeDomain.QNAME)).build())
+ .build());
+
+ try {
+ domDataWriteTransaction.submit().checkedGet();
+ } catch (TransactionCommitFailedException e) {
+ throw new IllegalStateException("Unable to initialize parent data structures", e);
+ }
+ }
+
+ private YangInstanceIdentifier.NodeIdentifier getNodeId(final QName qname) {
+ return new YangInstanceIdentifier.NodeIdentifier(qname);
+ }
+
+ @Override
+ public Collection<ProviderFunctionality> getProviderFunctionality() {
+ return null;
+ }
+ }
}