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;
24 import java.util.List;
25 import org.eclipse.jdt.annotation.NonNull;
26 import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.DataProvider;
27 import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfAccessor;
28 import org.opendaylight.yang.gen.v1.http.org.openroadm.alarm.rev191129.OrgOpenroadmAlarmListener;
29 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev191129.ChangeNotification;
30 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev191129.CreateTechInfoNotification;
31 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev191129.OrgOpenroadmDeviceListener;
32 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev191129.OtdrScanResult;
33 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev191129.change.notification.Edit;
34 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.EventlogBuilder;
35 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.SourceType;
36 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
37 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier.PathArgument;
38 import org.slf4j.Logger;
39 import org.slf4j.LoggerFactory;
42 * @author Shabnam Sultana
44 * Listener for Open roadm device specific change notifications
47 public class OpenroadmDeviceChangeNotificationListener implements OrgOpenroadmDeviceListener {
49 private static final Logger log = LoggerFactory.getLogger(OrgOpenroadmAlarmListener.class);
50 private Integer counter = 1;
51 private final NetconfAccessor netconfAccessor;
52 private final DataProvider databaseProvider;
56 public OpenroadmDeviceChangeNotificationListener(NetconfAccessor netconfAccessor, DataProvider databaseService) {
57 this.netconfAccessor = netconfAccessor;
58 this.databaseProvider = databaseService;
60 // end of constructors
64 public void onOtdrScanResult(OtdrScanResult notification) {
65 // TODO Auto-generated method stub
70 public void onChangeNotification(ChangeNotification notification) {
71 log.info("onDeviceConfigChange(1){}", notification);
72 StringBuffer sb = new StringBuffer();
75 List<Edit> editList = notification.nonnullEdit();
76 for (Edit edit : editList) {
77 if (sb.length() > 0) {
81 EventlogBuilder eventlogBuilder = new EventlogBuilder();
82 InstanceIdentifier<?> target = edit.getTarget();
84 eventlogBuilder.setObjectId(target.getPathArguments().toString());
85 log.info("TARGET: {} {}", target.getClass(), target.getTargetType());
86 for (PathArgument pa : target.getPathArguments()) {
87 log.info("PathArgument {}", pa);
89 eventlogBuilder.setAttributeName(target.getTargetType().getName());
91 eventlogBuilder.setNodeId(netconfAccessor.getNodeId().getValue());
92 eventlogBuilder.setNewValue(String.valueOf(edit.getOperation()));
93 eventlogBuilder.setTimestamp(notification.getChangeTime());
94 eventlogBuilder.setCounter(counter);
95 eventlogBuilder.setSourceType(SourceType.Netconf);
96 databaseProvider.writeEventLog(eventlogBuilder.build());
97 log.info("onDeviceConfigChange (2) {}", sb);
103 public void onCreateTechInfoNotification(CreateTechInfoNotification notification) {
104 // TODO Auto-generated method stub
105 log.info("onCreateTechInfoNotification(1){}", notification);
106 EventlogBuilder eventlogBuilder = new EventlogBuilder();
107 eventlogBuilder.setId(notification.getShelfId()).setAttributeName(notification.getShelfId())
108 .setObjectId(notification.getShelfId()).setNodeId(this.netconfAccessor.getNodeId().getValue())
109 .setCounter(counter).setNewValue(notification.getStatus().getName()).setSourceType(SourceType.Netconf);
110 databaseProvider.writeEventLog(eventlogBuilder.build());
111 log.info("Create-techInfo Notification written ");
114 // end of public methods