2 * Copyright © 2017-2018 AT&T Intellectual Property.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 package org.onap.ccsdk.apps.blueprintsprocessor.functions.netconf.executor.interfaces
19 import org.slf4j.LoggerFactory
20 import java.util.concurrent.CompletableFuture
22 interface NetconfSession {
25 * Executes an asynchronous RPC request to the server and obtains a future for it's response.
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
32 * @throws NetconfTransportException on secure transport-layer error
34 fun asyncRpc(request: String, msgId: String): CompletableFuture<String>
37 * Closes the Netconf session with the device. the first time it tries gracefully, then kills it
40 * @return true if closed
41 * @throws NetconfException when there is a problem in the communication process on the underlying
47 * Gets the session ID of the Netconf session.
49 * @return Session ID as a string.
51 fun getSessionId(): String
54 * Gets the capabilities of the remote Netconf device associated to this session.
56 * @return Network capabilities as strings in a Set.
58 fun getDeviceCapabilitiesSet(): Set<String>
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.
64 * @throws NetconfException when there is a problem in reestablishing the connection or the session
67 fun checkAndReestablish() {
68 val log = LoggerFactory.getLogger(NetconfSession::class.java)
69 log.error("Not implemented/exposed by the underlying ({}) implementation", "NetconfSession")
73 * Sets the ONOS side capabilities.
75 * @param capabilities list of capabilities has.
77 fun setCapabilities(capabilities: List<String>) {
78 // default implementation should be removed in the future
83 * Get the device information for initialised session.
85 * @return DeviceInfo as device information
87 //fun getDeviceInfo(): DeviceInfo