blob: daab1b50af1f34cf1adfec4fbb64c6ba5f181a6d [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 /**
Andrea Campanella101417d2015-12-11 17:58:07 -080063 * Executes an synchronous RPC to the server.
Andrea Campanellaf4fd0352015-12-14 17:03:05 -080064 *
andreaeb70a942015-10-16 21:34:46 -070065 * @param request the XML containing the RPC for the server.
66 * @return Server response or ERROR
Andrea Campanella101417d2015-12-11 17:58:07 -080067 * @throws NetconfException when there is a problem in the communication process on
68 * the underlying connection
andreaeb70a942015-10-16 21:34:46 -070069 */
Andrea Campanella101417d2015-12-11 17:58:07 -080070 String requestSync(String request) throws NetconfException;
andreaeb70a942015-10-16 21:34:46 -070071
72 /**
73 * Retrives the specified configuration.
74 *
75 * @param targetConfiguration the type of configuration to retrieve.
76 * @return specified configuration.
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 getConfig(String targetConfiguration) throws NetconfException;
andreaeb70a942015-10-16 21:34:46 -070081
82 /**
83 * Retrives part of the specivied configuration based on the filterSchema.
84 *
85 * @param targetConfiguration the type of configuration to retrieve.
86 * @param configurationFilterSchema XML schema to filter the configuration
87 * elements we are interested in
88 * @return device running configuration.
Andrea Campanella101417d2015-12-11 17:58:07 -080089 * @throws NetconfException when there is a problem in the communication process on
90 * the underlying connection
andreaeb70a942015-10-16 21:34:46 -070091 */
Andrea Campanella1cd641b2015-12-07 17:28:34 -080092 String getConfig(String targetConfiguration, String configurationFilterSchema)
Andrea Campanella101417d2015-12-11 17:58:07 -080093 throws NetconfException;
andreaeb70a942015-10-16 21:34:46 -070094
95 /**
96 * Retrives part of the specified configuration based on the filterSchema.
97 *
98 * @param newConfiguration configuration to set
99 * @return true if the configuration was edited correctly
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 */
103
Andrea Campanella101417d2015-12-11 17:58:07 -0800104 boolean editConfig(String newConfiguration) throws NetconfException;
andreaeb70a942015-10-16 21:34:46 -0700105
106 /**
Andrea Campanellaf4fd0352015-12-14 17:03:05 -0800107 * Retrives part of the specified configuration based on the filterSchema.
Andrea Campanella101417d2015-12-11 17:58:07 -0800108 *
Andrea Campanellaf4fd0352015-12-14 17:03:05 -0800109 * @param targetConfiguration the targetConfiguration to change
Andrea Campanella101417d2015-12-11 17:58:07 -0800110 * @param mode selected mode to change the configuration
111 * @param newConfiguration configuration to set
Andrea Campanellaf4fd0352015-12-14 17:03:05 -0800112 * @return true if the configuration was edited correctly
Andrea Campanella101417d2015-12-11 17:58:07 -0800113 * @throws NetconfException when there is a problem in the communication process on
114 * the underlying connection
Andrea Campanellaf4fd0352015-12-14 17:03:05 -0800115 */
116 boolean editConfig(String targetConfiguration, String mode, String newConfiguration)
Andrea Campanella101417d2015-12-11 17:58:07 -0800117 throws NetconfException;
Andrea Campanellaf4fd0352015-12-14 17:03:05 -0800118
119 /**
andreaeb70a942015-10-16 21:34:46 -0700120 * Copies the new configuration, an Url or a complete configuration xml tree
121 * to the target configuration.
122 * The target configuration can't be the running one
123 *
124 * @param targetConfiguration the type of configuration to retrieve.
125 * @param newConfiguration configuration to set
126 * @return true if the configuration was copied correctly
Andrea Campanella101417d2015-12-11 17:58:07 -0800127 * @throws NetconfException when there is a problem in the communication process on
128 * the underlying connection
andreaeb70a942015-10-16 21:34:46 -0700129 */
Andrea Campanella1cd641b2015-12-07 17:28:34 -0800130 boolean copyConfig(String targetConfiguration, String newConfiguration)
Andrea Campanella101417d2015-12-11 17:58:07 -0800131 throws NetconfException;
andreaeb70a942015-10-16 21:34:46 -0700132
133 /**
134 * Deletes part of the specified configuration based on the filterSchema.
135 *
136 * @param targetConfiguration the name of the configuration to delete
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 Campanella101417d2015-12-11 17:58:07 -0800141 boolean deleteConfig(String targetConfiguration) throws NetconfException;
andreaeb70a942015-10-16 21:34:46 -0700142
143 /**
helenyrwu0407c642016-06-09 12:01:30 -0700144 * Starts subscription to the device's notifications.
145 *
146 * @throws NetconfException when there is a problem starting the subscription
147 */
148 void startSubscription() throws NetconfException;
149
150 /**
151 * Ends subscription to the device's notifications.
152 *
153 * @throws NetconfException when there is a problem ending the subscription
154 */
155 void endSubscription() throws NetconfException;
156
157 /**
158 * Locks the specified configuration.
159 *
160 * @param configType type of configuration to be locked
161 * @return true if successful.
162 * @throws NetconfException when there is a problem in the communication process on
163 * the underlying connection
164 */
165 boolean lock(String configType) throws NetconfException;
166
167 /**
168 * Unlocks 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 unlock(String configType) throws NetconfException;
176
177 /**
178 * Locks the running configuration.
andreaeb70a942015-10-16 21:34:46 -0700179 *
180 * @return true if successful.
Andrea Campanella101417d2015-12-11 17:58:07 -0800181 * @throws NetconfException when there is a problem in the communication process on
182 * the underlying connection
andreaeb70a942015-10-16 21:34:46 -0700183 */
Andrea Campanella101417d2015-12-11 17:58:07 -0800184 boolean lock() throws NetconfException;
andreaeb70a942015-10-16 21:34:46 -0700185
186 /**
helenyrwu0407c642016-06-09 12:01:30 -0700187 * Unlocks the running configuration.
andreaeb70a942015-10-16 21:34:46 -0700188 *
189 * @return true if successful.
Andrea Campanella101417d2015-12-11 17:58:07 -0800190 * @throws NetconfException when there is a problem in the communication process on
191 * the underlying connection
andreaeb70a942015-10-16 21:34:46 -0700192 */
Andrea Campanella101417d2015-12-11 17:58:07 -0800193 boolean unlock() throws NetconfException;
andreaeb70a942015-10-16 21:34:46 -0700194
195 /**
196 * Closes the Netconf session with the device.
197 * the first time it tries gracefully, then kills it forcefully
Andrea Campanellaf4fd0352015-12-14 17:03:05 -0800198 *
andreaeb70a942015-10-16 21:34:46 -0700199 * @return true if closed
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 close() throws NetconfException;
andreaeb70a942015-10-16 21:34:46 -0700204
205 /**
206 * Gets the session ID of the Netconf session.
207 *
208 * @return Session ID as a string.
209 */
210 String getSessionId();
211
212 /**
213 * Gets the capabilities of the Netconf server associated to this session.
214 *
215 * @return Network capabilities as a string.
216 */
217 String getServerCapabilities();
218
219 /**
Andrea Campanella101417d2015-12-11 17:58:07 -0800220 * Sets the ONOS side capabilities.
Andrea Campanellaf4fd0352015-12-14 17:03:05 -0800221 *
andreaeb70a942015-10-16 21:34:46 -0700222 * @param capabilities list of capabilities the device has.
223 */
224 void setDeviceCapabilities(List<String> capabilities);
225
Andrea Campanella101417d2015-12-11 17:58:07 -0800226 /**
227 * Remove a listener from the underlying stream handler implementation.
228 *
229 * @param listener event listener.
230 */
231 void addDeviceOutputListener(NetconfDeviceOutputEventListener listener);
232
233 /**
234 * Remove a listener from the underlying stream handler implementation.
235 *
236 * @param listener event listener.
237 */
238 void removeDeviceOutputListener(NetconfDeviceOutputEventListener listener);
239
andreaeb70a942015-10-16 21:34:46 -0700240}