blob: 172d53cba5947056def557a59f0578e34e5e2132 [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;
andreaeb70a942015-10-16 21:34:46 -070020import java.util.List;
Andrea Campanella101417d2015-12-11 17:58:07 -080021import java.util.concurrent.CompletableFuture;
andreaeb70a942015-10-16 21:34:46 -070022
23/**
24 * NETCONF session object that allows NETCONF operations on top with the physical
25 * device on top of an SSH connection.
26 */
Sean Condond2c8d472017-02-17 17:09:39 +000027// TODO change return type of methods to <Capability, XMLdoc, string or yang obj>
andreaeb70a942015-10-16 21:34:46 -070028public interface NetconfSession {
29
30 /**
Andrea Campanella101417d2015-12-11 17:58:07 -080031 * Executes an asynchronous RPC to the server and obtains a future to be completed.
32 *
Sean Condond2c8d472017-02-17 17:09:39 +000033 * The caller must ensure that the message-id in any request is unique
34 * for the session
35 *
36 * @deprecated - 1.10.0 do not remove needs reworking
Andrea Campanella101417d2015-12-11 17:58:07 -080037 * @param request the XML containing the RPC for the server.
38 * @return Server response or ERROR
39 * @throws NetconfException when there is a problem in the communication process on
40 * the underlying connection
41 */
Sean Condond2c8d472017-02-17 17:09:39 +000042 @Deprecated
Andrea Campanella101417d2015-12-11 17:58:07 -080043 CompletableFuture<String> request(String request) throws NetconfException;
44
45
46 /**
Sean Condond2c8d472017-02-17 17:09:39 +000047 * Retrieves the requested configuration, different from get-config.
Andrea Campanellaf4fd0352015-12-14 17:03:05 -080048 *
andreaeb70a942015-10-16 21:34:46 -070049 * @param request the XML containing the request to the server.
50 * @return device running configuration
Andrea Campanella101417d2015-12-11 17:58:07 -080051 * @throws NetconfException when there is a problem in the communication process on
52 * the underlying connection
andreaeb70a942015-10-16 21:34:46 -070053 */
Andrea Campanella101417d2015-12-11 17:58:07 -080054 String get(String request) throws NetconfException;
andreaeb70a942015-10-16 21:34:46 -070055
56 /**
Sean Condond2c8d472017-02-17 17:09:39 +000057 * Retrieves the requested data.
Akihiro Yamanouchi5e5d4df2016-06-08 17:06:33 +090058 *
59 * @param filterSchema XML subtrees to include in the reply
60 * @param withDefaultsMode with-defaults mode
61 * @return Server response
62 * @throws NetconfException when there is a problem in the communication process on
63 * the underlying connection
64 */
65 String get(String filterSchema, String withDefaultsMode)
66 throws NetconfException;
67
68 /**
Akihiro Yamanouchi45122222016-07-15 13:13:11 +090069 * Executes an synchronous RPC to the server and wrap the request in RPC header.
Akihiro Yamanouchi8d3a9d32016-07-12 11:41:44 +090070 *
71 * @param request the XML containing the request to the server.
72 * @return Server response or ERROR
73 * @throws NetconfException when there is a problem in the communication process on
74 * the underlying connection
75 */
76 String doWrappedRpc(String request) throws NetconfException;
77
78 /**
Andrea Campanella101417d2015-12-11 17:58:07 -080079 * Executes an synchronous RPC to the server.
Andrea Campanellaf4fd0352015-12-14 17:03:05 -080080 *
andreaeb70a942015-10-16 21:34:46 -070081 * @param request the XML containing the RPC for the server.
82 * @return Server response or ERROR
Andrea Campanella101417d2015-12-11 17:58:07 -080083 * @throws NetconfException when there is a problem in the communication process on
84 * the underlying connection
andreaeb70a942015-10-16 21:34:46 -070085 */
Andrea Campanella101417d2015-12-11 17:58:07 -080086 String requestSync(String request) throws NetconfException;
andreaeb70a942015-10-16 21:34:46 -070087
88 /**
89 * Retrives the specified configuration.
90 *
91 * @param targetConfiguration the type of configuration to retrieve.
92 * @return specified configuration.
Andrea Campanella101417d2015-12-11 17:58:07 -080093 * @throws NetconfException when there is a problem in the communication process on
94 * the underlying connection
andreaeb70a942015-10-16 21:34:46 -070095 */
Andrea Campanella101417d2015-12-11 17:58:07 -080096 String getConfig(String targetConfiguration) throws NetconfException;
andreaeb70a942015-10-16 21:34:46 -070097
98 /**
99 * Retrives part of the specivied configuration based on the filterSchema.
100 *
101 * @param targetConfiguration the type of configuration to retrieve.
102 * @param configurationFilterSchema XML schema to filter the configuration
103 * elements we are interested in
104 * @return device running configuration.
Andrea Campanella101417d2015-12-11 17:58:07 -0800105 * @throws NetconfException when there is a problem in the communication process on
106 * the underlying connection
andreaeb70a942015-10-16 21:34:46 -0700107 */
Andrea Campanella1cd641b2015-12-07 17:28:34 -0800108 String getConfig(String targetConfiguration, String configurationFilterSchema)
Andrea Campanella101417d2015-12-11 17:58:07 -0800109 throws NetconfException;
andreaeb70a942015-10-16 21:34:46 -0700110
111 /**
112 * Retrives part of the specified configuration based on the filterSchema.
113 *
114 * @param newConfiguration configuration to set
115 * @return true if the configuration was edited correctly
Andrea Campanella101417d2015-12-11 17:58:07 -0800116 * @throws NetconfException when there is a problem in the communication process on
117 * the underlying connection
andreaeb70a942015-10-16 21:34:46 -0700118 */
119
Andrea Campanella101417d2015-12-11 17:58:07 -0800120 boolean editConfig(String newConfiguration) throws NetconfException;
andreaeb70a942015-10-16 21:34:46 -0700121
122 /**
Andrea Campanellaf4fd0352015-12-14 17:03:05 -0800123 * Retrives part of the specified configuration based on the filterSchema.
Andrea Campanella101417d2015-12-11 17:58:07 -0800124 *
Andrea Campanellaf4fd0352015-12-14 17:03:05 -0800125 * @param targetConfiguration the targetConfiguration to change
Andrea Campanella101417d2015-12-11 17:58:07 -0800126 * @param mode selected mode to change the configuration
127 * @param newConfiguration configuration to set
Andrea Campanellaf4fd0352015-12-14 17:03:05 -0800128 * @return true if the configuration was edited correctly
Andrea Campanella101417d2015-12-11 17:58:07 -0800129 * @throws NetconfException when there is a problem in the communication process on
130 * the underlying connection
Andrea Campanellaf4fd0352015-12-14 17:03:05 -0800131 */
132 boolean editConfig(String targetConfiguration, String mode, String newConfiguration)
Andrea Campanella101417d2015-12-11 17:58:07 -0800133 throws NetconfException;
Andrea Campanellaf4fd0352015-12-14 17:03:05 -0800134
135 /**
andreaeb70a942015-10-16 21:34:46 -0700136 * Copies the new configuration, an Url or a complete configuration xml tree
137 * to the target configuration.
138 * The target configuration can't be the running one
139 *
140 * @param targetConfiguration the type of configuration to retrieve.
141 * @param newConfiguration configuration to set
142 * @return true if the configuration was copied correctly
Andrea Campanella101417d2015-12-11 17:58:07 -0800143 * @throws NetconfException when there is a problem in the communication process on
144 * the underlying connection
andreaeb70a942015-10-16 21:34:46 -0700145 */
Andrea Campanella1cd641b2015-12-07 17:28:34 -0800146 boolean copyConfig(String targetConfiguration, String newConfiguration)
Andrea Campanella101417d2015-12-11 17:58:07 -0800147 throws NetconfException;
andreaeb70a942015-10-16 21:34:46 -0700148
149 /**
150 * Deletes part of the specified configuration based on the filterSchema.
151 *
152 * @param targetConfiguration the name of the configuration to delete
153 * @return true if the configuration was copied correctly
Andrea Campanella101417d2015-12-11 17:58:07 -0800154 * @throws NetconfException when there is a problem in the communication process on
155 * the underlying connection
andreaeb70a942015-10-16 21:34:46 -0700156 */
Andrea Campanella101417d2015-12-11 17:58:07 -0800157 boolean deleteConfig(String targetConfiguration) throws NetconfException;
andreaeb70a942015-10-16 21:34:46 -0700158
159 /**
helenyrwu0407c642016-06-09 12:01:30 -0700160 * Starts subscription to the device's notifications.
161 *
162 * @throws NetconfException when there is a problem starting the subscription
163 */
164 void startSubscription() throws NetconfException;
165
166 /**
Akihiro Yamanouchi45122222016-07-15 13:13:11 +0900167 * Starts subscription to the device's notifications.
168 *
169 * @param filterSchema XML subtrees to indicate specific notification
170 * @throws NetconfException when there is a problem starting the subscription
171 */
172 @Beta
173 void startSubscription(String filterSchema) throws NetconfException;
174
175 /**
helenyrwu0407c642016-06-09 12:01:30 -0700176 * Ends subscription to the device's notifications.
177 *
178 * @throws NetconfException when there is a problem ending the subscription
179 */
180 void endSubscription() throws NetconfException;
181
182 /**
183 * Locks the specified configuration.
184 *
185 * @param configType type of configuration to be locked
186 * @return true if successful.
187 * @throws NetconfException when there is a problem in the communication process on
188 * the underlying connection
189 */
190 boolean lock(String configType) throws NetconfException;
191
192 /**
193 * Unlocks the specified configuration.
194 *
195 * @param configType type of configuration to be locked
196 * @return true if successful.
197 * @throws NetconfException when there is a problem in the communication process on
198 * the underlying connection
199 */
200 boolean unlock(String configType) throws NetconfException;
201
202 /**
203 * Locks the running configuration.
andreaeb70a942015-10-16 21:34:46 -0700204 *
205 * @return true if successful.
Andrea Campanella101417d2015-12-11 17:58:07 -0800206 * @throws NetconfException when there is a problem in the communication process on
207 * the underlying connection
andreaeb70a942015-10-16 21:34:46 -0700208 */
Andrea Campanella101417d2015-12-11 17:58:07 -0800209 boolean lock() throws NetconfException;
andreaeb70a942015-10-16 21:34:46 -0700210
211 /**
helenyrwu0407c642016-06-09 12:01:30 -0700212 * Unlocks the running configuration.
andreaeb70a942015-10-16 21:34:46 -0700213 *
214 * @return true if successful.
Andrea Campanella101417d2015-12-11 17:58:07 -0800215 * @throws NetconfException when there is a problem in the communication process on
216 * the underlying connection
andreaeb70a942015-10-16 21:34:46 -0700217 */
Andrea Campanella101417d2015-12-11 17:58:07 -0800218 boolean unlock() throws NetconfException;
andreaeb70a942015-10-16 21:34:46 -0700219
220 /**
221 * Closes the Netconf session with the device.
222 * the first time it tries gracefully, then kills it forcefully
Andrea Campanellaf4fd0352015-12-14 17:03:05 -0800223 *
andreaeb70a942015-10-16 21:34:46 -0700224 * @return true if closed
Andrea Campanella101417d2015-12-11 17:58:07 -0800225 * @throws NetconfException when there is a problem in the communication process on
226 * the underlying connection
andreaeb70a942015-10-16 21:34:46 -0700227 */
Andrea Campanella101417d2015-12-11 17:58:07 -0800228 boolean close() throws NetconfException;
andreaeb70a942015-10-16 21:34:46 -0700229
230 /**
231 * Gets the session ID of the Netconf session.
232 *
233 * @return Session ID as a string.
234 */
235 String getSessionId();
236
237 /**
238 * Gets the capabilities of the Netconf server associated to this session.
239 *
240 * @return Network capabilities as a string.
241 */
242 String getServerCapabilities();
243
244 /**
Andrea Campanella101417d2015-12-11 17:58:07 -0800245 * Sets the ONOS side capabilities.
Andrea Campanellaf4fd0352015-12-14 17:03:05 -0800246 *
andreaeb70a942015-10-16 21:34:46 -0700247 * @param capabilities list of capabilities the device has.
248 */
249 void setDeviceCapabilities(List<String> capabilities);
250
Andrea Campanella101417d2015-12-11 17:58:07 -0800251 /**
252 * Remove a listener from the underlying stream handler implementation.
253 *
254 * @param listener event listener.
255 */
256 void addDeviceOutputListener(NetconfDeviceOutputEventListener listener);
257
258 /**
259 * Remove a listener from the underlying stream handler implementation.
260 *
261 * @param listener event listener.
262 */
263 void removeDeviceOutputListener(NetconfDeviceOutputEventListener listener);
264
andreaeb70a942015-10-16 21:34:46 -0700265}