blob: e2d435d7a5c3da9d8a047e387f254f837ccb7ba5 [file] [log] [blame]
andreaeb70a942015-10-16 21:34:46 -07001/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2015-present Open Networking Laboratory
andreaeb70a942015-10-16 21:34:46 -07003 *
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
17package org.onosproject.netconf;
18
Akihiro Yamanouchi45122222016-07-15 13:13:11 +090019import com.google.common.annotations.Beta;
Andrei Mihaescuac542ca2017-03-26 21:36:25 +030020
andreaeb70a942015-10-16 21:34:46 -070021import java.util.List;
Andrea Campanella101417d2015-12-11 17:58:07 -080022import java.util.concurrent.CompletableFuture;
andreaeb70a942015-10-16 21:34:46 -070023
24/**
25 * NETCONF session object that allows NETCONF operations on top with the physical
26 * device on top of an SSH connection.
27 */
Sean Condond2c8d472017-02-17 17:09:39 +000028// TODO change return type of methods to <Capability, XMLdoc, string or yang obj>
andreaeb70a942015-10-16 21:34:46 -070029public interface NetconfSession {
30
31 /**
Andrea Campanella101417d2015-12-11 17:58:07 -080032 * Executes an asynchronous RPC to the server and obtains a future to be completed.
33 *
Sean Condond2c8d472017-02-17 17:09:39 +000034 * The caller must ensure that the message-id in any request is unique
35 * for the session
36 *
37 * @deprecated - 1.10.0 do not remove needs reworking
Andrea Campanella101417d2015-12-11 17:58:07 -080038 * @param request the XML containing the RPC for the server.
39 * @return Server response or ERROR
40 * @throws NetconfException when there is a problem in the communication process on
41 * the underlying connection
42 */
Sean Condond2c8d472017-02-17 17:09:39 +000043 @Deprecated
Andrea Campanella101417d2015-12-11 17:58:07 -080044 CompletableFuture<String> request(String request) throws NetconfException;
45
46
47 /**
Sean Condond2c8d472017-02-17 17:09:39 +000048 * Retrieves the requested configuration, different from get-config.
Andrea Campanellaf4fd0352015-12-14 17:03:05 -080049 *
andreaeb70a942015-10-16 21:34:46 -070050 * @param request the XML containing the request to the server.
51 * @return device running configuration
Andrea Campanella101417d2015-12-11 17:58:07 -080052 * @throws NetconfException when there is a problem in the communication process on
53 * the underlying connection
andreaeb70a942015-10-16 21:34:46 -070054 */
Andrea Campanella101417d2015-12-11 17:58:07 -080055 String get(String request) throws NetconfException;
andreaeb70a942015-10-16 21:34:46 -070056
57 /**
Sean Condond2c8d472017-02-17 17:09:39 +000058 * Retrieves the requested data.
Akihiro Yamanouchi5e5d4df2016-06-08 17:06:33 +090059 *
60 * @param filterSchema XML subtrees to include in the reply
61 * @param withDefaultsMode with-defaults mode
62 * @return Server response
63 * @throws NetconfException when there is a problem in the communication process on
64 * the underlying connection
65 */
66 String get(String filterSchema, String withDefaultsMode)
67 throws NetconfException;
68
69 /**
Akihiro Yamanouchi45122222016-07-15 13:13:11 +090070 * Executes an synchronous RPC to the server and wrap the request in RPC header.
Akihiro Yamanouchi8d3a9d32016-07-12 11:41:44 +090071 *
72 * @param request the XML containing the request to the server.
73 * @return Server response or ERROR
74 * @throws NetconfException when there is a problem in the communication process on
75 * the underlying connection
76 */
77 String doWrappedRpc(String request) throws NetconfException;
78
79 /**
Andrea Campanella101417d2015-12-11 17:58:07 -080080 * Executes an synchronous RPC to the server.
Andrea Campanellaf4fd0352015-12-14 17:03:05 -080081 *
andreaeb70a942015-10-16 21:34:46 -070082 * @param request the XML containing the RPC for the server.
83 * @return Server response or ERROR
Andrea Campanella101417d2015-12-11 17:58:07 -080084 * @throws NetconfException when there is a problem in the communication process on
85 * the underlying connection
andreaeb70a942015-10-16 21:34:46 -070086 */
Andrea Campanella101417d2015-12-11 17:58:07 -080087 String requestSync(String request) throws NetconfException;
andreaeb70a942015-10-16 21:34:46 -070088
89 /**
90 * Retrives the specified configuration.
91 *
Andrei Mihaescuac542ca2017-03-26 21:36:25 +030092 * @param netconfTargetConfig the type of configuration to retrieve.
andreaeb70a942015-10-16 21:34:46 -070093 * @return specified configuration.
Andrea Campanella101417d2015-12-11 17:58:07 -080094 * @throws NetconfException when there is a problem in the communication process on
95 * the underlying connection
andreaeb70a942015-10-16 21:34:46 -070096 */
Andrei Mihaescuac542ca2017-03-26 21:36:25 +030097 String getConfig(TargetConfig netconfTargetConfig) throws NetconfException;
98
99 /**
100 * Retrives the specified configuration.
101 *
102 * @param netconfTargetConfig the type of configuration to retrieve.
103 * @return specified configuration.
104 * @throws NetconfException when there is a problem in the communication process on
105 * the underlying connection
106 * @deprecated - 1.10.0 Kingfisher use method overload that accepts
107 * org.onosproject.netconf.TargetConfig enum parameter instead
108 */
109 @Deprecated
110 String getConfig(String netconfTargetConfig) throws NetconfException;
111
andreaeb70a942015-10-16 21:34:46 -0700112
113 /**
114 * Retrives part of the specivied configuration based on the filterSchema.
115 *
Andrei Mihaescuac542ca2017-03-26 21:36:25 +0300116 * @param netconfTargetConfig the type of configuration to retrieve.
117 * @param configurationFilterSchema XML schema to filter the configuration
118 * elements we are interested in
119 * @return device running configuration.
120 * @throws NetconfException when there is a problem in the communication process on
121 * the underlying connection
122 * @deprecated - 1.10.0 Kingfisher use method overload that accepts
123 * org.onosproject.netconf.TargetConfig enum parameter instead
124 */
125 @Deprecated
126 String getConfig(String netconfTargetConfig, String configurationFilterSchema)
127 throws NetconfException;
128
129 /**
130 * Retrives part of the specivied configuration based on the filterSchema.
131 *
132 * @param netconfTargetConfig the type of configuration to retrieve.
andreaeb70a942015-10-16 21:34:46 -0700133 * @param configurationFilterSchema XML schema to filter the configuration
134 * elements we are interested in
135 * @return device running configuration.
Andrea Campanella101417d2015-12-11 17:58:07 -0800136 * @throws NetconfException when there is a problem in the communication process on
137 * the underlying connection
andreaeb70a942015-10-16 21:34:46 -0700138 */
Andrei Mihaescuac542ca2017-03-26 21:36:25 +0300139 String getConfig(TargetConfig netconfTargetConfig, String configurationFilterSchema)
Andrea Campanella101417d2015-12-11 17:58:07 -0800140 throws NetconfException;
andreaeb70a942015-10-16 21:34:46 -0700141
Andrei Mihaescuac542ca2017-03-26 21:36:25 +0300142
andreaeb70a942015-10-16 21:34:46 -0700143 /**
144 * Retrives part of the specified configuration based on the filterSchema.
145 *
146 * @param newConfiguration configuration to set
147 * @return true if the configuration was edited correctly
Andrea Campanella101417d2015-12-11 17:58:07 -0800148 * @throws NetconfException when there is a problem in the communication process on
149 * the underlying connection
andreaeb70a942015-10-16 21:34:46 -0700150 */
151
Andrea Campanella101417d2015-12-11 17:58:07 -0800152 boolean editConfig(String newConfiguration) throws NetconfException;
andreaeb70a942015-10-16 21:34:46 -0700153
154 /**
Andrea Campanellaf4fd0352015-12-14 17:03:05 -0800155 * Retrives part of the specified configuration based on the filterSchema.
Andrea Campanella101417d2015-12-11 17:58:07 -0800156 *
Andrei Mihaescuac542ca2017-03-26 21:36:25 +0300157 * @param netconfTargetConfig the targetConfiguration to change
158 * @param mode selected mode to change the configuration
159 * @param newConfiguration configuration to set
160 * @return true if the configuration was edited correctly
161 * @throws NetconfException when there is a problem in the communication process on
162 * the underlying connection
163 * @deprecated - 1.10.0 Kingfisher use method overload that accepts
164 * org.onosproject.netconf.TargetConfig enum parameter instead
165 */
166 @Deprecated
167 boolean editConfig(String netconfTargetConfig, String mode, String newConfiguration)
168 throws NetconfException;
169
170 /**
171 * Retrives part of the specified configuration based on the filterSchema.
172 *
173 * @param netconfTargetConfig the targetConfiguration to change
Andrea Campanella101417d2015-12-11 17:58:07 -0800174 * @param mode selected mode to change the configuration
175 * @param newConfiguration configuration to set
Andrea Campanellaf4fd0352015-12-14 17:03:05 -0800176 * @return true if the configuration was edited correctly
Andrea Campanella101417d2015-12-11 17:58:07 -0800177 * @throws NetconfException when there is a problem in the communication process on
178 * the underlying connection
Andrea Campanellaf4fd0352015-12-14 17:03:05 -0800179 */
Andrei Mihaescuac542ca2017-03-26 21:36:25 +0300180 boolean editConfig(TargetConfig netconfTargetConfig, String mode, String newConfiguration)
Andrea Campanella101417d2015-12-11 17:58:07 -0800181 throws NetconfException;
Andrea Campanellaf4fd0352015-12-14 17:03:05 -0800182
183 /**
andreaeb70a942015-10-16 21:34:46 -0700184 * Copies the new configuration, an Url or a complete configuration xml tree
185 * to the target configuration.
186 * The target configuration can't be the running one
187 *
Andrei Mihaescuac542ca2017-03-26 21:36:25 +0300188 * @param netconfTargetConfig the type of configuration to retrieve.
189 * @param newConfiguration configuration to set
190 * @return true if the configuration was copied correctly
191 * @throws NetconfException when there is a problem in the communication process on
192 * the underlying connection
193 * @deprecated - 1.10.0 Kingfisher use method overload that accepts
194 * org.onosproject.netconf.TargetConfig enum parameter instead
195 */
196 @Deprecated
197 boolean copyConfig(String netconfTargetConfig, String newConfiguration)
198 throws NetconfException;
199
200 /**
201 * Copies the new configuration, an Url or a complete configuration xml tree
202 * to the target configuration.
203 * The target configuration can't be the running one
204 *
205 * @param netconfTargetConfig the type of configuration to retrieve.
andreaeb70a942015-10-16 21:34:46 -0700206 * @param newConfiguration configuration to set
207 * @return true if the configuration was copied correctly
Andrea Campanella101417d2015-12-11 17:58:07 -0800208 * @throws NetconfException when there is a problem in the communication process on
209 * the underlying connection
andreaeb70a942015-10-16 21:34:46 -0700210 */
Andrei Mihaescuac542ca2017-03-26 21:36:25 +0300211 boolean copyConfig(TargetConfig netconfTargetConfig, String newConfiguration)
Andrea Campanella101417d2015-12-11 17:58:07 -0800212 throws NetconfException;
andreaeb70a942015-10-16 21:34:46 -0700213
214 /**
215 * Deletes part of the specified configuration based on the filterSchema.
216 *
Andrei Mihaescuac542ca2017-03-26 21:36:25 +0300217 * @param netconfTargetConfig the name of the configuration to delete
218 * @return true if the configuration was copied correctly
219 * @throws NetconfException when there is a problem in the communication process on
220 * the underlying connection
221 * @deprecated - 1.10.0 Kingfisher use method overload that accepts
222 * org.onosproject.netconf.TargetConfig enum parameter instead
223 */
224 @Deprecated
225 boolean deleteConfig(String netconfTargetConfig) throws NetconfException;
226
227 /**
228 * Deletes part of the specified configuration based on the filterSchema.
229 *
230 * @param netconfTargetConfig the name of the configuration to delete
andreaeb70a942015-10-16 21:34:46 -0700231 * @return true if the configuration was copied correctly
Andrea Campanella101417d2015-12-11 17:58:07 -0800232 * @throws NetconfException when there is a problem in the communication process on
233 * the underlying connection
andreaeb70a942015-10-16 21:34:46 -0700234 */
Andrei Mihaescuac542ca2017-03-26 21:36:25 +0300235 boolean deleteConfig(TargetConfig netconfTargetConfig) throws NetconfException;
andreaeb70a942015-10-16 21:34:46 -0700236
237 /**
helenyrwu0407c642016-06-09 12:01:30 -0700238 * Starts subscription to the device's notifications.
239 *
240 * @throws NetconfException when there is a problem starting the subscription
241 */
242 void startSubscription() throws NetconfException;
243
244 /**
Akihiro Yamanouchi45122222016-07-15 13:13:11 +0900245 * Starts subscription to the device's notifications.
246 *
247 * @param filterSchema XML subtrees to indicate specific notification
248 * @throws NetconfException when there is a problem starting the subscription
249 */
250 @Beta
251 void startSubscription(String filterSchema) throws NetconfException;
252
253 /**
helenyrwu0407c642016-06-09 12:01:30 -0700254 * Ends subscription to the device's notifications.
255 *
256 * @throws NetconfException when there is a problem ending the subscription
257 */
258 void endSubscription() throws NetconfException;
259
260 /**
261 * Locks the specified configuration.
262 *
263 * @param configType type of configuration to be locked
264 * @return true if successful.
265 * @throws NetconfException when there is a problem in the communication process on
266 * the underlying connection
267 */
268 boolean lock(String configType) throws NetconfException;
269
270 /**
271 * Unlocks the specified configuration.
272 *
273 * @param configType type of configuration to be locked
274 * @return true if successful.
275 * @throws NetconfException when there is a problem in the communication process on
276 * the underlying connection
277 */
278 boolean unlock(String configType) throws NetconfException;
279
280 /**
281 * Locks the running configuration.
andreaeb70a942015-10-16 21:34:46 -0700282 *
283 * @return true if successful.
Andrea Campanella101417d2015-12-11 17:58:07 -0800284 * @throws NetconfException when there is a problem in the communication process on
285 * the underlying connection
andreaeb70a942015-10-16 21:34:46 -0700286 */
Andrea Campanella101417d2015-12-11 17:58:07 -0800287 boolean lock() throws NetconfException;
andreaeb70a942015-10-16 21:34:46 -0700288
289 /**
helenyrwu0407c642016-06-09 12:01:30 -0700290 * Unlocks the running configuration.
andreaeb70a942015-10-16 21:34:46 -0700291 *
292 * @return true if successful.
Andrea Campanella101417d2015-12-11 17:58:07 -0800293 * @throws NetconfException when there is a problem in the communication process on
294 * the underlying connection
andreaeb70a942015-10-16 21:34:46 -0700295 */
Andrea Campanella101417d2015-12-11 17:58:07 -0800296 boolean unlock() throws NetconfException;
andreaeb70a942015-10-16 21:34:46 -0700297
298 /**
299 * Closes the Netconf session with the device.
300 * the first time it tries gracefully, then kills it forcefully
Andrea Campanellaf4fd0352015-12-14 17:03:05 -0800301 *
andreaeb70a942015-10-16 21:34:46 -0700302 * @return true if closed
Andrea Campanella101417d2015-12-11 17:58:07 -0800303 * @throws NetconfException when there is a problem in the communication process on
304 * the underlying connection
andreaeb70a942015-10-16 21:34:46 -0700305 */
Andrea Campanella101417d2015-12-11 17:58:07 -0800306 boolean close() throws NetconfException;
andreaeb70a942015-10-16 21:34:46 -0700307
308 /**
309 * Gets the session ID of the Netconf session.
310 *
311 * @return Session ID as a string.
312 */
313 String getSessionId();
314
315 /**
316 * Gets the capabilities of the Netconf server associated to this session.
317 *
318 * @return Network capabilities as a string.
319 */
320 String getServerCapabilities();
321
322 /**
Andrea Campanella101417d2015-12-11 17:58:07 -0800323 * Sets the ONOS side capabilities.
Andrea Campanellaf4fd0352015-12-14 17:03:05 -0800324 *
andreaeb70a942015-10-16 21:34:46 -0700325 * @param capabilities list of capabilities the device has.
326 */
327 void setDeviceCapabilities(List<String> capabilities);
328
Andrea Campanella101417d2015-12-11 17:58:07 -0800329 /**
330 * Remove a listener from the underlying stream handler implementation.
331 *
332 * @param listener event listener.
333 */
334 void addDeviceOutputListener(NetconfDeviceOutputEventListener listener);
335
336 /**
337 * Remove a listener from the underlying stream handler implementation.
338 *
339 * @param listener event listener.
340 */
341 void removeDeviceOutputListener(NetconfDeviceOutputEventListener listener);
342
andreaeb70a942015-10-16 21:34:46 -0700343}