2 * ============LICENSE_START========================================================================
3 * O-RAN-SC : oam/ccsdk feature sdnr wt
4 * =================================================================================================
5 * Copyright (C) 2020 highstreet technologies GmbH Intellectual Property. All rights reserved.
6 * =================================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
8 * in compliance with the License. You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software distributed under the License
13 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
14 * or implied. See the License for the specific language governing permissions and limitations under
16 * ============LICENSE_END==========================================================================
18 package org.oransc.oam.features.devicemanager.oran.impl;
20 import java.util.List;
21 import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.DataProvider;
22 import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfAccessor;
23 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.notifications.rev120206.IetfNetconfNotificationsListener;
24 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.notifications.rev120206.NetconfCapabilityChange;
25 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.notifications.rev120206.NetconfConfigChange;
26 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.notifications.rev120206.NetconfConfirmedCommit;
27 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.notifications.rev120206.NetconfSessionEnd;
28 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.notifications.rev120206.NetconfSessionStart;
29 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.notifications.rev120206.netconf.config.change.Edit;
30 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.EventlogBuilder;
31 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
32 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier.PathArgument;
33 import org.slf4j.Logger;
34 import org.slf4j.LoggerFactory;
37 * Listener for change notifications
39 public class ORanChangeNotificationListener implements IetfNetconfNotificationsListener {
41 private static final Logger log = LoggerFactory.getLogger(ORanChangeNotificationListener.class);
43 private final NetconfAccessor netconfAccessor;
44 private final DataProvider databaseService;
46 public ORanChangeNotificationListener(NetconfAccessor netconfAccessor, DataProvider databaseService) {
47 this.netconfAccessor = netconfAccessor;
48 this.databaseService = databaseService;
52 public void onNetconfConfirmedCommit(NetconfConfirmedCommit notification) {
53 log.info("onNetconfConfirmedCommit ", notification);
57 public void onNetconfSessionStart(NetconfSessionStart notification) {
58 log.info("onNetconfSessionStart ", notification);
62 public void onNetconfSessionEnd(NetconfSessionEnd notification) {
63 log.info("onNetconfSessionEnd ", notification);
67 public void onNetconfCapabilityChange(NetconfCapabilityChange notification) {
68 log.info("onNetconfCapabilityChange ", notification);
72 public void onNetconfConfigChange(NetconfConfigChange notification) {
73 log.info("onNetconfConfigChange (1) {}", notification);
74 StringBuffer sb = new StringBuffer();
75 List<Edit> editList = notification.nonnullEdit();
76 for (Edit edit : editList) {
77 if (sb.length() > 0) {
82 EventlogBuilder eventlogBuilder = new EventlogBuilder();
84 InstanceIdentifier<?> target = edit.getTarget();
86 eventlogBuilder.setObjectId(target.toString());
87 log.info("TARGET: {} {} {}", target.getClass(), target.getTargetType());
88 for (PathArgument pa : target.getPathArguments()) {
89 log.info("PathArgument {}", pa);
92 eventlogBuilder.setNodeId(netconfAccessor.getNodeId().getValue());
93 eventlogBuilder.setNewValue(String.valueOf(edit.getOperation()));
94 databaseService.writeEventLog(eventlogBuilder.build());
96 log.info("onNetconfConfigChange (2) {}", sb);