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 | /** |
gyewan.an | 91d7e7e | 2019-01-17 15:12:48 +0900 | [diff] [blame] | 125 | * Executes an synchronous RPC to the server with specific reply TIMEOUT. |
| 126 | * |
| 127 | * @param request the XML containing the RPC for the server. |
| 128 | * @param timeout the reply timeout. |
| 129 | * @return Server response or ERROR |
| 130 | * @throws NetconfException when there is a problem in the communication process on |
| 131 | * the underlying connection |
| 132 | */ |
| 133 | default String requestSync(String request, int timeout) throws NetconfException { |
| 134 | return ""; |
| 135 | } |
| 136 | |
| 137 | /** |
Yuta HIGUCHI | 89111d9 | 2017-05-04 11:29:17 -0700 | [diff] [blame] | 138 | * Retrieves the specified configuration. |
andrea | eb70a94 | 2015-10-16 21:34:46 -0700 | [diff] [blame] | 139 | * |
Andrei Mihaescu | ac542ca | 2017-03-26 21:36:25 +0300 | [diff] [blame] | 140 | * @param netconfTargetConfig the type of configuration to retrieve. |
andrea | eb70a94 | 2015-10-16 21:34:46 -0700 | [diff] [blame] | 141 | * @return specified configuration. |
Andrea Campanella | 101417d | 2015-12-11 17:58:07 -0800 | [diff] [blame] | 142 | * @throws NetconfException when there is a problem in the communication process on |
| 143 | * the underlying connection |
Yuta HIGUCHI | 5ac3443 | 2018-02-13 16:29:15 -0800 | [diff] [blame] | 144 | * |
| 145 | * @deprecated in 1.13.0 use async version instead. |
andrea | eb70a94 | 2015-10-16 21:34:46 -0700 | [diff] [blame] | 146 | */ |
Yuta HIGUCHI | 5ac3443 | 2018-02-13 16:29:15 -0800 | [diff] [blame] | 147 | @Deprecated |
Yuta HIGUCHI | dd7c3f8 | 2017-09-03 14:18:01 -0700 | [diff] [blame] | 148 | String getConfig(DatastoreId netconfTargetConfig) throws NetconfException; |
andrea | eb70a94 | 2015-10-16 21:34:46 -0700 | [diff] [blame] | 149 | |
| 150 | /** |
Yuta HIGUCHI | 89111d9 | 2017-05-04 11:29:17 -0700 | [diff] [blame] | 151 | * Retrieves part of the specified configuration based on the filterSchema. |
| 152 | * |
| 153 | * @param netconfTargetConfig the type of configuration to retrieve. |
| 154 | * @param configurationFilterSchema XML schema to filter the configuration |
| 155 | * elements we are interested in |
| 156 | * @return device running configuration. |
| 157 | * @throws NetconfException when there is a problem in the communication process on |
| 158 | * the underlying connection |
| 159 | */ |
Yuta HIGUCHI | dd7c3f8 | 2017-09-03 14:18:01 -0700 | [diff] [blame] | 160 | String getConfig(DatastoreId netconfTargetConfig, |
Yuta HIGUCHI | 89111d9 | 2017-05-04 11:29:17 -0700 | [diff] [blame] | 161 | String configurationFilterSchema) |
Yuta HIGUCHI | dd7c3f8 | 2017-09-03 14:18:01 -0700 | [diff] [blame] | 162 | throws NetconfException; |
Andrei Mihaescu | ac542ca | 2017-03-26 21:36:25 +0300 | [diff] [blame] | 163 | |
andrea | eb70a94 | 2015-10-16 21:34:46 -0700 | [diff] [blame] | 164 | /** |
Yuta HIGUCHI | 89111d9 | 2017-05-04 11:29:17 -0700 | [diff] [blame] | 165 | * Retrieves part of the specified configuration based on the filterSchema. |
andrea | eb70a94 | 2015-10-16 21:34:46 -0700 | [diff] [blame] | 166 | * |
| 167 | * @param newConfiguration configuration to set |
| 168 | * @return true if the configuration was edited correctly |
Andrea Campanella | 101417d | 2015-12-11 17:58:07 -0800 | [diff] [blame] | 169 | * @throws NetconfException when there is a problem in the communication process on |
| 170 | * the underlying connection |
andrea | eb70a94 | 2015-10-16 21:34:46 -0700 | [diff] [blame] | 171 | */ |
Andrea Campanella | 101417d | 2015-12-11 17:58:07 -0800 | [diff] [blame] | 172 | boolean editConfig(String newConfiguration) throws NetconfException; |
andrea | eb70a94 | 2015-10-16 21:34:46 -0700 | [diff] [blame] | 173 | |
| 174 | /** |
Yuta HIGUCHI | 89111d9 | 2017-05-04 11:29:17 -0700 | [diff] [blame] | 175 | * Retrieves part of the specified configuration based on the filterSchema. |
| 176 | * |
| 177 | * @param netconfTargetConfig the targetConfiguration to change |
Yuta HIGUCHI | e34c9c2 | 2017-12-04 17:47:14 -0800 | [diff] [blame] | 178 | * @param mode default-operation mode |
Yuta HIGUCHI | 89111d9 | 2017-05-04 11:29:17 -0700 | [diff] [blame] | 179 | * @param newConfiguration configuration to set |
| 180 | * @return true if the configuration was edited correctly |
| 181 | * @throws NetconfException when there is a problem in the communication process on |
| 182 | * the underlying connection |
| 183 | */ |
Yuta HIGUCHI | dd7c3f8 | 2017-09-03 14:18:01 -0700 | [diff] [blame] | 184 | boolean editConfig(DatastoreId netconfTargetConfig, String mode, String newConfiguration) |
| 185 | throws NetconfException; |
Yuta HIGUCHI | 89111d9 | 2017-05-04 11:29:17 -0700 | [diff] [blame] | 186 | |
| 187 | /** |
| 188 | * Copies the configuration between configuration datastores. |
| 189 | * <p> |
| 190 | * The target configuration can't be the running one |
| 191 | * |
| 192 | * @param destination configuration datastore |
| 193 | * @param source configuration datastore |
| 194 | * @return true if the configuration was copied correctly |
| 195 | * @throws NetconfException when there is a problem in the communication process on |
| 196 | * the underlying connection |
| 197 | */ |
Yuta HIGUCHI | dd7c3f8 | 2017-09-03 14:18:01 -0700 | [diff] [blame] | 198 | boolean copyConfig(DatastoreId destination, DatastoreId source) |
| 199 | throws NetconfException; |
Yuta HIGUCHI | 89111d9 | 2017-05-04 11:29:17 -0700 | [diff] [blame] | 200 | |
| 201 | /** |
| 202 | * Copies the new configuration, an Url or a complete configuration xml tree |
| 203 | * to the target configuration. |
| 204 | * The target configuration can't be the running one |
| 205 | * |
| 206 | * @param netconfTargetConfig the type of configuration to retrieve. |
| 207 | * @param newConfiguration configuration XML to set or URL tag to the configuration |
| 208 | * @return true if the configuration was copied correctly |
| 209 | * @throws NetconfException when there is a problem in the communication process on |
| 210 | * the underlying connection |
| 211 | */ |
Yuta HIGUCHI | dd7c3f8 | 2017-09-03 14:18:01 -0700 | [diff] [blame] | 212 | boolean copyConfig(DatastoreId netconfTargetConfig, String newConfiguration) |
| 213 | throws NetconfException; |
Andrea Campanella | f4fd035 | 2015-12-14 17:03:05 -0800 | [diff] [blame] | 214 | |
| 215 | /** |
andrea | eb70a94 | 2015-10-16 21:34:46 -0700 | [diff] [blame] | 216 | * Copies the new configuration, an Url or a complete configuration xml tree |
| 217 | * to the target configuration. |
| 218 | * The target configuration can't be the running one |
| 219 | * |
Andrei Mihaescu | ac542ca | 2017-03-26 21:36:25 +0300 | [diff] [blame] | 220 | * @param netconfTargetConfig the type of configuration to retrieve. |
| 221 | * @param newConfiguration configuration to set |
| 222 | * @return true if the configuration was copied correctly |
| 223 | * @throws NetconfException when there is a problem in the communication process on |
| 224 | * the underlying connection |
Andrei Mihaescu | ac542ca | 2017-03-26 21:36:25 +0300 | [diff] [blame] | 225 | */ |
Andrei Mihaescu | ac542ca | 2017-03-26 21:36:25 +0300 | [diff] [blame] | 226 | boolean copyConfig(String netconfTargetConfig, String newConfiguration) |
| 227 | throws NetconfException; |
| 228 | |
| 229 | /** |
Yuta HIGUCHI | 89111d9 | 2017-05-04 11:29:17 -0700 | [diff] [blame] | 230 | * Deletes part of the specified configuration based on the filterSchema. |
| 231 | * |
| 232 | * @param netconfTargetConfig the name of the configuration to delete |
| 233 | * @return true if the configuration was copied correctly |
| 234 | * @throws NetconfException when there is a problem in the communication process on |
| 235 | * the underlying connection |
| 236 | */ |
Yuta HIGUCHI | dd7c3f8 | 2017-09-03 14:18:01 -0700 | [diff] [blame] | 237 | boolean deleteConfig(DatastoreId netconfTargetConfig) throws NetconfException; |
andrea | eb70a94 | 2015-10-16 21:34:46 -0700 | [diff] [blame] | 238 | |
| 239 | /** |
helenyrwu | 0407c64 | 2016-06-09 12:01:30 -0700 | [diff] [blame] | 240 | * Starts subscription to the device's notifications. |
| 241 | * |
| 242 | * @throws NetconfException when there is a problem starting the subscription |
| 243 | */ |
| 244 | void startSubscription() throws NetconfException; |
| 245 | |
| 246 | /** |
Akihiro Yamanouchi | 4512222 | 2016-07-15 13:13:11 +0900 | [diff] [blame] | 247 | * Starts subscription to the device's notifications. |
| 248 | * |
| 249 | * @param filterSchema XML subtrees to indicate specific notification |
| 250 | * @throws NetconfException when there is a problem starting the subscription |
| 251 | */ |
| 252 | @Beta |
| 253 | void startSubscription(String filterSchema) throws NetconfException; |
| 254 | |
| 255 | /** |
helenyrwu | 0407c64 | 2016-06-09 12:01:30 -0700 | [diff] [blame] | 256 | * Ends subscription to the device's notifications. |
| 257 | * |
| 258 | * @throws NetconfException when there is a problem ending the subscription |
| 259 | */ |
| 260 | void endSubscription() throws NetconfException; |
| 261 | |
| 262 | /** |
| 263 | * Locks the specified configuration. |
| 264 | * |
Yuta HIGUCHI | 89111d9 | 2017-05-04 11:29:17 -0700 | [diff] [blame] | 265 | * @param datastore configuration datastore to be locked |
helenyrwu | 0407c64 | 2016-06-09 12:01:30 -0700 | [diff] [blame] | 266 | * @return true if successful. |
| 267 | * @throws NetconfException when there is a problem in the communication process on |
| 268 | * the underlying connection |
| 269 | */ |
Yuta HIGUCHI | dd7c3f8 | 2017-09-03 14:18:01 -0700 | [diff] [blame] | 270 | boolean lock(DatastoreId datastore) throws NetconfException; |
Yuta HIGUCHI | 89111d9 | 2017-05-04 11:29:17 -0700 | [diff] [blame] | 271 | |
| 272 | /** |
| 273 | * Unlocks the specified configuration. |
| 274 | * |
| 275 | * @param datastore configuration datastore to be unlocked |
| 276 | * @return true if successful. |
| 277 | * @throws NetconfException when there is a problem in the communication process on |
| 278 | * the underlying connection |
| 279 | */ |
Yuta HIGUCHI | dd7c3f8 | 2017-09-03 14:18:01 -0700 | [diff] [blame] | 280 | boolean unlock(DatastoreId datastore) throws NetconfException; |
helenyrwu | 0407c64 | 2016-06-09 12:01:30 -0700 | [diff] [blame] | 281 | |
| 282 | /** |
| 283 | * Locks the running configuration. |
andrea | eb70a94 | 2015-10-16 21:34:46 -0700 | [diff] [blame] | 284 | * |
| 285 | * @return true if successful. |
Andrea Campanella | 101417d | 2015-12-11 17:58:07 -0800 | [diff] [blame] | 286 | * @throws NetconfException when there is a problem in the communication process on |
| 287 | * the underlying connection |
andrea | eb70a94 | 2015-10-16 21:34:46 -0700 | [diff] [blame] | 288 | */ |
Yuta HIGUCHI | 89111d9 | 2017-05-04 11:29:17 -0700 | [diff] [blame] | 289 | default boolean lock() throws NetconfException { |
| 290 | return lock(DatastoreId.RUNNING); |
| 291 | } |
andrea | eb70a94 | 2015-10-16 21:34:46 -0700 | [diff] [blame] | 292 | |
| 293 | /** |
helenyrwu | 0407c64 | 2016-06-09 12:01:30 -0700 | [diff] [blame] | 294 | * Unlocks the running configuration. |
andrea | eb70a94 | 2015-10-16 21:34:46 -0700 | [diff] [blame] | 295 | * |
| 296 | * @return true if successful. |
Andrea Campanella | 101417d | 2015-12-11 17:58:07 -0800 | [diff] [blame] | 297 | * @throws NetconfException when there is a problem in the communication process on |
| 298 | * the underlying connection |
andrea | eb70a94 | 2015-10-16 21:34:46 -0700 | [diff] [blame] | 299 | */ |
Yuta HIGUCHI | 89111d9 | 2017-05-04 11:29:17 -0700 | [diff] [blame] | 300 | default boolean unlock() throws NetconfException { |
| 301 | return unlock(DatastoreId.RUNNING); |
| 302 | } |
andrea | eb70a94 | 2015-10-16 21:34:46 -0700 | [diff] [blame] | 303 | |
| 304 | /** |
Andrea Campanella | 3a36145 | 2019-08-02 10:17:53 +0200 | [diff] [blame] | 305 | * Commits the candidate configuration the running configuration. |
| 306 | * |
| 307 | * @return true if successful. |
| 308 | * @throws NetconfException when there is a problem in the communication process on |
| 309 | * the underlying connection |
| 310 | */ |
| 311 | default boolean commit() throws NetconfException { |
| 312 | return false; |
| 313 | } |
| 314 | |
| 315 | /** |
andrea | eb70a94 | 2015-10-16 21:34:46 -0700 | [diff] [blame] | 316 | * Closes the Netconf session with the device. |
| 317 | * the first time it tries gracefully, then kills it forcefully |
Andrea Campanella | f4fd035 | 2015-12-14 17:03:05 -0800 | [diff] [blame] | 318 | * |
andrea | eb70a94 | 2015-10-16 21:34:46 -0700 | [diff] [blame] | 319 | * @return true if closed |
Andrea Campanella | 101417d | 2015-12-11 17:58:07 -0800 | [diff] [blame] | 320 | * @throws NetconfException when there is a problem in the communication process on |
| 321 | * the underlying connection |
andrea | eb70a94 | 2015-10-16 21:34:46 -0700 | [diff] [blame] | 322 | */ |
Andrea Campanella | 101417d | 2015-12-11 17:58:07 -0800 | [diff] [blame] | 323 | boolean close() throws NetconfException; |
andrea | eb70a94 | 2015-10-16 21:34:46 -0700 | [diff] [blame] | 324 | |
| 325 | /** |
| 326 | * Gets the session ID of the Netconf session. |
| 327 | * |
| 328 | * @return Session ID as a string. |
| 329 | */ |
| 330 | String getSessionId(); |
| 331 | |
| 332 | /** |
Aaron Kruglikov | 72db642 | 2017-02-13 12:16:51 -0800 | [diff] [blame] | 333 | * Gets the capabilities of the remote Netconf device associated to this |
| 334 | * session. |
| 335 | * |
| 336 | * @return Network capabilities as strings in a Set. |
Aaron Kruglikov | 72db642 | 2017-02-13 12:16:51 -0800 | [diff] [blame] | 337 | * @since 1.10.0 |
Aaron Kruglikov | 72db642 | 2017-02-13 12:16:51 -0800 | [diff] [blame] | 338 | */ |
Yuta HIGUCHI | dd7c3f8 | 2017-09-03 14:18:01 -0700 | [diff] [blame] | 339 | Set<String> getDeviceCapabilitiesSet(); |
andrea | eb70a94 | 2015-10-16 21:34:46 -0700 | [diff] [blame] | 340 | |
Andrea Campanella | 101417d | 2015-12-11 17:58:07 -0800 | [diff] [blame] | 341 | /** |
Andrea Campanella | c362784 | 2017-04-04 18:06:54 +0200 | [diff] [blame] | 342 | * Checks the state of the underlying SSH session and connection |
| 343 | * and if necessary it reestablishes it. |
| 344 | * Should be implemented, providing a default here for retrocompatibility. |
| 345 | * @throws NetconfException when there is a problem in reestablishing |
| 346 | * the connection or the session to the device. |
| 347 | */ |
Andrea Campanella | c362784 | 2017-04-04 18:06:54 +0200 | [diff] [blame] | 348 | default void checkAndReestablish() throws NetconfException { |
| 349 | Logger log = LoggerFactory.getLogger(NetconfSession.class); |
| 350 | log.error("Not implemented/exposed by the underlying session implementation"); |
| 351 | } |
Yuta HIGUCHI | 89111d9 | 2017-05-04 11:29:17 -0700 | [diff] [blame] | 352 | |
Aaron Kruglikov | 72db642 | 2017-02-13 12:16:51 -0800 | [diff] [blame] | 353 | /** |
| 354 | * Sets the ONOS side capabilities. |
| 355 | * |
| 356 | * @param capabilities list of capabilities ONOS has. |
Aaron Kruglikov | 72db642 | 2017-02-13 12:16:51 -0800 | [diff] [blame] | 357 | * @since 1.10.0 |
| 358 | */ |
| 359 | default void setOnosCapabilities(Iterable<String> capabilities) { |
| 360 | // default implementation should be removed in the future |
| 361 | // no-op |
| 362 | } |
Andrea Campanella | c362784 | 2017-04-04 18:06:54 +0200 | [diff] [blame] | 363 | |
| 364 | /** |
Yuta HIGUCHI | 4f55c67 | 2018-06-14 18:10:43 -0700 | [diff] [blame] | 365 | * Add a listener to the underlying stream handler implementation. |
Andrea Campanella | 101417d | 2015-12-11 17:58:07 -0800 | [diff] [blame] | 366 | * |
| 367 | * @param listener event listener. |
gyewan.an | 91d7e7e | 2019-01-17 15:12:48 +0900 | [diff] [blame] | 368 | * @throws NetconfException when this method will be called by STANDBY or NONE node. |
Andrea Campanella | 101417d | 2015-12-11 17:58:07 -0800 | [diff] [blame] | 369 | */ |
gyewan.an | 91d7e7e | 2019-01-17 15:12:48 +0900 | [diff] [blame] | 370 | void addDeviceOutputListener(NetconfDeviceOutputEventListener listener) throws NetconfException; |
Andrea Campanella | 101417d | 2015-12-11 17:58:07 -0800 | [diff] [blame] | 371 | |
| 372 | /** |
| 373 | * Remove a listener from the underlying stream handler implementation. |
| 374 | * |
| 375 | * @param listener event listener. |
gyewan.an | 91d7e7e | 2019-01-17 15:12:48 +0900 | [diff] [blame] | 376 | * @throws NetconfException when this method will be called by STANDBY or NONE node. |
Andrea Campanella | 101417d | 2015-12-11 17:58:07 -0800 | [diff] [blame] | 377 | */ |
gyewan.an | 91d7e7e | 2019-01-17 15:12:48 +0900 | [diff] [blame] | 378 | void removeDeviceOutputListener(NetconfDeviceOutputEventListener listener) throws NetconfException; |
Andrea Campanella | 101417d | 2015-12-11 17:58:07 -0800 | [diff] [blame] | 379 | |
Sean Condon | 54d8243 | 2017-07-26 22:27:25 +0100 | [diff] [blame] | 380 | /** |
| 381 | * Read the connect timeout that this session was created with. |
| 382 | * @return timeout in seconds |
| 383 | */ |
| 384 | default int timeoutConnectSec() { |
| 385 | return 0; |
Yuta HIGUCHI | 4f55c67 | 2018-06-14 18:10:43 -0700 | [diff] [blame] | 386 | } |
Sean Condon | 54d8243 | 2017-07-26 22:27:25 +0100 | [diff] [blame] | 387 | |
| 388 | /** |
| 389 | * Read the reply timeout that this session was created with. |
| 390 | * @return timeout in seconds |
| 391 | */ |
| 392 | default int timeoutReplySec() { |
| 393 | return 0; |
Yuta HIGUCHI | 4f55c67 | 2018-06-14 18:10:43 -0700 | [diff] [blame] | 394 | } |
Sean Condon | 54d8243 | 2017-07-26 22:27:25 +0100 | [diff] [blame] | 395 | |
| 396 | /** |
| 397 | * Read the idle timeout that this session was created with. |
| 398 | * @return timeout in seconds |
| 399 | */ |
| 400 | default int timeoutIdleSec() { |
| 401 | return 0; |
Yuta HIGUCHI | 4f55c67 | 2018-06-14 18:10:43 -0700 | [diff] [blame] | 402 | } |
Sean Condon | 54d8243 | 2017-07-26 22:27:25 +0100 | [diff] [blame] | 403 | |
andrea | eb70a94 | 2015-10-16 21:34:46 -0700 | [diff] [blame] | 404 | } |