blob: 2f02125e08cdc7cec87450c725f3b9110bcbbc33 [file] [log] [blame]
andreaeb70a942015-10-16 21:34:46 -07001/*
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
17package org.onosproject.netconf;
18
Andrea Campanella1cd641b2015-12-07 17:28:34 -080019import java.io.IOException;
andreaeb70a942015-10-16 21:34:46 -070020import 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>
27public interface NetconfSession {
28
29 /**
30 * Retrives the requested configuration, different from get-config.
Andrea Campanellaf4fd0352015-12-14 17:03:05 -080031 *
andreaeb70a942015-10-16 21:34:46 -070032 * @param request the XML containing the request to the server.
33 * @return device running configuration
34 */
Andrea Campanella1cd641b2015-12-07 17:28:34 -080035 String get(String request) throws IOException;
andreaeb70a942015-10-16 21:34:46 -070036
37 /**
38 * Executes an RPC to the server.
Andrea Campanellaf4fd0352015-12-14 17:03:05 -080039 *
andreaeb70a942015-10-16 21:34:46 -070040 * @param request the XML containing the RPC for the server.
41 * @return Server response or ERROR
42 */
Andrea Campanella1cd641b2015-12-07 17:28:34 -080043 String doRPC(String request) throws IOException;
andreaeb70a942015-10-16 21:34:46 -070044
45 /**
46 * Retrives the specified configuration.
47 *
48 * @param targetConfiguration the type of configuration to retrieve.
49 * @return specified configuration.
50 */
Andrea Campanella1cd641b2015-12-07 17:28:34 -080051 String getConfig(String targetConfiguration) throws IOException;
andreaeb70a942015-10-16 21:34:46 -070052
53 /**
54 * Retrives part of the specivied configuration based on the filterSchema.
55 *
56 * @param targetConfiguration the type of configuration to retrieve.
57 * @param configurationFilterSchema XML schema to filter the configuration
58 * elements we are interested in
59 * @return device running configuration.
60 */
Andrea Campanella1cd641b2015-12-07 17:28:34 -080061 String getConfig(String targetConfiguration, String configurationFilterSchema)
62 throws IOException;
andreaeb70a942015-10-16 21:34:46 -070063
64 /**
65 * Retrives part of the specified configuration based on the filterSchema.
66 *
67 * @param newConfiguration configuration to set
68 * @return true if the configuration was edited correctly
69 */
70
Andrea Campanella1cd641b2015-12-07 17:28:34 -080071 boolean editConfig(String newConfiguration) throws IOException;
andreaeb70a942015-10-16 21:34:46 -070072
73 /**
Andrea Campanellaf4fd0352015-12-14 17:03:05 -080074 * Retrives part of the specified configuration based on the filterSchema.
75 * @param targetConfiguration the targetConfiguration to change
76 * @param mode selected mode to change the configuration
77 * @param newConfiguration configuration to set
78 * @return true if the configuration was edited correctly
79 */
80 boolean editConfig(String targetConfiguration, String mode, String newConfiguration)
81 throws IOException;
82
83 /**
andreaeb70a942015-10-16 21:34:46 -070084 * Copies the new configuration, an Url or a complete configuration xml tree
85 * to the target configuration.
86 * The target configuration can't be the running one
87 *
88 * @param targetConfiguration the type of configuration to retrieve.
89 * @param newConfiguration configuration to set
90 * @return true if the configuration was copied correctly
91 */
Andrea Campanella1cd641b2015-12-07 17:28:34 -080092 boolean copyConfig(String targetConfiguration, String newConfiguration)
93 throws IOException;
andreaeb70a942015-10-16 21:34:46 -070094
95 /**
96 * Deletes part of the specified configuration based on the filterSchema.
97 *
98 * @param targetConfiguration the name of the configuration to delete
99 * @return true if the configuration was copied correctly
100 */
Andrea Campanella1cd641b2015-12-07 17:28:34 -0800101 boolean deleteConfig(String targetConfiguration) throws IOException;
andreaeb70a942015-10-16 21:34:46 -0700102
103 /**
104 * Locks the candidate configuration.
105 *
106 * @return true if successful.
107 */
Andrea Campanella1cd641b2015-12-07 17:28:34 -0800108 boolean lock() throws IOException;
andreaeb70a942015-10-16 21:34:46 -0700109
110 /**
111 * Unlocks the candidate configuration.
112 *
113 * @return true if successful.
114 */
Andrea Campanella1cd641b2015-12-07 17:28:34 -0800115 boolean unlock() throws IOException;
andreaeb70a942015-10-16 21:34:46 -0700116
117 /**
118 * Closes the Netconf session with the device.
119 * the first time it tries gracefully, then kills it forcefully
Andrea Campanellaf4fd0352015-12-14 17:03:05 -0800120 *
andreaeb70a942015-10-16 21:34:46 -0700121 * @return true if closed
122 */
Andrea Campanella1cd641b2015-12-07 17:28:34 -0800123 boolean close() throws IOException;
andreaeb70a942015-10-16 21:34:46 -0700124
125 /**
126 * Gets the session ID of the Netconf session.
127 *
128 * @return Session ID as a string.
129 */
130 String getSessionId();
131
132 /**
133 * Gets the capabilities of the Netconf server associated to this session.
134 *
135 * @return Network capabilities as a string.
136 */
137 String getServerCapabilities();
138
139 /**
140 * Sets the device capabilities.
Andrea Campanellaf4fd0352015-12-14 17:03:05 -0800141 *
andreaeb70a942015-10-16 21:34:46 -0700142 * @param capabilities list of capabilities the device has.
143 */
144 void setDeviceCapabilities(List<String> capabilities);
145
146}