blob: 2a19514b1ff16fbf6163d45c5f1b2fa22931b109 [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.
31 * @param request the XML containing the request to the server.
32 * @return device running configuration
33 */
Andrea Campanella1cd641b2015-12-07 17:28:34 -080034 String get(String request) throws IOException;
andreaeb70a942015-10-16 21:34:46 -070035
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 Campanella1cd641b2015-12-07 17:28:34 -080041 String doRPC(String request) throws IOException;
andreaeb70a942015-10-16 21:34:46 -070042
43 /**
44 * Retrives the specified configuration.
45 *
46 * @param targetConfiguration the type of configuration to retrieve.
47 * @return specified configuration.
48 */
Andrea Campanella1cd641b2015-12-07 17:28:34 -080049 String getConfig(String targetConfiguration) throws IOException;
andreaeb70a942015-10-16 21:34:46 -070050
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 Campanella1cd641b2015-12-07 17:28:34 -080059 String getConfig(String targetConfiguration, String configurationFilterSchema)
60 throws IOException;
andreaeb70a942015-10-16 21:34:46 -070061
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 Campanella1cd641b2015-12-07 17:28:34 -080069 boolean editConfig(String newConfiguration) throws IOException;
andreaeb70a942015-10-16 21:34:46 -070070
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 Campanella1cd641b2015-12-07 17:28:34 -080080 boolean copyConfig(String targetConfiguration, String newConfiguration)
81 throws IOException;
andreaeb70a942015-10-16 21:34:46 -070082
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 Campanella1cd641b2015-12-07 17:28:34 -080089 boolean deleteConfig(String targetConfiguration) throws IOException;
andreaeb70a942015-10-16 21:34:46 -070090
91 /**
92 * Locks the candidate configuration.
93 *
94 * @return true if successful.
95 */
Andrea Campanella1cd641b2015-12-07 17:28:34 -080096 boolean lock() throws IOException;
andreaeb70a942015-10-16 21:34:46 -070097
98 /**
99 * Unlocks the candidate configuration.
100 *
101 * @return true if successful.
102 */
Andrea Campanella1cd641b2015-12-07 17:28:34 -0800103 boolean unlock() throws IOException;
andreaeb70a942015-10-16 21:34:46 -0700104
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 Campanella1cd641b2015-12-07 17:28:34 -0800110 boolean close() throws IOException;
andreaeb70a942015-10-16 21:34:46 -0700111
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}