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.onap.ccsdk.features.sdnr.wt.dataprovider.model.DataProvider;
26 import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfAccessor;
27 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.notifications.rev120206.IetfNetconfNotificationsListener;
28 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.notifications.rev120206.NetconfCapabilityChange;
29 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.notifications.rev120206.NetconfConfigChange;
30 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.notifications.rev120206.NetconfConfirmedCommit;
31 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.notifications.rev120206.NetconfSessionEnd;
32 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.notifications.rev120206.NetconfSessionStart;
33 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.notifications.rev120206.netconf.config.change.Edit;
34 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.EventlogBuilder;
35 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
36 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier.PathArgument;
37 import org.slf4j.Logger;
38 import org.slf4j.LoggerFactory;
42 * @author Shabnam Sultana
44 * Listener for change notifications
47 public class OpenroadmChangeNotificationListener implements IetfNetconfNotificationsListener {
50 private static final Logger log = LoggerFactory.getLogger(OpenroadmChangeNotificationListener.class);
51 private final NetconfAccessor netconfAccessor;
52 private final DataProvider databaseService;
56 public OpenroadmChangeNotificationListener(NetconfAccessor netconfAccessor, DataProvider databaseService) {
57 this.netconfAccessor = netconfAccessor;
58 this.databaseService = databaseService;
60 // end of constructors
64 public void onNetconfConfirmedCommit(NetconfConfirmedCommit notification) {
65 log.info("onNetconfConfirmedCommit {} ", notification);
69 public void onNetconfSessionStart(NetconfSessionStart notification) {
70 log.info("onNetconfSessionStart {} ", notification);
74 public void onNetconfSessionEnd(NetconfSessionEnd notification) {
75 log.info("onNetconfSessionEnd {}", notification);
79 public void onNetconfCapabilityChange(NetconfCapabilityChange notification) {
80 log.info("onNetconfCapabilityChange {}", notification);
84 public void onNetconfConfigChange(NetconfConfigChange notification) {
85 log.info("onNetconfConfigChange (1) {}", notification);
86 StringBuffer sb = new StringBuffer();
87 List<Edit> editList = notification.nonnullEdit();
88 for (Edit edit : editList) {
89 if (sb.length() > 0) {
94 EventlogBuilder eventlogBuilder = new EventlogBuilder();
96 InstanceIdentifier<?> target = edit.getTarget();
98 eventlogBuilder.setObjectId(target.toString());
99 log.info("TARGET: {} {}", target.getClass(), target.getTargetType());
100 for (PathArgument pa : target.getPathArguments()) {
101 log.info("PathArgument {}", pa);
104 eventlogBuilder.setNodeId(netconfAccessor.getNodeId().getValue());
105 eventlogBuilder.setNewValue(String.valueOf(edit.getOperation()));
106 databaseService.writeEventLog(eventlogBuilder.build());
108 log.info("onNetconfConfigChange (2) {}", sb);
111 // end of public methods