84310ea54404f11915cacd4fac6a63c20cde472f
[ccsdk/cds.git] /
1 /*
2  * Copyright © 2017-2018 AT&T Intellectual Property.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 package org.onap.ccsdk.apps.blueprintsprocessor.functions.netconf.executor.interfaces
18
19 import org.slf4j.LoggerFactory
20 import java.util.concurrent.CompletableFuture
21
22 interface NetconfSession {
23
24     /**
25      * Executes an asynchronous RPC request to the server and obtains a future for it's response.
26      *
27      * @param request the XML containing the RPC request for the server.
28      * @param msgId message id of the request.
29      * @return Server response or ERROR
30      * @throws NetconfException when there is a problem in the communication process on the underlying
31      * connection
32      * @throws NetconfTransportException on secure transport-layer error
33      */
34     fun asyncRpc(request: String, msgId: String): CompletableFuture<String>
35
36     /**
37      * Closes the Netconf session with the device. the first time it tries gracefully, then kills it
38      * forcefully
39      *
40      * @return true if closed
41      * @throws NetconfException when there is a problem in the communication process on the underlying
42      * connection
43      */
44     fun close(): Boolean
45
46     /**
47      * Gets the session ID of the Netconf session.
48      *
49      * @return Session ID as a string.
50      */
51     fun getSessionId(): String
52
53     /**
54      * Gets the capabilities of the remote Netconf device associated to this session.
55      *
56      * @return Network capabilities as strings in a Set.
57      */
58     fun getDeviceCapabilitiesSet(): Set<String>
59
60     /**
61      * Checks the state of the underlying SSH session and connection and if necessary it reestablishes
62      * it. Should be implemented, providing a default here for retro compatibility.
63      *
64      * @throws NetconfException when there is a problem in reestablishing the connection or the session
65      * to the device.
66      */
67     fun checkAndReestablish() {
68         val log = LoggerFactory.getLogger(NetconfSession::class.java)
69         log.error("Not implemented/exposed by the underlying ({}) implementation", "NetconfSession")
70     }
71
72     /**
73      * Sets the ONOS side capabilities.
74      *
75      * @param capabilities list of capabilities has.
76      */
77     fun setCapabilities(capabilities: List<String>) {
78         // default implementation should be removed in the future
79         // no-op
80     }
81
82     /**
83      * Get the device information for initialised session.
84      *
85      * @return DeviceInfo as device information
86      */
87     //fun getDeviceInfo(): DeviceInfo
88 }