blob: 0668422f43baf51e497c6504fae5c53c34fe2f3b [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 /**
144 * Locks the candidate configuration.
145 *
146 * @return true if successful.
Andrea Campanella101417d2015-12-11 17:58:07 -0800147 * @throws NetconfException when there is a problem in the communication process on
148 * the underlying connection
andreaeb70a942015-10-16 21:34:46 -0700149 */
Andrea Campanella101417d2015-12-11 17:58:07 -0800150 boolean lock() throws NetconfException;
andreaeb70a942015-10-16 21:34:46 -0700151
152 /**
153 * Unlocks the candidate configuration.
154 *
155 * @return true if successful.
Andrea Campanella101417d2015-12-11 17:58:07 -0800156 * @throws NetconfException when there is a problem in the communication process on
157 * the underlying connection
andreaeb70a942015-10-16 21:34:46 -0700158 */
Andrea Campanella101417d2015-12-11 17:58:07 -0800159 boolean unlock() throws NetconfException;
andreaeb70a942015-10-16 21:34:46 -0700160
161 /**
162 * Closes the Netconf session with the device.
163 * the first time it tries gracefully, then kills it forcefully
Andrea Campanellaf4fd0352015-12-14 17:03:05 -0800164 *
andreaeb70a942015-10-16 21:34:46 -0700165 * @return true if closed
Andrea Campanella101417d2015-12-11 17:58:07 -0800166 * @throws NetconfException when there is a problem in the communication process on
167 * the underlying connection
andreaeb70a942015-10-16 21:34:46 -0700168 */
Andrea Campanella101417d2015-12-11 17:58:07 -0800169 boolean close() throws NetconfException;
andreaeb70a942015-10-16 21:34:46 -0700170
171 /**
172 * Gets the session ID of the Netconf session.
173 *
174 * @return Session ID as a string.
175 */
176 String getSessionId();
177
178 /**
179 * Gets the capabilities of the Netconf server associated to this session.
180 *
181 * @return Network capabilities as a string.
182 */
183 String getServerCapabilities();
184
185 /**
Andrea Campanella101417d2015-12-11 17:58:07 -0800186 * Sets the ONOS side capabilities.
Andrea Campanellaf4fd0352015-12-14 17:03:05 -0800187 *
andreaeb70a942015-10-16 21:34:46 -0700188 * @param capabilities list of capabilities the device has.
189 */
190 void setDeviceCapabilities(List<String> capabilities);
191
Andrea Campanella101417d2015-12-11 17:58:07 -0800192 /**
193 * Remove a listener from the underlying stream handler implementation.
194 *
195 * @param listener event listener.
196 */
197 void addDeviceOutputListener(NetconfDeviceOutputEventListener listener);
198
199 /**
200 * Remove a listener from the underlying stream handler implementation.
201 *
202 * @param listener event listener.
203 */
204 void removeDeviceOutputListener(NetconfDeviceOutputEventListener listener);
205
andreaeb70a942015-10-16 21:34:46 -0700206}