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.access.dom.DomContext;
27 import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.NetconfNode;
28 import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.NetconfNodeConnectionStatus.ConnectionStatus;
29 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId;
30 import org.slf4j.Logger;
31 import org.slf4j.LoggerFactory;
33 public class NetconfAccessorImpl implements NetconfAccessor {
35 @SuppressWarnings("unused")
36 private static final Logger LOG = LoggerFactory.getLogger(NetconfAccessorImpl.class);
38 private final NodeId nodeId;
39 private final NetconfNode netconfNode;
40 private final Capabilities capabilities;
41 private final NetconfCommunicatorManager netconfCommunicatorManager;
42 private final DomContext domContext;
45 * Contains all data to access and manage netconf device
47 * @param netconfCommunicatorManager
49 * @param nodeId of managed netconf node
50 * @param netconfNode information
52 * @param dataBroker to access node
53 * @param mountpoint of netconfNode
55 public NetconfAccessorImpl(NodeId nodeId, NetconfNode netconfNode,
56 NetconfCommunicatorManager netconfCommunicatorManager, DomContext domContext) {
58 this.nodeId = Objects.requireNonNull(nodeId);
59 this.netconfNode = Objects.requireNonNull(netconfNode);
60 this.netconfCommunicatorManager = Objects.requireNonNull(netconfCommunicatorManager);
61 this.domContext = Objects.requireNonNull(domContext);
63 ConnectionStatus csts = netconfNode != null ? netconfNode.getConnectionStatus() : null;
65 throw new IllegalStateException(String.format("connection status for %s is not connected", nodeId));
67 Capabilities tmp = Capabilities.getAvailableCapabilities(netconfNode);
68 if (tmp.getCapabilities().size() <= 0) {
69 throw new IllegalStateException(String.format("no capabilities found for %s", nodeId));
71 this.capabilities = tmp;
75 * @param nodeId with uuid of managed netconf node
76 * @param dataBroker to access node
78 public NetconfAccessorImpl(String nodeId, NetconfNode netconfNode,
79 NetconfCommunicatorManager netconfCommunicatorManager, DomContext domContext) {
80 this(new NodeId(nodeId), netconfNode, netconfCommunicatorManager, domContext);
83 public NetconfAccessorImpl(NetconfAccessorImpl accessor) {
84 this.nodeId = accessor.getNodeId();
85 this.netconfNode = accessor.getNetconfNode();
86 this.capabilities = accessor.getCapabilites();
87 this.netconfCommunicatorManager = accessor.netconfCommunicatorManager;
88 this.domContext = accessor.domContext;
92 public NodeId getNodeId() {
97 public NetconfNode getNetconfNode() {
102 public Capabilities getCapabilites() {
107 public Optional<NetconfBindingAccessor> getNetconfBindingAccessor() {
108 return netconfCommunicatorManager.getNetconfBindingAccessor(this);
112 public Optional<NetconfDomAccessor> getNetconfDomAccessor() {
113 return netconfCommunicatorManager.getNetconfDomAccessor(this);