From 3eaa42a454569639597eded0df4a181ca66f45d4 Mon Sep 17 00:00:00 2001 From: Ravi Pendurty Date: Mon, 31 Jan 2022 16:34:09 +0530 Subject: Enhance netconfnode-state-service bundle Add support for new capabilities and DOM functions Issue-ID: CCSDK-3576 Signed-off-by: Ravi Pendurty Change-Id: Ie7a4a4d5002dd846c4028457e19d00490f819a94 Signed-off-by: Ravi Pendurty --- .../impl/NetconfNodeStateServiceImpl.java | 11 +++++++++++ .../impl/access/NetconfAccessorImpl.java | 6 ++++++ .../impl/access/NetconfAccessorManager.java | 3 --- .../impl/access/NetconfCommunicatorManager.java | 1 + .../impl/access/dom/NetconfDomAccessorImpl.java | 23 ++++++++++++++++++++++ .../org/opendaylight/blueprint/impl-blueprint.xml | 3 +++ 6 files changed, 44 insertions(+), 3 deletions(-) (limited to 'sdnr/wt/netconfnode-state-service/provider/src') diff --git a/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/NetconfNodeStateServiceImpl.java b/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/NetconfNodeStateServiceImpl.java index d3752cdc4..f759971fb 100644 --- a/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/NetconfNodeStateServiceImpl.java +++ b/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/NetconfNodeStateServiceImpl.java @@ -58,6 +58,7 @@ import org.opendaylight.mdsal.binding.api.NotificationPublishService; import org.opendaylight.mdsal.binding.api.RpcProviderService; import org.opendaylight.mdsal.binding.dom.codec.api.BindingNormalizedNodeSerializer; import org.opendaylight.mdsal.common.api.LogicalDatastoreType; +import org.opendaylight.mdsal.dom.api.DOMDataBroker; import org.opendaylight.mdsal.dom.api.DOMMountPointService; import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceProvider; import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceRegistration; @@ -104,6 +105,7 @@ public class NetconfNodeStateServiceImpl // -- OSGi services, provided private DataBroker dataBroker; + private DOMDataBroker domDataBroker; private MountPointService mountPointService; private DOMMountPointService domMountPointService; private RpcProviderService rpcProviderRegistry; @@ -159,6 +161,7 @@ public class NetconfNodeStateServiceImpl LOG.info("Creating provider for {}", APPLICATION_NAME); this.dataBroker = null; + this.domDataBroker = null; this.mountPointService = null; this.domMountPointService = null; this.rpcProviderRegistry = null; @@ -182,6 +185,10 @@ public class NetconfNodeStateServiceImpl this.dataBroker = dataBroker; } + public void setDomDataBroker(DOMDataBroker domDataBroker) { + this.domDataBroker = domDataBroker; + } + public void setRpcProviderRegistry(RpcProviderService rpcProviderRegistry) { this.rpcProviderRegistry = rpcProviderRegistry; } @@ -270,6 +277,10 @@ public class NetconfNodeStateServiceImpl return dataBroker; } + public DOMDataBroker getDOMDataBroker() { + return domDataBroker; + } + public NetconfnodeStateServiceRpcApiImpl getNetconfnodeStateServiceRpcApiImpl() { return Objects.requireNonNull(rpcApiService, "Initialization not completed for rpcApiService" ); } diff --git a/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/access/NetconfAccessorImpl.java b/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/access/NetconfAccessorImpl.java index 34073614e..8cdf33d1b 100644 --- a/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/access/NetconfAccessorImpl.java +++ b/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/access/NetconfAccessorImpl.java @@ -26,6 +26,7 @@ import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfDomAccesso import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.impl.NetconfNodeStateServiceImpl; import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.impl.access.dom.DomContext; import org.opendaylight.mdsal.binding.api.DataBroker; +import org.opendaylight.mdsal.dom.api.DOMDataBroker; import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.NetconfNode; import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.NetconfNodeConnectionStatus.ConnectionStatus; import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId; @@ -113,6 +114,11 @@ public class NetconfAccessorImpl implements NetconfAccessor { return netconfNodeStateService.getDataBroker(); } + @Override + public DOMDataBroker getControllerDOMDataBroker() { + return netconfNodeStateService.getDOMDataBroker(); + } + /** * check if nc-notifications.yang is supported by the device */ diff --git a/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/access/NetconfAccessorManager.java b/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/access/NetconfAccessorManager.java index 6c3704421..3b68004bc 100644 --- a/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/access/NetconfAccessorManager.java +++ b/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/access/NetconfAccessorManager.java @@ -70,7 +70,4 @@ public class NetconfAccessorManager { public void removeAccessor(NodeId nNodeId) { accessorList.remove(nNodeId); } - - - } diff --git a/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/access/NetconfCommunicatorManager.java b/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/access/NetconfCommunicatorManager.java index 30afb4a20..f1cf906be 100644 --- a/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/access/NetconfCommunicatorManager.java +++ b/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/access/NetconfCommunicatorManager.java @@ -65,6 +65,7 @@ public class NetconfCommunicatorManager { private final DOMMountPointService domMountPointService; private final DomContext domContext; + public NetconfCommunicatorManager(MountPointService mountPointService, DOMMountPointService domMountPointService, DomContext domContext) { super(); diff --git a/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/access/dom/NetconfDomAccessorImpl.java b/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/access/dom/NetconfDomAccessorImpl.java index 97d48d130..54ca395f4 100644 --- a/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/access/dom/NetconfDomAccessorImpl.java +++ b/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/access/dom/NetconfDomAccessorImpl.java @@ -146,6 +146,28 @@ public class NetconfDomAccessorImpl extends NetconfAccessorImpl implements Netco } } + @Override + public Optional> readControllerDataNode(LogicalDatastoreType dataStoreType, + YangInstanceIdentifier path) { + LOG.debug("Read to controller node datastore:{} path:{}", dataStoreType, path); + + DOMDataTreeReadTransaction readOnlyTransaction = this.getControllerDOMDataBroker().newReadOnlyTransaction(); + try { + FluentFuture>> foData = readOnlyTransaction.read(dataStoreType, path); + + Optional> data = foData.get(120, TimeUnit.SECONDS); + LOG.trace("read is done - {} ", foData.isDone()); + return data; + } catch (InterruptedException e) { + LOG.debug("Incomplete read to node transaction {} {}", dataStoreType, path, e); + Thread.currentThread().interrupt(); + return Optional.empty(); + } catch (ExecutionException | TimeoutException e) { + LOG.debug("Incomplete read to node transaction {} {}", dataStoreType, path, e); + return Optional.empty(); + } + } + @SuppressWarnings("unchecked") private static Optional convertNormalizedNode(BindingNormalizedNodeSerializer serializer, Optional> oData, YangInstanceIdentifier path, Class clazz) @@ -284,4 +306,5 @@ public class NetconfDomAccessorImpl extends NetconfAccessorImpl implements Netco final String formattedDate = DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(dateTime); return new DateAndTime(formattedDate); } + } diff --git a/sdnr/wt/netconfnode-state-service/provider/src/main/resources/org/opendaylight/blueprint/impl-blueprint.xml b/sdnr/wt/netconfnode-state-service/provider/src/main/resources/org/opendaylight/blueprint/impl-blueprint.xml index fbf36e5a0..ec4c64e67 100644 --- a/sdnr/wt/netconfnode-state-service/provider/src/main/resources/org/opendaylight/blueprint/impl-blueprint.xml +++ b/sdnr/wt/netconfnode-state-service/provider/src/main/resources/org/opendaylight/blueprint/impl-blueprint.xml @@ -28,6 +28,8 @@ + + @@ -55,6 +57,7 @@ + -- cgit 1.2.3-korg