2 * ============LICENSE_START=======================================================
3 * ONAP : ccsdk feature sdnr wt
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.onf14.impl.interfaces;
24 import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.DeviceManagerServiceProvider;
25 import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfAccessor;
26 import org.opendaylight.yang.gen.v1.urn.onf.yang.ethernet.container._2._0.rev200121.AttributeValueChangedNotification;
27 import org.opendaylight.yang.gen.v1.urn.onf.yang.ethernet.container._2._0.rev200121.EthernetContainer20Listener;
28 import org.opendaylight.yang.gen.v1.urn.onf.yang.ethernet.container._2._0.rev200121.ObjectCreationNotification;
29 import org.opendaylight.yang.gen.v1.urn.onf.yang.ethernet.container._2._0.rev200121.ObjectDeletionNotification;
30 import org.opendaylight.yang.gen.v1.urn.onf.yang.ethernet.container._2._0.rev200121.ProblemNotification;
31 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.EventlogBuilder;
32 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.SourceType;
33 import org.slf4j.Logger;
34 import org.slf4j.LoggerFactory;
36 public class Onf14EthernetContainerNotificationListener implements EthernetContainer20Listener {
38 private static final Logger log = LoggerFactory.getLogger(Onf14EthernetContainerNotificationListener.class);
40 private final NetconfAccessor netconfAccessor;
41 private final DeviceManagerServiceProvider serviceProvider;
43 public Onf14EthernetContainerNotificationListener(NetconfAccessor netconfAccessor,
44 DeviceManagerServiceProvider serviceProvider) {
45 this.netconfAccessor = netconfAccessor;
46 this.serviceProvider = serviceProvider;
50 public void onObjectDeletionNotification(ObjectDeletionNotification notification) {
51 log.debug("Got event of type :: {}", ObjectDeletionNotification.class.getSimpleName());
53 EventlogBuilder eventlogBuilder = new EventlogBuilder();
54 eventlogBuilder.setNodeId(netconfAccessor.getNodeId().getValue())
56 .setCounter(notification.getCounter().intValue())
57 .setNewValue("deleted")
58 .setObjectId(notification.getObjectIdRef().getValue())
59 .setSourceType(SourceType.Netconf)
60 .setTimestamp(notification.getTimestamp());
61 serviceProvider.getDataProvider().writeEventLog(eventlogBuilder.build());
62 serviceProvider.getNotificationService().deletionNotification(netconfAccessor.getNodeId(),
63 notification.getCounter().intValue(), notification.getTimestamp(), notification.getObjectIdRef().getValue());
65 log.debug("onObjectDeletionNotification log entry written");
69 public void onProblemNotification(ProblemNotification notification) {
70 log.debug("Got event of type :: {}", ProblemNotification.class.getSimpleName());
72 serviceProvider.getFaultService().faultNotification(netconfAccessor.getNodeId(),
73 notification.getCounter().intValue(), notification.getTimestamp(),
74 notification.getObjectIdRef().getValue(), notification.getProblem(),
75 Onf14EthernetContainer.mapSeverity(notification.getSeverity()));
80 public void onAttributeValueChangedNotification(AttributeValueChangedNotification notification) {
81 log.debug("Got event of type :: {}", AttributeValueChangedNotification.class.getSimpleName());
83 EventlogBuilder eventlogBuilder = new EventlogBuilder();
84 eventlogBuilder.setNodeId(netconfAccessor.getNodeId().getValue())
85 .setAttributeName(notification.getAttributeName())
86 .setCounter(notification.getCounter().intValue())
87 .setNewValue(notification.getNewValue())
88 .setObjectId(notification.getObjectIdRef().getValue())
89 .setSourceType(SourceType.Netconf)
90 .setTimestamp(notification.getTimestamp());
91 serviceProvider.getDataProvider().writeEventLog(eventlogBuilder.build());
92 serviceProvider.getNotificationService().eventNotification(eventlogBuilder.build());
94 log.debug("onAttributeValueChangedNotification log entry written");
98 public void onObjectCreationNotification(ObjectCreationNotification notification) {
99 log.debug("Got event of type :: {}", ObjectCreationNotification.class.getSimpleName());
101 EventlogBuilder eventlogBuilder = new EventlogBuilder();
102 eventlogBuilder.setNodeId(netconfAccessor.getNodeId().getValue())
103 .setAttributeName(notification.getObjectType())
104 .setCounter(notification.getCounter().intValue())
105 .setNewValue("created")
106 .setObjectId(notification.getObjectIdRef().getValue())
107 .setSourceType(SourceType.Netconf)
108 .setTimestamp(notification.getTimestamp());
109 serviceProvider.getDataProvider().writeEventLog(eventlogBuilder.build());
110 serviceProvider.getNotificationService().creationNotification(netconfAccessor.getNodeId(),
111 notification.getCounter().intValue(), notification.getTimestamp(), notification.getObjectIdRef().getValue());
113 log.debug("onObjectCreationNotification log entry written");