andrea | eb70a94 | 2015-10-16 21:34:46 -0700 | [diff] [blame] | 1 | /* |
Brian O'Connor | 5ab426f | 2016-04-09 01:19:45 -0700 | [diff] [blame] | 2 | * Copyright 2015-present Open Networking Laboratory |
andrea | eb70a94 | 2015-10-16 21:34:46 -0700 | [diff] [blame] | 3 | * |
| 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 | |
| 17 | package org.onosproject.netconf; |
| 18 | |
| 19 | import java.util.List; |
Andrea Campanella | 101417d | 2015-12-11 17:58:07 -0800 | [diff] [blame] | 20 | import java.util.concurrent.CompletableFuture; |
andrea | eb70a94 | 2015-10-16 21:34:46 -0700 | [diff] [blame] | 21 | |
| 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> |
| 27 | public interface NetconfSession { |
| 28 | |
| 29 | /** |
Andrea Campanella | 101417d | 2015-12-11 17:58:07 -0800 | [diff] [blame] | 30 | * 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 | /** |
andrea | eb70a94 | 2015-10-16 21:34:46 -0700 | [diff] [blame] | 41 | * Retrives the requested configuration, different from get-config. |
Andrea Campanella | f4fd035 | 2015-12-14 17:03:05 -0800 | [diff] [blame] | 42 | * |
andrea | eb70a94 | 2015-10-16 21:34:46 -0700 | [diff] [blame] | 43 | * @param request the XML containing the request to the server. |
| 44 | * @return device running configuration |
Andrea Campanella | 101417d | 2015-12-11 17:58:07 -0800 | [diff] [blame] | 45 | * @throws NetconfException when there is a problem in the communication process on |
| 46 | * the underlying connection |
andrea | eb70a94 | 2015-10-16 21:34:46 -0700 | [diff] [blame] | 47 | */ |
Andrea Campanella | 101417d | 2015-12-11 17:58:07 -0800 | [diff] [blame] | 48 | String get(String request) throws NetconfException; |
andrea | eb70a94 | 2015-10-16 21:34:46 -0700 | [diff] [blame] | 49 | |
| 50 | /** |
Andrea Campanella | 101417d | 2015-12-11 17:58:07 -0800 | [diff] [blame] | 51 | * Executes an synchronous RPC to the server. |
Andrea Campanella | f4fd035 | 2015-12-14 17:03:05 -0800 | [diff] [blame] | 52 | * |
andrea | eb70a94 | 2015-10-16 21:34:46 -0700 | [diff] [blame] | 53 | * @param request the XML containing the RPC for the server. |
| 54 | * @return Server response or ERROR |
Andrea Campanella | 101417d | 2015-12-11 17:58:07 -0800 | [diff] [blame] | 55 | * @throws NetconfException when there is a problem in the communication process on |
| 56 | * the underlying connection |
andrea | eb70a94 | 2015-10-16 21:34:46 -0700 | [diff] [blame] | 57 | */ |
Andrea Campanella | 101417d | 2015-12-11 17:58:07 -0800 | [diff] [blame] | 58 | String requestSync(String request) throws NetconfException; |
andrea | eb70a94 | 2015-10-16 21:34:46 -0700 | [diff] [blame] | 59 | |
| 60 | /** |
| 61 | * Retrives the specified configuration. |
| 62 | * |
| 63 | * @param targetConfiguration the type of configuration to retrieve. |
| 64 | * @return specified configuration. |
Andrea Campanella | 101417d | 2015-12-11 17:58:07 -0800 | [diff] [blame] | 65 | * @throws NetconfException when there is a problem in the communication process on |
| 66 | * the underlying connection |
andrea | eb70a94 | 2015-10-16 21:34:46 -0700 | [diff] [blame] | 67 | */ |
Andrea Campanella | 101417d | 2015-12-11 17:58:07 -0800 | [diff] [blame] | 68 | String getConfig(String targetConfiguration) throws NetconfException; |
andrea | eb70a94 | 2015-10-16 21:34:46 -0700 | [diff] [blame] | 69 | |
| 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 Campanella | 101417d | 2015-12-11 17:58:07 -0800 | [diff] [blame] | 77 | * @throws NetconfException when there is a problem in the communication process on |
| 78 | * the underlying connection |
andrea | eb70a94 | 2015-10-16 21:34:46 -0700 | [diff] [blame] | 79 | */ |
Andrea Campanella | 1cd641b | 2015-12-07 17:28:34 -0800 | [diff] [blame] | 80 | String getConfig(String targetConfiguration, String configurationFilterSchema) |
Andrea Campanella | 101417d | 2015-12-11 17:58:07 -0800 | [diff] [blame] | 81 | throws NetconfException; |
andrea | eb70a94 | 2015-10-16 21:34:46 -0700 | [diff] [blame] | 82 | |
| 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 Campanella | 101417d | 2015-12-11 17:58:07 -0800 | [diff] [blame] | 88 | * @throws NetconfException when there is a problem in the communication process on |
| 89 | * the underlying connection |
andrea | eb70a94 | 2015-10-16 21:34:46 -0700 | [diff] [blame] | 90 | */ |
| 91 | |
Andrea Campanella | 101417d | 2015-12-11 17:58:07 -0800 | [diff] [blame] | 92 | boolean editConfig(String newConfiguration) throws NetconfException; |
andrea | eb70a94 | 2015-10-16 21:34:46 -0700 | [diff] [blame] | 93 | |
| 94 | /** |
Andrea Campanella | f4fd035 | 2015-12-14 17:03:05 -0800 | [diff] [blame] | 95 | * Retrives part of the specified configuration based on the filterSchema. |
Andrea Campanella | 101417d | 2015-12-11 17:58:07 -0800 | [diff] [blame] | 96 | * |
Andrea Campanella | f4fd035 | 2015-12-14 17:03:05 -0800 | [diff] [blame] | 97 | * @param targetConfiguration the targetConfiguration to change |
Andrea Campanella | 101417d | 2015-12-11 17:58:07 -0800 | [diff] [blame] | 98 | * @param mode selected mode to change the configuration |
| 99 | * @param newConfiguration configuration to set |
Andrea Campanella | f4fd035 | 2015-12-14 17:03:05 -0800 | [diff] [blame] | 100 | * @return true if the configuration was edited correctly |
Andrea Campanella | 101417d | 2015-12-11 17:58:07 -0800 | [diff] [blame] | 101 | * @throws NetconfException when there is a problem in the communication process on |
| 102 | * the underlying connection |
Andrea Campanella | f4fd035 | 2015-12-14 17:03:05 -0800 | [diff] [blame] | 103 | */ |
| 104 | boolean editConfig(String targetConfiguration, String mode, String newConfiguration) |
Andrea Campanella | 101417d | 2015-12-11 17:58:07 -0800 | [diff] [blame] | 105 | throws NetconfException; |
Andrea Campanella | f4fd035 | 2015-12-14 17:03:05 -0800 | [diff] [blame] | 106 | |
| 107 | /** |
andrea | eb70a94 | 2015-10-16 21:34:46 -0700 | [diff] [blame] | 108 | * 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 Campanella | 101417d | 2015-12-11 17:58:07 -0800 | [diff] [blame] | 115 | * @throws NetconfException when there is a problem in the communication process on |
| 116 | * the underlying connection |
andrea | eb70a94 | 2015-10-16 21:34:46 -0700 | [diff] [blame] | 117 | */ |
Andrea Campanella | 1cd641b | 2015-12-07 17:28:34 -0800 | [diff] [blame] | 118 | boolean copyConfig(String targetConfiguration, String newConfiguration) |
Andrea Campanella | 101417d | 2015-12-11 17:58:07 -0800 | [diff] [blame] | 119 | throws NetconfException; |
andrea | eb70a94 | 2015-10-16 21:34:46 -0700 | [diff] [blame] | 120 | |
| 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 Campanella | 101417d | 2015-12-11 17:58:07 -0800 | [diff] [blame] | 126 | * @throws NetconfException when there is a problem in the communication process on |
| 127 | * the underlying connection |
andrea | eb70a94 | 2015-10-16 21:34:46 -0700 | [diff] [blame] | 128 | */ |
Andrea Campanella | 101417d | 2015-12-11 17:58:07 -0800 | [diff] [blame] | 129 | boolean deleteConfig(String targetConfiguration) throws NetconfException; |
andrea | eb70a94 | 2015-10-16 21:34:46 -0700 | [diff] [blame] | 130 | |
| 131 | /** |
| 132 | * Locks the candidate configuration. |
| 133 | * |
| 134 | * @return true if successful. |
Andrea Campanella | 101417d | 2015-12-11 17:58:07 -0800 | [diff] [blame] | 135 | * @throws NetconfException when there is a problem in the communication process on |
| 136 | * the underlying connection |
andrea | eb70a94 | 2015-10-16 21:34:46 -0700 | [diff] [blame] | 137 | */ |
Andrea Campanella | 101417d | 2015-12-11 17:58:07 -0800 | [diff] [blame] | 138 | boolean lock() throws NetconfException; |
andrea | eb70a94 | 2015-10-16 21:34:46 -0700 | [diff] [blame] | 139 | |
| 140 | /** |
| 141 | * Unlocks the candidate configuration. |
| 142 | * |
| 143 | * @return true if successful. |
Andrea Campanella | 101417d | 2015-12-11 17:58:07 -0800 | [diff] [blame] | 144 | * @throws NetconfException when there is a problem in the communication process on |
| 145 | * the underlying connection |
andrea | eb70a94 | 2015-10-16 21:34:46 -0700 | [diff] [blame] | 146 | */ |
Andrea Campanella | 101417d | 2015-12-11 17:58:07 -0800 | [diff] [blame] | 147 | boolean unlock() throws NetconfException; |
andrea | eb70a94 | 2015-10-16 21:34:46 -0700 | [diff] [blame] | 148 | |
| 149 | /** |
| 150 | * Closes the Netconf session with the device. |
| 151 | * the first time it tries gracefully, then kills it forcefully |
Andrea Campanella | f4fd035 | 2015-12-14 17:03:05 -0800 | [diff] [blame] | 152 | * |
andrea | eb70a94 | 2015-10-16 21:34:46 -0700 | [diff] [blame] | 153 | * @return true if closed |
Andrea Campanella | 101417d | 2015-12-11 17:58:07 -0800 | [diff] [blame] | 154 | * @throws NetconfException when there is a problem in the communication process on |
| 155 | * the underlying connection |
andrea | eb70a94 | 2015-10-16 21:34:46 -0700 | [diff] [blame] | 156 | */ |
Andrea Campanella | 101417d | 2015-12-11 17:58:07 -0800 | [diff] [blame] | 157 | boolean close() throws NetconfException; |
andrea | eb70a94 | 2015-10-16 21:34:46 -0700 | [diff] [blame] | 158 | |
| 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 Campanella | 101417d | 2015-12-11 17:58:07 -0800 | [diff] [blame] | 174 | * Sets the ONOS side capabilities. |
Andrea Campanella | f4fd035 | 2015-12-14 17:03:05 -0800 | [diff] [blame] | 175 | * |
andrea | eb70a94 | 2015-10-16 21:34:46 -0700 | [diff] [blame] | 176 | * @param capabilities list of capabilities the device has. |
| 177 | */ |
| 178 | void setDeviceCapabilities(List<String> capabilities); |
| 179 | |
Andrea Campanella | 101417d | 2015-12-11 17:58:07 -0800 | [diff] [blame] | 180 | /** |
| 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 | |
andrea | eb70a94 | 2015-10-16 21:34:46 -0700 | [diff] [blame] | 194 | } |