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.mdsal.dom.api.DOMDataBroker;
30 import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.device.rev221225.ConnectionOper.ConnectionStatus;
31 import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev221225.NetconfNode;
32 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId;
33 import org.slf4j.Logger;
34 import org.slf4j.LoggerFactory;
36 public class NetconfAccessorImpl implements NetconfAccessor {
38 @SuppressWarnings("unused")
39 private static final Logger LOG = LoggerFactory.getLogger(NetconfAccessorImpl.class);
41 private final NodeId nodeId;
42 private final NetconfNode netconfNode;
43 private final Capabilities capabilities;
44 private final NetconfCommunicatorManager netconfCommunicatorManager;
45 private final DomContext domContext;
46 private final NetconfNodeStateServiceImpl netconfNodeStateService;
48 * Contains all data to access and manage netconf device
50 * @param netconfCommunicatorManager
52 * @param nodeId of managed netconf node
53 * @param netconfNode information
55 * @param dataBroker to access node
56 * @param mountpoint of netconfNode
58 public NetconfAccessorImpl(NodeId nodeId, NetconfNode netconfNode,
59 NetconfCommunicatorManager netconfCommunicatorManager, DomContext domContext, NetconfNodeStateServiceImpl netconfNodeStateService) {
61 this.nodeId = Objects.requireNonNull(nodeId);
62 this.netconfNode = Objects.requireNonNull(netconfNode);
63 this.netconfCommunicatorManager = Objects.requireNonNull(netconfCommunicatorManager);
64 this.domContext = Objects.requireNonNull(domContext);
65 this.netconfNodeStateService = Objects.requireNonNull(netconfNodeStateService);
67 ConnectionStatus csts = netconfNode.getConnectionStatus();
69 throw new IllegalStateException(String.format("connection status for %s is not connected", nodeId));
71 Capabilities tmp = Capabilities.getAvailableCapabilities(netconfNode);
72 if (tmp.getCapabilities().size() <= 0) {
73 throw new IllegalStateException(String.format("no capabilities found for %s", nodeId));
75 this.capabilities = tmp;
78 public NetconfAccessorImpl(NetconfAccessorImpl accessor) {
79 this.nodeId = accessor.getNodeId();
80 this.netconfNode = accessor.getNetconfNode();
81 this.capabilities = accessor.getCapabilites();
82 this.netconfCommunicatorManager = accessor.netconfCommunicatorManager;
83 this.domContext = accessor.domContext;
84 this.netconfNodeStateService = accessor.netconfNodeStateService;
88 public NodeId getNodeId() {
93 public NetconfNode getNetconfNode() {
98 public Capabilities getCapabilites() {
103 public Optional<NetconfBindingAccessor> getNetconfBindingAccessor() {
104 return netconfCommunicatorManager.getNetconfBindingAccessor(this);
108 public Optional<NetconfDomAccessor> getNetconfDomAccessor() {
109 return netconfCommunicatorManager.getNetconfDomAccessor(this);
113 public DataBroker getControllerBindingDataBroker() {
114 return netconfNodeStateService.getDataBroker();
118 public DOMDataBroker getControllerDOMDataBroker() {
119 return netconfNodeStateService.getDOMDataBroker();
123 * check if nc-notifications.yang is supported by the device
126 public boolean isNotificationsRFC5277Supported() {
127 return getCapabilites().isSupportingNamespace("urn:ietf:params:netconf:capability:notification:1.0");