blob: e5668edec6663076d5426fd30488078ddc29556a [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 /**
Andrea Campanella101417d2015-12-11 17:58:07 -080051 * Executes an synchronous RPC to the server.
Andrea Campanellaf4fd0352015-12-14 17:03:05 -080052 *
andreaeb70a942015-10-16 21:34:46 -070053 * @param request the XML containing the RPC for the server.
54 * @return Server response or ERROR
Andrea Campanella101417d2015-12-11 17:58:07 -080055 * @throws NetconfException when there is a problem in the communication process on
56 * the underlying connection
andreaeb70a942015-10-16 21:34:46 -070057 */
Andrea Campanella101417d2015-12-11 17:58:07 -080058 String requestSync(String request) throws NetconfException;
andreaeb70a942015-10-16 21:34:46 -070059
60 /**
61 * Retrives the specified configuration.
62 *
63 * @param targetConfiguration the type of configuration to retrieve.
64 * @return specified configuration.
Andrea Campanella101417d2015-12-11 17:58:07 -080065 * @throws NetconfException when there is a problem in the communication process on
66 * the underlying connection
andreaeb70a942015-10-16 21:34:46 -070067 */
Andrea Campanella101417d2015-12-11 17:58:07 -080068 String getConfig(String targetConfiguration) throws NetconfException;
andreaeb70a942015-10-16 21:34:46 -070069
70 /**
71 * Retrives part of the specivied configuration based on the filterSchema.
72 *
73 * @param targetConfiguration the type of configuration to retrieve.
74 * @param configurationFilterSchema XML schema to filter the configuration
75 * elements we are interested in
76 * @return device running 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 Campanella1cd641b2015-12-07 17:28:34 -080080 String getConfig(String targetConfiguration, String configurationFilterSchema)
Andrea Campanella101417d2015-12-11 17:58:07 -080081 throws NetconfException;
andreaeb70a942015-10-16 21:34:46 -070082
83 /**
84 * Retrives part of the specified configuration based on the filterSchema.
85 *
86 * @param newConfiguration configuration to set
87 * @return true if the configuration was edited correctly
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 */
91
Andrea Campanella101417d2015-12-11 17:58:07 -080092 boolean editConfig(String newConfiguration) throws NetconfException;
andreaeb70a942015-10-16 21:34:46 -070093
94 /**
Andrea Campanellaf4fd0352015-12-14 17:03:05 -080095 * Retrives part of the specified configuration based on the filterSchema.
Andrea Campanella101417d2015-12-11 17:58:07 -080096 *
Andrea Campanellaf4fd0352015-12-14 17:03:05 -080097 * @param targetConfiguration the targetConfiguration to change
Andrea Campanella101417d2015-12-11 17:58:07 -080098 * @param mode selected mode to change the configuration
99 * @param newConfiguration configuration to set
Andrea Campanellaf4fd0352015-12-14 17:03:05 -0800100 * @return true if the configuration was edited correctly
Andrea Campanella101417d2015-12-11 17:58:07 -0800101 * @throws NetconfException when there is a problem in the communication process on
102 * the underlying connection
Andrea Campanellaf4fd0352015-12-14 17:03:05 -0800103 */
104 boolean editConfig(String targetConfiguration, String mode, String newConfiguration)
Andrea Campanella101417d2015-12-11 17:58:07 -0800105 throws NetconfException;
Andrea Campanellaf4fd0352015-12-14 17:03:05 -0800106
107 /**
andreaeb70a942015-10-16 21:34:46 -0700108 * Copies the new configuration, an Url or a complete configuration xml tree
109 * to the target configuration.
110 * The target configuration can't be the running one
111 *
112 * @param targetConfiguration the type of configuration to retrieve.
113 * @param newConfiguration configuration to set
114 * @return true if the configuration was copied correctly
Andrea Campanella101417d2015-12-11 17:58:07 -0800115 * @throws NetconfException when there is a problem in the communication process on
116 * the underlying connection
andreaeb70a942015-10-16 21:34:46 -0700117 */
Andrea Campanella1cd641b2015-12-07 17:28:34 -0800118 boolean copyConfig(String targetConfiguration, String newConfiguration)
Andrea Campanella101417d2015-12-11 17:58:07 -0800119 throws NetconfException;
andreaeb70a942015-10-16 21:34:46 -0700120
121 /**
122 * Deletes part of the specified configuration based on the filterSchema.
123 *
124 * @param targetConfiguration the name of the configuration to delete
125 * @return true if the configuration was copied correctly
Andrea Campanella101417d2015-12-11 17:58:07 -0800126 * @throws NetconfException when there is a problem in the communication process on
127 * the underlying connection
andreaeb70a942015-10-16 21:34:46 -0700128 */
Andrea Campanella101417d2015-12-11 17:58:07 -0800129 boolean deleteConfig(String targetConfiguration) throws NetconfException;
andreaeb70a942015-10-16 21:34:46 -0700130
131 /**
132 * Locks the candidate configuration.
133 *
134 * @return true if successful.
Andrea Campanella101417d2015-12-11 17:58:07 -0800135 * @throws NetconfException when there is a problem in the communication process on
136 * the underlying connection
andreaeb70a942015-10-16 21:34:46 -0700137 */
Andrea Campanella101417d2015-12-11 17:58:07 -0800138 boolean lock() throws NetconfException;
andreaeb70a942015-10-16 21:34:46 -0700139
140 /**
141 * Unlocks the candidate configuration.
142 *
143 * @return true if successful.
Andrea Campanella101417d2015-12-11 17:58:07 -0800144 * @throws NetconfException when there is a problem in the communication process on
145 * the underlying connection
andreaeb70a942015-10-16 21:34:46 -0700146 */
Andrea Campanella101417d2015-12-11 17:58:07 -0800147 boolean unlock() throws NetconfException;
andreaeb70a942015-10-16 21:34:46 -0700148
149 /**
150 * Closes the Netconf session with the device.
151 * the first time it tries gracefully, then kills it forcefully
Andrea Campanellaf4fd0352015-12-14 17:03:05 -0800152 *
andreaeb70a942015-10-16 21:34:46 -0700153 * @return true if closed
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 close() throws NetconfException;
andreaeb70a942015-10-16 21:34:46 -0700158
159 /**
160 * Gets the session ID of the Netconf session.
161 *
162 * @return Session ID as a string.
163 */
164 String getSessionId();
165
166 /**
167 * Gets the capabilities of the Netconf server associated to this session.
168 *
169 * @return Network capabilities as a string.
170 */
171 String getServerCapabilities();
172
173 /**
Andrea Campanella101417d2015-12-11 17:58:07 -0800174 * Sets the ONOS side capabilities.
Andrea Campanellaf4fd0352015-12-14 17:03:05 -0800175 *
andreaeb70a942015-10-16 21:34:46 -0700176 * @param capabilities list of capabilities the device has.
177 */
178 void setDeviceCapabilities(List<String> capabilities);
179
Andrea Campanella101417d2015-12-11 17:58:07 -0800180 /**
181 * Remove a listener from the underlying stream handler implementation.
182 *
183 * @param listener event listener.
184 */
185 void addDeviceOutputListener(NetconfDeviceOutputEventListener listener);
186
187 /**
188 * Remove a listener from the underlying stream handler implementation.
189 *
190 * @param listener event listener.
191 */
192 void removeDeviceOutputListener(NetconfDeviceOutputEventListener listener);
193
andreaeb70a942015-10-16 21:34:46 -0700194}