andrea | eb70a94 | 2015-10-16 21:34:46 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2015 Open Networking Laboratory |
| 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 | |
Andrea Campanella | 1cd641b | 2015-12-07 17:28:34 -0800 | [diff] [blame^] | 19 | import java.io.IOException; |
andrea | eb70a94 | 2015-10-16 21:34:46 -0700 | [diff] [blame] | 20 | import java.util.List; |
| 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 | /** |
| 30 | * Retrives the requested configuration, different from get-config. |
| 31 | * @param request the XML containing the request to the server. |
| 32 | * @return device running configuration |
| 33 | */ |
Andrea Campanella | 1cd641b | 2015-12-07 17:28:34 -0800 | [diff] [blame^] | 34 | String get(String request) throws IOException; |
andrea | eb70a94 | 2015-10-16 21:34:46 -0700 | [diff] [blame] | 35 | |
| 36 | /** |
| 37 | * Executes an RPC to the server. |
| 38 | * @param request the XML containing the RPC for the server. |
| 39 | * @return Server response or ERROR |
| 40 | */ |
Andrea Campanella | 1cd641b | 2015-12-07 17:28:34 -0800 | [diff] [blame^] | 41 | String doRPC(String request) throws IOException; |
andrea | eb70a94 | 2015-10-16 21:34:46 -0700 | [diff] [blame] | 42 | |
| 43 | /** |
| 44 | * Retrives the specified configuration. |
| 45 | * |
| 46 | * @param targetConfiguration the type of configuration to retrieve. |
| 47 | * @return specified configuration. |
| 48 | */ |
Andrea Campanella | 1cd641b | 2015-12-07 17:28:34 -0800 | [diff] [blame^] | 49 | String getConfig(String targetConfiguration) throws IOException; |
andrea | eb70a94 | 2015-10-16 21:34:46 -0700 | [diff] [blame] | 50 | |
| 51 | /** |
| 52 | * Retrives part of the specivied configuration based on the filterSchema. |
| 53 | * |
| 54 | * @param targetConfiguration the type of configuration to retrieve. |
| 55 | * @param configurationFilterSchema XML schema to filter the configuration |
| 56 | * elements we are interested in |
| 57 | * @return device running configuration. |
| 58 | */ |
Andrea Campanella | 1cd641b | 2015-12-07 17:28:34 -0800 | [diff] [blame^] | 59 | String getConfig(String targetConfiguration, String configurationFilterSchema) |
| 60 | throws IOException; |
andrea | eb70a94 | 2015-10-16 21:34:46 -0700 | [diff] [blame] | 61 | |
| 62 | /** |
| 63 | * Retrives part of the specified configuration based on the filterSchema. |
| 64 | * |
| 65 | * @param newConfiguration configuration to set |
| 66 | * @return true if the configuration was edited correctly |
| 67 | */ |
| 68 | |
Andrea Campanella | 1cd641b | 2015-12-07 17:28:34 -0800 | [diff] [blame^] | 69 | boolean editConfig(String newConfiguration) throws IOException; |
andrea | eb70a94 | 2015-10-16 21:34:46 -0700 | [diff] [blame] | 70 | |
| 71 | /** |
| 72 | * Copies the new configuration, an Url or a complete configuration xml tree |
| 73 | * to the target configuration. |
| 74 | * The target configuration can't be the running one |
| 75 | * |
| 76 | * @param targetConfiguration the type of configuration to retrieve. |
| 77 | * @param newConfiguration configuration to set |
| 78 | * @return true if the configuration was copied correctly |
| 79 | */ |
Andrea Campanella | 1cd641b | 2015-12-07 17:28:34 -0800 | [diff] [blame^] | 80 | boolean copyConfig(String targetConfiguration, String newConfiguration) |
| 81 | throws IOException; |
andrea | eb70a94 | 2015-10-16 21:34:46 -0700 | [diff] [blame] | 82 | |
| 83 | /** |
| 84 | * Deletes part of the specified configuration based on the filterSchema. |
| 85 | * |
| 86 | * @param targetConfiguration the name of the configuration to delete |
| 87 | * @return true if the configuration was copied correctly |
| 88 | */ |
Andrea Campanella | 1cd641b | 2015-12-07 17:28:34 -0800 | [diff] [blame^] | 89 | boolean deleteConfig(String targetConfiguration) throws IOException; |
andrea | eb70a94 | 2015-10-16 21:34:46 -0700 | [diff] [blame] | 90 | |
| 91 | /** |
| 92 | * Locks the candidate configuration. |
| 93 | * |
| 94 | * @return true if successful. |
| 95 | */ |
Andrea Campanella | 1cd641b | 2015-12-07 17:28:34 -0800 | [diff] [blame^] | 96 | boolean lock() throws IOException; |
andrea | eb70a94 | 2015-10-16 21:34:46 -0700 | [diff] [blame] | 97 | |
| 98 | /** |
| 99 | * Unlocks the candidate configuration. |
| 100 | * |
| 101 | * @return true if successful. |
| 102 | */ |
Andrea Campanella | 1cd641b | 2015-12-07 17:28:34 -0800 | [diff] [blame^] | 103 | boolean unlock() throws IOException; |
andrea | eb70a94 | 2015-10-16 21:34:46 -0700 | [diff] [blame] | 104 | |
| 105 | /** |
| 106 | * Closes the Netconf session with the device. |
| 107 | * the first time it tries gracefully, then kills it forcefully |
| 108 | * @return true if closed |
| 109 | */ |
Andrea Campanella | 1cd641b | 2015-12-07 17:28:34 -0800 | [diff] [blame^] | 110 | boolean close() throws IOException; |
andrea | eb70a94 | 2015-10-16 21:34:46 -0700 | [diff] [blame] | 111 | |
| 112 | /** |
| 113 | * Gets the session ID of the Netconf session. |
| 114 | * |
| 115 | * @return Session ID as a string. |
| 116 | */ |
| 117 | String getSessionId(); |
| 118 | |
| 119 | /** |
| 120 | * Gets the capabilities of the Netconf server associated to this session. |
| 121 | * |
| 122 | * @return Network capabilities as a string. |
| 123 | */ |
| 124 | String getServerCapabilities(); |
| 125 | |
| 126 | /** |
| 127 | * Sets the device capabilities. |
| 128 | * @param capabilities list of capabilities the device has. |
| 129 | */ |
| 130 | void setDeviceCapabilities(List<String> capabilities); |
| 131 | |
| 132 | } |