2a36cfd9674fa35d5cd2d80fa5490f5ec4c24d37
[ccsdk/features.git] /
1 /*
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
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
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
15  * the License.
16  * ============LICENSE_END==========================================================================
17  */
18 package org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice;
19
20 import com.google.common.util.concurrent.ListenableFuture;
21 import java.time.Instant;
22 import java.util.Collection;
23 import java.util.Map;
24 import java.util.Optional;
25 import org.eclipse.jdt.annotation.NonNull;
26 import org.opendaylight.mdsal.binding.dom.codec.api.BindingNormalizedNodeSerializer;
27 import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
28 import org.opendaylight.mdsal.dom.api.DOMDataBroker;
29 import org.opendaylight.mdsal.dom.api.DOMMountPoint;
30 import org.opendaylight.mdsal.dom.api.DOMNotificationListener;
31 import org.opendaylight.mdsal.dom.api.DOMRpcResult;
32 import org.opendaylight.mdsal.dom.api.DOMRpcService;
33 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netconf.notification._1._0.rev080714.CreateSubscriptionInput;
34 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netconf.notification._1._0.rev080714.create.subscription.input.Filter;
35 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netmod.notification.rev080714.netconf.streams.Stream;
36 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netmod.notification.rev080714.netconf.streams.StreamKey;
37 import org.opendaylight.yangtools.concepts.ListenerRegistration;
38 import org.opendaylight.yangtools.yang.binding.DataObject;
39 import org.opendaylight.yangtools.yang.common.QName;
40 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
41 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
42 import org.opendaylight.yangtools.yang.model.api.stmt.SchemaNodeIdentifier.Absolute;
43
44 /**
45  * Interface handling netconf connection.
46  */
47 public interface NetconfDomAccessor extends NetconfAccessor {
48
49     /**
50      * @return the dataBroker
51      */
52     DOMDataBroker getDataBroker();
53
54     /**
55      * @return the MDSAL Mountpoint service
56      */
57     DOMMountPoint getMountpoint();
58
59     /**
60      * @return DOMRpcService
61      */
62     DOMRpcService getRpcService();
63
64     /**
65      * @return DomContext
66      */
67     DomContext getDomContext();
68
69     /**
70      * Deliver the data into a class
71      *
72      * @param <T> DataObject type
73      * @param dataStoreType config or operational database
74      * @param path data path
75      * @return Optional<T> with object
76      */
77     <T extends DataObject> Optional<T> readData(LogicalDatastoreType dataStoreType, YangInstanceIdentifier path,
78             Class<T> clazz);
79
80     /**
81      * Read data from device
82      *
83      * @param dataStoreType
84      * @param path
85      * @return NormalizedNode<?, ?> with data
86      */
87     Optional<NormalizedNode> readDataNode(LogicalDatastoreType dataStoreType, YangInstanceIdentifier path);
88
89     /**
90      * Read data from Controller node - controller-config
91      *
92      * @param dataStoreType
93      * @param path
94      * @return NormalizedNode<?, ?> with data
95      */
96     Optional<NormalizedNode> readControllerDataNode(LogicalDatastoreType dataStoreType,
97             YangInstanceIdentifier path);
98
99
100     /**
101      * Register netconf notification listener for related mountpoint
102      *
103      * @param <T> specific child class of DOMNotificationListener
104      * @param listener listener to be called
105      * @param types as list of SchemaPath
106      * @return handler to manager registration
107      */
108     <T extends DOMNotificationListener> @NonNull ListenerRegistration<DOMNotificationListener> doRegisterNotificationListener(
109             @NonNull T listener, Collection<Absolute> types);
110
111     /**
112      * Register netconf notification listener for related mountpoint
113      *
114      * @See <a href="https://tools.ietf.org/html/rfc5277">https://tools.ietf.org/html/rfc5277</a>
115      * @param <T>
116      * @param listener to be registers
117      * @param types as array of SchemaPath
118      * @return Object to close and access
119      */
120     <T extends DOMNotificationListener> @NonNull ListenerRegistration<DOMNotificationListener> doRegisterNotificationListener(
121             @NonNull T listener, Absolute[] types);
122
123     /**
124      * Register netconf notification listener for related mountpoint
125      *
126      * @param <T>
127      * @param listener to be registers
128      * @param types as array of QName
129      * @return Object to close and access
130      */
131     <T extends DOMNotificationListener> @NonNull ListenerRegistration<DOMNotificationListener> doRegisterNotificationListener(
132             @NonNull T listener, QName[] types);
133
134     /**
135      * Request notification streams from device.
136      *
137      * @return provided streams.
138      */
139     @NonNull
140     Map<StreamKey, Stream> getNotificationStreamsAsMap();
141
142     /**
143      * Send out a NETCONF create-subscription for one notification stream.
144      *
145      * @See <a href="https://tools.ietf.org/html/rfc5277">https://tools.ietf.org/html/rfc5277</a>
146      * @param input with CreateSubscriptionInput
147      * @return RpcMessage for the RPC call.
148      */
149     ListenableFuture<? extends DOMRpcResult> invokeCreateSubscription(CreateSubscriptionInput input);
150
151     /**
152      * Send out a NETCONF create-subscription for one notification stream, using parameters.
153      *
154      * @See <a href="https://tools.ietf.org/html/rfc5277">https://tools.ietf.org/html/rfc5277</a>
155      * @param oStream Optional Stream
156      * @param filter Optional Filter
157      * @param startTime startTime according the RFC
158      * @param stopTime stopTime according the RFC
159      * @return
160      */
161     ListenableFuture<? extends DOMRpcResult> invokeCreateSubscription(Optional<Stream> oStream, Optional<Filter> filter,
162             Optional<Instant> startTime, Optional<Instant> stopTime);
163
164     /**
165      * Send out a NETCONF create-subscription for a list of streams, not offering replay options.
166      *
167      * @param streams is a list of stream with 0..n elements.
168      * @return if ok last rpc call result, if notok the result provided by rpc call providing error response.
169      */
170     ListenableFuture<? extends DOMRpcResult> invokeCreateSubscription(Stream... streams);
171
172     /**
173      * Get NETCONF object to serialize between GenericNodes and Java classes
174      *
175      * @return serialization object.
176      */
177     //BindingNormalizedNodeSerializer getBindingNormalizedNodeSerializer();
178 }