blob: 3e35b5acf3136da7b75f239af278a90a02f061b3 [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
19import java.util.List;
Andrea Campanella101417d2015-12-11 17:58:07 -080020import java.util.concurrent.CompletableFuture;
andreaeb70a942015-10-16 21:34:46 -070021
22/**
23 * NETCONF session object that allows NETCONF operations on top with the physical
24 * device on top of an SSH connection.
25 */
26// TODO change return type of methdos to <Capability, XMLdoc, string or yang obj>
27public interface NetconfSession {
28
29 /**
Andrea Campanella101417d2015-12-11 17:58:07 -080030 * Executes an asynchronous RPC to the server and obtains a future to be completed.
31 *
32 * @param request the XML containing the RPC for the server.
33 * @return Server response or ERROR
34 * @throws NetconfException when there is a problem in the communication process on
35 * the underlying connection
36 */
37 CompletableFuture<String> request(String request) throws NetconfException;
38
39
40 /**
andreaeb70a942015-10-16 21:34:46 -070041 * Retrives the requested configuration, different from get-config.
Andrea Campanellaf4fd0352015-12-14 17:03:05 -080042 *
andreaeb70a942015-10-16 21:34:46 -070043 * @param request the XML containing the request to the server.
44 * @return device running configuration
Andrea Campanella101417d2015-12-11 17:58:07 -080045 * @throws NetconfException when there is a problem in the communication process on
46 * the underlying connection
andreaeb70a942015-10-16 21:34:46 -070047 */
Andrea Campanella101417d2015-12-11 17:58:07 -080048 String get(String request) throws NetconfException;
andreaeb70a942015-10-16 21:34:46 -070049
50 /**
Akihiro Yamanouchi5e5d4df2016-06-08 17:06:33 +090051 * Retrives the requested data.
52 *
53 * @param filterSchema XML subtrees to include in the reply
54 * @param withDefaultsMode with-defaults mode
55 * @return Server response
56 * @throws NetconfException when there is a problem in the communication process on
57 * the underlying connection
58 */
59 String get(String filterSchema, String withDefaultsMode)
60 throws NetconfException;
61
62 /**
Akihiro Yamanouchi8d3a9d32016-07-12 11:41:44 +090063 * Executes an RPC to the server and wrap the request in RPC header.
64 *
65 * @param request the XML containing the request to the server.
66 * @return Server response or ERROR
67 * @throws NetconfException when there is a problem in the communication process on
68 * the underlying connection
69 */
70 String doWrappedRpc(String request) throws NetconfException;
71
72 /**
Andrea Campanella101417d2015-12-11 17:58:07 -080073 * Executes an synchronous RPC to the server.
Andrea Campanellaf4fd0352015-12-14 17:03:05 -080074 *
andreaeb70a942015-10-16 21:34:46 -070075 * @param request the XML containing the RPC for the server.
76 * @return Server response or ERROR
Andrea Campanella101417d2015-12-11 17:58:07 -080077 * @throws NetconfException when there is a problem in the communication process on
78 * the underlying connection
andreaeb70a942015-10-16 21:34:46 -070079 */
Andrea Campanella101417d2015-12-11 17:58:07 -080080 String requestSync(String request) throws NetconfException;
andreaeb70a942015-10-16 21:34:46 -070081
82 /**
83 * Retrives the specified configuration.
84 *
85 * @param targetConfiguration the type of configuration to retrieve.
86 * @return specified configuration.
Andrea Campanella101417d2015-12-11 17:58:07 -080087 * @throws NetconfException when there is a problem in the communication process on
88 * the underlying connection
andreaeb70a942015-10-16 21:34:46 -070089 */
Andrea Campanella101417d2015-12-11 17:58:07 -080090 String getConfig(String targetConfiguration) throws NetconfException;
andreaeb70a942015-10-16 21:34:46 -070091
92 /**
93 * Retrives part of the specivied configuration based on the filterSchema.
94 *
95 * @param targetConfiguration the type of configuration to retrieve.
96 * @param configurationFilterSchema XML schema to filter the configuration
97 * elements we are interested in
98 * @return device running configuration.
Andrea Campanella101417d2015-12-11 17:58:07 -080099 * @throws NetconfException when there is a problem in the communication process on
100 * the underlying connection
andreaeb70a942015-10-16 21:34:46 -0700101 */
Andrea Campanella1cd641b2015-12-07 17:28:34 -0800102 String getConfig(String targetConfiguration, String configurationFilterSchema)
Andrea Campanella101417d2015-12-11 17:58:07 -0800103 throws NetconfException;
andreaeb70a942015-10-16 21:34:46 -0700104
105 /**
106 * Retrives part of the specified configuration based on the filterSchema.
107 *
108 * @param newConfiguration configuration to set
109 * @return true if the configuration was edited correctly
Andrea Campanella101417d2015-12-11 17:58:07 -0800110 * @throws NetconfException when there is a problem in the communication process on
111 * the underlying connection
andreaeb70a942015-10-16 21:34:46 -0700112 */
113
Andrea Campanella101417d2015-12-11 17:58:07 -0800114 boolean editConfig(String newConfiguration) throws NetconfException;
andreaeb70a942015-10-16 21:34:46 -0700115
116 /**
Andrea Campanellaf4fd0352015-12-14 17:03:05 -0800117 * Retrives part of the specified configuration based on the filterSchema.
Andrea Campanella101417d2015-12-11 17:58:07 -0800118 *
Andrea Campanellaf4fd0352015-12-14 17:03:05 -0800119 * @param targetConfiguration the targetConfiguration to change
Andrea Campanella101417d2015-12-11 17:58:07 -0800120 * @param mode selected mode to change the configuration
121 * @param newConfiguration configuration to set
Andrea Campanellaf4fd0352015-12-14 17:03:05 -0800122 * @return true if the configuration was edited correctly
Andrea Campanella101417d2015-12-11 17:58:07 -0800123 * @throws NetconfException when there is a problem in the communication process on
124 * the underlying connection
Andrea Campanellaf4fd0352015-12-14 17:03:05 -0800125 */
126 boolean editConfig(String targetConfiguration, String mode, String newConfiguration)
Andrea Campanella101417d2015-12-11 17:58:07 -0800127 throws NetconfException;
Andrea Campanellaf4fd0352015-12-14 17:03:05 -0800128
129 /**
andreaeb70a942015-10-16 21:34:46 -0700130 * Copies the new configuration, an Url or a complete configuration xml tree
131 * to the target configuration.
132 * The target configuration can't be the running one
133 *
134 * @param targetConfiguration the type of configuration to retrieve.
135 * @param newConfiguration configuration to set
136 * @return true if the configuration was copied correctly
Andrea Campanella101417d2015-12-11 17:58:07 -0800137 * @throws NetconfException when there is a problem in the communication process on
138 * the underlying connection
andreaeb70a942015-10-16 21:34:46 -0700139 */
Andrea Campanella1cd641b2015-12-07 17:28:34 -0800140 boolean copyConfig(String targetConfiguration, String newConfiguration)
Andrea Campanella101417d2015-12-11 17:58:07 -0800141 throws NetconfException;
andreaeb70a942015-10-16 21:34:46 -0700142
143 /**
144 * Deletes part of the specified configuration based on the filterSchema.
145 *
146 * @param targetConfiguration the name of the configuration to delete
147 * @return true if the configuration was copied 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 */
Andrea Campanella101417d2015-12-11 17:58:07 -0800151 boolean deleteConfig(String targetConfiguration) throws NetconfException;
andreaeb70a942015-10-16 21:34:46 -0700152
153 /**
helenyrwu0407c642016-06-09 12:01:30 -0700154 * Starts subscription to the device's notifications.
155 *
156 * @throws NetconfException when there is a problem starting the subscription
157 */
158 void startSubscription() throws NetconfException;
159
160 /**
161 * Ends subscription to the device's notifications.
162 *
163 * @throws NetconfException when there is a problem ending the subscription
164 */
165 void endSubscription() throws NetconfException;
166
167 /**
168 * Locks the specified configuration.
169 *
170 * @param configType type of configuration to be locked
171 * @return true if successful.
172 * @throws NetconfException when there is a problem in the communication process on
173 * the underlying connection
174 */
175 boolean lock(String configType) throws NetconfException;
176
177 /**
178 * Unlocks the specified configuration.
179 *
180 * @param configType type of configuration to be locked
181 * @return true if successful.
182 * @throws NetconfException when there is a problem in the communication process on
183 * the underlying connection
184 */
185 boolean unlock(String configType) throws NetconfException;
186
187 /**
188 * Locks the running configuration.
andreaeb70a942015-10-16 21:34:46 -0700189 *
190 * @return true if successful.
Andrea Campanella101417d2015-12-11 17:58:07 -0800191 * @throws NetconfException when there is a problem in the communication process on
192 * the underlying connection
andreaeb70a942015-10-16 21:34:46 -0700193 */
Andrea Campanella101417d2015-12-11 17:58:07 -0800194 boolean lock() throws NetconfException;
andreaeb70a942015-10-16 21:34:46 -0700195
196 /**
helenyrwu0407c642016-06-09 12:01:30 -0700197 * Unlocks the running configuration.
andreaeb70a942015-10-16 21:34:46 -0700198 *
199 * @return true if successful.
Andrea Campanella101417d2015-12-11 17:58:07 -0800200 * @throws NetconfException when there is a problem in the communication process on
201 * the underlying connection
andreaeb70a942015-10-16 21:34:46 -0700202 */
Andrea Campanella101417d2015-12-11 17:58:07 -0800203 boolean unlock() throws NetconfException;
andreaeb70a942015-10-16 21:34:46 -0700204
205 /**
206 * Closes the Netconf session with the device.
207 * the first time it tries gracefully, then kills it forcefully
Andrea Campanellaf4fd0352015-12-14 17:03:05 -0800208 *
andreaeb70a942015-10-16 21:34:46 -0700209 * @return true if closed
Andrea Campanella101417d2015-12-11 17:58:07 -0800210 * @throws NetconfException when there is a problem in the communication process on
211 * the underlying connection
andreaeb70a942015-10-16 21:34:46 -0700212 */
Andrea Campanella101417d2015-12-11 17:58:07 -0800213 boolean close() throws NetconfException;
andreaeb70a942015-10-16 21:34:46 -0700214
215 /**
216 * Gets the session ID of the Netconf session.
217 *
218 * @return Session ID as a string.
219 */
220 String getSessionId();
221
222 /**
223 * Gets the capabilities of the Netconf server associated to this session.
224 *
225 * @return Network capabilities as a string.
226 */
227 String getServerCapabilities();
228
229 /**
Andrea Campanella101417d2015-12-11 17:58:07 -0800230 * Sets the ONOS side capabilities.
Andrea Campanellaf4fd0352015-12-14 17:03:05 -0800231 *
andreaeb70a942015-10-16 21:34:46 -0700232 * @param capabilities list of capabilities the device has.
233 */
234 void setDeviceCapabilities(List<String> capabilities);
235
Andrea Campanella101417d2015-12-11 17:58:07 -0800236 /**
237 * Remove a listener from the underlying stream handler implementation.
238 *
239 * @param listener event listener.
240 */
241 void addDeviceOutputListener(NetconfDeviceOutputEventListener listener);
242
243 /**
244 * Remove a listener from the underlying stream handler implementation.
245 *
246 * @param listener event listener.
247 */
248 void removeDeviceOutputListener(NetconfDeviceOutputEventListener listener);
249
andreaeb70a942015-10-16 21:34:46 -0700250}