blob: 1d83fd63d74cdecd2efce8c62628d68f16feca6f [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 */
27// TODO change return type of methdos to <Capability, XMLdoc, string or yang obj>
28public 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 *
33 * @param request the XML containing the RPC for the server.
34 * @return Server response or ERROR
35 * @throws NetconfException when there is a problem in the communication process on
36 * the underlying connection
37 */
38 CompletableFuture<String> request(String request) throws NetconfException;
39
40
41 /**
andreaeb70a942015-10-16 21:34:46 -070042 * Retrives the requested configuration, different from get-config.
Andrea Campanellaf4fd0352015-12-14 17:03:05 -080043 *
andreaeb70a942015-10-16 21:34:46 -070044 * @param request the XML containing the request to the server.
45 * @return device running configuration
Andrea Campanella101417d2015-12-11 17:58:07 -080046 * @throws NetconfException when there is a problem in the communication process on
47 * the underlying connection
andreaeb70a942015-10-16 21:34:46 -070048 */
Andrea Campanella101417d2015-12-11 17:58:07 -080049 String get(String request) throws NetconfException;
andreaeb70a942015-10-16 21:34:46 -070050
51 /**
Akihiro Yamanouchi5e5d4df2016-06-08 17:06:33 +090052 * Retrives the requested data.
53 *
54 * @param filterSchema XML subtrees to include in the reply
55 * @param withDefaultsMode with-defaults mode
56 * @return Server response
57 * @throws NetconfException when there is a problem in the communication process on
58 * the underlying connection
59 */
60 String get(String filterSchema, String withDefaultsMode)
61 throws NetconfException;
62
63 /**
Akihiro Yamanouchi45122222016-07-15 13:13:11 +090064 * Executes an synchronous RPC to the server and wrap the request in RPC header.
Akihiro Yamanouchi8d3a9d32016-07-12 11:41:44 +090065 *
66 * @param request the XML containing the request to the server.
67 * @return Server response or ERROR
68 * @throws NetconfException when there is a problem in the communication process on
69 * the underlying connection
70 */
71 String doWrappedRpc(String request) throws NetconfException;
72
73 /**
Andrea Campanella101417d2015-12-11 17:58:07 -080074 * Executes an synchronous RPC to the server.
Andrea Campanellaf4fd0352015-12-14 17:03:05 -080075 *
andreaeb70a942015-10-16 21:34:46 -070076 * @param request the XML containing the RPC for the server.
77 * @return Server response or ERROR
Andrea Campanella101417d2015-12-11 17:58:07 -080078 * @throws NetconfException when there is a problem in the communication process on
79 * the underlying connection
andreaeb70a942015-10-16 21:34:46 -070080 */
Andrea Campanella101417d2015-12-11 17:58:07 -080081 String requestSync(String request) throws NetconfException;
andreaeb70a942015-10-16 21:34:46 -070082
83 /**
84 * Retrives the specified configuration.
85 *
86 * @param targetConfiguration the type of configuration to retrieve.
87 * @return specified configuration.
Andrea Campanella101417d2015-12-11 17:58:07 -080088 * @throws NetconfException when there is a problem in the communication process on
89 * the underlying connection
andreaeb70a942015-10-16 21:34:46 -070090 */
Andrea Campanella101417d2015-12-11 17:58:07 -080091 String getConfig(String targetConfiguration) throws NetconfException;
andreaeb70a942015-10-16 21:34:46 -070092
93 /**
94 * Retrives part of the specivied configuration based on the filterSchema.
95 *
96 * @param targetConfiguration the type of configuration to retrieve.
97 * @param configurationFilterSchema XML schema to filter the configuration
98 * elements we are interested in
99 * @return device running configuration.
Andrea Campanella101417d2015-12-11 17:58:07 -0800100 * @throws NetconfException when there is a problem in the communication process on
101 * the underlying connection
andreaeb70a942015-10-16 21:34:46 -0700102 */
Andrea Campanella1cd641b2015-12-07 17:28:34 -0800103 String getConfig(String targetConfiguration, String configurationFilterSchema)
Andrea Campanella101417d2015-12-11 17:58:07 -0800104 throws NetconfException;
andreaeb70a942015-10-16 21:34:46 -0700105
106 /**
107 * Retrives part of the specified configuration based on the filterSchema.
108 *
109 * @param newConfiguration configuration to set
110 * @return true if the configuration was edited correctly
Andrea Campanella101417d2015-12-11 17:58:07 -0800111 * @throws NetconfException when there is a problem in the communication process on
112 * the underlying connection
andreaeb70a942015-10-16 21:34:46 -0700113 */
114
Andrea Campanella101417d2015-12-11 17:58:07 -0800115 boolean editConfig(String newConfiguration) throws NetconfException;
andreaeb70a942015-10-16 21:34:46 -0700116
117 /**
Andrea Campanellaf4fd0352015-12-14 17:03:05 -0800118 * Retrives part of the specified configuration based on the filterSchema.
Andrea Campanella101417d2015-12-11 17:58:07 -0800119 *
Andrea Campanellaf4fd0352015-12-14 17:03:05 -0800120 * @param targetConfiguration the targetConfiguration to change
Andrea Campanella101417d2015-12-11 17:58:07 -0800121 * @param mode selected mode to change the configuration
122 * @param newConfiguration configuration to set
Andrea Campanellaf4fd0352015-12-14 17:03:05 -0800123 * @return true if the configuration was edited correctly
Andrea Campanella101417d2015-12-11 17:58:07 -0800124 * @throws NetconfException when there is a problem in the communication process on
125 * the underlying connection
Andrea Campanellaf4fd0352015-12-14 17:03:05 -0800126 */
127 boolean editConfig(String targetConfiguration, String mode, String newConfiguration)
Andrea Campanella101417d2015-12-11 17:58:07 -0800128 throws NetconfException;
Andrea Campanellaf4fd0352015-12-14 17:03:05 -0800129
130 /**
andreaeb70a942015-10-16 21:34:46 -0700131 * Copies the new configuration, an Url or a complete configuration xml tree
132 * to the target configuration.
133 * The target configuration can't be the running one
134 *
135 * @param targetConfiguration the type of configuration to retrieve.
136 * @param newConfiguration configuration to set
137 * @return true if the configuration was copied correctly
Andrea Campanella101417d2015-12-11 17:58:07 -0800138 * @throws NetconfException when there is a problem in the communication process on
139 * the underlying connection
andreaeb70a942015-10-16 21:34:46 -0700140 */
Andrea Campanella1cd641b2015-12-07 17:28:34 -0800141 boolean copyConfig(String targetConfiguration, String newConfiguration)
Andrea Campanella101417d2015-12-11 17:58:07 -0800142 throws NetconfException;
andreaeb70a942015-10-16 21:34:46 -0700143
144 /**
145 * Deletes part of the specified configuration based on the filterSchema.
146 *
147 * @param targetConfiguration the name of the configuration to delete
148 * @return true if the configuration was copied correctly
Andrea Campanella101417d2015-12-11 17:58:07 -0800149 * @throws NetconfException when there is a problem in the communication process on
150 * the underlying connection
andreaeb70a942015-10-16 21:34:46 -0700151 */
Andrea Campanella101417d2015-12-11 17:58:07 -0800152 boolean deleteConfig(String targetConfiguration) throws NetconfException;
andreaeb70a942015-10-16 21:34:46 -0700153
154 /**
helenyrwu0407c642016-06-09 12:01:30 -0700155 * Starts subscription to the device's notifications.
156 *
157 * @throws NetconfException when there is a problem starting the subscription
158 */
159 void startSubscription() throws NetconfException;
160
161 /**
Akihiro Yamanouchi45122222016-07-15 13:13:11 +0900162 * Starts subscription to the device's notifications.
163 *
164 * @param filterSchema XML subtrees to indicate specific notification
165 * @throws NetconfException when there is a problem starting the subscription
166 */
167 @Beta
168 void startSubscription(String filterSchema) throws NetconfException;
169
170 /**
helenyrwu0407c642016-06-09 12:01:30 -0700171 * Ends subscription to the device's notifications.
172 *
173 * @throws NetconfException when there is a problem ending the subscription
174 */
175 void endSubscription() throws NetconfException;
176
177 /**
178 * Locks 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 lock(String configType) throws NetconfException;
186
187 /**
188 * Unlocks the specified configuration.
189 *
190 * @param configType type of configuration to be locked
191 * @return true if successful.
192 * @throws NetconfException when there is a problem in the communication process on
193 * the underlying connection
194 */
195 boolean unlock(String configType) throws NetconfException;
196
197 /**
198 * Locks the running configuration.
andreaeb70a942015-10-16 21:34:46 -0700199 *
200 * @return true if successful.
Andrea Campanella101417d2015-12-11 17:58:07 -0800201 * @throws NetconfException when there is a problem in the communication process on
202 * the underlying connection
andreaeb70a942015-10-16 21:34:46 -0700203 */
Andrea Campanella101417d2015-12-11 17:58:07 -0800204 boolean lock() throws NetconfException;
andreaeb70a942015-10-16 21:34:46 -0700205
206 /**
helenyrwu0407c642016-06-09 12:01:30 -0700207 * Unlocks the running configuration.
andreaeb70a942015-10-16 21:34:46 -0700208 *
209 * @return true if successful.
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 unlock() throws NetconfException;
andreaeb70a942015-10-16 21:34:46 -0700214
215 /**
216 * Closes the Netconf session with the device.
217 * the first time it tries gracefully, then kills it forcefully
Andrea Campanellaf4fd0352015-12-14 17:03:05 -0800218 *
andreaeb70a942015-10-16 21:34:46 -0700219 * @return true if closed
Andrea Campanella101417d2015-12-11 17:58:07 -0800220 * @throws NetconfException when there is a problem in the communication process on
221 * the underlying connection
andreaeb70a942015-10-16 21:34:46 -0700222 */
Andrea Campanella101417d2015-12-11 17:58:07 -0800223 boolean close() throws NetconfException;
andreaeb70a942015-10-16 21:34:46 -0700224
225 /**
226 * Gets the session ID of the Netconf session.
227 *
228 * @return Session ID as a string.
229 */
230 String getSessionId();
231
232 /**
233 * Gets the capabilities of the Netconf server associated to this session.
234 *
235 * @return Network capabilities as a string.
236 */
237 String getServerCapabilities();
238
239 /**
Andrea Campanella101417d2015-12-11 17:58:07 -0800240 * Sets the ONOS side capabilities.
Andrea Campanellaf4fd0352015-12-14 17:03:05 -0800241 *
andreaeb70a942015-10-16 21:34:46 -0700242 * @param capabilities list of capabilities the device has.
243 */
244 void setDeviceCapabilities(List<String> capabilities);
245
Andrea Campanella101417d2015-12-11 17:58:07 -0800246 /**
247 * Remove a listener from the underlying stream handler implementation.
248 *
249 * @param listener event listener.
250 */
251 void addDeviceOutputListener(NetconfDeviceOutputEventListener listener);
252
253 /**
254 * Remove a listener from the underlying stream handler implementation.
255 *
256 * @param listener event listener.
257 */
258 void removeDeviceOutputListener(NetconfDeviceOutputEventListener listener);
259
andreaeb70a942015-10-16 21:34:46 -0700260}