2 * ============LICENSE_START========================================================================
3 * ONAP : ccsdk feature sdnr wt
4 * =================================================================================================
5 * Copyright (C) 2020 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.impl.access;
20 import java.util.Objects;
21 import java.util.Optional;
22 import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.Capabilities;
23 import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfAccessor;
24 import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfBindingAccessor;
25 import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfDomAccessor;
26 import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.impl.NetconfNodeStateServiceImpl;
27 import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.impl.access.dom.DomContext;
28 import org.opendaylight.mdsal.binding.api.DataBroker;
29 import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.NetconfNode;
30 import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.NetconfNodeConnectionStatus.ConnectionStatus;
31 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId;
32 import org.slf4j.Logger;
33 import org.slf4j.LoggerFactory;
35 public class NetconfAccessorImpl implements NetconfAccessor {
37 @SuppressWarnings("unused")
38 private static final Logger LOG = LoggerFactory.getLogger(NetconfAccessorImpl.class);
40 private final NodeId nodeId;
41 private final NetconfNode netconfNode;
42 private final Capabilities capabilities;
43 private final NetconfCommunicatorManager netconfCommunicatorManager;
44 private final DomContext domContext;
45 private final NetconfNodeStateServiceImpl netconfNodeStateService;
47 * Contains all data to access and manage netconf device
49 * @param netconfCommunicatorManager
51 * @param nodeId of managed netconf node
52 * @param netconfNode information
54 * @param dataBroker to access node
55 * @param mountpoint of netconfNode
57 public NetconfAccessorImpl(NodeId nodeId, NetconfNode netconfNode,
58 NetconfCommunicatorManager netconfCommunicatorManager, DomContext domContext, NetconfNodeStateServiceImpl netconfNodeStateService) {
60 this.nodeId = Objects.requireNonNull(nodeId);
61 this.netconfNode = Objects.requireNonNull(netconfNode);
62 this.netconfCommunicatorManager = Objects.requireNonNull(netconfCommunicatorManager);
63 this.domContext = Objects.requireNonNull(domContext);
64 this.netconfNodeStateService = Objects.requireNonNull(netconfNodeStateService);
66 ConnectionStatus csts = netconfNode != null ? netconfNode.getConnectionStatus() : null;
68 throw new IllegalStateException(String.format("connection status for %s is not connected", nodeId));
70 Capabilities tmp = Capabilities.getAvailableCapabilities(netconfNode);
71 if (tmp.getCapabilities().size() <= 0) {
72 throw new IllegalStateException(String.format("no capabilities found for %s", nodeId));
74 this.capabilities = tmp;
77 public NetconfAccessorImpl(NetconfAccessorImpl accessor) {
78 this.nodeId = accessor.getNodeId();
79 this.netconfNode = accessor.getNetconfNode();
80 this.capabilities = accessor.getCapabilites();
81 this.netconfCommunicatorManager = accessor.netconfCommunicatorManager;
82 this.domContext = accessor.domContext;
83 this.netconfNodeStateService = accessor.netconfNodeStateService;
87 public NodeId getNodeId() {
92 public NetconfNode getNetconfNode() {
97 public Capabilities getCapabilites() {
102 public Optional<NetconfBindingAccessor> getNetconfBindingAccessor() {
103 return netconfCommunicatorManager.getNetconfBindingAccessor(this);
107 public Optional<NetconfDomAccessor> getNetconfDomAccessor() {
108 return netconfCommunicatorManager.getNetconfDomAccessor(this);
112 public DataBroker getControllerBindingDataBroker() {
113 return netconfNodeStateService.getDataBroker();
117 * check if nc-notifications.yang is supported by the device
120 public boolean isNotificationsRFC5277Supported() {
121 return getCapabilites().isSupportingNamespace("urn:ietf:params:netconf:capability:notification:1.0");