2 * ============LICENSE_START========================================================================
3 * ONAP : ccsdk feature sdnr wt
4 * =================================================================================================
5 * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. All rights reserved.
6 * =================================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
8 * in compliance with the License. You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software distributed under the License
13 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
14 * or implied. See the License for the specific language governing permissions and limitations under
16 * ============LICENSE_END==========================================================================
18 package org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice;
20 import java.util.Optional;
21 import org.eclipse.jdt.annotation.NonNull;
22 import org.opendaylight.mdsal.binding.api.DataBroker;
23 import org.opendaylight.mdsal.binding.api.MountPoint;
24 import org.opendaylight.mdsal.binding.api.NotificationService;
25 import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.NetconfNode;
26 import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.NetconfNodeConnectionStatus.ConnectionStatus;
27 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId;
28 import org.opendaylight.yangtools.concepts.ListenerRegistration;
29 import org.opendaylight.yangtools.yang.binding.NotificationListener;
30 import org.slf4j.Logger;
31 import org.slf4j.LoggerFactory;
33 public class NetconfAccessor implements INetconfAcessor {
35 private static final Logger log = LoggerFactory.getLogger(NetconfAccessor.class);
37 private final NodeId nodeId;
38 private final DataBroker dataBroker;
39 private final TransactionUtils transactionUtils;
40 private final MountPoint mountpoint;
41 private final NetconfNode netconfNode;
42 private final Capabilities capabilities;
45 * @param nodeId of managed netconf node
46 * @param dataBroker to access node
48 public NetconfAccessor(NodeId nodeId, NetconfNode netconfNode, DataBroker dataBroker, MountPoint mountpoint,
49 TransactionUtils transactionUtils) {
52 this.netconfNode = netconfNode;
53 this.dataBroker = dataBroker;
54 this.mountpoint = mountpoint;
55 this.transactionUtils = transactionUtils;
57 ConnectionStatus csts = netconfNode != null ? netconfNode.getConnectionStatus() : null;
58 this.capabilities = Capabilities.getAvailableCapabilities(csts != null ? netconfNode : null);
62 * @param nodeId with uuid of managed netconf node
63 * @param dataBroker to access node
65 public NetconfAccessor(String nodeId, NetconfNode netconfNode, DataBroker dataBroker, MountPoint mountpoint,
66 TransactionUtils transactionUtils) {
67 this(new NodeId(nodeId), netconfNode, dataBroker, mountpoint, transactionUtils);
71 public NodeId getNodeId() {
76 public DataBroker getDataBroker() {
80 public MountPoint getMountpoint() {
84 public TransactionUtils getTransactionUtils() {
85 return transactionUtils;
88 public NetconfNode getNetconfNode() {
92 public Capabilities getCapabilites() {
97 public @NonNull <T extends NotificationListener> ListenerRegistration<NotificationListener> doRegisterNotificationListener(@NonNull T listener) {
98 log.info("Begin register listener for Mountpoint {}", mountpoint.getIdentifier().toString());
99 final Optional<NotificationService> optionalNotificationService = mountpoint
100 .getService(NotificationService.class);
101 final NotificationService notificationService = optionalNotificationService.get();
102 final ListenerRegistration<NotificationListener> ranListenerRegistration = notificationService
103 .registerNotificationListener(listener);
104 log.info("End registration listener for Mountpoint {} Listener: {} Result: {}",
105 mountpoint.getIdentifier().toString(), optionalNotificationService, ranListenerRegistration);
106 return ranListenerRegistration;