blob: 0a9f1aa42f3ab8be0868111f2da473363c85fad0 [file] [log] [blame]
Andrea Campanella7bbe7b12017-05-03 16:03:38 -07001/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2015-present Open Networking Foundation
Andrea Campanella7bbe7b12017-05-03 16:03:38 -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.ctl.impl;
18
19import com.google.common.annotations.Beta;
20import com.google.common.base.MoreObjects;
21import com.google.common.base.Objects;
Kamil Stasiak9f59f442017-05-02 11:02:24 +020022import com.google.common.collect.ImmutableList;
Andrea Campanella7bbe7b12017-05-03 16:03:38 -070023import com.google.common.collect.ImmutableSet;
quan PHAM VAN32d70e52018-08-01 17:35:30 -070024import com.google.common.collect.Sets;
Andrea Campanella7bbe7b12017-05-03 16:03:38 -070025import org.apache.sshd.client.SshClient;
26import org.apache.sshd.client.channel.ClientChannel;
27import org.apache.sshd.client.future.ConnectFuture;
28import org.apache.sshd.client.future.OpenFuture;
29import org.apache.sshd.client.session.ClientSession;
Sean Condon7347de92017-07-21 12:17:25 +010030import org.apache.sshd.common.FactoryManager;
Andrea Campanella7bbe7b12017-05-03 16:03:38 -070031import org.apache.sshd.server.keyprovider.SimpleGeneratorHostKeyProvider;
Holger Schulz092cbbf2017-08-31 17:52:30 +020032import org.bouncycastle.jce.provider.BouncyCastleProvider;
Holger Schulz092cbbf2017-08-31 17:52:30 +020033import org.bouncycastle.openssl.PEMKeyPair;
quan PHAM VAN32d70e52018-08-01 17:35:30 -070034import org.bouncycastle.openssl.PEMParser;
Holger Schulz092cbbf2017-08-31 17:52:30 +020035import org.bouncycastle.openssl.jcajce.JcaPEMKeyConverter;
quan PHAM VAN32d70e52018-08-01 17:35:30 -070036import org.onlab.osgi.DefaultServiceDirectory;
37import org.onlab.osgi.ServiceDirectory;
Andrea Campanellaa2a6c3c2018-12-11 12:56:38 +010038import org.onlab.util.ItemNotFoundException;
Yuta HIGUCHI6e6c26e2017-09-06 14:25:57 -070039import org.onlab.util.SharedExecutors;
quan PHAM VAN32d70e52018-08-01 17:35:30 -070040import org.onosproject.net.DeviceId;
41import org.onosproject.net.driver.Driver;
42import org.onosproject.net.driver.DriverService;
Yuta HIGUCHI4f55c672018-06-14 18:10:43 -070043import org.onosproject.netconf.AbstractNetconfSession;
gyewan.an91d7e7e2019-01-17 15:12:48 +090044import org.onosproject.netconf.NetconfController;
Andrea Campanella7bbe7b12017-05-03 16:03:38 -070045import org.onosproject.netconf.NetconfDeviceInfo;
46import org.onosproject.netconf.NetconfDeviceOutputEvent;
47import org.onosproject.netconf.NetconfDeviceOutputEvent.Type;
48import org.onosproject.netconf.NetconfDeviceOutputEventListener;
49import org.onosproject.netconf.NetconfException;
50import org.onosproject.netconf.NetconfSession;
51import org.onosproject.netconf.NetconfSessionFactory;
Yuta HIGUCHI6e6c26e2017-09-06 14:25:57 -070052import org.onosproject.netconf.NetconfTransportException;
Andrea Campanella7bbe7b12017-05-03 16:03:38 -070053import org.slf4j.Logger;
Yuta HIGUCHI15677982017-08-16 15:50:29 -070054
Holger Schulz092cbbf2017-08-31 17:52:30 +020055import java.io.CharArrayReader;
Andrea Campanella7bbe7b12017-05-03 16:03:38 -070056import java.io.IOException;
Andrea Campanella7bbe7b12017-05-03 16:03:38 -070057import java.security.KeyFactory;
58import java.security.KeyPair;
59import java.security.NoSuchAlgorithmException;
60import java.security.PublicKey;
61import java.security.spec.InvalidKeySpecException;
62import java.security.spec.X509EncodedKeySpec;
quan PHAM VAN32d70e52018-08-01 17:35:30 -070063import java.util.ArrayList;
64import java.util.Arrays;
Andrea Campanella7bbe7b12017-05-03 16:03:38 -070065import java.util.Collection;
66import java.util.Collections;
quan PHAM VAN32d70e52018-08-01 17:35:30 -070067import java.util.LinkedHashSet;
68import java.util.List;
69import java.util.Map;
Andrea Campanella7bbe7b12017-05-03 16:03:38 -070070import java.util.Optional;
quan PHAM VAN32d70e52018-08-01 17:35:30 -070071import java.util.Set;
Andrea Campanella7bbe7b12017-05-03 16:03:38 -070072import java.util.concurrent.CompletableFuture;
73import java.util.concurrent.ConcurrentHashMap;
74import java.util.concurrent.CopyOnWriteArrayList;
75import java.util.concurrent.ExecutionException;
76import java.util.concurrent.TimeUnit;
77import java.util.concurrent.TimeoutException;
78import java.util.concurrent.atomic.AtomicInteger;
79import java.util.regex.Matcher;
80import java.util.regex.Pattern;
81
quan PHAM VAN32d70e52018-08-01 17:35:30 -070082import static java.nio.charset.StandardCharsets.UTF_8;
83import static org.slf4j.LoggerFactory.getLogger;
84
Andrea Campanella7bbe7b12017-05-03 16:03:38 -070085/**
86 * Implementation of a NETCONF session to talk to a device.
87 */
Yuta HIGUCHI4f55c672018-06-14 18:10:43 -070088public class NetconfSessionMinaImpl extends AbstractNetconfSession {
Andrea Campanella7bbe7b12017-05-03 16:03:38 -070089
Yuta HIGUCHI6e6c26e2017-09-06 14:25:57 -070090 private static final Logger log = getLogger(NetconfSessionMinaImpl.class);
Andrea Campanella7bbe7b12017-05-03 16:03:38 -070091
Yuta HIGUCHI371667d2017-09-05 17:30:51 -070092 /**
93 * NC 1.0, RFC4742 EOM sequence.
94 */
Andrea Campanella7bbe7b12017-05-03 16:03:38 -070095 private static final String ENDPATTERN = "]]>]]>";
96 private static final String MESSAGE_ID_STRING = "message-id";
97 private static final String HELLO = "<hello";
98 private static final String NEW_LINE = "\n";
99 private static final String END_OF_RPC_OPEN_TAG = "\">";
100 private static final String EQUAL = "=";
101 private static final String NUMBER_BETWEEN_QUOTES_MATCHER = "\"+([0-9]+)+\"";
Andrea Campanella7bbe7b12017-05-03 16:03:38 -0700102 private static final String SUBTREE_FILTER_CLOSE = "</filter>";
Yuta HIGUCHI371667d2017-09-05 17:30:51 -0700103 // FIXME hard coded namespace nc
Andrea Campanella7bbe7b12017-05-03 16:03:38 -0700104 private static final String XML_HEADER =
105 "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
Yuta HIGUCHI4f55c672018-06-14 18:10:43 -0700106
Yuta HIGUCHI371667d2017-09-05 17:30:51 -0700107 // FIXME hard coded namespace base10
Andrea Campanella7bbe7b12017-05-03 16:03:38 -0700108 private static final String SUBSCRIPTION_SUBTREE_FILTER_OPEN =
109 "<filter xmlns:base10=\"urn:ietf:params:xml:ns:netconf:base:1.0\" base10:type=\"subtree\">";
110
111 private static final String INTERLEAVE_CAPABILITY_STRING = "urn:ietf:params:netconf:capability:interleave:1.0";
112
113 private static final String CAPABILITY_REGEX = "<capability>\\s*(.*?)\\s*</capability>";
114 private static final Pattern CAPABILITY_REGEX_PATTERN = Pattern.compile(CAPABILITY_REGEX);
115
116 private static final String SESSION_ID_REGEX = "<session-id>\\s*(.*?)\\s*</session-id>";
117 private static final Pattern SESSION_ID_REGEX_PATTERN = Pattern.compile(SESSION_ID_REGEX);
Kamil Stasiak9f59f442017-05-02 11:02:24 +0200118 private static final String HASH = "#";
119 private static final String LF = "\n";
120 private static final String MSGLEN_REGEX_PATTERN = "\n#\\d+\n";
121 private static final String NETCONF_10_CAPABILITY = "urn:ietf:params:netconf:base:1.0";
122 private static final String NETCONF_11_CAPABILITY = "urn:ietf:params:netconf:base:1.1";
quan PHAM VAN32d70e52018-08-01 17:35:30 -0700123 private static final String NETCONF_CLIENT_CAPABILITY = "netconfClientCapability";
Laszlo Pappbdb64082018-09-11 12:21:29 +0100124 private static final String NOTIFICATION_STREAM = "notificationStream";
quan PHAM VAN32d70e52018-08-01 17:35:30 -0700125
126 private static ServiceDirectory directory = new DefaultServiceDirectory();
Andrea Campanella7bbe7b12017-05-03 16:03:38 -0700127
128 private String sessionID;
129 private final AtomicInteger messageIdInteger = new AtomicInteger(1);
130 protected final NetconfDeviceInfo deviceInfo;
131 private Iterable<String> onosCapabilities =
Kamil Stasiak9f59f442017-05-02 11:02:24 +0200132 ImmutableList.of(NETCONF_10_CAPABILITY, NETCONF_11_CAPABILITY);
Andrea Campanella7bbe7b12017-05-03 16:03:38 -0700133
Andrea Campanella7bbe7b12017-05-03 16:03:38 -0700134 private final Set<String> deviceCapabilities = new LinkedHashSet<>();
135 private NetconfStreamHandler streamHandler;
Yuta HIGUCHI371667d2017-09-05 17:30:51 -0700136 // FIXME ONOS-7019 key type should be revised to a String, see RFC6241
137 /**
138 * Message-ID and corresponding Future waiting for response.
139 */
Andrea Campanella7bbe7b12017-05-03 16:03:38 -0700140 private Map<Integer, CompletableFuture<String>> replies;
Sean Condon7347de92017-07-21 12:17:25 +0100141 private List<String> errorReplies; // Not sure why we need this?
Andrea Campanella7bbe7b12017-05-03 16:03:38 -0700142 private boolean subscriptionConnected = false;
143 private String notificationFilterSchema = null;
144
145 private final Collection<NetconfDeviceOutputEventListener> primaryListeners =
146 new CopyOnWriteArrayList<>();
147 private final Collection<NetconfSession> children =
148 new CopyOnWriteArrayList<>();
149
Sean Condon54d82432017-07-26 22:27:25 +0100150 private int connectTimeout;
151 private int replyTimeout;
152 private int idleTimeout;
153
Andrea Campanella7bbe7b12017-05-03 16:03:38 -0700154 private ClientChannel channel = null;
155 private ClientSession session = null;
156 private SshClient client = null;
157
DongRyeol Chac29f9072018-11-06 14:05:56 +0900158 private boolean disconnected = false;
159
Andrea Campanella7bbe7b12017-05-03 16:03:38 -0700160 public NetconfSessionMinaImpl(NetconfDeviceInfo deviceInfo) throws NetconfException {
161 this.deviceInfo = deviceInfo;
162 replies = new ConcurrentHashMap<>();
163 errorReplies = new ArrayList<>();
quan PHAM VAN32d70e52018-08-01 17:35:30 -0700164 Set<String> capabilities = getClientCapabilites(deviceInfo.getDeviceId());
165 if (!capabilities.isEmpty()) {
166 capabilities.addAll(Sets.newHashSet(onosCapabilities));
167 setOnosCapabilities(capabilities);
168 }
Yuta HIGUCHI6e6c26e2017-09-06 14:25:57 -0700169 // FIXME should not immediately start session on construction
170 // setOnosCapabilities() is useless due to this behavior
Andrea Campanella7bbe7b12017-05-03 16:03:38 -0700171 startConnection();
172 }
173
Kamil Stasiak9f59f442017-05-02 11:02:24 +0200174 public NetconfSessionMinaImpl(NetconfDeviceInfo deviceInfo, List<String> capabilities) throws NetconfException {
175 this.deviceInfo = deviceInfo;
176 replies = new ConcurrentHashMap<>();
177 errorReplies = new ArrayList<>();
178 setOnosCapabilities(capabilities);
Yuta HIGUCHI6e6c26e2017-09-06 14:25:57 -0700179 // FIXME should not immediately start session on construction
180 // setOnosCapabilities() is useless due to this behavior
Kamil Stasiak9f59f442017-05-02 11:02:24 +0200181 startConnection();
182 }
183
quan PHAM VAN32d70e52018-08-01 17:35:30 -0700184 /**
185 * Get the list of the netconf client capabilities from device driver property.
186 *
187 * @param deviceId the deviceID for which to recover the capabilities from the driver.
188 * @return the String list of clientCapability property, or null if it is not configured
189 */
190 public Set<String> getClientCapabilites(DeviceId deviceId) {
191 Set<String> capabilities = new LinkedHashSet<>();
192 DriverService driverService = directory.get(DriverService.class);
Andrea Campanellaa2a6c3c2018-12-11 12:56:38 +0100193 try {
194 Driver driver = driverService.getDriver(deviceId);
195 if (driver == null) {
196 return capabilities;
197 }
198 String clientCapabilities = driver.getProperty(NETCONF_CLIENT_CAPABILITY);
199 if (clientCapabilities == null) {
200 return capabilities;
201 }
202 String[] textStr = clientCapabilities.split("\\|");
203 capabilities.addAll(Arrays.asList(textStr));
204 return capabilities;
205 } catch (ItemNotFoundException e) {
206 log.warn("Driver for device {} currently not available", deviceId);
quan PHAM VAN32d70e52018-08-01 17:35:30 -0700207 return capabilities;
208 }
quan PHAM VAN32d70e52018-08-01 17:35:30 -0700209 }
210
Andrea Campanella7bbe7b12017-05-03 16:03:38 -0700211 private void startConnection() throws NetconfException {
Sean Condon54d82432017-07-26 22:27:25 +0100212 connectTimeout = deviceInfo.getConnectTimeoutSec().orElse(
213 NetconfControllerImpl.netconfConnectTimeout);
214 replyTimeout = deviceInfo.getReplyTimeoutSec().orElse(
215 NetconfControllerImpl.netconfReplyTimeout);
216 idleTimeout = deviceInfo.getIdleTimeoutSec().orElse(
217 NetconfControllerImpl.netconfIdleTimeout);
218 log.info("Connecting to {} with timeouts C:{}, R:{}, I:{}", deviceInfo,
219 connectTimeout, replyTimeout, idleTimeout);
220
Andrea Campanella7bbe7b12017-05-03 16:03:38 -0700221 try {
222 startClient();
DongRyeol Chac29f9072018-11-06 14:05:56 +0900223 } catch (Exception e) {
224 stopClient();
Andrea Campanella7bbe7b12017-05-03 16:03:38 -0700225 throw new NetconfException("Failed to establish SSH with device " + deviceInfo, e);
226 }
227 }
228
229 private void startClient() throws IOException {
Yuta HIGUCHI2ee4fba2018-06-12 16:21:06 -0700230 log.info("Creating NETCONF session to {}",
231 deviceInfo.getDeviceId());
232
Andrea Campanella7bbe7b12017-05-03 16:03:38 -0700233 client = SshClient.setUpDefaultClient();
Andrea Campanella59227c32019-01-07 14:52:35 +0100234 if (idleTimeout != NetconfControllerImpl.netconfIdleTimeout) {
235 client.getProperties().putIfAbsent(FactoryManager.IDLE_TIMEOUT,
236 TimeUnit.SECONDS.toMillis(idleTimeout));
237 client.getProperties().putIfAbsent(FactoryManager.NIO2_READ_TIMEOUT,
238 TimeUnit.SECONDS.toMillis(idleTimeout + 15L));
239 }
Andrea Campanella7bbe7b12017-05-03 16:03:38 -0700240 client.start();
241 client.setKeyPairProvider(new SimpleGeneratorHostKeyProvider());
242 startSession();
DongRyeol Chac29f9072018-11-06 14:05:56 +0900243
244 disconnected = false;
Andrea Campanella7bbe7b12017-05-03 16:03:38 -0700245 }
246
Yuta HIGUCHI4f55c672018-06-14 18:10:43 -0700247 //TODO: Remove the default methods already implemented in NetconfSession
248
Yuta HIGUCHI6e6c26e2017-09-06 14:25:57 -0700249 // FIXME blocking
250 @Deprecated
Andrea Campanella7bbe7b12017-05-03 16:03:38 -0700251 private void startSession() throws IOException {
252 final ConnectFuture connectFuture;
253 connectFuture = client.connect(deviceInfo.name(),
Kamil Stasiak9f59f442017-05-02 11:02:24 +0200254 deviceInfo.ip().toString(),
255 deviceInfo.port())
Sean Condon54d82432017-07-26 22:27:25 +0100256 .verify(connectTimeout, TimeUnit.SECONDS);
Andrea Campanella7bbe7b12017-05-03 16:03:38 -0700257 session = connectFuture.getSession();
258 //Using the device ssh key if possible
259 if (deviceInfo.getKey() != null) {
Yuta HIGUCHIb2d05242017-09-05 15:44:34 -0700260 try (PEMParser pemParser = new PEMParser(new CharArrayReader(deviceInfo.getKey()))) {
261 JcaPEMKeyConverter converter = new JcaPEMKeyConverter().setProvider(BouncyCastleProvider.PROVIDER_NAME);
262 try {
263 KeyPair kp = converter.getKeyPair((PEMKeyPair) pemParser.readObject());
264 session.addPublicKeyIdentity(kp);
265 } catch (IOException e) {
266 throw new NetconfException("Failed to authenticate session with device " +
267 deviceInfo + "check key to be a valid key", e);
268 }
Andrea Campanella7bbe7b12017-05-03 16:03:38 -0700269 }
Andrea Campanella7bbe7b12017-05-03 16:03:38 -0700270 } else {
271 session.addPasswordIdentity(deviceInfo.password());
272 }
Sean Condon54d82432017-07-26 22:27:25 +0100273 session.auth().verify(connectTimeout, TimeUnit.SECONDS);
Andrea Campanella7bbe7b12017-05-03 16:03:38 -0700274 Set<ClientSession.ClientSessionEvent> event = session.waitFor(
275 ImmutableSet.of(ClientSession.ClientSessionEvent.WAIT_AUTH,
Kamil Stasiak9f59f442017-05-02 11:02:24 +0200276 ClientSession.ClientSessionEvent.CLOSED,
277 ClientSession.ClientSessionEvent.AUTHED), 0);
Andrea Campanella7bbe7b12017-05-03 16:03:38 -0700278
279 if (!event.contains(ClientSession.ClientSessionEvent.AUTHED)) {
280 log.debug("Session closed {} {}", event, session.isClosed());
281 throw new NetconfException("Failed to authenticate session with device " +
Kamil Stasiak9f59f442017-05-02 11:02:24 +0200282 deviceInfo + "check the user/pwd or key");
Andrea Campanella7bbe7b12017-05-03 16:03:38 -0700283 }
284 openChannel();
285 }
286
287 private PublicKey getPublicKey(byte[] keyBytes, String type)
288 throws NoSuchAlgorithmException, InvalidKeySpecException {
289
290 X509EncodedKeySpec spec =
291 new X509EncodedKeySpec(keyBytes);
292 KeyFactory kf = KeyFactory.getInstance(type);
293 return kf.generatePublic(spec);
294 }
295
Yuta HIGUCHI6e6c26e2017-09-06 14:25:57 -0700296 // FIXME blocking
297 @Deprecated
Andrea Campanella7bbe7b12017-05-03 16:03:38 -0700298 private void openChannel() throws IOException {
299 channel = session.createSubsystemChannel("netconf");
300 OpenFuture channelFuture = channel.open();
Sean Condon54d82432017-07-26 22:27:25 +0100301 if (channelFuture.await(connectTimeout, TimeUnit.SECONDS)) {
Andrea Campanella7bbe7b12017-05-03 16:03:38 -0700302 if (channelFuture.isOpened()) {
303 streamHandler = new NetconfStreamThread(channel.getInvertedOut(), channel.getInvertedIn(),
Kamil Stasiak9f59f442017-05-02 11:02:24 +0200304 channel.getInvertedErr(), deviceInfo,
305 new NetconfSessionDelegateImpl(), replies);
Andrea Campanella59227c32019-01-07 14:52:35 +0100306 primaryListeners.forEach(l -> streamHandler.addDeviceEventListener(l));
Andrea Campanella7bbe7b12017-05-03 16:03:38 -0700307 } else {
308 throw new NetconfException("Failed to open channel with device " +
Kamil Stasiak9f59f442017-05-02 11:02:24 +0200309 deviceInfo);
Andrea Campanella7bbe7b12017-05-03 16:03:38 -0700310 }
311 sendHello();
312 }
313 }
314
315
316 @Beta
317 protected void startSubscriptionStream(String filterSchema) throws NetconfException {
318 boolean openNewSession = false;
319 if (!deviceCapabilities.contains(INTERLEAVE_CAPABILITY_STRING)) {
320 log.info("Device {} doesn't support interleave, creating child session", deviceInfo);
321 openNewSession = true;
322
323 } else if (subscriptionConnected &&
324 notificationFilterSchema != null &&
325 !Objects.equal(filterSchema, notificationFilterSchema)) {
326 // interleave supported and existing filter is NOT "no filtering"
327 // and was requested with different filtering schema
328 log.info("Cannot use existing session for subscription {} ({})",
Kamil Stasiak9f59f442017-05-02 11:02:24 +0200329 deviceInfo, filterSchema);
Andrea Campanella7bbe7b12017-05-03 16:03:38 -0700330 openNewSession = true;
331 }
332
333 if (openNewSession) {
334 log.info("Creating notification session to {} with filter {}",
Kamil Stasiak9f59f442017-05-02 11:02:24 +0200335 deviceInfo, filterSchema);
Andrea Campanella7bbe7b12017-05-03 16:03:38 -0700336 NetconfSession child = new NotificationSession(deviceInfo);
337
338 child.addDeviceOutputListener(new NotificationForwarder());
339
340 child.startSubscription(filterSchema);
341 children.add(child);
342 return;
343 }
344
345 // request to start interleaved notification session
346 String reply = sendRequest(createSubscriptionString(filterSchema));
347 if (!checkReply(reply)) {
348 throw new NetconfException("Subscription not successful with device "
Kamil Stasiak9f59f442017-05-02 11:02:24 +0200349 + deviceInfo + " with reply " + reply);
Andrea Campanella7bbe7b12017-05-03 16:03:38 -0700350 }
351 subscriptionConnected = true;
352 }
353
Andrea Campanella7bbe7b12017-05-03 16:03:38 -0700354 @Beta
355 @Override
356 public void startSubscription(String filterSchema) throws NetconfException {
357 if (!subscriptionConnected) {
358 notificationFilterSchema = filterSchema;
359 startSubscriptionStream(filterSchema);
360 }
361 streamHandler.setEnableNotifications(true);
362 }
363
364 @Beta
365 protected String createSubscriptionString(String filterSchema) {
366 StringBuilder subscriptionbuffer = new StringBuilder();
367 subscriptionbuffer.append("<rpc xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\">\n");
368 subscriptionbuffer.append(" <create-subscription\n");
369 subscriptionbuffer.append("xmlns=\"urn:ietf:params:xml:ns:netconf:notification:1.0\">\n");
Laszlo Pappbdb64082018-09-11 12:21:29 +0100370 DriverService driverService = directory.get(DriverService.class);
371 Driver driver = driverService.getDriver(deviceInfo.getDeviceId());
372 if (driver != null) {
373 String stream = driver.getProperty(NOTIFICATION_STREAM);
374 if (stream != null) {
375 subscriptionbuffer.append(" <stream>");
376 subscriptionbuffer.append(stream);
377 subscriptionbuffer.append("</stream>\n");
378 }
379 }
Andrea Campanella7bbe7b12017-05-03 16:03:38 -0700380 // FIXME Only subtree filtering supported at the moment.
381 if (filterSchema != null) {
382 subscriptionbuffer.append(" ");
383 subscriptionbuffer.append(SUBSCRIPTION_SUBTREE_FILTER_OPEN).append(NEW_LINE);
384 subscriptionbuffer.append(filterSchema).append(NEW_LINE);
385 subscriptionbuffer.append(" ");
386 subscriptionbuffer.append(SUBTREE_FILTER_CLOSE).append(NEW_LINE);
387 }
388 subscriptionbuffer.append(" </create-subscription>\n");
389 subscriptionbuffer.append("</rpc>\n");
390 subscriptionbuffer.append(ENDPATTERN);
391 return subscriptionbuffer.toString();
392 }
393
394 @Override
395 public void endSubscription() throws NetconfException {
396 if (subscriptionConnected) {
397 streamHandler.setEnableNotifications(false);
398 } else {
399 throw new NetconfException("Subscription does not exist.");
400 }
401 }
402
DongRyeol Chac29f9072018-11-06 14:05:56 +0900403 private void stopClient() {
404 if (session != null) {
405 try {
406 session.close();
407 } catch (IOException ex) {
408 log.warn("Cannot close session {} {}", sessionID, deviceInfo, ex);
409 }
410 }
411
412 if (channel != null) {
413 try {
414 channel.close();
415 } catch (IOException ex) {
416 log.warn("Cannot close channel {} {}", sessionID, deviceInfo, ex);
417 }
418 }
419
420 if (client != null) {
421 try {
422 client.close();
423 } catch (IOException ex) {
424 log.warn("Cannot close client {} {}", sessionID, deviceInfo, ex);
425 }
426
427 client.stop();
428 }
429 }
430
Andrea Campanella7bbe7b12017-05-03 16:03:38 -0700431 private void sendHello() throws NetconfException {
Yuta HIGUCHI371667d2017-09-05 17:30:51 -0700432 String serverHelloResponse = sendRequest(createHelloString(), true);
433 Matcher capabilityMatcher = CAPABILITY_REGEX_PATTERN.matcher(serverHelloResponse);
Andrea Campanella7bbe7b12017-05-03 16:03:38 -0700434 while (capabilityMatcher.find()) {
435 deviceCapabilities.add(capabilityMatcher.group(1));
436 }
437 sessionID = String.valueOf(-1);
Yuta HIGUCHI371667d2017-09-05 17:30:51 -0700438 Matcher sessionIDMatcher = SESSION_ID_REGEX_PATTERN.matcher(serverHelloResponse);
Andrea Campanella7bbe7b12017-05-03 16:03:38 -0700439 if (sessionIDMatcher.find()) {
440 sessionID = sessionIDMatcher.group(1);
441 } else {
442 throw new NetconfException("Missing SessionID in server hello " +
Kamil Stasiak9f59f442017-05-02 11:02:24 +0200443 "reponse.");
Andrea Campanella7bbe7b12017-05-03 16:03:38 -0700444 }
445
446 }
447
448 private String createHelloString() {
449 StringBuilder hellobuffer = new StringBuilder();
450 hellobuffer.append(XML_HEADER);
451 hellobuffer.append("\n");
452 hellobuffer.append("<hello xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\">\n");
453 hellobuffer.append(" <capabilities>\n");
454 onosCapabilities.forEach(
455 cap -> hellobuffer.append(" <capability>")
456 .append(cap)
457 .append("</capability>\n"));
458 hellobuffer.append(" </capabilities>\n");
459 hellobuffer.append("</hello>\n");
460 hellobuffer.append(ENDPATTERN);
461 return hellobuffer.toString();
462
463 }
464
465 @Override
466 public void checkAndReestablish() throws NetconfException {
DongRyeol Chac29f9072018-11-06 14:05:56 +0900467 if (disconnected) {
468 log.warn("Can't reopen connection for device because of disconnected {}", deviceInfo.getDeviceId());
469 throw new NetconfException("Can't reopen connection for device because of disconnected " + deviceInfo);
470 }
471
Andrea Campanella7bbe7b12017-05-03 16:03:38 -0700472 try {
zhongguo zhao98bb37a2018-08-28 16:17:06 +0800473 if (client.isClosed() || client.isClosing()) {
Andrea Campanella7bbe7b12017-05-03 16:03:38 -0700474 log.debug("Trying to restart the whole SSH connection with {}", deviceInfo.getDeviceId());
475 cleanUp();
476 startConnection();
zhongguo zhao98bb37a2018-08-28 16:17:06 +0800477 } else if (session.isClosed() || session.isClosing()) {
Kieran McPeakee1b418f2019-05-23 13:42:13 +0100478 log.debug("Trying to restart the session {} with {}", session, deviceInfo.getDeviceId());
Andrea Campanella7bbe7b12017-05-03 16:03:38 -0700479 cleanUp();
480 startSession();
zhongguo zhao98bb37a2018-08-28 16:17:06 +0800481 } else if (channel.isClosed() || channel.isClosing()) {
Andrea Campanella7bbe7b12017-05-03 16:03:38 -0700482 log.debug("Trying to reopen the channel with {}", deviceInfo.getDeviceId());
483 cleanUp();
484 openChannel();
Andrea Campanella856f3132017-10-23 15:46:36 +0200485 } else {
486 return;
Andrea Campanella7bbe7b12017-05-03 16:03:38 -0700487 }
488 if (subscriptionConnected) {
489 log.debug("Restarting subscription with {}", deviceInfo.getDeviceId());
490 subscriptionConnected = false;
491 startSubscription(notificationFilterSchema);
492 }
Sean Condon7347de92017-07-21 12:17:25 +0100493 } catch (IOException | IllegalStateException e) {
Andrea Campanella7bbe7b12017-05-03 16:03:38 -0700494 log.error("Can't reopen connection for device {}", e.getMessage());
495 throw new NetconfException("Cannot re-open the connection with device" + deviceInfo, e);
496 }
497 }
498
499 private void cleanUp() {
500 //makes sure everything is at a clean state.
501 replies.clear();
David K. Bainbridge9b582b02019-02-01 16:04:05 -0800502 if (streamHandler != null) {
503 streamHandler.close();
504 }
Andrea Campanella7bbe7b12017-05-03 16:03:38 -0700505 }
506
507 @Override
508 public String requestSync(String request) throws NetconfException {
gyewan.an91d7e7e2019-01-17 15:12:48 +0900509 return requestSync(request, replyTimeout);
510 }
511
512 @Override
513 public String requestSync(String request, int timeout) throws NetconfException {
514 String reply = sendRequest(request, timeout);
Kim JeongWoo8b03bc52018-08-10 16:50:23 +0900515 if (!checkReply(reply)) {
516 throw new NetconfException("Request not successful with device "
gyewan.an91d7e7e2019-01-17 15:12:48 +0900517 + deviceInfo + " with reply " + reply);
Kim JeongWoo8b03bc52018-08-10 16:50:23 +0900518 }
Andrea Campanella7bbe7b12017-05-03 16:03:38 -0700519 return reply;
520 }
521
Kamil Stasiak9f59f442017-05-02 11:02:24 +0200522
Yuta HIGUCHI371667d2017-09-05 17:30:51 -0700523 // FIXME rename to align with what it actually do
Kamil Stasiak9f59f442017-05-02 11:02:24 +0200524 /**
525 * Validate and format netconf message.
Yuta HIGUCHI371667d2017-09-05 17:30:51 -0700526 * - NC1.0 if no EOM sequence present on {@code message}, append.
527 * - NC1.1 chunk-encode given message unless it already is chunk encoded
Kamil Stasiak9f59f442017-05-02 11:02:24 +0200528 *
529 * @param message to format
530 * @return formated message
531 */
532 private String formatNetconfMessage(String message) {
533 if (deviceCapabilities.contains(NETCONF_11_CAPABILITY)) {
534 message = formatChunkedMessage(message);
535 } else {
Yuta HIGUCHI371667d2017-09-05 17:30:51 -0700536 if (!message.endsWith(ENDPATTERN)) {
Kamil Stasiak9f59f442017-05-02 11:02:24 +0200537 message = message + NEW_LINE + ENDPATTERN;
538 }
539 }
Yuta HIGUCHI371667d2017-09-05 17:30:51 -0700540 return message;
Kamil Stasiak9f59f442017-05-02 11:02:24 +0200541 }
542
543 /**
544 * Validate and format message according to chunked framing mechanism.
545 *
546 * @param message to format
547 * @return formated message
548 */
549 private String formatChunkedMessage(String message) {
550 if (message.endsWith(ENDPATTERN)) {
Yuta HIGUCHIb2d05242017-09-05 15:44:34 -0700551 // message given had Netconf 1.0 EOM pattern -> remove
Kamil Stasiak9f59f442017-05-02 11:02:24 +0200552 message = message.substring(0, message.length() - ENDPATTERN.length());
553 }
554 if (!message.startsWith(LF + HASH)) {
Yuta HIGUCHIb2d05242017-09-05 15:44:34 -0700555 // chunk encode message
Yuta HIGUCHI15677982017-08-16 15:50:29 -0700556 message = LF + HASH + message.getBytes(UTF_8).length + LF + message + LF + HASH + HASH + LF;
Kamil Stasiak9f59f442017-05-02 11:02:24 +0200557 }
558 return message;
559 }
560
Andrea Campanella7bbe7b12017-05-03 16:03:38 -0700561 @Override
562 @Deprecated
563 public CompletableFuture<String> request(String request) {
564 return streamHandler.sendMessage(request);
565 }
566
Yuta HIGUCHI6e6c26e2017-09-06 14:25:57 -0700567 /**
568 * {@inheritDoc}
569 * <p>
570 * FIXME Note: as of 1.12.0
571 * {@code request} must not include message-id, this method will assign
572 * and insert message-id on it's own.
573 * Will require ONOS-7019 to remove this limitation.
574 */
575 @Override
576 public CompletableFuture<String> rpc(String request) {
577
578 String rpc = request;
579 // - assign message-id
580 int msgId = messageIdInteger.incrementAndGet();
581 // - re-write request to insert message-id
582 // FIXME avoid using formatRequestMessageId
583 rpc = formatRequestMessageId(rpc, msgId);
584 // - ensure it contains XML header
585 rpc = formatXmlHeader(rpc);
586 // - use chunked framing if talking to NC 1.1 device
587 // FIXME avoid using formatNetconfMessage
588 rpc = formatNetconfMessage(rpc);
589
590 // TODO session liveness check & recovery
591
592 log.debug("Sending {} to {}", rpc, this.deviceInfo.getDeviceId());
593 return streamHandler.sendMessage(rpc, msgId)
594 .handleAsync((reply, t) -> {
595 if (t != null) {
596 // secure transport-layer error
597 // cannot use NetconfException, which is
598 // checked Exception.
599 throw new NetconfTransportException(t);
600 } else {
601 // FIXME avoid using checkReply, error handling is weird
Kim JeongWoo8b03bc52018-08-10 16:50:23 +0900602 if (!checkReply(reply)) {
603 throw new NetconfTransportException("rpc-request not successful with device "
604 + deviceInfo + " with reply " + reply);
605 }
Yuta HIGUCHI6e6c26e2017-09-06 14:25:57 -0700606 return reply;
607 }
608 }, SharedExecutors.getPoolThreadExecutor());
609 }
610
Sean Condon54d82432017-07-26 22:27:25 +0100611 @Override
612 public int timeoutConnectSec() {
613 return connectTimeout;
614 }
615
616 @Override
617 public int timeoutReplySec() {
618 return replyTimeout;
619 }
620
621 @Override
622 public int timeoutIdleSec() {
623 return idleTimeout;
624 }
625
Andrea Campanella7bbe7b12017-05-03 16:03:38 -0700626 private CompletableFuture<String> request(String request, int messageId) {
627 return streamHandler.sendMessage(request, messageId);
628 }
629
gyewan.an91d7e7e2019-01-17 15:12:48 +0900630 private String sendRequest(String request, boolean isHello) throws NetconfException {
631 return sendRequest(request, isHello, replyTimeout);
632 }
633
Andrea Campanella7bbe7b12017-05-03 16:03:38 -0700634 private String sendRequest(String request) throws NetconfException {
Yuta HIGUCHIb2d05242017-09-05 15:44:34 -0700635 // FIXME probably chunk-encoding too early
Kamil Stasiak9f59f442017-05-02 11:02:24 +0200636 request = formatNetconfMessage(request);
gyewan.an91d7e7e2019-01-17 15:12:48 +0900637 return sendRequest(request, false, replyTimeout);
Andrea Campanella7bbe7b12017-05-03 16:03:38 -0700638 }
639
gyewan.an91d7e7e2019-01-17 15:12:48 +0900640 private String sendRequest(String request, int timeout) throws NetconfException {
641 // FIXME probably chunk-encoding too early
642 request = formatNetconfMessage(request);
643 return sendRequest(request, false, timeout);
644 }
645
646 private String sendRequest(String request, boolean isHello, int timeout) throws NetconfException {
Andrea Campanella7bbe7b12017-05-03 16:03:38 -0700647 checkAndReestablish();
648 int messageId = -1;
649 if (!isHello) {
650 messageId = messageIdInteger.getAndIncrement();
651 }
Yuta HIGUCHIb2d05242017-09-05 15:44:34 -0700652 // FIXME potentially re-writing chunked encoded String?
Andrea Campanella7bbe7b12017-05-03 16:03:38 -0700653 request = formatXmlHeader(request);
Kamil Stasiak9f59f442017-05-02 11:02:24 +0200654 request = formatRequestMessageId(request, messageId);
Yuta HIGUCHI371667d2017-09-05 17:30:51 -0700655 log.debug("Sending request to NETCONF with timeout {} for {}",
656 replyTimeout, deviceInfo.name());
Andrea Campanella7bbe7b12017-05-03 16:03:38 -0700657 CompletableFuture<String> futureReply = request(request, messageId);
Andrea Campanella7bbe7b12017-05-03 16:03:38 -0700658 String rp;
659 try {
660 rp = futureReply.get(replyTimeout, TimeUnit.SECONDS);
Sean Condon7347de92017-07-21 12:17:25 +0100661 replies.remove(messageId); // Why here???
662 } catch (InterruptedException e) {
663 Thread.currentThread().interrupt();
664 throw new NetconfException("Interrupted waiting for reply for request" + request, e);
665 } catch (TimeoutException e) {
Sean Condon54d82432017-07-26 22:27:25 +0100666 throw new NetconfException("Timed out waiting for reply for request " +
667 request + " after " + replyTimeout + " sec.", e);
Sean Condon7347de92017-07-21 12:17:25 +0100668 } catch (ExecutionException e) {
669 log.warn("Closing session {} for {} due to unexpected Error", sessionID, deviceInfo, e);
DongRyeol Chac29f9072018-11-06 14:05:56 +0900670 stopClient();
Sean Condon7347de92017-07-21 12:17:25 +0100671 NetconfDeviceOutputEvent event = new NetconfDeviceOutputEvent(
672 NetconfDeviceOutputEvent.Type.SESSION_CLOSED,
673 null, "Closed due to unexpected error " + e.getCause(),
674 Optional.of(-1), deviceInfo);
675 publishEvent(event);
676 errorReplies.clear(); // move to cleanUp()?
677 cleanUp();
678
679 throw new NetconfException("Closing session " + sessionID + " for " + deviceInfo +
680 " for request " + request, e);
Andrea Campanella7bbe7b12017-05-03 16:03:38 -0700681 }
682 log.debug("Result {} from request {} to device {}", rp, request, deviceInfo);
683 return rp.trim();
684 }
685
686 private String formatRequestMessageId(String request, int messageId) {
687 if (request.contains(MESSAGE_ID_STRING)) {
688 //FIXME if application provides his own counting of messages this fails that count
Yuta HIGUCHI371667d2017-09-05 17:30:51 -0700689 // FIXME assumes message-id is integer. RFC6241 allows anything as long as it is allowed in XML
Andrea Campanella7bbe7b12017-05-03 16:03:38 -0700690 request = request.replaceFirst(MESSAGE_ID_STRING + EQUAL + NUMBER_BETWEEN_QUOTES_MATCHER,
Kamil Stasiak9f59f442017-05-02 11:02:24 +0200691 MESSAGE_ID_STRING + EQUAL + "\"" + messageId + "\"");
Andrea Campanella7bbe7b12017-05-03 16:03:38 -0700692 } else if (!request.contains(MESSAGE_ID_STRING) && !request.contains(HELLO)) {
693 //FIXME find out a better way to enforce the presence of message-id
694 request = request.replaceFirst(END_OF_RPC_OPEN_TAG, "\" " + MESSAGE_ID_STRING + EQUAL + "\""
695 + messageId + "\"" + ">");
696 }
Yuta HIGUCHI371667d2017-09-05 17:30:51 -0700697 request = updateRequestLength(request);
Kamil Stasiak9f59f442017-05-02 11:02:24 +0200698 return request;
699 }
700
Yuta HIGUCHI371667d2017-09-05 17:30:51 -0700701 private String updateRequestLength(String request) {
Kamil Stasiak9f59f442017-05-02 11:02:24 +0200702 if (request.contains(LF + HASH + HASH + LF)) {
703 int oldLen = Integer.parseInt(request.split(HASH)[1].split(LF)[0]);
704 String rpcWithEnding = request.substring(request.indexOf('<'));
705 String firstBlock = request.split(MSGLEN_REGEX_PATTERN)[1].split(LF + HASH + HASH + LF)[0];
706 int newLen = 0;
Yuta HIGUCHI15677982017-08-16 15:50:29 -0700707 newLen = firstBlock.getBytes(UTF_8).length;
Kamil Stasiak9f59f442017-05-02 11:02:24 +0200708 if (oldLen != newLen) {
709 return LF + HASH + newLen + LF + rpcWithEnding;
710 }
711 }
Andrea Campanella7bbe7b12017-05-03 16:03:38 -0700712 return request;
713 }
714
Yuta HIGUCHI371667d2017-09-05 17:30:51 -0700715 /**
716 * Ensures xml start directive/declaration appears in the {@code request}.
717 * @param request RPC request message
718 * @return XML RPC message
719 */
Andrea Campanella7bbe7b12017-05-03 16:03:38 -0700720 private String formatXmlHeader(String request) {
Sean Condon2d647172017-09-19 12:29:13 +0100721 if (!request.contains(XML_HEADER)) {
Yuta HIGUCHI15677982017-08-16 15:50:29 -0700722 //FIXME if application provides his own XML header of different type there is a clash
Kamil Stasiak9f59f442017-05-02 11:02:24 +0200723 if (request.startsWith(LF + HASH)) {
724 request = request.split("<")[0] + XML_HEADER + request.substring(request.split("<")[0].length());
725 } else {
726 request = XML_HEADER + "\n" + request;
727 }
Andrea Campanella7bbe7b12017-05-03 16:03:38 -0700728 }
729 return request;
730 }
731
732 @Override
Andrea Campanella7bbe7b12017-05-03 16:03:38 -0700733 public String getSessionId() {
734 return sessionID;
735 }
736
737 @Override
738 public Set<String> getDeviceCapabilitiesSet() {
739 return Collections.unmodifiableSet(deviceCapabilities);
740 }
741
Andrea Campanella7bbe7b12017-05-03 16:03:38 -0700742 @Override
743 public void setOnosCapabilities(Iterable<String> capabilities) {
744 onosCapabilities = capabilities;
745 }
746
747
748 @Override
749 public void addDeviceOutputListener(NetconfDeviceOutputEventListener listener) {
750 streamHandler.addDeviceEventListener(listener);
751 primaryListeners.add(listener);
752 }
753
754 @Override
755 public void removeDeviceOutputListener(NetconfDeviceOutputEventListener listener) {
756 primaryListeners.remove(listener);
757 streamHandler.removeDeviceEventListener(listener);
758 }
759
Yuta HIGUCHI4f55c672018-06-14 18:10:43 -0700760 @Override
761 protected boolean checkReply(String reply) {
762 // Overridden to record error logs
Andrea Campanella7bbe7b12017-05-03 16:03:38 -0700763 if (reply != null) {
764 if (!reply.contains("<rpc-error>")) {
765 log.debug("Device {} sent reply {}", deviceInfo, reply);
766 return true;
767 } else if (reply.contains("<ok/>")
768 || (reply.contains("<rpc-error>")
769 && reply.contains("warning"))) {
Yuta HIGUCHI6e6c26e2017-09-06 14:25:57 -0700770 // FIXME rpc-error with a warning is considered same as Ok??
Andrea Campanella7bbe7b12017-05-03 16:03:38 -0700771 log.debug("Device {} sent reply {}", deviceInfo, reply);
772 return true;
773 }
774 }
775 log.warn("Device {} has error in reply {}", deviceInfo, reply);
776 return false;
777 }
778
zhongguo zhao78eab372018-08-27 16:22:39 +0800779 @Override
780 public boolean close() throws NetconfException {
781 try {
DongRyeol Chac29f9072018-11-06 14:05:56 +0900782 if (client != null && (client.isClosed() || client.isClosing())) {
783 return true;
784 }
785
zhongguo zhao78eab372018-08-27 16:22:39 +0800786 return super.close();
787 } catch (IOException ioe) {
788 throw new NetconfException(ioe.getMessage());
789 } finally {
DongRyeol Chac29f9072018-11-06 14:05:56 +0900790 disconnected = true;
791 stopClient();
zhongguo zhao78eab372018-08-27 16:22:39 +0800792 }
793 }
794
Sean Condon7347de92017-07-21 12:17:25 +0100795 protected void publishEvent(NetconfDeviceOutputEvent event) {
796 primaryListeners.forEach(lsnr -> {
797 if (lsnr.isRelevant(event)) {
798 lsnr.event(event);
799 }
800 });
801 }
802
Andrea Campanella7bbe7b12017-05-03 16:03:38 -0700803 static class NotificationSession extends NetconfSessionMinaImpl {
804
805 private String notificationFilter;
806
807 NotificationSession(NetconfDeviceInfo deviceInfo)
808 throws NetconfException {
809 super(deviceInfo);
810 }
811
812 @Override
813 protected void startSubscriptionStream(String filterSchema)
814 throws NetconfException {
815
816 notificationFilter = filterSchema;
817 requestSync(createSubscriptionString(filterSchema));
818 }
819
820 @Override
821 public String toString() {
822 return MoreObjects.toStringHelper(getClass())
823 .add("deviceInfo", deviceInfo)
824 .add("sessionID", getSessionId())
825 .add("notificationFilter", notificationFilter)
826 .toString();
827 }
828 }
829
830 /**
831 * Listener attached to child session for notification streaming.
832 * <p>
833 * Forwards all notification event from child session to primary session
834 * listeners.
835 */
836 private final class NotificationForwarder
837 implements NetconfDeviceOutputEventListener {
838
839 @Override
840 public boolean isRelevant(NetconfDeviceOutputEvent event) {
841 return event.type() == Type.DEVICE_NOTIFICATION;
842 }
843
844 @Override
845 public void event(NetconfDeviceOutputEvent event) {
Sean Condon7347de92017-07-21 12:17:25 +0100846 publishEvent(event);
Andrea Campanella7bbe7b12017-05-03 16:03:38 -0700847 }
848 }
849
850 public class NetconfSessionDelegateImpl implements NetconfSessionDelegate {
851
852 @Override
853 public void notify(NetconfDeviceOutputEvent event) {
854 Optional<Integer> messageId = event.getMessageID();
855 log.debug("messageID {}, waiting replies messageIDs {}", messageId,
Kamil Stasiak9f59f442017-05-02 11:02:24 +0200856 replies.keySet());
Andrea Campanella7bbe7b12017-05-03 16:03:38 -0700857 if (!messageId.isPresent()) {
858 errorReplies.add(event.getMessagePayload());
859 log.error("Device {} sent error reply {}",
Kamil Stasiak9f59f442017-05-02 11:02:24 +0200860 event.getDeviceInfo(), event.getMessagePayload());
Andrea Campanella7bbe7b12017-05-03 16:03:38 -0700861 return;
862 }
David K. Bainbridge77d8ca42019-02-01 11:47:29 -0800863 // Remove the message as it has been processed.
864 CompletableFuture<String> completedReply = replies.remove(messageId.get());
Andrea Campanella7bbe7b12017-05-03 16:03:38 -0700865 if (completedReply != null) {
866 completedReply.complete(event.getMessagePayload());
867 }
868 }
869 }
870
Yuta HIGUCHI2ee4fba2018-06-12 16:21:06 -0700871 /**
872 * @deprecated in 1.14.0
873 */
874 @Deprecated
Andrea Campanella7bbe7b12017-05-03 16:03:38 -0700875 public static class MinaSshNetconfSessionFactory implements NetconfSessionFactory {
876
877 @Override
gyewan.an91d7e7e2019-01-17 15:12:48 +0900878 public NetconfSession createNetconfSession(NetconfDeviceInfo netconfDeviceInfo,
879 NetconfController netconfController) throws NetconfException {
Andrea Campanella7bbe7b12017-05-03 16:03:38 -0700880 return new NetconfSessionMinaImpl(netconfDeviceInfo);
881 }
882 }
Sean Condon54d82432017-07-26 22:27:25 +0100883}