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