andrea | eb70a94 | 2015-10-16 21:34:46 -0700 | [diff] [blame] | 1 | /* |
Brian O'Connor | a09fe5b | 2017-08-03 21:12:30 -0700 | [diff] [blame] | 2 | * Copyright 2015-present Open Networking Foundation |
andrea | eb70a94 | 2015-10-16 21:34:46 -0700 | [diff] [blame] | 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.onosproject.netconf; |
| 18 | |
Akihiro Yamanouchi | 4512222 | 2016-07-15 13:13:11 +0900 | [diff] [blame] | 19 | import com.google.common.annotations.Beta; |
Andrea Campanella | c362784 | 2017-04-04 18:06:54 +0200 | [diff] [blame] | 20 | import org.slf4j.Logger; |
| 21 | import org.slf4j.LoggerFactory; |
Andrei Mihaescu | ac542ca | 2017-03-26 21:36:25 +0300 | [diff] [blame] | 22 | |
Aaron Kruglikov | 72db642 | 2017-02-13 12:16:51 -0800 | [diff] [blame] | 23 | import java.util.Set; |
Andrea Campanella | 101417d | 2015-12-11 17:58:07 -0800 | [diff] [blame] | 24 | import java.util.concurrent.CompletableFuture; |
andrea | eb70a94 | 2015-10-16 21:34:46 -0700 | [diff] [blame] | 25 | |
| 26 | /** |
| 27 | * NETCONF session object that allows NETCONF operations on top with the physical |
| 28 | * device on top of an SSH connection. |
| 29 | */ |
Sean Condon | d2c8d47 | 2017-02-17 17:09:39 +0000 | [diff] [blame] | 30 | // TODO change return type of methods to <Capability, XMLdoc, string or yang obj> |
andrea | eb70a94 | 2015-10-16 21:34:46 -0700 | [diff] [blame] | 31 | public interface NetconfSession { |
| 32 | |
| 33 | /** |
Andrea Campanella | 101417d | 2015-12-11 17:58:07 -0800 | [diff] [blame] | 34 | * Executes an asynchronous RPC to the server and obtains a future to be completed. |
| 35 | * |
Sean Condon | d2c8d47 | 2017-02-17 17:09:39 +0000 | [diff] [blame] | 36 | * The caller must ensure that the message-id in any request is unique |
| 37 | * for the session |
| 38 | * |
| 39 | * @deprecated - 1.10.0 do not remove needs reworking |
Andrea Campanella | 101417d | 2015-12-11 17:58:07 -0800 | [diff] [blame] | 40 | * @param request the XML containing the RPC for the server. |
| 41 | * @return Server response or ERROR |
| 42 | * @throws NetconfException when there is a problem in the communication process on |
| 43 | * the underlying connection |
| 44 | */ |
Sean Condon | d2c8d47 | 2017-02-17 17:09:39 +0000 | [diff] [blame] | 45 | @Deprecated |
Andrea Campanella | 101417d | 2015-12-11 17:58:07 -0800 | [diff] [blame] | 46 | CompletableFuture<String> request(String request) throws NetconfException; |
| 47 | |
Yuta HIGUCHI | 6e6c26e | 2017-09-06 14:25:57 -0700 | [diff] [blame] | 48 | /** |
| 49 | * Executes an asynchronous RPC request to the server and obtains a future |
| 50 | * for it's response. |
| 51 | * |
| 52 | * @param request the XML containing the RPC request for the server. |
| 53 | * @return Server response or ERROR |
| 54 | * @throws NetconfException when there is a problem in the communication process on |
| 55 | * the underlying connection |
| 56 | * @throws NetconfTransportException on secure transport-layer error |
| 57 | */ |
Yuta HIGUCHI | 4f55c67 | 2018-06-14 18:10:43 -0700 | [diff] [blame] | 58 | CompletableFuture<String> rpc(String request) throws NetconfException; |
Yuta HIGUCHI | 6e6c26e | 2017-09-06 14:25:57 -0700 | [diff] [blame] | 59 | |
Yuta HIGUCHI | 5ac3443 | 2018-02-13 16:29:15 -0800 | [diff] [blame] | 60 | /** |
| 61 | * Retrieves the specified configuration. |
| 62 | * |
| 63 | * @param datastore to retrieve configuration from |
| 64 | * @return specified configuration |
| 65 | * |
| 66 | * @throws NetconfException when there is a problem in the communication process on |
| 67 | * the underlying connection |
| 68 | */ |
Yuta HIGUCHI | 4f55c67 | 2018-06-14 18:10:43 -0700 | [diff] [blame] | 69 | CompletableFuture<CharSequence> asyncGetConfig(DatastoreId datastore) throws NetconfException; |
Yuta HIGUCHI | 5ac3443 | 2018-02-13 16:29:15 -0800 | [diff] [blame] | 70 | |
| 71 | /** |
| 72 | * Retrieves running configuration and device state. |
| 73 | * |
| 74 | * @return running configuration and device state |
| 75 | * |
| 76 | * @throws NetconfException when there is a problem in the communication process on |
| 77 | * the underlying connection |
| 78 | */ |
Yuta HIGUCHI | 4f55c67 | 2018-06-14 18:10:43 -0700 | [diff] [blame] | 79 | CompletableFuture<CharSequence> asyncGet() throws NetconfException; |
Yuta HIGUCHI | 5ac3443 | 2018-02-13 16:29:15 -0800 | [diff] [blame] | 80 | |
Andrea Campanella | 101417d | 2015-12-11 17:58:07 -0800 | [diff] [blame] | 81 | |
| 82 | /** |
Sean Condon | d2c8d47 | 2017-02-17 17:09:39 +0000 | [diff] [blame] | 83 | * Retrieves the requested configuration, different from get-config. |
Andrea Campanella | f4fd035 | 2015-12-14 17:03:05 -0800 | [diff] [blame] | 84 | * |
andrea | eb70a94 | 2015-10-16 21:34:46 -0700 | [diff] [blame] | 85 | * @param request the XML containing the request to the server. |
| 86 | * @return device running configuration |
Andrea Campanella | 101417d | 2015-12-11 17:58:07 -0800 | [diff] [blame] | 87 | * @throws NetconfException when there is a problem in the communication process on |
| 88 | * the underlying connection |
andrea | eb70a94 | 2015-10-16 21:34:46 -0700 | [diff] [blame] | 89 | */ |
Andrea Campanella | 101417d | 2015-12-11 17:58:07 -0800 | [diff] [blame] | 90 | String get(String request) throws NetconfException; |
andrea | eb70a94 | 2015-10-16 21:34:46 -0700 | [diff] [blame] | 91 | |
| 92 | /** |
Sean Condon | d2c8d47 | 2017-02-17 17:09:39 +0000 | [diff] [blame] | 93 | * Retrieves the requested data. |
Akihiro Yamanouchi | 5e5d4df | 2016-06-08 17:06:33 +0900 | [diff] [blame] | 94 | * |
| 95 | * @param filterSchema XML subtrees to include in the reply |
| 96 | * @param withDefaultsMode with-defaults mode |
| 97 | * @return Server response |
| 98 | * @throws NetconfException when there is a problem in the communication process on |
| 99 | * the underlying connection |
| 100 | */ |
| 101 | String get(String filterSchema, String withDefaultsMode) |
| 102 | throws NetconfException; |
| 103 | |
| 104 | /** |
Akihiro Yamanouchi | 4512222 | 2016-07-15 13:13:11 +0900 | [diff] [blame] | 105 | * Executes an synchronous RPC to the server and wrap the request in RPC header. |
Akihiro Yamanouchi | 8d3a9d3 | 2016-07-12 11:41:44 +0900 | [diff] [blame] | 106 | * |
| 107 | * @param request the XML containing the request to the server. |
| 108 | * @return Server response or ERROR |
| 109 | * @throws NetconfException when there is a problem in the communication process on |
| 110 | * the underlying connection |
| 111 | */ |
| 112 | String doWrappedRpc(String request) throws NetconfException; |
| 113 | |
| 114 | /** |
Andrea Campanella | 101417d | 2015-12-11 17:58:07 -0800 | [diff] [blame] | 115 | * Executes an synchronous RPC to the server. |
Andrea Campanella | f4fd035 | 2015-12-14 17:03:05 -0800 | [diff] [blame] | 116 | * |
andrea | eb70a94 | 2015-10-16 21:34:46 -0700 | [diff] [blame] | 117 | * @param request the XML containing the RPC for the server. |
| 118 | * @return Server response or ERROR |
Andrea Campanella | 101417d | 2015-12-11 17:58:07 -0800 | [diff] [blame] | 119 | * @throws NetconfException when there is a problem in the communication process on |
| 120 | * the underlying connection |
andrea | eb70a94 | 2015-10-16 21:34:46 -0700 | [diff] [blame] | 121 | */ |
Andrea Campanella | 101417d | 2015-12-11 17:58:07 -0800 | [diff] [blame] | 122 | String requestSync(String request) throws NetconfException; |
andrea | eb70a94 | 2015-10-16 21:34:46 -0700 | [diff] [blame] | 123 | |
| 124 | /** |
Yuta HIGUCHI | 89111d9 | 2017-05-04 11:29:17 -0700 | [diff] [blame] | 125 | * Retrieves the specified configuration. |
andrea | eb70a94 | 2015-10-16 21:34:46 -0700 | [diff] [blame] | 126 | * |
Andrei Mihaescu | ac542ca | 2017-03-26 21:36:25 +0300 | [diff] [blame] | 127 | * @param netconfTargetConfig the type of configuration to retrieve. |
andrea | eb70a94 | 2015-10-16 21:34:46 -0700 | [diff] [blame] | 128 | * @return specified configuration. |
Andrea Campanella | 101417d | 2015-12-11 17:58:07 -0800 | [diff] [blame] | 129 | * @throws NetconfException when there is a problem in the communication process on |
| 130 | * the underlying connection |
Yuta HIGUCHI | 5ac3443 | 2018-02-13 16:29:15 -0800 | [diff] [blame] | 131 | * |
| 132 | * @deprecated in 1.13.0 use async version instead. |
andrea | eb70a94 | 2015-10-16 21:34:46 -0700 | [diff] [blame] | 133 | */ |
Yuta HIGUCHI | 5ac3443 | 2018-02-13 16:29:15 -0800 | [diff] [blame] | 134 | @Deprecated |
Yuta HIGUCHI | dd7c3f8 | 2017-09-03 14:18:01 -0700 | [diff] [blame] | 135 | String getConfig(DatastoreId netconfTargetConfig) throws NetconfException; |
andrea | eb70a94 | 2015-10-16 21:34:46 -0700 | [diff] [blame] | 136 | |
| 137 | /** |
Yuta HIGUCHI | 89111d9 | 2017-05-04 11:29:17 -0700 | [diff] [blame] | 138 | * Retrieves part of the specified configuration based on the filterSchema. |
| 139 | * |
| 140 | * @param netconfTargetConfig the type of configuration to retrieve. |
| 141 | * @param configurationFilterSchema XML schema to filter the configuration |
| 142 | * elements we are interested in |
| 143 | * @return device running configuration. |
| 144 | * @throws NetconfException when there is a problem in the communication process on |
| 145 | * the underlying connection |
| 146 | */ |
Yuta HIGUCHI | dd7c3f8 | 2017-09-03 14:18:01 -0700 | [diff] [blame] | 147 | String getConfig(DatastoreId netconfTargetConfig, |
Yuta HIGUCHI | 89111d9 | 2017-05-04 11:29:17 -0700 | [diff] [blame] | 148 | String configurationFilterSchema) |
Yuta HIGUCHI | dd7c3f8 | 2017-09-03 14:18:01 -0700 | [diff] [blame] | 149 | throws NetconfException; |
Andrei Mihaescu | ac542ca | 2017-03-26 21:36:25 +0300 | [diff] [blame] | 150 | |
andrea | eb70a94 | 2015-10-16 21:34:46 -0700 | [diff] [blame] | 151 | /** |
Yuta HIGUCHI | 89111d9 | 2017-05-04 11:29:17 -0700 | [diff] [blame] | 152 | * Retrieves part of the specified configuration based on the filterSchema. |
andrea | eb70a94 | 2015-10-16 21:34:46 -0700 | [diff] [blame] | 153 | * |
| 154 | * @param newConfiguration configuration to set |
| 155 | * @return true if the configuration was edited correctly |
Andrea Campanella | 101417d | 2015-12-11 17:58:07 -0800 | [diff] [blame] | 156 | * @throws NetconfException when there is a problem in the communication process on |
| 157 | * the underlying connection |
andrea | eb70a94 | 2015-10-16 21:34:46 -0700 | [diff] [blame] | 158 | */ |
Andrea Campanella | 101417d | 2015-12-11 17:58:07 -0800 | [diff] [blame] | 159 | boolean editConfig(String newConfiguration) throws NetconfException; |
andrea | eb70a94 | 2015-10-16 21:34:46 -0700 | [diff] [blame] | 160 | |
| 161 | /** |
Yuta HIGUCHI | 89111d9 | 2017-05-04 11:29:17 -0700 | [diff] [blame] | 162 | * Retrieves part of the specified configuration based on the filterSchema. |
| 163 | * |
| 164 | * @param netconfTargetConfig the targetConfiguration to change |
Yuta HIGUCHI | e34c9c2 | 2017-12-04 17:47:14 -0800 | [diff] [blame] | 165 | * @param mode default-operation mode |
Yuta HIGUCHI | 89111d9 | 2017-05-04 11:29:17 -0700 | [diff] [blame] | 166 | * @param newConfiguration configuration to set |
| 167 | * @return true if the configuration was edited correctly |
| 168 | * @throws NetconfException when there is a problem in the communication process on |
| 169 | * the underlying connection |
| 170 | */ |
Yuta HIGUCHI | dd7c3f8 | 2017-09-03 14:18:01 -0700 | [diff] [blame] | 171 | boolean editConfig(DatastoreId netconfTargetConfig, String mode, String newConfiguration) |
| 172 | throws NetconfException; |
Yuta HIGUCHI | 89111d9 | 2017-05-04 11:29:17 -0700 | [diff] [blame] | 173 | |
| 174 | /** |
| 175 | * Copies the configuration between configuration datastores. |
| 176 | * <p> |
| 177 | * The target configuration can't be the running one |
| 178 | * |
| 179 | * @param destination configuration datastore |
| 180 | * @param source configuration datastore |
| 181 | * @return true if the configuration was copied correctly |
| 182 | * @throws NetconfException when there is a problem in the communication process on |
| 183 | * the underlying connection |
| 184 | */ |
Yuta HIGUCHI | dd7c3f8 | 2017-09-03 14:18:01 -0700 | [diff] [blame] | 185 | boolean copyConfig(DatastoreId destination, DatastoreId source) |
| 186 | throws NetconfException; |
Yuta HIGUCHI | 89111d9 | 2017-05-04 11:29:17 -0700 | [diff] [blame] | 187 | |
| 188 | /** |
| 189 | * Copies the new configuration, an Url or a complete configuration xml tree |
| 190 | * to the target configuration. |
| 191 | * The target configuration can't be the running one |
| 192 | * |
| 193 | * @param netconfTargetConfig the type of configuration to retrieve. |
| 194 | * @param newConfiguration configuration XML to set or URL tag to the configuration |
| 195 | * @return true if the configuration was copied correctly |
| 196 | * @throws NetconfException when there is a problem in the communication process on |
| 197 | * the underlying connection |
| 198 | */ |
Yuta HIGUCHI | dd7c3f8 | 2017-09-03 14:18:01 -0700 | [diff] [blame] | 199 | boolean copyConfig(DatastoreId netconfTargetConfig, String newConfiguration) |
| 200 | throws NetconfException; |
Andrea Campanella | f4fd035 | 2015-12-14 17:03:05 -0800 | [diff] [blame] | 201 | |
| 202 | /** |
andrea | eb70a94 | 2015-10-16 21:34:46 -0700 | [diff] [blame] | 203 | * Copies the new configuration, an Url or a complete configuration xml tree |
| 204 | * to the target configuration. |
| 205 | * The target configuration can't be the running one |
| 206 | * |
Andrei Mihaescu | ac542ca | 2017-03-26 21:36:25 +0300 | [diff] [blame] | 207 | * @param netconfTargetConfig the type of configuration to retrieve. |
| 208 | * @param newConfiguration configuration to set |
| 209 | * @return true if the configuration was copied correctly |
| 210 | * @throws NetconfException when there is a problem in the communication process on |
| 211 | * the underlying connection |
Andrei Mihaescu | ac542ca | 2017-03-26 21:36:25 +0300 | [diff] [blame] | 212 | */ |
Andrei Mihaescu | ac542ca | 2017-03-26 21:36:25 +0300 | [diff] [blame] | 213 | boolean copyConfig(String netconfTargetConfig, String newConfiguration) |
| 214 | throws NetconfException; |
| 215 | |
| 216 | /** |
Yuta HIGUCHI | 89111d9 | 2017-05-04 11:29:17 -0700 | [diff] [blame] | 217 | * Deletes part of the specified configuration based on the filterSchema. |
| 218 | * |
| 219 | * @param netconfTargetConfig the name of the configuration to delete |
| 220 | * @return true if the configuration was copied correctly |
| 221 | * @throws NetconfException when there is a problem in the communication process on |
| 222 | * the underlying connection |
| 223 | */ |
Yuta HIGUCHI | dd7c3f8 | 2017-09-03 14:18:01 -0700 | [diff] [blame] | 224 | boolean deleteConfig(DatastoreId netconfTargetConfig) throws NetconfException; |
andrea | eb70a94 | 2015-10-16 21:34:46 -0700 | [diff] [blame] | 225 | |
| 226 | /** |
helenyrwu | 0407c64 | 2016-06-09 12:01:30 -0700 | [diff] [blame] | 227 | * Starts subscription to the device's notifications. |
| 228 | * |
| 229 | * @throws NetconfException when there is a problem starting the subscription |
| 230 | */ |
| 231 | void startSubscription() throws NetconfException; |
| 232 | |
| 233 | /** |
Akihiro Yamanouchi | 4512222 | 2016-07-15 13:13:11 +0900 | [diff] [blame] | 234 | * Starts subscription to the device's notifications. |
| 235 | * |
| 236 | * @param filterSchema XML subtrees to indicate specific notification |
| 237 | * @throws NetconfException when there is a problem starting the subscription |
| 238 | */ |
| 239 | @Beta |
| 240 | void startSubscription(String filterSchema) throws NetconfException; |
| 241 | |
| 242 | /** |
helenyrwu | 0407c64 | 2016-06-09 12:01:30 -0700 | [diff] [blame] | 243 | * Ends subscription to the device's notifications. |
| 244 | * |
| 245 | * @throws NetconfException when there is a problem ending the subscription |
| 246 | */ |
| 247 | void endSubscription() throws NetconfException; |
| 248 | |
| 249 | /** |
| 250 | * Locks the specified configuration. |
| 251 | * |
Yuta HIGUCHI | 89111d9 | 2017-05-04 11:29:17 -0700 | [diff] [blame] | 252 | * @param datastore configuration datastore to be locked |
helenyrwu | 0407c64 | 2016-06-09 12:01:30 -0700 | [diff] [blame] | 253 | * @return true if successful. |
| 254 | * @throws NetconfException when there is a problem in the communication process on |
| 255 | * the underlying connection |
| 256 | */ |
Yuta HIGUCHI | dd7c3f8 | 2017-09-03 14:18:01 -0700 | [diff] [blame] | 257 | boolean lock(DatastoreId datastore) throws NetconfException; |
Yuta HIGUCHI | 89111d9 | 2017-05-04 11:29:17 -0700 | [diff] [blame] | 258 | |
| 259 | /** |
| 260 | * Unlocks the specified configuration. |
| 261 | * |
| 262 | * @param datastore configuration datastore to be unlocked |
| 263 | * @return true if successful. |
| 264 | * @throws NetconfException when there is a problem in the communication process on |
| 265 | * the underlying connection |
| 266 | */ |
Yuta HIGUCHI | dd7c3f8 | 2017-09-03 14:18:01 -0700 | [diff] [blame] | 267 | boolean unlock(DatastoreId datastore) throws NetconfException; |
helenyrwu | 0407c64 | 2016-06-09 12:01:30 -0700 | [diff] [blame] | 268 | |
| 269 | /** |
| 270 | * Locks the running configuration. |
andrea | eb70a94 | 2015-10-16 21:34:46 -0700 | [diff] [blame] | 271 | * |
| 272 | * @return true if successful. |
Andrea Campanella | 101417d | 2015-12-11 17:58:07 -0800 | [diff] [blame] | 273 | * @throws NetconfException when there is a problem in the communication process on |
| 274 | * the underlying connection |
andrea | eb70a94 | 2015-10-16 21:34:46 -0700 | [diff] [blame] | 275 | */ |
Yuta HIGUCHI | 89111d9 | 2017-05-04 11:29:17 -0700 | [diff] [blame] | 276 | default boolean lock() throws NetconfException { |
| 277 | return lock(DatastoreId.RUNNING); |
| 278 | } |
andrea | eb70a94 | 2015-10-16 21:34:46 -0700 | [diff] [blame] | 279 | |
| 280 | /** |
helenyrwu | 0407c64 | 2016-06-09 12:01:30 -0700 | [diff] [blame] | 281 | * Unlocks the running configuration. |
andrea | eb70a94 | 2015-10-16 21:34:46 -0700 | [diff] [blame] | 282 | * |
| 283 | * @return true if successful. |
Andrea Campanella | 101417d | 2015-12-11 17:58:07 -0800 | [diff] [blame] | 284 | * @throws NetconfException when there is a problem in the communication process on |
| 285 | * the underlying connection |
andrea | eb70a94 | 2015-10-16 21:34:46 -0700 | [diff] [blame] | 286 | */ |
Yuta HIGUCHI | 89111d9 | 2017-05-04 11:29:17 -0700 | [diff] [blame] | 287 | default boolean unlock() throws NetconfException { |
| 288 | return unlock(DatastoreId.RUNNING); |
| 289 | } |
andrea | eb70a94 | 2015-10-16 21:34:46 -0700 | [diff] [blame] | 290 | |
| 291 | /** |
| 292 | * Closes the Netconf session with the device. |
| 293 | * the first time it tries gracefully, then kills it forcefully |
Andrea Campanella | f4fd035 | 2015-12-14 17:03:05 -0800 | [diff] [blame] | 294 | * |
andrea | eb70a94 | 2015-10-16 21:34:46 -0700 | [diff] [blame] | 295 | * @return true if closed |
Andrea Campanella | 101417d | 2015-12-11 17:58:07 -0800 | [diff] [blame] | 296 | * @throws NetconfException when there is a problem in the communication process on |
| 297 | * the underlying connection |
andrea | eb70a94 | 2015-10-16 21:34:46 -0700 | [diff] [blame] | 298 | */ |
Andrea Campanella | 101417d | 2015-12-11 17:58:07 -0800 | [diff] [blame] | 299 | boolean close() throws NetconfException; |
andrea | eb70a94 | 2015-10-16 21:34:46 -0700 | [diff] [blame] | 300 | |
| 301 | /** |
| 302 | * Gets the session ID of the Netconf session. |
| 303 | * |
| 304 | * @return Session ID as a string. |
| 305 | */ |
| 306 | String getSessionId(); |
| 307 | |
| 308 | /** |
Aaron Kruglikov | 72db642 | 2017-02-13 12:16:51 -0800 | [diff] [blame] | 309 | * Gets the capabilities of the remote Netconf device associated to this |
| 310 | * session. |
| 311 | * |
| 312 | * @return Network capabilities as strings in a Set. |
Aaron Kruglikov | 72db642 | 2017-02-13 12:16:51 -0800 | [diff] [blame] | 313 | * @since 1.10.0 |
Aaron Kruglikov | 72db642 | 2017-02-13 12:16:51 -0800 | [diff] [blame] | 314 | */ |
Yuta HIGUCHI | dd7c3f8 | 2017-09-03 14:18:01 -0700 | [diff] [blame] | 315 | Set<String> getDeviceCapabilitiesSet(); |
andrea | eb70a94 | 2015-10-16 21:34:46 -0700 | [diff] [blame] | 316 | |
Andrea Campanella | 101417d | 2015-12-11 17:58:07 -0800 | [diff] [blame] | 317 | /** |
Andrea Campanella | c362784 | 2017-04-04 18:06:54 +0200 | [diff] [blame] | 318 | * Checks the state of the underlying SSH session and connection |
| 319 | * and if necessary it reestablishes it. |
| 320 | * Should be implemented, providing a default here for retrocompatibility. |
| 321 | * @throws NetconfException when there is a problem in reestablishing |
| 322 | * the connection or the session to the device. |
| 323 | */ |
Andrea Campanella | c362784 | 2017-04-04 18:06:54 +0200 | [diff] [blame] | 324 | default void checkAndReestablish() throws NetconfException { |
| 325 | Logger log = LoggerFactory.getLogger(NetconfSession.class); |
| 326 | log.error("Not implemented/exposed by the underlying session implementation"); |
| 327 | } |
Yuta HIGUCHI | 89111d9 | 2017-05-04 11:29:17 -0700 | [diff] [blame] | 328 | |
Aaron Kruglikov | 72db642 | 2017-02-13 12:16:51 -0800 | [diff] [blame] | 329 | /** |
| 330 | * Sets the ONOS side capabilities. |
| 331 | * |
| 332 | * @param capabilities list of capabilities ONOS has. |
Aaron Kruglikov | 72db642 | 2017-02-13 12:16:51 -0800 | [diff] [blame] | 333 | * @since 1.10.0 |
| 334 | */ |
| 335 | default void setOnosCapabilities(Iterable<String> capabilities) { |
| 336 | // default implementation should be removed in the future |
| 337 | // no-op |
| 338 | } |
Andrea Campanella | c362784 | 2017-04-04 18:06:54 +0200 | [diff] [blame] | 339 | |
| 340 | /** |
Yuta HIGUCHI | 4f55c67 | 2018-06-14 18:10:43 -0700 | [diff] [blame] | 341 | * Add a listener to the underlying stream handler implementation. |
Andrea Campanella | 101417d | 2015-12-11 17:58:07 -0800 | [diff] [blame] | 342 | * |
| 343 | * @param listener event listener. |
| 344 | */ |
| 345 | void addDeviceOutputListener(NetconfDeviceOutputEventListener listener); |
| 346 | |
| 347 | /** |
| 348 | * Remove a listener from the underlying stream handler implementation. |
| 349 | * |
| 350 | * @param listener event listener. |
| 351 | */ |
| 352 | void removeDeviceOutputListener(NetconfDeviceOutputEventListener listener); |
| 353 | |
Sean Condon | 54d8243 | 2017-07-26 22:27:25 +0100 | [diff] [blame] | 354 | /** |
| 355 | * Read the connect timeout that this session was created with. |
| 356 | * @return timeout in seconds |
| 357 | */ |
| 358 | default int timeoutConnectSec() { |
| 359 | return 0; |
Yuta HIGUCHI | 4f55c67 | 2018-06-14 18:10:43 -0700 | [diff] [blame] | 360 | } |
Sean Condon | 54d8243 | 2017-07-26 22:27:25 +0100 | [diff] [blame] | 361 | |
| 362 | /** |
| 363 | * Read the reply timeout that this session was created with. |
| 364 | * @return timeout in seconds |
| 365 | */ |
| 366 | default int timeoutReplySec() { |
| 367 | return 0; |
Yuta HIGUCHI | 4f55c67 | 2018-06-14 18:10:43 -0700 | [diff] [blame] | 368 | } |
Sean Condon | 54d8243 | 2017-07-26 22:27:25 +0100 | [diff] [blame] | 369 | |
| 370 | /** |
| 371 | * Read the idle timeout that this session was created with. |
| 372 | * @return timeout in seconds |
| 373 | */ |
| 374 | default int timeoutIdleSec() { |
| 375 | return 0; |
Yuta HIGUCHI | 4f55c67 | 2018-06-14 18:10:43 -0700 | [diff] [blame] | 376 | } |
Sean Condon | 54d8243 | 2017-07-26 22:27:25 +0100 | [diff] [blame] | 377 | |
andrea | eb70a94 | 2015-10-16 21:34:46 -0700 | [diff] [blame] | 378 | } |