blob: 22351cbc36563c07dbdd3f95a004a02a981b5f23 [file] [log] [blame]
Andrea Campanella101417d2015-12-11 17:58:07 -08001/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2015-present Open Networking Laboratory
Andrea Campanella101417d2015-12-11 17:58:07 -08003 *
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;
18
19import org.onosproject.netconf.NetconfDeviceInfo;
20import org.onosproject.netconf.NetconfDeviceOutputEvent;
21import org.onosproject.netconf.NetconfDeviceOutputEventListener;
22import org.slf4j.Logger;
23import org.slf4j.LoggerFactory;
24
25/**
26 * Example of a listener for events that happen a Netconf session established
27 * for a particular NETCONF device.
Yuta HIGUCHIe3ae8212017-04-20 10:18:41 -070028 *
Yuta HIGUCHI66372fd2017-04-21 20:19:34 -070029 * @deprecated in 1.10.0 use FilteringNetconfDeviceOutputEventListener
Andrea Campanella101417d2015-12-11 17:58:07 -080030 */
Yuta HIGUCHIe3ae8212017-04-20 10:18:41 -070031@Deprecated
Andrea Campanella101417d2015-12-11 17:58:07 -080032public class NetconfDeviceOutputEventListenerImpl implements NetconfDeviceOutputEventListener {
33
34 private static final Logger log =
35 LoggerFactory.getLogger(NetconfDeviceOutputEventListenerImpl.class);
36
37 private NetconfDeviceInfo deviceInfo;
38
39 public NetconfDeviceOutputEventListenerImpl(NetconfDeviceInfo deviceInfo) {
40 this.deviceInfo = deviceInfo;
41 }
42
43 @Override
44 public void event(NetconfDeviceOutputEvent event) {
45 switch (event.type()) {
46 case DEVICE_REPLY:
47 log.debug("Device {} has reply: {}", deviceInfo, event.getMessagePayload());
48 break;
49 case DEVICE_NOTIFICATION:
50 log.info("Device {} has notification: {}", deviceInfo, event.getMessagePayload());
51 break;
52 case DEVICE_UNREGISTERED:
53 log.warn("Device {} has closed session", deviceInfo);
Andrea Campanella101417d2015-12-11 17:58:07 -080054 break;
55 case DEVICE_ERROR:
56 log.warn("Device {} has error: {}", deviceInfo, event.getMessagePayload());
57 break;
Andrea Campanellac3627842017-04-04 18:06:54 +020058 case SESSION_CLOSED:
59 log.warn("Device {} has closed Session: {}", deviceInfo, event.getMessagePayload());
60 break;
Andrea Campanella101417d2015-12-11 17:58:07 -080061 default:
62 log.warn("Wrong event type {} ", event.type());
63 }
64
65 }
66
67 @Override
68 public boolean isRelevant(NetconfDeviceOutputEvent event) {
69 return deviceInfo.equals(event.getDeviceInfo());
70 }
71}