2 * ============LICENSE_START=======================================================
3 * ONAP : ccsdk features
4 * ================================================================================
5 * Copyright (C) 2020 highstreet technologies GmbH Intellectual Property.
7 * ================================================================================
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 * ============LICENSE_END=========================================================
22 package org.onap.ccsdk.features.sdnr.wt.devicemanager.openroadm.impl;
25 import org.eclipse.jdt.annotation.NonNull;
26 import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.DeviceManagerServiceProvider;
27 import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.FaultService;
28 import org.onap.ccsdk.features.sdnr.wt.websocketmanager.model.WebsocketManagerService;
29 import org.opendaylight.yang.gen.v1.http.org.openroadm.alarm.rev191129.AlarmNotification;
30 import org.opendaylight.yang.gen.v1.http.org.openroadm.alarm.rev191129.OrgOpenroadmAlarmListener;
31 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.FaultlogBuilder;
32 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.FaultlogEntity;
33 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.SourceType;
34 import org.slf4j.Logger;
35 import org.slf4j.LoggerFactory;
38 * @author Shabnam Sultana
40 * Listener for Open roadm device specific alarm notifications
42 public class OpenroadmFaultNotificationListener implements OrgOpenroadmAlarmListener {
43 private static final Logger log = LoggerFactory.getLogger(OpenroadmFaultNotificationListener.class);
45 private final @NonNull FaultService faultEventListener;
46 private @NonNull WebsocketManagerService notificationService;
47 private Integer count = 1;
50 public OpenroadmFaultNotificationListener(DeviceManagerServiceProvider serviceProvider) {
51 this.faultEventListener = serviceProvider.getFaultService();
52 this.notificationService = serviceProvider.getWebsocketService();
57 public void onAlarmNotification(AlarmNotification notification) {
60 log.info("AlarmNotification {} \t {}", notification.getId(), notification.getAdditionalDetail());
61 final String nodeId = notification.getResource().getDevice().getNodeId().getValue();
62 FaultlogEntity faultAlarm = new FaultlogBuilder().setObjectId(notification.getCircuitId())
63 .setProblem(notification.getProbableCause().getCause().getName()).setSourceType(SourceType.Netconf)
64 .setTimestamp(notification.getRaiseTime()).setId(notification.getId()).setNodeId(nodeId)
65 .setSeverity(InitialDeviceAlarmReader.checkSeverityValue(notification.getSeverity())).setCounter(count)
68 this.faultEventListener.faultNotification(faultAlarm);
69 this.notificationService.sendNotification(notification, nodeId, AlarmNotification.QNAME,
70 notification.getRaiseTime());
72 log.info("Notification is written into the database {}", faultAlarm.getObjectId());