2 * ============LICENSE_START========================================================================
3 * ONAP : ccsdk feature sdnr wt
4 * =================================================================================================
5 * Copyright (C) 2019 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.onap.ccsdk.features.sdnr.wt.devicemanager.oran.impl;
20 import java.time.Instant;
21 import java.util.HashMap;
22 import java.util.List;
23 import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.DataProvider;
24 import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.VESCollectorService;
25 import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfBindingAccessor;
26 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.notifications.rev120206.IetfNetconfNotificationsListener;
27 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.notifications.rev120206.NetconfCapabilityChange;
28 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.notifications.rev120206.NetconfConfigChange;
29 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.notifications.rev120206.NetconfConfirmedCommit;
30 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.notifications.rev120206.NetconfSessionEnd;
31 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.notifications.rev120206.NetconfSessionStart;
32 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.notifications.rev120206.netconf.config.change.Edit;
33 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.EventlogBuilder;
34 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
35 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier.PathArgument;
36 import org.slf4j.Logger;
37 import org.slf4j.LoggerFactory;
40 * Listener for change notifications
42 public class ORanChangeNotificationListener implements IetfNetconfNotificationsListener {
44 private static final Logger log = LoggerFactory.getLogger(ORanChangeNotificationListener.class);
46 private final NetconfBindingAccessor netconfAccessor;
47 private final DataProvider databaseService;
48 private final VESCollectorService vesCollectorService;
50 private static int sequenceNo = 0;
52 public ORanChangeNotificationListener(NetconfBindingAccessor netconfAccessor, DataProvider databaseService, VESCollectorService vesCollectorService) {
53 this.netconfAccessor = netconfAccessor;
54 this.databaseService = databaseService;
55 this.vesCollectorService = vesCollectorService;
59 public void onNetconfConfirmedCommit(NetconfConfirmedCommit notification) {
60 log.info("onNetconfConfirmedCommit {}", notification);
64 public void onNetconfSessionStart(NetconfSessionStart notification) {
65 log.info("onNetconfSessionStart {}", notification);
69 public void onNetconfSessionEnd(NetconfSessionEnd notification) {
70 log.info("onNetconfSessionEnd {}", notification);
74 public void onNetconfCapabilityChange(NetconfCapabilityChange notification) {
75 log.info("onNetconfCapabilityChange {}", notification);
79 public void onNetconfConfigChange(NetconfConfigChange notification) {
80 log.info("onNetconfConfigChange (1) {}", notification);
82 StringBuffer sb = new StringBuffer();
83 List<Edit> editList = notification.nonnullEdit();
84 for (Edit edit : editList) {
85 if (sb.length() > 0) {
90 EventlogBuilder eventlogBuilder = new EventlogBuilder();
92 InstanceIdentifier<?> target = edit.getTarget();
94 eventlogBuilder.setObjectId(target.toString());
95 log.info("TARGET: {} {} {}", target.getClass(), target.getTargetType());
96 for (PathArgument pa : target.getPathArguments()) {
97 log.info("PathArgument {}", pa);
100 eventlogBuilder.setNodeId(netconfAccessor.getNodeId().getValue());
101 eventlogBuilder.setNewValue(String.valueOf(edit.getOperation()));
102 databaseService.writeEventLog(eventlogBuilder.build());
104 log.info("onNetconfConfigChange (2) {}", sb);
105 ORanNotificationMapper mapper = new ORanNotificationMapper();
106 HashMap<String, String> xPathFieldsMap = mapper.performMapping(notification);
107 log.info("MappingInfo after mapping notification - {}", xPathFieldsMap);
108 Instant instant = mapper.getTime(notification);
110 ORanNotifToVESEventAssembly oranVESEventAssembly = new ORanNotifToVESEventAssembly(netconfAccessor, vesCollectorService);
111 String data = oranVESEventAssembly.performAssembly(xPathFieldsMap, instant, NetconfConfigChange.class.getSimpleName(),
113 vesCollectorService.publishVESMessage(data);