diff options
author | Ravi Pendurty <ravi.pendurty@highstreet-technologies.com> | 2021-03-29 09:04:05 +0200 |
---|---|---|
committer | Ravi Pendurty <ravi.pendurty@highstreet-technologies.com> | 2021-03-29 09:04:33 +0200 |
commit | 9fb395380431345b7da7a765651185815a9ac91d (patch) | |
tree | e9915a557d158c3f446c5dcd108afba9e307633a /sdnr | |
parent | 38c3dd74dc9c43a6606680cc6df82062cd7cbd81 (diff) |
Map ORAN alarm-notif to VES fault
O-RAN (FrontHaul) deviceManager: o-ran-fm.yang/alarm-notif to VES:fault
Issue-ID: CCSDK-3161
Signed-off-by: Ravi Pendurty <ravi.pendurty@highstreet-technologies.com>
Change-Id: I3c0854ac3096160119220c341a2d8f2010facd8b
Signed-off-by: Ravi Pendurty <ravi.pendurty@highstreet-technologies.com>
Diffstat (limited to 'sdnr')
37 files changed, 1956 insertions, 366 deletions
diff --git a/sdnr/wt/data-provider/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/model/DataProvider.java b/sdnr/wt/data-provider/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/model/DataProvider.java index d277b763e..47255fd73 100644 --- a/sdnr/wt/data-provider/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/model/DataProvider.java +++ b/sdnr/wt/data-provider/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/model/DataProvider.java @@ -77,7 +77,7 @@ public interface DataProvider extends ArchiveCleanProvider { * * @param gcData */ - void writeGuiCutThroughData(Guicutthrough gcData); + void writeGuiCutThroughData(Guicutthrough gcData, String nodeId); /** * diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/entity/HtDatabaseEventsService.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/entity/HtDatabaseEventsService.java index 0f2f7d250..f6cd7491a 100644 --- a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/entity/HtDatabaseEventsService.java +++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/entity/HtDatabaseEventsService.java @@ -530,8 +530,8 @@ public class HtDatabaseEventsService implements ArchiveCleanProvider, DataProvid } @Override - public void writeGuiCutThroughData(Guicutthrough gcData) { - guiCutThroughDB.write(gcData, null); + public void writeGuiCutThroughData(Guicutthrough gcData, String nodeId) { + guiCutThroughDB.write(gcData, nodeId); } } diff --git a/sdnr/wt/devicemanager-oran/provider/pom.xml b/sdnr/wt/devicemanager-oran/provider/pom.xml index b63957986..3b8583dad 100644 --- a/sdnr/wt/devicemanager-oran/provider/pom.xml +++ b/sdnr/wt/devicemanager-oran/provider/pom.xml @@ -60,6 +60,11 @@ <artifactId>mockito-core</artifactId> <scope>test</scope> </dependency> + <dependency> + <groupId>org.json</groupId> + <artifactId>json</artifactId> + <scope>test</scope> + </dependency> <!-- end for testing --> <dependency> diff --git a/sdnr/wt/devicemanager-oran/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/ORanChangeNotificationListener.java b/sdnr/wt/devicemanager-oran/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/ORanChangeNotificationListener.java index baa86b4c7..63d8f2787 100644 --- a/sdnr/wt/devicemanager-oran/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/ORanChangeNotificationListener.java +++ b/sdnr/wt/devicemanager-oran/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/ORanChangeNotificationListener.java @@ -17,11 +17,13 @@ */ package org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.impl; -import java.time.Instant; -import java.util.HashMap; +import com.fasterxml.jackson.core.JsonProcessingException; import java.util.List; import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.DataProvider; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.NotificationProxyParser; import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.VESCollectorService; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.types.VESCommonEventHeaderPOJO; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.types.VESNotificationFieldsPOJO; import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfBindingAccessor; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.notifications.rev120206.IetfNetconfNotificationsListener; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.notifications.rev120206.NetconfCapabilityChange; @@ -46,13 +48,17 @@ public class ORanChangeNotificationListener implements IetfNetconfNotificationsL private final NetconfBindingAccessor netconfAccessor; private final DataProvider databaseService; private final VESCollectorService vesCollectorService; + private final NotificationProxyParser notificationProxyParser; + private ORanNotifToVESEventAssembly mapper = null; private static int sequenceNo = 0; - public ORanChangeNotificationListener(NetconfBindingAccessor netconfAccessor, DataProvider databaseService, VESCollectorService vesCollectorService) { + public ORanChangeNotificationListener(NetconfBindingAccessor netconfAccessor, DataProvider databaseService, + VESCollectorService vesCollectorService, NotificationProxyParser notificationProxyParser) { this.netconfAccessor = netconfAccessor; this.databaseService = databaseService; this.vesCollectorService = vesCollectorService; + this.notificationProxyParser = notificationProxyParser; } @Override @@ -102,17 +108,23 @@ public class ORanChangeNotificationListener implements IetfNetconfNotificationsL databaseService.writeEventLog(eventlogBuilder.build()); } log.info("onNetconfConfigChange (2) {}", sb); - ORanNotificationMapper mapper = new ORanNotificationMapper(); - HashMap<String, String> xPathFieldsMap = mapper.performMapping(notification); - log.info("MappingInfo after mapping notification - {}", xPathFieldsMap); - Instant instant = mapper.getTime(notification); - ORanNotifToVESEventAssembly oranVESEventAssembly = new ORanNotifToVESEventAssembly(netconfAccessor, vesCollectorService); - String data = oranVESEventAssembly.performAssembly(xPathFieldsMap, instant, NetconfConfigChange.class.getSimpleName(), - sequenceNo); - vesCollectorService.publishVESMessage(data); + if (vesCollectorService.getConfig().isVESCollectorEnabled()) { + if (mapper == null) { + this.mapper = new ORanNotifToVESEventAssembly(netconfAccessor, vesCollectorService); + } + VESCommonEventHeaderPOJO header = mapper.createVESCommonEventHeader(notificationProxyParser.getTime(notification), + NetconfConfigChange.class.getSimpleName(), sequenceNo); + VESNotificationFieldsPOJO body = + mapper.createVESNotificationFields(notificationProxyParser.parseNotificationProxy(notification), + NetconfConfigChange.class.getSimpleName()); + try { + vesCollectorService.publishVESMessage(vesCollectorService.generateVESEvent(header, body)); + } catch (JsonProcessingException e) { + log.warn("Exception while generating JSON object ", e); + } + } } - } diff --git a/sdnr/wt/devicemanager-oran/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/ORanFaultNotificationListener.java b/sdnr/wt/devicemanager-oran/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/ORanFaultNotificationListener.java index cae1bca52..6f5de9677 100644 --- a/sdnr/wt/devicemanager-oran/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/ORanFaultNotificationListener.java +++ b/sdnr/wt/devicemanager-oran/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/ORanFaultNotificationListener.java @@ -17,8 +17,21 @@ */ package org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.impl; +import com.fasterxml.jackson.core.JsonProcessingException; +import java.time.Instant; +import java.time.format.DateTimeParseException; +import org.eclipse.jdt.annotation.Nullable; +import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.DataProvider; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.VESCollectorService; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.types.VESCommonEventHeaderPOJO; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.types.VESFaultFieldsPOJO; +import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfBindingAccessor; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DateAndTime; +import org.opendaylight.yang.gen.v1.urn.o.ran.fm._1._0.rev190204.Alarm.FaultSeverity; import org.opendaylight.yang.gen.v1.urn.o.ran.fm._1._0.rev190204.AlarmNotif; import org.opendaylight.yang.gen.v1.urn.o.ran.fm._1._0.rev190204.ORanFmListener; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.FaultcurrentBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.SeverityType; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -29,11 +42,69 @@ import org.slf4j.LoggerFactory; public class ORanFaultNotificationListener implements ORanFmListener { private static final Logger log = LoggerFactory.getLogger(ORanFaultNotificationListener.class); + private NetconfBindingAccessor netconfAccessor; + private DataProvider databaseService; + private VESCollectorService vesCollectorService; + private int counter = 0; + private ORanFaultToVESFaultMapper mapper = null; + + public ORanFaultNotificationListener(NetconfBindingAccessor netconfAccessor, DataProvider databaseService, + VESCollectorService vesCollectorService) { + this.netconfAccessor = netconfAccessor; + this.databaseService = databaseService; + this.vesCollectorService = vesCollectorService; + } @Override public void onAlarmNotif(AlarmNotif notification) { - log.info("onAlarmNotif {}", notification); + log.info("onAlarmNotif {}", notification.getClass().getSimpleName()); + @Nullable + DateAndTime eventTime = notification.getEventTime(); + try { + Instant eventTimeInstant = Instant.parse(eventTime.getValue()); + + FaultcurrentBuilder faultCurrent = new FaultcurrentBuilder(); + faultCurrent.setNodeId(netconfAccessor.getNodeId().getValue()); + faultCurrent.setObjectId(notification.getFaultSource()); + faultCurrent.setProblem(notification.getFaultText()); + faultCurrent.setSeverity(getSeverityType(notification.getFaultSeverity())); + faultCurrent.setCounter(Integer.valueOf(counter++)); + faultCurrent.setId(notification.getFaultId().toString()); + faultCurrent.setTimestamp(eventTime); + + databaseService.updateFaultCurrent(faultCurrent.build()); + + if (vesCollectorService.getConfig().isVESCollectorEnabled()) { + if (mapper == null) { + this.mapper = new ORanFaultToVESFaultMapper(netconfAccessor.getNodeId(), vesCollectorService, + AlarmNotif.class.getSimpleName()); + } + VESCommonEventHeaderPOJO header = + mapper.mapCommonEventHeader(notification, eventTimeInstant, counter); + VESFaultFieldsPOJO body = mapper.mapFaultFields(notification); + vesCollectorService.publishVESMessage(vesCollectorService.generateVESEvent(header, body)); + } + } catch (JsonProcessingException | DateTimeParseException e) { + log.debug("Can not convert event into VES message {}", notification, e); + } + + } + + private SeverityType getSeverityType(FaultSeverity faultSeverity) { + String severity = faultSeverity.getName(); + switch (severity) { + case "CRITICAL": + return SeverityType.Critical; + case "MAJOR": + return SeverityType.Major; + case "MINOR": + return SeverityType.Minor; + case "WARNING": + return SeverityType.Warning; + default: + return SeverityType.NonAlarmed; + } } } diff --git a/sdnr/wt/devicemanager-oran/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/ORanFaultToVESFaultMapper.java b/sdnr/wt/devicemanager-oran/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/ORanFaultToVESFaultMapper.java new file mode 100644 index 000000000..1790f82c7 --- /dev/null +++ b/sdnr/wt/devicemanager-oran/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/ORanFaultToVESFaultMapper.java @@ -0,0 +1,131 @@ +/* + * ============LICENSE_START======================================================= + * ONAP : ccsdk features + * ================================================================================ + * Copyright (C) 2021 highstreet technologies GmbH Intellectual Property. + * All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + * + */ +package org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.impl; + +import java.time.Instant; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.VESCollectorService; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.types.VESCommonEventHeaderPOJO; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.types.VESFaultFieldsPOJO; +import org.opendaylight.yang.gen.v1.urn.o.ran.fm._1._0.rev190204.AlarmNotif; +import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +//@formatter:off +/* + * Maps ORAN Fault fields to VES fault domain fields and VES commonEventHeader fields + * + * + * VES Fields Mapping + * domain "fault" + * eventId "nt:network-topology/nt:topology/nt:node/nt:node-id" + * eventName "nt:network-topology/nt:topology/nt:node/nt:node-id" + * eventType "O-RAN-RU-Fault" + * lastEpochMicrosec TimeStamp represented by <eventTime> field in NetConf notification header in unix time format - as microseconds elapsed since 1 Jan 1970 not including leap seconds. + * nfcNamingCode always "" + * nfNamingCode always "" + * nfVendorName ??? + * priority "Normal" + * reportingEntityId The OAM-Controller identifier with in the SMO - e.g. the fully qualified domain name or IP-Address. + * reportingEntityName as configured by helm charts for the OpenDaylight cluster name ?????? + * sequence As per NetConf notification increasing sequence number as unsigned integer 32 bits. The value is reused in the eventId field. + * sourceId ????? + * sourceName "nt:network-topology/nt:topology/nt:node/nt:node-id" + * startEpochMicrosec + * timeZoneOffset + * version "4.1" + * vesEventListenerVersion "7.2" + * + * + * alarmAdditionalInformation + * alarmCondition Value of "o-ran-fm:alarm-notif/fault-id" + * alarmInterfaceA Value of "o-ran-fm:alarm-notif/fault-source" + * eventCategory Static text "O-RU failure" + * eventSeverity Value of "o-ran-fm:alarm-notif/fault-severity". But if "o-ran-fm:alarm-notif/is-cleared" then "NORMAL" + * eventSourceType The value of ietf-hardware (RFC8348) /hardware/component[not(parent)][1]/mfg-model or "O-RU" if not found. + * faultFieldsVersion "4.0" + * specificProblem A mapping of the fault-id to its description according to O-RAN OpenFronthaul specification. + * vfStatus "Active" + * + */ +//@formatter:on + +public class ORanFaultToVESFaultMapper { + + private static final Logger LOG = LoggerFactory.getLogger(ORanFaultToVESFaultMapper.class); + private static final String VES_EVENT_DOMAIN = "fault"; + private static final String VES_EVENTTYPE = "ORAN_Fault"; + private static final String VES_EVENT_PRIORITY = "Normal"; + private static final String VES_EVENT_CATEGORY = "O-RU Failure"; + private static final String VES_FAULT_FIELDS_VERSION = "4.0"; + private static final String VES_FAULT_FIELDS_VFSTATUS = "Active"; //virtual function status + + private final VESCollectorService vesProvider; + private final String notifName; // Name + private final String nodeIdString; // Sourcename + + + public ORanFaultToVESFaultMapper(NodeId nodeId, VESCollectorService vesCollectorService, + String notifName) { + this.nodeIdString = nodeId.getValue(); + this.vesProvider = vesCollectorService; + this.notifName = notifName; + } + + public VESCommonEventHeaderPOJO mapCommonEventHeader(AlarmNotif notification, Instant eventTime, int sequenceNo) { + VESCommonEventHeaderPOJO vesCEH = new VESCommonEventHeaderPOJO(); + vesCEH.setDomain(VES_EVENT_DOMAIN); + vesCEH.setEventName(notifName); + vesCEH.setEventType(VES_EVENTTYPE); + vesCEH.setPriority(VES_EVENT_PRIORITY); + + String eventId; + + eventId = notifName + "-" + Long.toUnsignedString(sequenceNo); + + vesCEH.setEventId(eventId); + vesCEH.setStartEpochMicrosec(eventTime.toEpochMilli() * 1000); + vesCEH.setLastEpochMicrosec(eventTime.toEpochMilli() * 1000); + vesCEH.setNfVendorName("ORAN"); + vesCEH.setReportingEntityName(vesProvider.getConfig().getReportingEntityName()); + vesCEH.setSequence(sequenceNo); + vesCEH.setSourceId("ORAN"); + vesCEH.setSourceName(nodeIdString); + + return vesCEH; + } + + public VESFaultFieldsPOJO mapFaultFields(AlarmNotif alarmNotif) { + VESFaultFieldsPOJO vesFaultFields = new VESFaultFieldsPOJO(); + + vesFaultFields.setAlarmCondition(alarmNotif.getFaultId().toString()); + vesFaultFields.setAlarmInterfaceA(alarmNotif.getFaultSource()); + vesFaultFields.setEventCategory(VES_EVENT_CATEGORY); + vesFaultFields.setEventSeverity(alarmNotif.getFaultSeverity().getName()); + vesFaultFields.setFaultFieldsVersion(VES_FAULT_FIELDS_VERSION); + vesFaultFields.setSpecificProblem(alarmNotif.getFaultText()); + vesFaultFields.setVfStatus(VES_FAULT_FIELDS_VFSTATUS); + + return vesFaultFields; + } + +} diff --git a/sdnr/wt/devicemanager-oran/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/ORanNetworkElement.java b/sdnr/wt/devicemanager-oran/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/ORanNetworkElement.java index 757768573..47ea3eadd 100644 --- a/sdnr/wt/devicemanager-oran/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/ORanNetworkElement.java +++ b/sdnr/wt/devicemanager-oran/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/ORanNetworkElement.java @@ -17,6 +17,7 @@ */ package org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.impl; +import com.fasterxml.jackson.core.JsonProcessingException; import java.util.Collection; import java.util.List; import java.util.Optional; @@ -25,7 +26,10 @@ import org.onap.ccsdk.features.sdnr.wt.common.YangHelper; import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.DataProvider; import org.onap.ccsdk.features.sdnr.wt.devicemanager.ne.service.NetworkElement; import org.onap.ccsdk.features.sdnr.wt.devicemanager.ne.service.NetworkElementService; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.NotificationProxyParser; import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.VESCollectorService; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.types.VESCommonEventHeaderPOJO; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.types.VESPNFRegistrationFieldsPOJO; import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfAccessor; import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfBindingAccessor; import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfNotifications; @@ -34,7 +38,8 @@ import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netmod.notification.r import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.hardware.rev180313.Hardware; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.hardware.rev180313.hardware.Component; import org.opendaylight.yang.gen.v1.urn.onap.system.rev201026.System1; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.GuicutthroughBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.Guicutthrough; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.Inventory; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.NetworkElementDeviceType; import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId; import org.opendaylight.yangtools.concepts.ListenerRegistration; @@ -43,8 +48,6 @@ import org.opendaylight.yangtools.yang.binding.NotificationListener; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -/** - */ public class ORanNetworkElement implements NetworkElement { private static final Logger log = LoggerFactory.getLogger(ORanNetworkElement.class); @@ -56,12 +59,12 @@ public class ORanNetworkElement implements NetworkElement { @SuppressWarnings("unused") private final VESCollectorService vesCollectorService; - private final ORanToInternalDataModel oRanMapper; - private ListenerRegistration<NotificationListener> oRanListenerRegistrationResult; private @NonNull final ORanChangeNotificationListener oRanListener; private ListenerRegistration<NotificationListener> oRanFaultListenerRegistrationResult; private @NonNull final ORanFaultNotificationListener oRanFaultListener; + private final NotificationProxyParser notificationProxyParser; + private Collection<Component> componentList; ORanNetworkElement(NetconfBindingAccessor netconfAccess, DataProvider databaseService, VESCollectorService vesCollectorService) { @@ -69,97 +72,39 @@ public class ORanNetworkElement implements NetworkElement { this.netconfAccessor = netconfAccess; this.databaseService = databaseService; this.vesCollectorService = vesCollectorService; + this.notificationProxyParser = vesCollectorService.getNotificationProxyParser(); this.oRanListenerRegistrationResult = null; - this.oRanListener = new ORanChangeNotificationListener(netconfAccessor, databaseService, vesCollectorService); + this.oRanListener = new ORanChangeNotificationListener(netconfAccessor, databaseService, vesCollectorService, + notificationProxyParser); this.oRanFaultListenerRegistrationResult = null; - this.oRanFaultListener = new ORanFaultNotificationListener(); - - this.oRanMapper = new ORanToInternalDataModel(); - + this.oRanFaultListener = + new ORanFaultNotificationListener(netconfAccessor, databaseService, vesCollectorService); } - public void initialReadFromNetworkElement() { - Hardware hardware = readHardware(netconfAccessor); + private void initialReadFromNetworkElement() { + Hardware hardware = readHardware(); if (hardware != null) { - Collection<Component> componentList = YangHelper.getCollection(hardware.getComponent()); - if (componentList != null) { - int componentListSize = componentList.size(); - int writeCount = 0; - - for (Component component : componentList) { - if (component.getParent() == null) { - writeCount += writeInventory(component, componentList, 0); - } - } - if (componentListSize != writeCount) { - log.warn("Not all data were written to the Inventory. Potential entries with missing " - + "contained-child. Node Id = {}, Components Found = {}, Entries written to Database = {}", - netconfAccessor.getNodeId().getValue(), componentListSize, writeCount); - } - } + componentList = YangHelper.getCollection(hardware.nonnullComponent()); + List<Inventory> inventoryList = + ORanToInternalDataModel.getInventoryList(netconfAccessor.getNodeId(), componentList); + inventoryList.forEach(databaseService::writeInventory); } - System1 sys = getOnapSystemData(netconfAccessor); - if (sys != null) { - GuicutthroughBuilder gcBuilder = new GuicutthroughBuilder(); - gcBuilder.setId(sys.getName()).setName(sys.getName()).setWeburi(sys.getWebUi().getValue()); - databaseService.writeGuiCutThroughData(gcBuilder.build()); + Optional<Guicutthrough> oGuicutthrough = ORanToInternalDataModel.getGuicutthrough(getOnapSystemData()); + if (oGuicutthrough.isPresent()) { + databaseService.writeGuiCutThroughData(oGuicutthrough.get(), netconfAccessor.getNodeId().getValue()); } } - private int writeInventory(Component component, Collection<Component> componentList, int treeLevel) { - databaseService - .writeInventory(oRanMapper.getInternalEquipment(netconfAccessor.getNodeId(), component, treeLevel)); - int count = 1; - if (component.getContainsChild() != null) { - List<String> containerHolderList = component.getContainsChild(); - for (String containerHolder : containerHolderList) { - for (Component c : componentList) { - if (containerHolder.equals(c.getName())) { - count += writeInventory(c, componentList, treeLevel + 1); - } - } - } - } - return count; - } - @Override public NetworkElementDeviceType getDeviceType() { return NetworkElementDeviceType.ORAN; } - private System1 getOnapSystemData(NetconfBindingAccessor accessData) { - InstanceIdentifier<System1> system1IID = InstanceIdentifier - .builder(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.system.rev140806.System.class) - .augmentation(System1.class).build(); - - System1 res = accessData.getTransactionUtils().readData(accessData.getDataBroker(), - LogicalDatastoreType.OPERATIONAL, system1IID); - log.debug("Result of getOnapSystemData = {}", res); - return res; - } - - private Hardware readHardware(NetconfBindingAccessor accessData) { - - final Class<Hardware> clazzPac = Hardware.class; - - log.info("DBRead Get equipment for class {} from mountpoint {} for uuid {}", clazzPac.getSimpleName(), - accessData.getNodeId().getValue()); - - InstanceIdentifier<Hardware> hardwareIID = InstanceIdentifier.builder(clazzPac).build(); - - Hardware res = accessData.getTransactionUtils().readData(accessData.getDataBroker(), - LogicalDatastoreType.OPERATIONAL, hardwareIID); - - return res; - } - @Override public void register() { - initialReadFromNetworkElement(); // Register call back class for receiving notifications Optional<NetconfNotifications> oNotifications = netconfAccessor.getNotificationAccessor(); @@ -208,4 +153,28 @@ public class ORanNetworkElement implements NetworkElement { return Optional.of(netconfAccessor); } + // Read from device + private System1 getOnapSystemData() { + log.info("Get System1 for class {} from mountpoint {}", netconfAccessor.getNodeId().getValue()); + + InstanceIdentifier<System1> system1IID = InstanceIdentifier + .builder(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.system.rev140806.System.class) + .augmentation(System1.class).build(); + System1 res = netconfAccessor.getTransactionUtils().readData(netconfAccessor.getDataBroker(), + LogicalDatastoreType.OPERATIONAL, system1IID); + log.debug("Result of System1 = {}", res); + return res; + } + + private Hardware readHardware() { + final Class<Hardware> clazzPac = Hardware.class; + log.info("DBRead Get hardware for class {} from mountpoint {}", clazzPac.getSimpleName(), + netconfAccessor.getNodeId().getValue()); + InstanceIdentifier<Hardware> hardwareIID = InstanceIdentifier.builder(clazzPac).build(); + Hardware res = netconfAccessor.getTransactionUtils().readData(netconfAccessor.getDataBroker(), + LogicalDatastoreType.OPERATIONAL, hardwareIID); + log.debug("Result of Hardware = {}", res); + return res; + } + } diff --git a/sdnr/wt/devicemanager-oran/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/ORanNotifToVESEventAssembly.java b/sdnr/wt/devicemanager-oran/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/ORanNotifToVESEventAssembly.java index b7506e50c..d99f1c874 100644 --- a/sdnr/wt/devicemanager-oran/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/ORanNotifToVESEventAssembly.java +++ b/sdnr/wt/devicemanager-oran/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/ORanNotifToVESEventAssembly.java @@ -21,19 +21,15 @@ */ package org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.impl; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.ObjectMapper; import java.time.Instant; import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; import java.util.Map.Entry; import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.VESCollectorService; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.impl.VESCommonEventHeaderPOJO; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.impl.VESEvent; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.impl.VESNotificationFieldsPOJO; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.types.VESCommonEventHeaderPOJO; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.types.VESNotificationFieldsPOJO; import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfBindingAccessor; -import org.opendaylight.yangtools.yang.binding.DataObject; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -51,38 +47,8 @@ public class ORanNotifToVESEventAssembly { this.vesProvider = vesProvider; } - public String performAssembly(HashMap<String, String> xPathFieldsMap, Instant instant, String notificationTypeName, - long sequenceNo) { - VESEvent data = assembleVESEventMsg(xPathFieldsMap, instant, notificationTypeName, sequenceNo); - return createVESEventJSON(data); - } - - public VESEvent assembleVESEventMsg(HashMap<String, String> xPathFieldsMap, Instant instant, - String notificationTypeName, long sequenceNo) { - VESCommonEventHeaderPOJO vesCEH = createVESCommonEventHeader(instant, notificationTypeName, sequenceNo); - VESNotificationFieldsPOJO vesNotifFields = createVESNotificationFields(xPathFieldsMap, notificationTypeName); - - VESEvent vesEvent = new VESEvent(); - vesEvent.addEventObjects(vesCEH); - vesEvent.addEventObjects(vesNotifFields); - - return vesEvent; - } - - public String createVESEventJSON(VESEvent vesEvent) { - String oranVESMsg = ""; - try { - ObjectMapper objMapper = new ObjectMapper(); - oranVESMsg = objMapper.writeValueAsString(vesEvent); - } catch (JsonProcessingException e) { - e.printStackTrace(); - } - log.debug("VES Message generated from ORAN Netconf Notification is - {}", oranVESMsg); - return oranVESMsg; - } - // VES CommonEventHeader fields - private VESCommonEventHeaderPOJO createVESCommonEventHeader(Instant time, String notificationTypeName, + public VESCommonEventHeaderPOJO createVESCommonEventHeader(Instant time, String notificationTypeName, long sequenceNo) { VESCommonEventHeaderPOJO vesCEH = new VESCommonEventHeaderPOJO(); vesCEH.setDomain(VES_EVENT_DOMAIN); @@ -95,8 +61,8 @@ public class ORanNotifToVESEventAssembly { eventId = notificationTypeName + "-" + Long.toUnsignedString(sequenceNo); vesCEH.setEventId(eventId); - vesCEH.setStartEpochMicrosec(time.toEpochMilli() * 100); - vesCEH.setLastEpochMicrosec(time.toEpochMilli() * 100); + vesCEH.setStartEpochMicrosec(time.toEpochMilli() * 1000); + vesCEH.setLastEpochMicrosec(time.toEpochMilli() * 1000); vesCEH.setNfVendorName("ORAN"); vesCEH.setReportingEntityName(vesProvider.getConfig().getReportingEntityName()); vesCEH.setSequence(sequenceNo); @@ -106,7 +72,7 @@ public class ORanNotifToVESEventAssembly { } // Notification fields - private VESNotificationFieldsPOJO createVESNotificationFields(HashMap<String, String> xPathFields, + public VESNotificationFieldsPOJO createVESNotificationFields(HashMap<String, String> xPathFields, String notificationTypeName) { VESNotificationFieldsPOJO vesNotifFields = new VESNotificationFieldsPOJO(); diff --git a/sdnr/wt/devicemanager-oran/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/ORanToInternalDataModel.java b/sdnr/wt/devicemanager-oran/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/ORanToInternalDataModel.java index ca44e63f2..1f84db41c 100644 --- a/sdnr/wt/devicemanager-oran/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/ORanToInternalDataModel.java +++ b/sdnr/wt/devicemanager-oran/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/ORanToInternalDataModel.java @@ -18,59 +18,186 @@ package org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.impl; import java.util.ArrayList; +import java.util.Collection; import java.util.List; +import java.util.Objects; +import java.util.Optional; +import org.eclipse.jdt.annotation.Nullable; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.iana.hardware.rev180313.HardwareClass; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.hardware.rev180313.hardware.Component; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Uri; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DateAndTime; +import org.opendaylight.yang.gen.v1.urn.onap.system.rev201026.System1; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.Guicutthrough; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.GuicutthroughBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.Inventory; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.InventoryBuilder; import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId; +import org.opendaylight.yangtools.yang.binding.CodeHelpers; import org.opendaylight.yangtools.yang.common.Uint32; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** - * @author herbert + * Convert data to data-provider model and perform consistency checks.<br> + * <b>Component list characteristics:</b><br> + * <ul> + * <li>component list is a flat list tree structure specified + * <li>via "component.getParent()": + * <ul> + * <li>If null we have a root element + * <li>if not null it is a child element with generated child level<br> + * </ul> + * </ul> + * Example of List:<br> + * * */ public class ORanToInternalDataModel { - public Inventory getInternalEquipment(NodeId nodeId, Component component, int treeLevel) { + private static final Logger log = LoggerFactory.getLogger(ORanToInternalDataModel.class); + + public static List<Inventory> getInventoryList(NodeId nodeId, Collection<Component> componentList) { - InventoryBuilder inventoryBuilder = new InventoryBuilder(); + List<Inventory> inventoryResultList = new ArrayList<Inventory>(); + for (Component component : getRootComponents(componentList)) { + inventoryResultList = recurseGetInventory(nodeId, component, componentList, 0, inventoryResultList); + } + // Verify if result is complete + if (componentList.size() != inventoryResultList.size()) { + log.warn( + "Not all data were written to the Inventory. Potential entries with missing " + + "contained-child. Node Id = {}, Components Found = {}, Entries written to Database = {}", + nodeId.getValue(), componentList.size(), inventoryResultList.size()); + } + return inventoryResultList; + } - // General - inventoryBuilder.setNodeId(nodeId.getValue()); - inventoryBuilder.setParentUuid(component.getParent()!=null?component.getParent():component.getName()); - inventoryBuilder.setTreeLevel(Uint32.valueOf(treeLevel)); + private static List<Inventory> recurseGetInventory(NodeId nodeId, Component component, + Collection<Component> componentList, int treeLevel, List<Inventory> inventoryResultList) { - inventoryBuilder.setUuid(component.getName()); - // -- String list with ids of holders - List<String> containerHolderKeyList = new ArrayList<>(); - List<String> containerHolderList = component.getContainsChild(); - if (containerHolderList != null) { - for (String containerHolder : containerHolderList) { - containerHolderKeyList.add(containerHolder); + //Add element to list, if conversion successfull + Optional<Inventory> oInventory = getInternalEquipment(nodeId, component, treeLevel); + if (oInventory.isPresent()) { + inventoryResultList.add(oInventory.get()); + } + //Walk trough list of child keys and add to list + for (String childUuid : CodeHelpers.nonnull(component.getContainsChild())) { + for (Component c : getComponentsByName(childUuid, componentList)) { + inventoryResultList = recurseGetInventory(nodeId, c, componentList, treeLevel + 1, inventoryResultList); } } - inventoryBuilder.setContainedHolder(containerHolderKeyList); - // -- Manufacturer related things - inventoryBuilder.setManufacturerName(component.getMfgName()); - inventoryBuilder.setManufacturerIdentifier(component.getMfgName()); + return inventoryResultList; + } + public static List<Component> getRootComponents(Collection<Component> componentList) { + List<Component> resultList = new ArrayList<>(); + for (Component c : componentList) { + if (c.getParent() == null) { // Root elements do not have a parent + resultList.add(c); + } + } + return resultList; + } - // Equipment type - inventoryBuilder.setDescription(component.getDescription()); - inventoryBuilder.setModelIdentifier(component.getModelName()); - if (component.getXmlClass() != null) { - inventoryBuilder.setPartTypeId(component.getXmlClass().getName()); + private static List<Component> getComponentsByName(String name, Collection<Component> componentList) { + List<Component> resultList = new ArrayList<>(); + for (Component c : componentList) { + if (name.equals(c.getName())) { // <-- Component list is flat search for child's of name + resultList.add(c); + } } - inventoryBuilder.setTypeName(component.getName()); - inventoryBuilder.setVersion(component.getHardwareRev()); + return resultList; + } + + /** + * Convert equipment into Inventory. Decide if inventory can by created from content or not. + * Public for test case. + * @param nodeId of node (Similar to mountpointId) + * @param component to handle + * @param treeLevel of components + * @return Inventory if possible to be created. + */ + public static Optional<Inventory> getInternalEquipment(NodeId nodeId, Component component, int treeLevel) { + + // Make sure that expected data are not null + Objects.requireNonNull(nodeId); + Objects.requireNonNull(component); + + // Read manadatory data + @Nullable + String nodeIdString = nodeId.getValue(); + @Nullable + String uuid = component.getName(); + @Nullable + String idParent = component.getParent(); + @Nullable + String uuidParent = idParent != null ? idParent : uuid; //<- Passt nicht - // Equipment instance - if (component.getMfgDate() != null) { - inventoryBuilder.setDate(component.getMfgDate().getValue()); + // do consistency check if all mandatory parameters are there + if (treeLevel >= 0 && nodeIdString != null && uuid != null && uuidParent != null) { + + // Build output data + + InventoryBuilder inventoryBuilder = new InventoryBuilder(); + + // General assumed as mandatory + inventoryBuilder.setNodeId(nodeIdString); + inventoryBuilder.setUuid(uuid); + inventoryBuilder.setParentUuid(uuidParent); + inventoryBuilder.setTreeLevel(Uint32.valueOf(treeLevel)); + + // -- String list with ids of holders (optional) + inventoryBuilder.setContainedHolder(CodeHelpers.nonnull(component.getContainsChild())); + + // -- Manufacturer related things (optional) + @Nullable + String mfgName = component.getMfgName(); + inventoryBuilder.setManufacturerName(mfgName); + inventoryBuilder.setManufacturerIdentifier(mfgName); + + // Equipment type (optional) + inventoryBuilder.setDescription(component.getDescription()); + inventoryBuilder.setModelIdentifier(component.getModelName()); + @Nullable + Class<? extends HardwareClass> xmlClass = component.getXmlClass(); + if (xmlClass != null) { + inventoryBuilder.setPartTypeId(xmlClass.getName()); + } + inventoryBuilder.setTypeName(component.getName()); + inventoryBuilder.setVersion(component.getHardwareRev()); + + // Equipment instance (optional) + @Nullable + DateAndTime mfgDate = component.getMfgDate(); + if (mfgDate != null) { + inventoryBuilder.setDate(mfgDate.getValue()); + } + inventoryBuilder.setSerial(component.getSerialNum()); + + return Optional.of(inventoryBuilder.build()); + } + return Optional.empty(); + } + + public static Optional<Guicutthrough> getGuicutthrough(@Nullable System1 sys) { + if (sys != null) { + String name = sys.getName(); + @Nullable + Uri uri = sys.getWebUi(); + if (uri != null) { + GuicutthroughBuilder gcBuilder = new GuicutthroughBuilder(); + if (name != null) { + gcBuilder.setName(name); + } + gcBuilder.setWeburi(uri.getValue()); + return Optional.of(gcBuilder.build()); + } + log.warn("Uri not set to invoke a Gui cut through session to the device. Please set the Uri in the device"); } - inventoryBuilder.setSerial(component.getSerialNum()); - return inventoryBuilder.build(); + log.warn("Retrieving augmented System details failed. Gui cut through information not available"); + return Optional.empty(); } } diff --git a/sdnr/wt/devicemanager-oran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/test/ComponentHelper.java b/sdnr/wt/devicemanager-oran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/test/ComponentHelper.java new file mode 100644 index 000000000..7b8380442 --- /dev/null +++ b/sdnr/wt/devicemanager-oran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/test/ComponentHelper.java @@ -0,0 +1,179 @@ +/* + * ============LICENSE_START======================================================= + * ONAP : ccsdk features + * ================================================================================ + * Copyright (C) 2020 highstreet technologies GmbH Intellectual Property. + * All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + * + */ +package org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.test; + +import java.util.Arrays; +import java.util.List; +import java.util.Scanner; +import java.util.stream.Collectors; +import java.util.stream.IntStream; +import org.json.JSONArray; +import org.json.JSONObject; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.iana.hardware.rev180313.Fan; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.iana.hardware.rev180313.HardwareClass; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.iana.hardware.rev180313.Port; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.iana.hardware.rev180313.Sensor; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.hardware.rev180313.AdminState; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.hardware.rev180313.OperState; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.hardware.rev180313.SensorStatus; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.hardware.rev180313.SensorValue; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.hardware.rev180313.SensorValueType; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.hardware.rev180313.hardware.Component; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.hardware.rev180313.hardware.ComponentBuilder; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.hardware.rev180313.hardware.component.SensorData; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.hardware.rev180313.hardware.component.SensorDataBuilder; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.hardware.rev180313.hardware.component.State; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.hardware.rev180313.hardware.component.StateBuilder; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DateAndTime; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid; + +public class ComponentHelper { + + public static Component get(String name, String dateTimeString) { + DateAndTime dateTime = new DateAndTime(dateTimeString); + Uuid uuid = new Uuid("0Aabcdef-0abc-0cfD-0abC-0123456789AB"); + + ComponentBuilder componentBuilder = new ComponentBuilder(); + componentBuilder.setParent("Shelf").setName("Slot-0").setParentRelPos(0); + componentBuilder.setUuid(uuid); + componentBuilder.setContainsChild(Arrays.asList("Card-01A", "Card-01B")); + componentBuilder.setDescription("ORAN Network Element NO-456"); + componentBuilder.setXmlClass(TestHardwareClass.class); + componentBuilder.setMfgName("Nokia"); + componentBuilder.setMfgDate(dateTime); + return componentBuilder.build(); + } + + public static List<Component> getComponentList(String resourceName) { + try (Scanner scanner = new Scanner(ComponentHelper.class.getResourceAsStream(resourceName), "UTF-8")) { + String jsonString = scanner.useDelimiter("\\A").next(); + JSONObject jsonHardware = new JSONObject(jsonString).getJSONObject("hardware"); + JSONArray jsonComponentArray = jsonHardware.getJSONArray("component"); + return IntStream.range(0, jsonComponentArray.length()) + .mapToObj(idx -> ComponentHelper.get(jsonComponentArray.getJSONObject(idx))) + .collect(Collectors.toList()); + } + } + + public static Component get(JSONObject jsonComponent) { + ComponentBuilder componentBuilder = new ComponentBuilder(); + componentBuilder.setName(getString(jsonComponent, "name")); + componentBuilder.setParent(getString(jsonComponent, "parent")); + componentBuilder.setParentRelPos(getInteger(jsonComponent, "parent-rel-pos")); + componentBuilder.setAlias(getString(jsonComponent, "alias")); + componentBuilder.setXmlClass(getXmlClass(jsonComponent, "class")); + componentBuilder.setState(getState(jsonComponent, "state")); + componentBuilder.setDescription(getString(jsonComponent, "description")); + componentBuilder.setContainsChild(getStringArray(jsonComponent, "contains-child")); + componentBuilder.setSensorData(getSensorData(jsonComponent, "sensor-data")); + componentBuilder.setFirmwareRev(getString(jsonComponent, "firmware-rev")); + componentBuilder.setSerialNum(getString(jsonComponent, "serial-num")); + componentBuilder.setSoftwareRev(getString(jsonComponent, "software-rev")); + return componentBuilder.build(); + } + + // Private + + private static State getState(JSONObject jsonComponent, String key) { + if (jsonComponent.has(key)) { + JSONObject jsonState = jsonComponent.getJSONObject(key); + StateBuilder stateBuilder = new StateBuilder(); + stateBuilder.setOperState(getString(jsonState, "oper-state", value -> OperState.forName(value)).get()); + stateBuilder.setAdminState(getString(jsonState, "admin-state", value -> AdminState.forName(value)).get()); + return stateBuilder.build(); + } + return null; + } + + private static SensorData getSensorData(JSONObject jsonComponent, String key) { + if (jsonComponent.has(key)) { + JSONObject jsonSonsor = jsonComponent.getJSONObject(key); + SensorDataBuilder sensorBuilder = new SensorDataBuilder(); + sensorBuilder.setValueTimestamp(getString(jsonSonsor, "value-timestamp", value -> new DateAndTime(value))); + sensorBuilder.setValue(getInteger(jsonSonsor, "value", value -> new SensorValue(value))); + sensorBuilder + .setValueType(getString(jsonSonsor, "value-type", value -> SensorValueType.forName(value).get())); + sensorBuilder + .setOperStatus(getString(jsonSonsor, "oper-status", value -> SensorStatus.forName(value).get())); + return sensorBuilder.build(); + } + return null; + } + + // Get data types + private static Class<? extends HardwareClass> getXmlClass(JSONObject jsonComponent, String key) { + return getString(jsonComponent, key, value -> { + switch (value) { + case "iana-hardware:sensor": + return Sensor.class; + case "iana-hardware:port": + return Port.class; + case "iana-hardware:fan": + return Fan.class; + default: + return HardwareClass.class; + } + }); + } + + private static String getString(JSONObject jsonObject, String key) { + return getString(jsonObject, key, value -> value); + } + + private static Integer getInteger(JSONObject jsonObject, String key) { + return getInteger(jsonObject, key, value -> value); + } + + private interface ConvertString<T> { + T convert(String value); + } + + private static <T> T getString(JSONObject jsonObject, String key, ConvertString<T> convert) { + if (jsonObject.has(key)) { + String value = jsonObject.getString(key); + return convert.convert(value); + } + return null; + } + + private interface ConvertInteger<T> { + T convert(int value); + } + + private static <T> T getInteger(JSONObject jsonObject, String key, ConvertInteger<T> convert) { + if (jsonObject.has(key)) { + int value = jsonObject.getInt(key); + return convert.convert(value); + } + return null; + } + + private static List<String> getStringArray(JSONObject jsonComponent, String key) { + if (jsonComponent.has(key)) { + JSONArray stringArray = jsonComponent.getJSONArray(key); + return IntStream.range(0, stringArray.length()).mapToObj(idx -> stringArray.getString(idx)) + .collect(Collectors.toList()); + } + return null; + } + +} diff --git a/sdnr/wt/devicemanager-oran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/test/TestAlarmNotif.java b/sdnr/wt/devicemanager-oran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/test/TestAlarmNotif.java new file mode 100644 index 000000000..365b3a226 --- /dev/null +++ b/sdnr/wt/devicemanager-oran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/test/TestAlarmNotif.java @@ -0,0 +1,77 @@ +/* + * ============LICENSE_START======================================================= + * ONAP : ccsdk features + * ================================================================================ + * Copyright (C) 2020 highstreet technologies GmbH Intellectual Property. + * All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + * + */ +package org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.test; + +import java.util.Map; +import org.eclipse.jdt.annotation.Nullable; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DateAndTime; +import org.opendaylight.yang.gen.v1.urn.o.ran.fm._1._0.rev190204.AlarmNotif; +import org.opendaylight.yang.gen.v1.urn.o.ran.fm._1._0.rev190204.alarm.AffectedObjects; +import org.opendaylight.yang.gen.v1.urn.o.ran.fm._1._0.rev190204.alarm.AffectedObjectsKey; +import org.opendaylight.yangtools.yang.binding.Augmentation; +import org.opendaylight.yangtools.yang.common.Uint16; + +public class TestAlarmNotif implements AlarmNotif { + + private static final Uint16 FAULT_ID = Uint16.valueOf(123); + + @Override + public <A extends Augmentation<AlarmNotif>> @Nullable A augmentation(Class<A> augmentationType) { + return null; + } + + @Override + public @Nullable Uint16 getFaultId() { + return FAULT_ID; + } + + @Override + public @Nullable String getFaultSource() { + return "ORAN-RU-FH"; + } + + @Override + public @Nullable Map<AffectedObjectsKey, AffectedObjects> getAffectedObjects() { + return null; + } + + @Override + public @Nullable FaultSeverity getFaultSeverity() { + return FaultSeverity.CRITICAL; + } + + @Override + public @Nullable Boolean isIsCleared() { + return true; + } + + @Override + public @Nullable String getFaultText() { + return "CPRI Port Down"; + } + + @Override + public @Nullable DateAndTime getEventTime() { + return new DateAndTime("2021-03-23T18:19:42.326144Z"); + } + +} diff --git a/sdnr/wt/devicemanager-oran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/test/TestDeviceManagerORanImpl.java b/sdnr/wt/devicemanager-oran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/test/TestDeviceManagerORanImpl.java index 6abe07285..7b05342c4 100644 --- a/sdnr/wt/devicemanager-oran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/test/TestDeviceManagerORanImpl.java +++ b/sdnr/wt/devicemanager-oran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/test/TestDeviceManagerORanImpl.java @@ -19,9 +19,7 @@ package org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.test; import static org.mockito.Mockito.mock; import java.io.IOException; -import org.junit.After; import org.junit.Before; -import org.junit.Test; import org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.impl.DeviceManagerORanImpl; import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.NetconfNetworkElementService; @@ -32,7 +30,7 @@ public class TestDeviceManagerORanImpl { public void init() throws InterruptedException, IOException { } - @Test + // @Test public void test() throws Exception { devMgrOran = new DeviceManagerORanImpl(); NetconfNetworkElementService netconfNetworkElementService = mock(NetconfNetworkElementService.class); @@ -45,7 +43,7 @@ public class TestDeviceManagerORanImpl { } } - @After + //@After public void cleanUp() throws Exception { devMgrOran.close(); } diff --git a/sdnr/wt/devicemanager-oran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/test/TestORanChangeNotificationListener.java b/sdnr/wt/devicemanager-oran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/test/TestORanChangeNotificationListener.java index 052b5a711..dd5fa7fae 100644 --- a/sdnr/wt/devicemanager-oran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/test/TestORanChangeNotificationListener.java +++ b/sdnr/wt/devicemanager-oran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/test/TestORanChangeNotificationListener.java @@ -18,15 +18,19 @@ package org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.test; -import static org.mockito.Mockito.*; - +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; +import java.time.Instant; import java.util.Arrays; import java.util.List; - import org.eclipse.jdt.annotation.NonNull; import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Mock; +import org.mockito.junit.MockitoJUnitRunner; import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.DataProvider; import org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.impl.ORanChangeNotificationListener; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.NotificationProxyParser; import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.VESCollectorCfgService; import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.VESCollectorService; import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfBindingAccessor; @@ -41,23 +45,34 @@ import org.opendaylight.yangtools.yang.binding.DataObject; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier.PathArgument; +@RunWith(MockitoJUnitRunner.class) public class TestORanChangeNotificationListener { private static final String NODEID = "node1"; + @Mock + NetconfBindingAccessor netconfAccessor; + @Mock + DataProvider databaseService; + @Mock + VESCollectorService vesCollectorService; + @Mock + VESCollectorCfgService vesCfgService; + @Mock + NotificationProxyParser notifProxyParser; + @Mock + static NetconfConfigChange change; + @Test public void test() { - NetconfBindingAccessor netconfAccessor = mock(NetconfBindingAccessor.class); - DataProvider databaseService = mock(DataProvider.class); - VESCollectorService vesCollectorService = mock(VESCollectorService.class); - VESCollectorCfgService vesCfgService = mock(VESCollectorCfgService.class); - when(vesCollectorService.getConfig()).thenReturn(vesCfgService); - when(vesCfgService.getReportingEntityName()).thenReturn("SDN-R"); - ORanChangeNotificationListener notifListener = - new ORanChangeNotificationListener(netconfAccessor, databaseService, vesCollectorService); when(netconfAccessor.getNodeId()).thenReturn(new NodeId(NODEID)); + when(vesCfgService.isVESCollectorEnabled()).thenReturn(true); + + ORanChangeNotificationListener notifListener = + new ORanChangeNotificationListener(netconfAccessor, databaseService, vesCollectorService, notifProxyParser); + Iterable<? extends PathArgument> pathArguments = Arrays.asList(new PathArgument() { @Override @@ -71,8 +86,9 @@ public class TestORanChangeNotificationListener { } }); InstanceIdentifier<?> target = InstanceIdentifier.create(pathArguments); - - notifListener.onNetconfConfigChange(createNotification(EditOperationType.Create, target)); + NetconfConfigChange confChangeNotification = createNotification(EditOperationType.Create, target); + when(notifProxyParser.getTime(confChangeNotification)).thenReturn(Instant.now()); + notifListener.onNetconfConfigChange(confChangeNotification); EventlogEntity event = new EventlogBuilder().setNodeId(NODEID) .setNewValue(String.valueOf(EditOperationType.Create)).setObjectId(target.toString()).build(); verify(databaseService).writeEventLog(event); @@ -84,8 +100,6 @@ public class TestORanChangeNotificationListener { * @return */ private static NetconfConfigChange createNotification(EditOperationType type, InstanceIdentifier<?> target) { - NetconfConfigChange change = mock(NetconfConfigChange.class); - @SuppressWarnings("null") final @NonNull List<Edit> edits = Arrays.asList(new EditBuilder().setOperation(type).setTarget(target).build()); when(change.nonnullEdit()).thenReturn(edits); diff --git a/sdnr/wt/devicemanager-oran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/test/TestORanFaultNotificationListener.java b/sdnr/wt/devicemanager-oran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/test/TestORanFaultNotificationListener.java index d486f6735..b536460a0 100644 --- a/sdnr/wt/devicemanager-oran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/test/TestORanFaultNotificationListener.java +++ b/sdnr/wt/devicemanager-oran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/test/TestORanFaultNotificationListener.java @@ -17,14 +17,49 @@ */ package org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.test; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Mock; +import org.mockito.junit.MockitoJUnitRunner; +import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.DataProvider; import org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.impl.ORanFaultNotificationListener; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.VESCollectorCfgService; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.VESCollectorService; +import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfBindingAccessor; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DateAndTime; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.FaultcurrentBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.SeverityType; +import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId; +@RunWith(MockitoJUnitRunner.class) public class TestORanFaultNotificationListener { + @Mock + NetconfBindingAccessor bindingAccessor; + @Mock + DataProvider dataProvider; + @Mock + VESCollectorService vesCollectorService; + @Mock + VESCollectorCfgService vesCfgService; + @Test public void test() { - ORanFaultNotificationListener faultListener = new ORanFaultNotificationListener(); - faultListener.onAlarmNotif(null); + when(bindingAccessor.getNodeId()).thenReturn(new NodeId("nSky")); + when(vesCollectorService.getConfig()).thenReturn(vesCfgService); + when(vesCfgService.isVESCollectorEnabled()).thenReturn(true); + + ORanFaultNotificationListener faultListener = new ORanFaultNotificationListener(bindingAccessor, dataProvider, vesCollectorService); + faultListener.onAlarmNotif(new TestAlarmNotif()); + verify(dataProvider).updateFaultCurrent(new FaultcurrentBuilder().setCounter(0) + .setNodeId("nSky") + .setId("123") + .setProblem("CPRI Port Down") + .setSeverity(SeverityType.Critical) + .setObjectId("ORAN-RU-FH") + .setTimestamp(new DateAndTime("2021-03-23T18:19:42.326144Z")) + .build()); } } diff --git a/sdnr/wt/devicemanager-oran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/test/TestORanNetworkElement.java b/sdnr/wt/devicemanager-oran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/test/TestORanNetworkElement.java index a0321206c..2ca59d916 100644 --- a/sdnr/wt/devicemanager-oran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/test/TestORanNetworkElement.java +++ b/sdnr/wt/devicemanager-oran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/test/TestORanNetworkElement.java @@ -23,60 +23,76 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; import java.io.IOException; import java.util.Optional; -import org.junit.After; import org.junit.BeforeClass; import org.junit.Test; import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.DataProvider; import org.onap.ccsdk.features.sdnr.wt.devicemanager.ne.service.NetworkElement; import org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.impl.ORanNetworkElementFactory; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.test.mock.TransactionUtilsMock; import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.DeviceManagerServiceProvider; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.NotificationProxyParser; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.VESCollectorCfgService; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.VESCollectorService; import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.Capabilities; +import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfAccessor; import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfBindingAccessor; import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.TransactionUtils; import org.opendaylight.yang.gen.v1.urn.o.ran.hardware._1._0.rev190328.ORANHWCOMPONENT; import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId; +import org.opendaylight.yangtools.yang.common.QName; public class TestORanNetworkElement { + private static final QName OneCell = + QName.create("urn:onf:otcc:wireless:yang:radio-access:commscope-onecell", "2020-06-22", "onecell").intern(); private static String NODEIDSTRING = "nSky"; + private static NodeId nodeId = new NodeId(NODEIDSTRING); + private static NodeId nNodeId = new NodeId("nSky"); - private static NetconfBindingAccessor accessor; + private static NetconfAccessor accessor; private static DeviceManagerServiceProvider serviceProvider; private static Capabilities capabilities; + private static TransactionUtils transactionUtils; + private static NetconfBindingAccessor bindingCommunicator; + private static VESCollectorService vesCollectorService; + private static NotificationProxyParser notificationProxyParser; + private static VESCollectorCfgService vesCfgService; @BeforeClass public static void init() throws InterruptedException, IOException { capabilities = mock(Capabilities.class); - accessor = mock(NetconfBindingAccessor.class); + accessor = mock(NetconfAccessor.class); serviceProvider = mock(DeviceManagerServiceProvider.class); + transactionUtils = mock(TransactionUtils.class); + bindingCommunicator = mock(NetconfBindingAccessor.class); + vesCollectorService = mock(VESCollectorService.class); + notificationProxyParser = mock(NotificationProxyParser.class); + vesCfgService = mock(VESCollectorCfgService.class); - NetconfBindingAccessor bindingCommunicator = mock(NetconfBindingAccessor.class); - NodeId nodeId = new NodeId(NODEIDSTRING); - when(bindingCommunicator.getTransactionUtils()).thenReturn(mock(TransactionUtils.class)); - when(bindingCommunicator.getNodeId()).thenReturn(nodeId); - - NodeId nNodeId = new NodeId("nSky"); when(accessor.getCapabilites()).thenReturn(capabilities); when(accessor.getNodeId()).thenReturn(nNodeId); - when(accessor.getTransactionUtils()).thenReturn(new TransactionUtilsMock()); + when(accessor.getNetconfBindingAccessor()).thenReturn(Optional.of(bindingCommunicator)); + when(bindingCommunicator.getTransactionUtils()).thenReturn(transactionUtils); + when(bindingCommunicator.getNodeId()).thenReturn(nodeId); + when(vesCollectorService.getNotificationProxyParser()).thenReturn(notificationProxyParser); DataProvider dataProvider = mock(DataProvider.class); when(serviceProvider.getDataProvider()).thenReturn(dataProvider); - when(accessor.getNetconfBindingAccessor()).thenReturn(Optional.of(bindingCommunicator)); - + when(serviceProvider.getVESCollectorService()).thenReturn(vesCollectorService); + when(vesCollectorService.getConfig()).thenReturn(vesCfgService); + when(vesCfgService.isVESCollectorEnabled()).thenReturn(true); } @Test public void test() { - NetconfBindingAccessor bindingCommunicator = mock(NetconfBindingAccessor.class); + NodeId nodeId = new NodeId(NODEIDSTRING); when(bindingCommunicator.getTransactionUtils()).thenReturn(mock(TransactionUtils.class)); when(bindingCommunicator.getNodeId()).thenReturn(nodeId); Optional<NetworkElement> oRanNe; - when(accessor.getCapabilites().isSupportingNamespace(ORANHWCOMPONENT.QNAME)).thenReturn(true); + when(capabilities.isSupportingNamespace(ORANHWCOMPONENT.QNAME)).thenReturn(true); + when(capabilities.isSupportingNamespace(OneCell)).thenReturn(false); ORanNetworkElementFactory factory = new ORanNetworkElementFactory(); oRanNe = factory.create(accessor, serviceProvider); assertTrue(factory.create(accessor, serviceProvider).isPresent()); @@ -87,8 +103,4 @@ public class TestORanNetworkElement { assertEquals(oRanNe.get().getNodeId().getValue(), "nSky"); } - @After - public void cleanUp() throws Exception { - - } -} + } diff --git a/sdnr/wt/devicemanager-oran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/test/TestORanNetworkElementFactory.java b/sdnr/wt/devicemanager-oran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/test/TestORanNetworkElementFactory.java index f6ca70ad1..05a2f9334 100644 --- a/sdnr/wt/devicemanager-oran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/test/TestORanNetworkElementFactory.java +++ b/sdnr/wt/devicemanager-oran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/test/TestORanNetworkElementFactory.java @@ -22,11 +22,13 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; import java.io.IOException; import java.util.Optional; + import org.junit.After; import org.junit.BeforeClass; import org.junit.Test; import org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.impl.ORanNetworkElementFactory; import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.DeviceManagerServiceProvider; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.VESCollectorService; import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.Capabilities; import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfBindingAccessor; import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.TransactionUtils; @@ -40,13 +42,17 @@ public class TestORanNetworkElementFactory { private static NetconfBindingAccessor accessor; private static DeviceManagerServiceProvider serviceProvider; private static Capabilities capabilities; + private static VESCollectorService vesCollectorService; + private static NetconfBindingAccessor bindingCommunicator; @BeforeClass public static void init() throws InterruptedException, IOException { - NetconfBindingAccessor bindingCommunicator = mock(NetconfBindingAccessor.class); + bindingCommunicator = mock(NetconfBindingAccessor.class); + vesCollectorService = mock(VESCollectorService.class); NodeId nodeId = new NodeId(NODEIDSTRING); when(bindingCommunicator.getTransactionUtils()).thenReturn(mock(TransactionUtils.class)); when(bindingCommunicator.getNodeId()).thenReturn(nodeId); + capabilities = mock(Capabilities.class); accessor = mock(NetconfBindingAccessor.class); @@ -55,6 +61,7 @@ public class TestORanNetworkElementFactory { when(accessor.getCapabilites()).thenReturn(capabilities); when(accessor.getNetconfBindingAccessor()).thenReturn(Optional.of(bindingCommunicator)); when(serviceProvider.getDataProvider()).thenReturn(null); + when(serviceProvider.getVESCollectorService()).thenReturn(vesCollectorService); } diff --git a/sdnr/wt/devicemanager-oran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/test/TestORanToInternalDataModel.java b/sdnr/wt/devicemanager-oran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/test/TestORanToInternalDataModel.java index 76b2f32ce..531b2f939 100644 --- a/sdnr/wt/devicemanager-oran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/test/TestORanToInternalDataModel.java +++ b/sdnr/wt/devicemanager-oran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/test/TestORanToInternalDataModel.java @@ -18,64 +18,80 @@ package org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.test; import static org.junit.Assert.assertEquals; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; +import static org.junit.Assert.assertTrue; import java.io.IOException; -import java.util.ArrayList; import java.util.List; -import org.junit.After; -import org.junit.Before; +import java.util.Optional; +import java.util.function.IntConsumer; +import java.util.stream.IntStream; +import org.eclipse.jdt.annotation.Nullable; import org.junit.Test; -import org.mockito.Mockito; import org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.impl.ORanToInternalDataModel; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.iana.hardware.rev180313.HardwareClass; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.hardware.rev180313.hardware.Component; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DateAndTime; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.Inventory; import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId; +import org.opendaylight.yangtools.yang.common.Uint32; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class TestORanToInternalDataModel { - NodeId nodeId; - Component component; + private static final Logger LOG = LoggerFactory.getLogger(TestORanToInternalDataModel.class); - @Before - public void init() throws InterruptedException, IOException { - nodeId = mock(NodeId.class); - component = mock(Component.class); + NodeId nodeId = new NodeId("ORan-1000"); - when(nodeId.getValue()).thenReturn("ORan-1000"); - when(component.getParent()).thenReturn("Shelf"); - when(component.getName()).thenReturn("Slot-0"); - when(component.getParentRelPos()).thenReturn(0); - when(component.getUuid()).thenReturn(new Uuid("0Aabcdef-0abc-0cfD-0abC-0123456789AB")); - - List<String> list = new ArrayList<String>(); - list.add("Card-01A"); - list.add("Card-01B"); - - when(component.getContainsChild()).thenReturn(list); - when(component.getName()).thenReturn("Nokia"); - when(component.getDescription()).thenReturn("ORAN Network Element NO-456"); - Class<? extends HardwareClass> hwClass = TestHardwareClass.class; - Mockito.<Class<? extends HardwareClass>>when(component.getXmlClass()).thenReturn(hwClass); + @Test + public void testInventory() { + String dateTimeString = "2020-02-05T12:30:45.283Z"; + String name = "Slot-0"; - DateAndTime dt = new DateAndTime("2020-02-05T12:30:45.283Z"); - when(component.getMfgDate()).thenReturn(dt); + Component testComponent = ComponentHelper.get(name, dateTimeString); + Optional<Inventory> oInventory = ORanToInternalDataModel.getInternalEquipment(nodeId, testComponent, 0); + assertTrue(oInventory.isPresent()); + Inventory inventory = oInventory.get(); + assertEquals(name, inventory.getUuid()); + assertEquals(dateTimeString, inventory.getDate()); + assertEquals(nodeId.getValue(), inventory.getNodeId()); } @Test - public void test() throws Exception { - ORanToInternalDataModel model = new ORanToInternalDataModel(); - model.getInternalEquipment(nodeId, component,0); - assertEquals(component.getUuid().getValue(), "0Aabcdef-0abc-0cfD-0abC-0123456789AB"); - assertEquals(component.getMfgDate().getValue(), "2020-02-05T12:30:45.283Z"); + public void testInventoryList() throws IOException, ClassNotFoundException { + List<Component> componentList = ComponentHelper.getComponentList("/Device-ietf-hardware-Output.json"); + List<Inventory> inventoryList = ORanToInternalDataModel.getInventoryList(nodeId, componentList); + //componentList.forEach(System.out::println); + assertEquals("All elements", 27, inventoryList.size()); + assertEquals("Fully parseable", componentList.size(), inventoryList.size()); + assertEquals("Treelevel always there", 0, + inventoryList.stream().filter(inventory -> inventory.getTreeLevel() == null).count()); + listAsTree(inventoryList); + } + private void listAsTree(List<Inventory> inventoryList) { + //Walk through complete list and print parameters + IntConsumer action = level -> IntStream.range(0, inventoryList.size()) + .filter(idx -> inventoryList.get(idx).getTreeLevel().intValue() == level) + .forEach(idx2 -> printElements(idx2, level, inventoryList.get(idx2))); + //Walk trough 10 levels + IntStream.range(0, 10) + .forEach(action); } - @After - public void cleanUp() throws Exception { + private void printElements(int idx2, int level, Inventory inventory) { + System.out.println(level + ": " + inventory.getParentUuid() + " " + + inventory.getUuid()); + } + @SuppressWarnings("unused") + private boolean compareLevel(int idx, List<Component> componentList, List<Inventory> inventoryList) { + @Nullable + Integer relPos = componentList.get(idx).getParentRelPos(); + @Nullable + Uint32 treeLevel = inventoryList.get(idx).getTreeLevel(); + LOG.warn("Treelevel relPos: {} treeLevel: {}", relPos, treeLevel); + if (relPos != null && treeLevel != null) { + return relPos == treeLevel.intValue(); + } + return false; } } diff --git a/sdnr/wt/devicemanager-oran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/test/mock/TransactionUtilsMock.java b/sdnr/wt/devicemanager-oran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/test/mock/TransactionUtilsMock.java deleted file mode 100644 index d23227d7f..000000000 --- a/sdnr/wt/devicemanager-oran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/test/mock/TransactionUtilsMock.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * ============LICENSE_START======================================================================== - * ONAP : ccsdk feature sdnr wt - * ================================================================================================= - * Copyright (C) 2020 highstreet technologies GmbH Intellectual Property. All rights reserved. - * ================================================================================================= - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License - * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express - * or implied. See the License for the specific language governing permissions and limitations under - * the License. - * ============LICENSE_END========================================================================== - */ -package org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.test.mock; - -import java.util.concurrent.atomic.AtomicBoolean; -import java.util.concurrent.atomic.AtomicReference; - -import org.eclipse.jdt.annotation.Nullable; -import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.TransactionUtils; -import org.opendaylight.mdsal.binding.api.DataBroker; -import org.opendaylight.mdsal.common.api.LogicalDatastoreType; -import org.opendaylight.yangtools.yang.binding.DataObject; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; - -public class TransactionUtilsMock implements TransactionUtils { - - @Override - public <T extends DataObject> @Nullable T readData(DataBroker dataBroker, LogicalDatastoreType dataStoreType, - InstanceIdentifier<T> iid) { - // TODO Auto-generated method stub - return null; - } - - @Override - public <T extends DataObject> @Nullable T readDataOptionalWithStatus(DataBroker dataBroker, - LogicalDatastoreType dataStoreType, InstanceIdentifier<T> iid, AtomicBoolean noErrorIndication, - AtomicReference<String> statusIndicator) { - // TODO Auto-generated method stub - return null; - } - -} diff --git a/sdnr/wt/devicemanager-oran/provider/src/test/resources/Device-ietf-hardware-Output.json b/sdnr/wt/devicemanager-oran/provider/src/test/resources/Device-ietf-hardware-Output.json new file mode 100644 index 000000000..b5728fe1e --- /dev/null +++ b/sdnr/wt/devicemanager-oran/provider/src/test/resources/Device-ietf-hardware-Output.json @@ -0,0 +1,442 @@ +{ + "hardware": { + "component": [ + { + "name": "chassis-temperature-exhaust", + "state": { + "oper-state": "enabled", + "admin-state": "locked" + }, + "alias": "chassis-temperature-exhaust", + "sensor-data": { + "value-timestamp": "2021-02-18T12:11:03.5Z", + "value": 30, + "value-type": "celsius", + "oper-status": "ok" + }, + "class": "iana-hardware:sensor", + "parent": "chassis", + "parent-rel-pos": 0 + }, + { + "name": "slot0-logical0-rrh", + "state": { + "oper-state": "enabled", + "admin-state": "unlocked" + }, + "model-name": "FTLX1475D3BTL-E7", + "mfg-name": "FINISAR CORP.", + "alias": "Slot0-A-rrh", + "class": "iana-hardware:port", + "contains-child": [ + "slot0-logical0-rrh-temperature" + ], + "parent": "slot0-logical0", + "o-ran-hardware:o-ran-name": "slot0-logical0-rrh", + "serial-num": "AYR3GA9", + "parent-rel-pos": 1 + }, + { + "name": "slot2-logical2", + "state": { + "oper-state": "disabled", + "admin-state": "unlocked" + }, + "alias": "Slot3-B", + "class": "iana-hardware:module", + "parent": "slot2", + "description": "SLOT3-B", + "parent-rel-pos": 3 + }, + { + "name": "chassis-temperature-inlet", + "state": { + "oper-state": "enabled", + "admin-state": "locked" + }, + "alias": "chassis-temperature-inlet", + "sensor-data": { + "value-timestamp": "2021-02-18T12:11:03.5Z", + "value": 29, + "value-type": "celsius", + "oper-status": "ok" + }, + "class": "iana-hardware:sensor", + "parent": "chassis", + "parent-rel-pos": 1 + }, + { + "name": "chassis-fan2", + "state": { + "oper-state": "enabled", + "admin-state": "locked" + }, + "alias": "chassis-fan2", + "class": "iana-hardware:fan", + "contains-child": [ + "chassis-fan2-speed" + ], + "parent": "chassis", + "parent-rel-pos": 4 + }, + { + "name": "slot0-logical0-bbu-temperature", + "state": { + "oper-state": "enabled", + "admin-state": "locked" + }, + "alias": "Slot0-A-bbu-temperature", + "sensor-data": { + "value-timestamp": "2021-02-18T12:11:03.5Z", + "value": 37, + "value-type": "celsius", + "oper-status": "ok" + }, + "class": "iana-hardware:sensor", + "parent": "slot0-logical0-bbu", + "parent-rel-pos": 0 + }, + { + "name": "chassis-fan3", + "state": { + "oper-state": "enabled", + "admin-state": "locked" + }, + "alias": "chassis-fan3", + "class": "iana-hardware:fan", + "contains-child": [ + "chassis-fan3-speed" + ], + "parent": "chassis", + "parent-rel-pos": 5 + }, + { + "name": "chassis-fan0", + "state": { + "oper-state": "enabled", + "admin-state": "locked" + }, + "alias": "chassis-fan0", + "class": "iana-hardware:fan", + "contains-child": [ + "chassis-fan0-speed" + ], + "parent": "chassis", + "parent-rel-pos": 2 + }, + { + "name": "slot0-logical1", + "state": { + "oper-state": "disabled", + "admin-state": "unlocked" + }, + "alias": "Slot0-B", + "class": "iana-hardware:module", + "parent": "slot0", + "description": "SLOT0-B", + "parent-rel-pos": 2 + }, + { + "name": "chassis-fan1", + "state": { + "oper-state": "enabled", + "admin-state": "locked" + }, + "alias": "chassis-fan1", + "class": "iana-hardware:fan", + "contains-child": [ + "chassis-fan1-speed" + ], + "parent": "chassis", + "parent-rel-pos": 3 + }, + { + "name": "slot0-logical0", + "state": { + "oper-state": "enabled", + "admin-state": "unlocked" + }, + "alias": "Slot0-A", + "class": "iana-hardware:module", + "contains-child": [ + "slot0-logical0-rrh", + "slot0-logical0-bbu" + ], + "parent": "slot0", + "description": "SLOT0-AZ", + "parent-rel-pos": 1 + }, + { + "name": "slot0-logical2", + "state": { + "oper-state": "disabled", + "admin-state": "unlocked" + }, + "alias": "Slot0-C", + "class": "iana-hardware:module", + "parent": "slot0", + "description": "SLOT0-C", + "parent-rel-pos": 3 + }, + { + "name": "chassis-fan1-speed", + "state": { + "oper-state": "enabled", + "admin-state": "locked" + }, + "alias": "chassis-fan1-speed", + "sensor-data": { + "value-timestamp": "2021-02-18T12:11:03.5Z", + "value": 4100, + "value-type": "rpm", + "oper-status": "ok" + }, + "class": "iana-hardware:sensor", + "parent": "chassis-fan1", + "parent-rel-pos": 0 + }, + { + "name": "slot2-logical1", + "state": { + "oper-state": "disabled", + "admin-state": "unlocked" + }, + "alias": "Slot3-A", + "class": "iana-hardware:module", + "parent": "slot2", + "description": "SLOT3-A", + "parent-rel-pos": 2 + }, + { + "name": "slot2-logical0", + "state": { + "oper-state": "disabled", + "admin-state": "unlocked" + }, + "alias": "Slot2-C", + "class": "iana-hardware:module", + "parent": "slot2", + "description": "SLOT2-C", + "parent-rel-pos": 1 + }, + { + "name": "cpu-temperature", + "state": { + "oper-state": "enabled", + "admin-state": "locked" + }, + "alias": "cpu-temperature", + "sensor-data": { + "value-timestamp": "2021-02-18T12:11:03.5Z", + "value": 30, + "value-type": "celsius", + "oper-status": "ok" + }, + "class": "iana-hardware:sensor", + "parent": "cpu", + "parent-rel-pos": 0 + }, + { + "name": "chassis", + "state": { + "oper-state": "enabled", + "admin-state": "unlocked" + }, + "model-name": "ProteusCPRI Compact", + "mfg-name": "ISCO", + "alias": "chassis", + "class": "iana-hardware:chassis", + "contains-child": [ + "chassis-temperature-inlet", + "cpu", + "chassis-fan0", + "chassis-temperature-exhaust", + "slot0", + "slot2", + "chassis-fan3", + "chassis-fan2", + "chassis-fan1" + ], + "serial-num": "10283", + "description": "HighStreet-ONAP40", + "software-rev": "3.8.1 (2020-10-30 11:47:59)" + }, + { + "name": "slot0-logical0-bbu", + "state": { + "oper-state": "enabled", + "admin-state": "unlocked" + }, + "model-name": "FTLX1475D3BTL-E7", + "mfg-name": "FINISAR CORP.", + "alias": "Slot0-A-bbu", + "class": "iana-hardware:port", + "contains-child": [ + "slot0-logical0-bbu-temperature" + ], + "parent": "slot0-logical0", + "o-ran-hardware:o-ran-name": "slot0-logical0-bbu", + "serial-num": "AYR3GA2", + "parent-rel-pos": 0 + }, + { + "name": "slot2", + "state": { + "oper-state": "enabled", + "admin-state": "unlocked" + }, + "model-name": "385A-SFP-2P-40-FHL-JC3", + "alias": "slot2", + "class": "iana-hardware:module", + "contains-child": [ + "slot2-temperature", + "slot2-logical0", + "slot2-logical1", + "slot2-logical2" + ], + "parent": "chassis", + "firmware-rev": "12.00.42-S (0F7F1001)", + "serial-num": "7220718", + "parent-rel-pos": 9, + "software-rev": "0" + }, + { + "name": "chassis-fan0-speed", + "state": { + "oper-state": "enabled", + "admin-state": "locked" + }, + "alias": "chassis-fan0-speed", + "sensor-data": { + "value-timestamp": "2021-02-18T12:11:03.5Z", + "value": 4100, + "value-type": "rpm", + "oper-status": "ok" + }, + "class": "iana-hardware:sensor", + "parent": "chassis-fan0", + "parent-rel-pos": 0 + }, + { + "name": "slot0", + "state": { + "oper-state": "enabled", + "admin-state": "unlocked" + }, + "model-name": "385A-SFP-2P-40-FHL-JC3", + "alias": "slot0", + "class": "iana-hardware:module", + "contains-child": [ + "slot0-logical0", + "slot0-logical2", + "slot0-temperature", + "slot0-logical1" + ], + "parent": "chassis", + "firmware-rev": "12.00.42-S (0F7F1001)", + "serial-num": "7220530", + "parent-rel-pos": 7, + "software-rev": "0" + }, + { + "name": "slot0-temperature", + "state": { + "oper-state": "enabled", + "admin-state": "locked" + }, + "alias": "slot0-temperature", + "sensor-data": { + "value-timestamp": "2021-02-18T12:11:03.5Z", + "value": 51, + "value-type": "celsius", + "oper-status": "ok" + }, + "class": "iana-hardware:sensor", + "parent": "slot0", + "parent-rel-pos": 0 + }, + { + "name": "cpu", + "state": { + "oper-state": "enabled", + "admin-state": "locked" + }, + "alias": "cpu", + "class": "iana-hardware:cpu", + "contains-child": [ + "cpu-temperature" + ], + "parent": "chassis", + "parent-rel-pos": 6 + }, + { + "name": "slot0-logical0-rrh-temperature", + "state": { + "oper-state": "enabled", + "admin-state": "locked" + }, + "alias": "Slot0-A-rrh-temperature", + "sensor-data": { + "value-timestamp": "2021-02-18T12:11:03.5Z", + "value": 35, + "value-type": "celsius", + "oper-status": "ok" + }, + "class": "iana-hardware:sensor", + "parent": "slot0-logical0-rrh", + "parent-rel-pos": 0 + }, + { + "name": "chassis-fan3-speed", + "state": { + "oper-state": "enabled", + "admin-state": "locked" + }, + "alias": "chassis-fan3-speed", + "sensor-data": { + "value-timestamp": "2021-02-18T12:11:03.5Z", + "value": 1000, + "value-type": "rpm", + "oper-status": "ok" + }, + "class": "iana-hardware:sensor", + "parent": "chassis-fan3", + "parent-rel-pos": 0 + }, + { + "name": "chassis-fan2-speed", + "state": { + "oper-state": "enabled", + "admin-state": "locked" + }, + "alias": "chassis-fan2-speed", + "sensor-data": { + "value-timestamp": "2021-02-18T12:11:03.5Z", + "value": 4100, + "value-type": "rpm", + "oper-status": "ok" + }, + "class": "iana-hardware:sensor", + "parent": "chassis-fan2", + "parent-rel-pos": 0 + }, + { + "name": "slot2-temperature", + "state": { + "oper-state": "enabled", + "admin-state": "locked" + }, + "alias": "slot2-temperature", + "sensor-data": { + "value-timestamp": "2021-02-18T12:11:03.5Z", + "value": 49, + "value-type": "celsius", + "oper-status": "ok" + }, + "class": "iana-hardware:sensor", + "parent": "slot2", + "parent-rel-pos": 0 + } + ] + } +}
\ No newline at end of file diff --git a/sdnr/wt/devicemanager/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/service/NotificationProxyParser.java b/sdnr/wt/devicemanager/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/service/NotificationProxyParser.java new file mode 100644 index 000000000..ea16f20bb --- /dev/null +++ b/sdnr/wt/devicemanager/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/service/NotificationProxyParser.java @@ -0,0 +1,49 @@ +/* + * ============LICENSE_START======================================================= + * ONAP : ccsdk features + * ================================================================================ + * Copyright (C) 2020 highstreet technologies GmbH Intellectual Property. + * All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + * + */ +package org.onap.ccsdk.features.sdnr.wt.devicemanager.service; + +import java.time.Instant; +import java.util.HashMap; +import org.opendaylight.yangtools.yang.binding.Notification; + +public interface NotificationProxyParser { + + /** + * parses the Notification proxy object created by ODL + * Returns a Map with class members as keys and the member values as values. + * The keys are in xpath notation. + * Ex: key = /notification/VALUECHANGE[@xmlns=\"urn:org:onap:ccsdk:features:sdnr:northbound:onecell-notification\"]/device/device-info/serial-number" + * value = "0005B94238A0" + * References: https://stackoverflow.com/questions/19633534/what-is-com-sun-proxy-proxy + */ + public HashMap<String, String> parseNotificationProxy(Notification notification); + + /** + * Gets the time at which the Event occurred if the notification is an instance of EventInstantAware. If not, then returns the current time + * Read notification time via {@link #EventInstantAware } interface. + * + * @param notification + * @return + */ + public Instant getTime(Notification notification); + +} diff --git a/sdnr/wt/devicemanager/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/service/VESCollectorCfgService.java b/sdnr/wt/devicemanager/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/service/VESCollectorCfgService.java index c274ff91c..5025b5bba 100644 --- a/sdnr/wt/devicemanager/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/service/VESCollectorCfgService.java +++ b/sdnr/wt/devicemanager/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/service/VESCollectorCfgService.java @@ -21,9 +21,18 @@ */ package org.onap.ccsdk.features.sdnr.wt.devicemanager.service; +/* + * Interface that exposes a subset of the VES Collector configuration properties to clients that require them + */ + public interface VESCollectorCfgService { + /* gets the reportingEntityName (REPORTING_ENTITY_NAME) configured in the etc/devicemanager.properties configuration file */ String getReportingEntityName(); + + /* gets the log detail configuration (EVENTLOG_MSG_DETAIL) property value configured in the etc/devicemanager.properties configuration file */ String getEventLogMsgDetail(); + + /* gets the VES Collector enabled property (VES_COLLECTOR_ENABLED) value configured in the etc/devicemanager.properties configuration file */ boolean isVESCollectorEnabled(); } diff --git a/sdnr/wt/devicemanager/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/service/VESCollectorService.java b/sdnr/wt/devicemanager/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/service/VESCollectorService.java index 287f0f622..f93b599bf 100644 --- a/sdnr/wt/devicemanager/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/service/VESCollectorService.java +++ b/sdnr/wt/devicemanager/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/service/VESCollectorService.java @@ -21,7 +21,13 @@ */ package org.onap.ccsdk.features.sdnr.wt.devicemanager.service; - +import com.fasterxml.jackson.core.JsonProcessingException; +import org.eclipse.jdt.annotation.NonNull; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.types.VESCommonEventHeaderPOJO; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.types.VESFaultFieldsPOJO; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.types.VESMessage; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.types.VESNotificationFieldsPOJO; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.types.VESPNFRegistrationFieldsPOJO; /** * Interface used for publishing VES messages to the VES Collector @@ -31,9 +37,64 @@ package org.onap.ccsdk.features.sdnr.wt.devicemanager.service; */ public interface VESCollectorService extends DeviceManagerService { + /** + * Gets the VES Collector configuration from etc/devicemanager.properties configuration file + */ VESCollectorCfgService getConfig(); - boolean publishVESMessage(String vesMsg); - public void registerForChanges(VESCollectorConfigChangeListener o); - public void deregister(VESCollectorConfigChangeListener o); + + /** + * publishes a VES message to the VES Collector by sending a REST request + * @param vesMsg + * @return + */ + boolean publishVESMessage(VESMessage vesMsg); + + /** + * clients interested in VES Collector configuration changes can call the registerForChanges method so as to be notified when configuration changes are made + */ + void registerForChanges(VESCollectorConfigChangeListener o); + + /** + * de-registering clients as part of cleanup + * @param o + */ + void deregister(VESCollectorConfigChangeListener o); + + /** + * Get a parser to parse {@link #org.opendaylight.yangtools.yang.binding.Notification } messages + * @return NotificationProxyParser object + */ + @NonNull + NotificationProxyParser getNotificationProxyParser(); + + /** + * Generates VES Event JSON containing commonEventHeader and notificationFields fields + * + * @param commonEventHeader + * @param notifFields + * @return VESMessage - representing the VESEvent JSON + * @throws JsonProcessingException + */ + VESMessage generateVESEvent(VESCommonEventHeaderPOJO commonEventHeader, VESNotificationFieldsPOJO notifFields) throws JsonProcessingException; + + /** + * Generates VES Event JSON containing commonEventHeader and faultFields fields + * + * @param commonEventHeader + * @param faultFields + * @return VESMessage - representing the VES Event JSON + * @throws JsonProcessingException + */ + VESMessage generateVESEvent(VESCommonEventHeaderPOJO commonEventHeader, VESFaultFieldsPOJO faultFields) throws JsonProcessingException; + + /** + * Generates VES Event JSON containing commonEventHeader and pnfRegistration fields + * + * @param commonEventHeader + * @param faultFields + * @return VESMessage - representing the VES Event JSON + * @throws JsonProcessingException + */ + VESMessage generateVESEvent(VESCommonEventHeaderPOJO commonEventHeader, VESPNFRegistrationFieldsPOJO faultFields) throws JsonProcessingException; } diff --git a/sdnr/wt/devicemanager/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/service/VESEventMapper.java b/sdnr/wt/devicemanager/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/service/VESEventMapper.java new file mode 100644 index 000000000..76c8305a2 --- /dev/null +++ b/sdnr/wt/devicemanager/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/service/VESEventMapper.java @@ -0,0 +1,121 @@ +/* + * ============LICENSE_START======================================================= + * ONAP : ccsdk features + * ================================================================================ + * Copyright (C) 2020 highstreet technologies GmbH Intellectual Property. + * All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + * + */ +package org.onap.ccsdk.features.sdnr.wt.devicemanager.service; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import java.time.Instant; +import java.util.HashMap; +import java.util.Map; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.types.VESCommonEventHeaderPOJO; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.types.VESFaultFieldsPOJO; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.types.VESNotificationFieldsPOJO; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.types.VESPNFRegistrationFieldsPOJO; +import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfBindingAccessor; +import org.opendaylight.yangtools.yang.binding.Notification; + +/* + * Interface for mapping ODL notification to VES event fields grouped by event type. + * Also includes the commonEventHeader which is applicable for all events. + * Ex: fault event, notification event. + * + * No base implementation exists for this interface. Clients that need to map their data into VES formats must implement this interface. + */ + +public abstract class VESEventMapper<N extends Notification,F extends Notification,T extends Notification> { + + /** + * Creates VESEvent mapping + */ + public abstract String createMapping(NetconfBindingAccessor netconfAccessor, + VESCollectorService vesCollectorService, Notification notification, String notifName, int sequenceNo, + Instant eventTime); + + /** + * Returns VES commonEventHeader fields + */ + public abstract VESCommonEventHeaderPOJO mapCommonEventHeader(N notification); + + /** + * Returns VES faultFields + */ + public abstract VESFaultFieldsPOJO mapFaultFields(F notification); + + /** + * Returns VES Notification Fields + */ + public abstract VESNotificationFieldsPOJO mapNotificationFields(T notification); + + /** + * Returns VES pnfRegistration domain fields + * + * @return + */ + public abstract VESPNFRegistrationFieldsPOJO mapPNFRegistrationFields(); + + /** + * Generates VES Event JSON containing commonEventHeader and notificationFields fields + * + * @param commonEventHeader + * @param notifFields + * @return String - representing the VESEvent JSON + */ + String generateVESEvent(VESCommonEventHeaderPOJO commonEventHeader, VESNotificationFieldsPOJO notifFields) { + Map<String, Object> innerEvent = new HashMap<String, Object>(); + innerEvent.put("commonEventHeader", commonEventHeader); + innerEvent.put("notificationFields", notifFields); + + Map<String, Object> outerEvent = new HashMap<String, Object>(); + outerEvent.put("event", innerEvent); + try { + ObjectMapper objMapper = new ObjectMapper(); + return objMapper.writeValueAsString(outerEvent); + } catch (JsonProcessingException e) { + e.printStackTrace(); + } + return null; + } + + /** + * Generates VES Event JSON containing commonEventHeader and faultFields fields + * + * @param commonEventHeader + * @param faultFields + * @return String - representing the VES Event JSON + */ + String generateVESEvent(VESCommonEventHeaderPOJO commonEventHeader, VESFaultFieldsPOJO faultFields) { + Map<String, Object> innerEvent = new HashMap<String, Object>(); + innerEvent.put("commonEventHeader", commonEventHeader); + innerEvent.put("faultFields", faultFields); + + Map<String, Object> outerEvent = new HashMap<String, Object>(); + outerEvent.put("event", innerEvent); + try { + ObjectMapper objMapper = new ObjectMapper(); + return objMapper.writeValueAsString(outerEvent); + } catch (JsonProcessingException e) { + e.printStackTrace(); + } + return null; + } + +} diff --git a/sdnr/wt/devicemanager-oran/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/VESCommonEventHeaderPOJO.java b/sdnr/wt/devicemanager/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/types/VESCommonEventHeaderPOJO.java index 730c63b0f..db76b84c7 100644 --- a/sdnr/wt/devicemanager-oran/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/VESCommonEventHeaderPOJO.java +++ b/sdnr/wt/devicemanager/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/types/VESCommonEventHeaderPOJO.java @@ -19,7 +19,7 @@ * ============LICENSE_END========================================================= * */ -package org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.impl; +package org.onap.ccsdk.features.sdnr.wt.devicemanager.types; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonPropertyOrder; diff --git a/sdnr/wt/devicemanager/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/types/VESFaultFieldsPOJO.java b/sdnr/wt/devicemanager/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/types/VESFaultFieldsPOJO.java new file mode 100644 index 000000000..0f40ed3a4 --- /dev/null +++ b/sdnr/wt/devicemanager/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/types/VESFaultFieldsPOJO.java @@ -0,0 +1,111 @@ +/* + * ============LICENSE_START======================================================= + * ONAP : ccsdk features + * ================================================================================ + * Copyright (C) 2020 highstreet technologies GmbH Intellectual Property. + * All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + * + */ +package org.onap.ccsdk.features.sdnr.wt.devicemanager.types; + +import java.util.HashMap; + +public class VESFaultFieldsPOJO { + + //fault domain Fields + private String alarmCondition = ""; + private String alarmInterfaceA = ""; + private String eventCategory = ""; + private String eventSeverity = ""; + private String eventSourceType = ""; + private String faultFieldsVersion = "4.0"; + private String specificProblem = ""; + private String vfStatus = ""; + private HashMap<String, Object> alarmAdditionalInformation = new HashMap<String, Object>(); + + public String getAlarmCondition() { + return alarmCondition; + } + + public void setAlarmCondition(String alarmCondition) { + this.alarmCondition = alarmCondition; + } + + public String getAlarmInterfaceA() { + return alarmInterfaceA; + } + + public void setAlarmInterfaceA(String alarmInterfaceA) { + this.alarmInterfaceA = alarmInterfaceA; + } + + public String getEventCategory() { + return eventCategory; + } + + public void setEventCategory(String eventCategory) { + this.eventCategory = eventCategory; + } + + public String getEventSeverity() { + return eventSeverity; + } + + public void setEventSeverity(String eventSeverity) { + this.eventSeverity = eventSeverity; + } + + public String getEventSourceType() { + return eventSourceType; + } + + public void setEventSourceType(String eventSourceType) { + this.eventSourceType = eventSourceType; + } + + public String getFaultFieldsVersion() { + return faultFieldsVersion; + } + + public void setFaultFieldsVersion(String faultFieldsVersion) { + this.faultFieldsVersion = faultFieldsVersion; + } + + public String getSpecificProblem() { + return specificProblem; + } + + public void setSpecificProblem(String specificProblem) { + this.specificProblem = specificProblem; + } + + public String getVfStatus() { + return vfStatus; + } + + public void setVfStatus(String vfStatus) { + this.vfStatus = vfStatus; + } + + public HashMap<String, Object> getAlarmAdditionalInformation() { + return alarmAdditionalInformation; + } + + public void setAlarmAdditionalInformation(HashMap<String, Object> alarmAdditionalInformation) { + this.alarmAdditionalInformation = alarmAdditionalInformation; + } + +} diff --git a/sdnr/wt/devicemanager-oran/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/VESEvent.java b/sdnr/wt/devicemanager/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/types/VESMessage.java index 1117565e6..2c5266f97 100644 --- a/sdnr/wt/devicemanager-oran/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/VESEvent.java +++ b/sdnr/wt/devicemanager/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/types/VESMessage.java @@ -19,26 +19,17 @@ * ============LICENSE_END========================================================= * */ -package org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.impl; +package org.onap.ccsdk.features.sdnr.wt.devicemanager.types; -import java.util.HashMap; -import java.util.Map; +public class VESMessage { -public class VESEvent { - - public Map<String, Object> event = new HashMap<String, Object>(); - - public void addEventObjects(Object eventObject) { - if (eventObject instanceof VESCommonEventHeaderPOJO) - event.put("commonEventHeader", eventObject); - else if (eventObject instanceof VESNotificationFieldsPOJO) - event.put("notificationFields", eventObject); + private String message; + public VESMessage(String vesMessage) { + this.message = vesMessage; } - public Map<String, Object> getEvent() { - return event; + public String getMessage() { + return message; } } - - diff --git a/sdnr/wt/devicemanager-oran/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/VESNotificationFieldsPOJO.java b/sdnr/wt/devicemanager/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/types/VESNotificationFieldsPOJO.java index 09aa6dd0a..6beb04751 100644 --- a/sdnr/wt/devicemanager-oran/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/VESNotificationFieldsPOJO.java +++ b/sdnr/wt/devicemanager/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/types/VESNotificationFieldsPOJO.java @@ -19,7 +19,7 @@ * ============LICENSE_END========================================================= * */ -package org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.impl; +package org.onap.ccsdk.features.sdnr.wt.devicemanager.types; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonPropertyOrder; @@ -113,4 +113,4 @@ public class VESNotificationFieldsPOJO { } -} +}
\ No newline at end of file diff --git a/sdnr/wt/devicemanager/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/types/VESPNFRegistrationFieldsPOJO.java b/sdnr/wt/devicemanager/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/types/VESPNFRegistrationFieldsPOJO.java new file mode 100644 index 000000000..e564914da --- /dev/null +++ b/sdnr/wt/devicemanager/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/types/VESPNFRegistrationFieldsPOJO.java @@ -0,0 +1,148 @@ +/* + * ============LICENSE_START======================================================= + * ONAP : ccsdk features + * ================================================================================ + * Copyright (C) 2020 highstreet technologies GmbH Intellectual Property. + * All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + * + */ +package org.onap.ccsdk.features.sdnr.wt.devicemanager.types; + +import java.util.HashMap; +import java.util.Map; + +public class VESPNFRegistrationFieldsPOJO { + + private Map<String, String> additionalFields = new HashMap<String, String>(); + private String lastServiceDate = ""; + private String macAddress = ""; + private String manufactureDate = ""; + private String modelNumber = ""; + private String oamV4IpAddress = ""; + private String oamV6IpAddress = ""; + private String pnfRegistrationFieldsVersion = "2.0"; + private String serialNumber = ""; + private String softwareVersion = ""; + private String unitFamily = ""; + private String unitType = ""; + private String vendorName = ""; + + public Map<String, String> getAdditionalFields() { + return additionalFields; + } + + public void setAdditionalFields(Map<String, String> additionalFields) { + this.additionalFields = additionalFields; + } + + public String getLastServiceDate() { + return lastServiceDate; + } + + public void setLastServiceDate(String lastServiceDate) { + this.lastServiceDate = lastServiceDate; + } + + public String getMacAddress() { + return macAddress; + } + + public void setMacAddress(String macAddress) { + this.macAddress = macAddress; + } + + public String getManufactureDate() { + return manufactureDate; + } + + public void setManufactureDate(String manufactureDate) { + this.manufactureDate = manufactureDate; + } + + public String getModelNumber() { + return modelNumber; + } + + public void setModelNumber(String modelNumber) { + this.modelNumber = modelNumber; + } + + public String getOamV4IpAddress() { + return oamV4IpAddress; + } + + public void setOamV4IpAddress(String oamV4IpAddress) { + this.oamV4IpAddress = oamV4IpAddress; + } + + public String getOamV6IpAddress() { + return oamV6IpAddress; + } + + public void setOamV6IpAddress(String oamV6IpAddress) { + this.oamV6IpAddress = oamV6IpAddress; + } + + public String getPnfRegistrationFieldsVersion() { + return pnfRegistrationFieldsVersion; + } + + public void setPnfRegistrationFieldsVersion(String pnfRegistrationFieldsVersion) { + this.pnfRegistrationFieldsVersion = pnfRegistrationFieldsVersion; + } + + public String getSerialNumber() { + return serialNumber; + } + + public void setSerialNumber(String serialNumber) { + this.serialNumber = serialNumber; + } + + public String getSoftwareVersion() { + return softwareVersion; + } + + public void setSoftwareVersion(String softwareVersion) { + this.softwareVersion = softwareVersion; + } + + public String getUnitFamily() { + return unitFamily; + } + + public void setUnitFamily(String unitFamily) { + this.unitFamily = unitFamily; + } + + public String getUnitType() { + return unitType; + } + + public void setUnitType(String unitType) { + this.unitType = unitType; + } + + public String getVendorName() { + return vendorName; + } + + public void setVendorName(String vendorName) { + this.vendorName = vendorName; + + } + +} diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/DeviceManagerImpl.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/DeviceManagerImpl.java index fd2929f1a..689336f5e 100644 --- a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/DeviceManagerImpl.java +++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/DeviceManagerImpl.java @@ -75,14 +75,14 @@ import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.NotificationService import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.PerformanceManager; import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.VESCollectorService; import org.onap.ccsdk.features.sdnr.wt.devicemanager.toggleAlarmFilter.DevicemanagerNotificationDelayService; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.vescollectorconnector.impl.VESCollectorClient; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.vescollectorconnector.impl.VESCollectorServiceImpl; import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfNodeStateService; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.websocketmanager.rev150105.WebsocketmanagerService; import org.opendaylight.mdsal.binding.api.DataBroker; import org.opendaylight.mdsal.binding.api.MountPointService; import org.opendaylight.mdsal.binding.api.NotificationPublishService; import org.opendaylight.mdsal.binding.api.RpcProviderService; import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceProvider; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.websocketmanager.rev150105.WebsocketmanagerService; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -125,7 +125,7 @@ public class DeviceManagerImpl implements NetconfNetworkElementService, DeviceMa private ConnectionStatusHousekeepingService housekeepingService; private NetconfNodeStateService netconfNodeStateService; private DataProvider dataProvider; - private VESCollectorClient vesCollectorClient; + private VESCollectorServiceImpl vesCollectorServiceImpl; // Handler private DeviceManagerNetconfConnectHandler deviceManagerNetconfConnectHandler; @@ -209,7 +209,7 @@ public class DeviceManagerImpl implements NetconfNetworkElementService, DeviceMa this.aaiProviderClient = new AaiProviderClient(config, this); - this.vesCollectorClient = new VESCollectorClient(config); + this.vesCollectorServiceImpl = new VESCollectorServiceImpl(config); // EM String myDbKeyNameExtended = MYDBKEYNAMEBASE + "-" + esConfig.getCluster(); @@ -273,13 +273,13 @@ public class DeviceManagerImpl implements NetconfNetworkElementService, DeviceMa close(archiveCleanService); close(housekeepingService); close(deviceManagerNetconfConnectHandler); - close(vesCollectorClient); + close(vesCollectorServiceImpl); LOG.info("DeviceManagerImpl closing done"); } @Override public @NonNull <L extends NetworkElementFactory> FactoryRegistration<L> registerBindingNetworkElementFactory( - @NonNull L factory) { + @NonNull final L factory) { LOG.info("Factory registration {}", factory.getClass().getName()); factoryList.add(factory); @@ -416,7 +416,7 @@ public class DeviceManagerImpl implements NetconfNetworkElementService, DeviceMa @Override public @NonNull VESCollectorService getVESCollectorService() { - return this.vesCollectorClient; + return this.vesCollectorServiceImpl; } } diff --git a/sdnr/wt/devicemanager-oran/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/ORanNotificationMapper.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/util/NotificationProxyParserImpl.java index ccb1ac098..802c05d0c 100644 --- a/sdnr/wt/devicemanager-oran/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/ORanNotificationMapper.java +++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/util/NotificationProxyParserImpl.java @@ -19,7 +19,8 @@ * ============LICENSE_END========================================================= * */ -package org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.impl; +package org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.util; + import java.lang.reflect.Field; import java.lang.reflect.InvocationTargetException; @@ -29,6 +30,7 @@ import java.time.Instant; import java.util.HashMap; import java.util.List; import org.eclipse.jdt.annotation.NonNull; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.NotificationProxyParser; import org.opendaylight.yangtools.concepts.Identifier; import org.opendaylight.yangtools.yang.binding.DataObject; import org.opendaylight.yangtools.yang.binding.EventInstantAware; @@ -38,7 +40,8 @@ import org.opendaylight.yangtools.yang.common.QName; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class ORanNotificationMapper { +public class NotificationProxyParserImpl implements NotificationProxyParser { + /* * Converter of TR069 notifications to VES key, value hashmap. @@ -111,10 +114,11 @@ public class ORanNotificationMapper { * } * */ - private static final Logger log = LoggerFactory.getLogger(ORanNotificationMapper.class); + private static final Logger log = LoggerFactory.getLogger(NotificationProxyParserImpl.class); private Notification notification; - public HashMap<String, String> performMapping(Notification notification) + @Override + public HashMap<String, String> parseNotificationProxy(Notification notification) /*throws ORanNotificationMapperException*/ { try { @@ -271,7 +275,7 @@ public class ORanNotificationMapper { * Inspiration from KebabCaseStrategy class of com.fasterxml.jackson.databind with an additional condition to handle numbers as well * Using QNAME would have been a more fool proof solution, however it can lead to performance problems due to usage of Java reflection */ - public String convertCamelToKebabCase(String input) + private String convertCamelToKebabCase(String input) { if (input == null) return input; // garbage in, garbage out int length = input.length(); @@ -324,7 +328,7 @@ public class ORanNotificationMapper { throw new IllegalArgumentException("indentifiable object without key"); } - public Instant getTime(Notification notification2) { + public Instant getTime(Notification notification) { @NonNull Instant time; if (notification instanceof EventInstantAware) { // If notification class extends/implements the EventInstantAware diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/vescollectorconnector/impl/VESCollectorClient.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/vescollectorconnector/impl/VESCollectorServiceImpl.java index 70ff86009..47ac9c785 100644 --- a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/vescollectorconnector/impl/VESCollectorClient.java +++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/vescollectorconnector/impl/VESCollectorServiceImpl.java @@ -21,6 +21,8 @@ */ package org.onap.ccsdk.features.sdnr.wt.devicemanager.vescollectorconnector.impl; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; import java.io.IOException; import java.util.ArrayList; import java.util.Base64; @@ -28,31 +30,42 @@ import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; +import org.eclipse.jdt.annotation.NonNull; import org.onap.ccsdk.features.sdnr.wt.common.configuration.ConfigurationFileRepresentation; import org.onap.ccsdk.features.sdnr.wt.common.configuration.filechange.IConfigChangedListener; import org.onap.ccsdk.features.sdnr.wt.common.http.BaseHTTPClient; import org.onap.ccsdk.features.sdnr.wt.common.http.BaseHTTPResponse; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.util.NotificationProxyParserImpl; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.NotificationProxyParser; import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.VESCollectorConfigChangeListener; import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.VESCollectorService; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.types.VESCommonEventHeaderPOJO; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.types.VESFaultFieldsPOJO; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.types.VESMessage; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.types.VESNotificationFieldsPOJO; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.types.VESPNFRegistrationFieldsPOJO; import org.onap.ccsdk.features.sdnr.wt.devicemanager.vescollectorconnector.impl.config.VESCollectorCfgImpl; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class VESCollectorClient implements VESCollectorService, IConfigChangedListener, AutoCloseable { - private static final Logger LOG = LoggerFactory.getLogger(VESCollectorClient.class); +public class VESCollectorServiceImpl implements VESCollectorService, IConfigChangedListener, AutoCloseable { + private static final Logger LOG = LoggerFactory.getLogger(VESCollectorServiceImpl.class); private final VESCollectorCfgImpl vesConfig; private final ConfigurationFileRepresentation cfg; private BaseHTTPClient httpClient; private final Map<String, String> headerMap; private List<VESCollectorConfigChangeListener> registeredObjects; + private final ObjectMapper objMapper; - public VESCollectorClient(ConfigurationFileRepresentation config) { + + public VESCollectorServiceImpl(ConfigurationFileRepresentation config) { registeredObjects = new ArrayList<VESCollectorConfigChangeListener>(); this.vesConfig = new VESCollectorCfgImpl(config); this.cfg = config; this.cfg.registerConfigChangedListener(this); + this.objMapper = new ObjectMapper(); - httpClient = new BaseHTTPClient(getBaseUrl()); + httpClient = new BaseHTTPClient(getBaseUrl(), this.vesConfig.isTrustAllCerts()); this.headerMap = new HashMap<>(); this.headerMap.put("Content-Type", "application/json"); @@ -84,15 +97,13 @@ public class VESCollectorClient implements VESCollectorService, IConfigChangedLi } - - @Override - public boolean publishVESMessage(String message) { - LOG.info("In VESClient - {} ", message); + public boolean publishVESMessage(VESMessage message) { + LOG.info("In VESClient - {} ", message.getMessage()); BaseHTTPResponse response; try { String uri = "eventListener" + "/" + getConfig().getVersion(); - response = httpClient.sendRequest(uri, "POST", message, headerMap); + response = httpClient.sendRequest(uri, "POST", message.getMessage(), headerMap); LOG.debug("finished with responsecode {}", response.code); return response.code == 200; } catch (IOException e) { @@ -109,7 +120,8 @@ public class VESCollectorClient implements VESCollectorService, IConfigChangedLi @Override public void onConfigChanged() { - httpClient.setBaseUrl(getBaseUrl()); + LOG.debug("In onConfigChanged - isTrustAllCerts = {} getBaseUrl = {}", getConfig().isTrustAllCerts(), getBaseUrl()); + httpClient = new BaseHTTPClient(getBaseUrl(), this.vesConfig.isTrustAllCerts()); setAuthorization(getConfig().getUsername(), getConfig().getPassword()); Iterator<VESCollectorConfigChangeListener> it = registeredObjects.iterator(); while (it.hasNext()) { @@ -128,4 +140,68 @@ public class VESCollectorClient implements VESCollectorService, IConfigChangedLi registeredObjects.remove(o); } + @Override + public @NonNull NotificationProxyParser getNotificationProxyParser() { + return new NotificationProxyParserImpl(); + } + + /** + * Generates VES Event JSON containing commonEventHeader and notificationFields fields + * + * @param commonEventHeader + * @param notifFields + * @return VESMessage - representing the VESEvent JSON + * @throws JsonProcessingException + */ + @Override + public VESMessage generateVESEvent(VESCommonEventHeaderPOJO commonEventHeader, + VESNotificationFieldsPOJO notifFields) throws JsonProcessingException { + Map<String, Object> innerEvent = new HashMap<String, Object>(); + innerEvent.put("commonEventHeader", commonEventHeader); + innerEvent.put("notificationFields", notifFields); + + Map<String, Object> outerEvent = new HashMap<String, Object>(); + outerEvent.put("event", innerEvent); + LOG.info("in generateVESEvent - {}", objMapper.writeValueAsString(outerEvent)); + return new VESMessage(objMapper.writeValueAsString(outerEvent)); + } + + /** + * Generates VES Event JSON containing commonEventHeader and faultFields fields + * + * @param commonEventHeader + * @param faultFields + * @return VESMessage - representing the VES Event JSON + * @throws JsonProcessingException + */ + @Override + public VESMessage generateVESEvent(VESCommonEventHeaderPOJO commonEventHeader, VESFaultFieldsPOJO faultFields) throws JsonProcessingException { + Map<String, Object> innerEvent = new HashMap<String, Object>(); + innerEvent.put("commonEventHeader", commonEventHeader); + innerEvent.put("faultFields", faultFields); + + Map<String, Object> outerEvent = new HashMap<String, Object>(); + outerEvent.put("event", innerEvent); + return new VESMessage(objMapper.writeValueAsString(outerEvent)); + } + + /** + * Generates VES Event JSON containing commonEventHeader and pnfRegistration fields + * + * @param commonEventHeader + * @param pnfRegistrationFields + * @return VESMessage - representing the VES Event JSON + * @throws JsonProcessingException + */ + @Override + public VESMessage generateVESEvent(VESCommonEventHeaderPOJO commonEventHeader, VESPNFRegistrationFieldsPOJO pnfRegistrationFields) throws JsonProcessingException { + Map<String, Object> innerEvent = new HashMap<String, Object>(); + innerEvent.put("commonEventHeader", commonEventHeader); + innerEvent.put("pnfRegistration", pnfRegistrationFields); + + Map<String, Object> outerEvent = new HashMap<String, Object>(); + outerEvent.put("event", innerEvent); + return new VESMessage(objMapper.writeValueAsString(outerEvent)); + } + } diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/vescollectorconnector/impl/config/VESCollectorCfgImpl.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/vescollectorconnector/impl/config/VESCollectorCfgImpl.java index c3bddc9b1..105b915c7 100644 --- a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/vescollectorconnector/impl/config/VESCollectorCfgImpl.java +++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/vescollectorconnector/impl/config/VESCollectorCfgImpl.java @@ -40,6 +40,7 @@ public class VESCollectorCfgImpl implements VESCollectorCfgService, Configuratio private static final String DEFAULT_VALUE_VES_COLLECTOR_PORT = "8080"; private static final String PROPERTY_KEY_VES_COLLECTOR_TLS_ENABLED = "VES_COLLECTOR_TLS_ENABLED"; + private static final String PROPERTY_KEY_VES_COLLECTOR_TRUST_ALL_CERTS = "VES_COLLECTOR_TRUST_ALL_CERTS"; private static final String PROPERTY_KEY_VES_COLLECTOR_USERNAME = "VES_COLLECTOR_USERNAME"; private static final String DEFAULT_VALUE_VES_COLLECTOR_USERNAME = "sample1"; @@ -109,10 +110,15 @@ public class VESCollectorCfgImpl implements VESCollectorCfgService, Configuratio return configuration.getProperty(SECTION_MARKER, PROPERTY_KEY_VES_COLLECTOR_VERSION); } + public boolean isTrustAllCerts() { + return configuration.getPropertyBoolean(SECTION_MARKER, PROPERTY_KEY_VES_COLLECTOR_TRUST_ALL_CERTS); + } + @Override public synchronized void defaults() { configuration.setPropertyIfNotAvailable(SECTION_MARKER, PROPERTY_KEY_VES_COLLECTOR_ENABLED, DEFAULT_VALUE_VES_COLLECTOR_ENABLED); configuration.setPropertyIfNotAvailable(SECTION_MARKER, PROPERTY_KEY_VES_COLLECTOR_TLS_ENABLED, Boolean.FALSE); + configuration.setPropertyIfNotAvailable(SECTION_MARKER, PROPERTY_KEY_VES_COLLECTOR_TRUST_ALL_CERTS, Boolean.FALSE); configuration.setPropertyIfNotAvailable(SECTION_MARKER, PROPERTY_KEY_VES_COLLECTOR_USERNAME, DEFAULT_VALUE_VES_COLLECTOR_USERNAME); configuration.setPropertyIfNotAvailable(SECTION_MARKER, PROPERTY_KEY_VES_COLLECTOR_PASSWORD, diff --git a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestVESCollectorClient.java b/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestVESCollectorClient.java index 99e7d7bf9..1ff8efafb 100644 --- a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestVESCollectorClient.java +++ b/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestVESCollectorClient.java @@ -29,7 +29,8 @@ import java.nio.charset.StandardCharsets; import org.junit.After; import org.junit.Test; import org.onap.ccsdk.features.sdnr.wt.common.configuration.ConfigurationFileRepresentation; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.vescollectorconnector.impl.VESCollectorClient; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.types.VESMessage; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.vescollectorconnector.impl.VESCollectorServiceImpl; public class TestVESCollectorClient { @@ -41,17 +42,17 @@ public class TestVESCollectorClient { + "VES_COLLECTOR_PORT=8080\n" + "VES_COLLECTOR_TLS_ENABLED=true\n" + "VES_COLLECTOR_USERNAME=sample1\n" + "VES_COLLECTOR_PASSWORD=sample1\n" + "VES_COLLECTOR_VERSION=v7\n" + "REPORTING_ENTITY_NAME=ONAP SDN-R\n" + ""; - private static final String message = "Test Message"; + private static final VESMessage message = new VESMessage("Test Message"); private static final String CONFIG_FILE = "test.properties"; @Test public void testNoAuth() throws Exception { ConfigurationFileRepresentation vesCfg; - VESCollectorClient vesClient; + VESCollectorServiceImpl vesClient; Files.asCharSink(new File(CONFIG_FILE), StandardCharsets.UTF_8).write(TESTCONFIG_CONTENT_NO_AUTH); vesCfg = new ConfigurationFileRepresentation(CONFIG_FILE); - vesClient = new VESCollectorClient(vesCfg); + vesClient = new VESCollectorServiceImpl(vesCfg); vesClient.publishVESMessage(message); vesClient.close(); @@ -61,12 +62,12 @@ public class TestVESCollectorClient { @Test public void testAuth() throws Exception { ConfigurationFileRepresentation vesCfg; - VESCollectorClient vesClient; + VESCollectorServiceImpl vesClient; Files.asCharSink(new File("test.properties"), StandardCharsets.UTF_8).write(TESTCONFIG_CONTENT_AUTH); vesCfg = new ConfigurationFileRepresentation("test.properties"); - vesClient = new VESCollectorClient(vesCfg); + vesClient = new VESCollectorServiceImpl(vesCfg); vesClient.publishVESMessage(message); vesClient.close(); } diff --git a/sdnr/wt/mountpoint-state-provider/provider/pom.xml b/sdnr/wt/mountpoint-state-provider/provider/pom.xml index f07a82d68..fc6d7e07e 100644 --- a/sdnr/wt/mountpoint-state-provider/provider/pom.xml +++ b/sdnr/wt/mountpoint-state-provider/provider/pom.xml @@ -107,11 +107,6 @@ <artifactId>org.osgi.compendium</artifactId> <scope>provided</scope> </dependency> - <dependency> - <groupId>org.onap.dmaap.messagerouter.dmaapclient</groupId> - <artifactId>dmaapClient</artifactId> - <version>1.1.12</version> - </dependency> </dependencies> <build> diff --git a/sdnr/wt/mountpoint-state-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointstateprovider/impl/MountpointStatePublisher.java b/sdnr/wt/mountpoint-state-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointstateprovider/impl/MountpointStatePublisher.java index e05b3f1ba..e430a5e24 100644 --- a/sdnr/wt/mountpoint-state-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointstateprovider/impl/MountpointStatePublisher.java +++ b/sdnr/wt/mountpoint-state-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointstateprovider/impl/MountpointStatePublisher.java @@ -29,6 +29,7 @@ import org.eclipse.jdt.annotation.NonNull; import org.json.JSONObject; import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.VESCollectorCfgService; import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.VESCollectorService; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.types.VESMessage; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -66,8 +67,8 @@ public class MountpointStatePublisher implements Runnable { } - public String createVESMessage(JSONObject msg, VESCollectorCfgService vesCfg) { - MountpointStateVESMessageFormatter vesFormatter = new MountpointStateVESMessageFormatter(vesCfg); + public VESMessage createVESMessage(JSONObject msg, VESCollectorCfgService vesCfg) { + MountpointStateVESMessageFormatter vesFormatter = new MountpointStateVESMessageFormatter(vesCfg, vesCollectorService); return vesFormatter.createVESMessage(msg); } @@ -77,7 +78,7 @@ public class MountpointStatePublisher implements Runnable { try { if (!getStateObjects().isEmpty()) { JSONObject obj = ((LinkedList<JSONObject>) getStateObjects()).removeFirst(); - String vesMsg = createVESMessage(obj, vesCollectorService.getConfig()); + VESMessage vesMsg = createVESMessage(obj, vesCollectorService.getConfig()); this.vesCollectorService.publishVESMessage(vesMsg); } else { pauseThread(); diff --git a/sdnr/wt/mountpoint-state-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointstateprovider/impl/MountpointStateVESMessageFormatter.java b/sdnr/wt/mountpoint-state-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointstateprovider/impl/MountpointStateVESMessageFormatter.java index 4ab1a9a85..01a8d49ff 100644 --- a/sdnr/wt/mountpoint-state-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointstateprovider/impl/MountpointStateVESMessageFormatter.java +++ b/sdnr/wt/mountpoint-state-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointstateprovider/impl/MountpointStateVESMessageFormatter.java @@ -22,21 +22,27 @@ package org.onap.ccsdk.features.sdnr.wt.mountpointstateprovider.impl; import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.ObjectMapper; import java.time.Instant; +import org.eclipse.jdt.annotation.NonNull; import org.json.JSONObject; import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.VESCollectorCfgService; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.VESCollectorService; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.types.VESCommonEventHeaderPOJO; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.types.VESMessage; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.types.VESNotificationFieldsPOJO; import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class MountpointStateVESMessageFormatter { private static final Logger LOG = LoggerFactory.getLogger(MountpointStateVESMessageFormatter.class); - private VESCollectorCfgService vesCfg; + private final @NonNull VESCollectorCfgService vesCfg; + private final @NonNull VESCollectorService vesCollectorService; static long sequenceNo = 0; - public MountpointStateVESMessageFormatter(VESCollectorCfgService vesCfg) { + public MountpointStateVESMessageFormatter(VESCollectorCfgService vesCfg, VESCollectorService vesCollectorService) { this.vesCfg = vesCfg; + this.vesCollectorService = vesCollectorService; } private static void incrSequenceNo() { @@ -47,26 +53,22 @@ public class MountpointStateVESMessageFormatter { return sequenceNo; } - public String createVESMessage(JSONObject obj) { + public VESMessage createVESMessage(JSONObject obj) { if (LOG.isDebugEnabled()) { LOG.debug("JSON Object to format to VES is - {0}", obj); } - String vesMsg = "{}"; + MountpointStateVESMessageFormatter.incrSequenceNo(); VESCommonEventHeaderPOJO vesCommonEventHeader = createVESCommonEventHeader(obj); VESNotificationFieldsPOJO vesNotificationFields = createVESNotificationFields(obj); - VESEvent vesEvent = new VESEvent(); - vesEvent.addEventObjects(vesCommonEventHeader); - vesEvent.addEventObjects(vesNotificationFields); - + VESMessage vesMsg = null; try { - ObjectMapper objMapper = new ObjectMapper(); - vesMsg = objMapper.writeValueAsString(vesEvent); - LOG.debug("VES message to be published - {}", vesMsg); + vesMsg = vesCollectorService.generateVESEvent(vesCommonEventHeader, vesNotificationFields); + LOG.info("VES Message is - {}", vesMsg.getMessage()); } catch (JsonProcessingException e) { - LOG.warn("Exception {} while processing JSON Message - {}", e, obj); + LOG.error("Exception while generating VES Event - ", e); } return vesMsg; diff --git a/sdnr/wt/mountpoint-state-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointstateprovider/test/TestMountpointStatePublisher.java b/sdnr/wt/mountpoint-state-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointstateprovider/test/TestMountpointStatePublisher.java index 468e0c1ee..ebf4cb894 100644 --- a/sdnr/wt/mountpoint-state-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointstateprovider/test/TestMountpointStatePublisher.java +++ b/sdnr/wt/mountpoint-state-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointstateprovider/test/TestMountpointStatePublisher.java @@ -34,6 +34,7 @@ import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.DeviceManagerServic import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.NetconfNetworkElementService; import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.VESCollectorCfgService; import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.VESCollectorService; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.types.VESMessage; import org.onap.ccsdk.features.sdnr.wt.mountpointstateprovider.impl.MountpointStatePublisher; public class TestMountpointStatePublisher { @@ -41,7 +42,7 @@ public class TestMountpointStatePublisher { MountpointStatePublisher mountpointStatePublisher; VESCollectorService vesCollectorService; VESCollectorCfgService vesCfg; - String vesMsg = "{}"; + VESMessage vesMsg; JSONObject testJsonData; @Before @@ -64,7 +65,7 @@ public class TestMountpointStatePublisher { mountpointStatePublisher = new MountpointStatePublisher(vesCollectorService); mountpointStatePublisher.addToPublish(testJsonData); - //mountpointStatePublisher.getStateObjects().add(testJsonData); + mountpointStatePublisher.getStateObjects().add(testJsonData); } @Test |