aboutsummaryrefslogtreecommitdiffstats
path: root/sdnr/wt/devicemanager/provider/src/main/java
diff options
context:
space:
mode:
authorHerbert Eiselt <herbert.eiselt@highstreet-technologies.com>2019-02-07 17:50:41 +0100
committerHerbert Eiselt <herbert.eiselt@highstreet-technologies.com>2019-02-07 17:51:11 +0100
commit12a8c669f52c0e84d580c078cee849b25133b585 (patch)
tree1a0ddb6cc13f225e8a58833b8975f98b453a8d52 /sdnr/wt/devicemanager/provider/src/main/java
parentbd2aa3c75e0073ff07fb46b14b8b51926915d5c8 (diff)
Add sdnr wt devicemanager
Add complete sdnr wireless transport app devicemanager Change-Id: I433014ee579a3c8833b3b8f84c4087c5f776704f Issue-ID: SDNC-575 Signed-off-by: Herbert Eiselt <herbert.eiselt@highstreet-technologies.com>
Diffstat (limited to 'sdnr/wt/devicemanager/provider/src/main/java')
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/aaiconnector/impl/AaiProviderClient.java168
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/aaiconnector/impl/AaiWebApiClient.java157
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/aaiconnector/impl/URLParamEncoder.java46
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/database/EsBaseRequireNetworkElement.java31
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/database/EsObject.java41
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/database/HtDataBase.java49
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/database/HtDataBaseReaderAndWriter.java242
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/database/HtDatabaseClientAbstract.java766
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/database/HtDatabaseNode.java261
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/database/HtDatabaseUpdateFile.java114
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/database/HtDatabaseWebAPIClient.java98
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/database/HtMapper.java166
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/database/IndexClientBuilder.java141
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/database/IsEsObject.java37
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/database/JsonMapperBase.java137
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/http/BaseHTTPClient.java325
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/http/BaseHTTPResponse.java38
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/internalTypes/Environment.java46
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/internalTypes/FileWatchdog.java128
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/internalTypes/IniConfigurationFile.java397
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/internalTypes/InternalDateAndTime.java103
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/internalTypes/InternalSeverity.java125
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/internalTypes/InventoryInformation.java130
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/internalTypes/Resources.java336
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/internalTypes/TemplateFile.java84
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/internalTypes/TimeSpan.java650
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/NotificationActor.java24
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/NotificationWorker.java81
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/ONFCOreNetworkElementCoreData.java29
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/ONFCoreEmpty.java111
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/ONFCoreInterfacePac.java37
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/ONFCoreNetworkElement12.java741
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/ONFCoreNetworkElement12Base.java232
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/ONFCoreNetworkElement12Equipment.java293
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/ONFCoreNetworkElementBase.java127
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/ONFCoreNetworkElementCallback.java26
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/ONFCoreNetworkElementFactory.java87
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/ONFCoreNetworkElementRepresentation.java55
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/container/AllPm.java59
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/container/Capabilities.java173
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/container/ExtendedAirInterfaceHistoricalPerformanceType12.java105
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/container/ExtendedAirInterfaceHistoricalPerformanceType1211.java106
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/container/ExtendedAirInterfaceHistoricalPerformanceType1211p.java106
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/container/ONFLayerProtocolName.java57
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/container/ValueNameList.java84
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/util/GenericTransactionUtils.java164
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/util/LinkIdentifyingObject.java24
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/util/NetconfTimeStamp.java255
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/wrapperc/OnfInterfacePac.java39
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/wrapperc/OnfMicrowaveModel.java45
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/wrapperc/OnfMicrowaveModelNotification.java38
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/wrapperc/WrapperEquipmentPacRev170402.java127
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/wrapperc/WrapperMicrowaveModelRev170324.java593
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/wrapperc/WrapperMicrowaveModelRev180907.java596
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/wrapperc/WrapperMicrowaveModelRev181010.java594
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/toggleAlarmFilter/NotificationDelayFilter.java162
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/toggleAlarmFilter/NotificationDelayService.java64
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/toggleAlarmFilter/NotificationDelayedListener.java25
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/toggleAlarmFilter/NotificationWithServerTimeStamp.java78
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/config/BaseSubConfig.java127
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/config/HtDevicemanagerConfiguration.java147
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/config/IConfigChangedListener.java22
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/config/ISubConfigHandler.java22
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/config/impl/AaiClientPropertiesFile.java74
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/config/impl/AaiConfig.java467
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/config/impl/AkkaConfig.java88
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/config/impl/DcaeConfig.java200
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/config/impl/EsConfig.java219
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/config/impl/GeoConfig.java163
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/config/impl/PmConfig.java209
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/config/impl/ToggleAlarmConfig.java139
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/config/util/ClusterConfig.java133
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/config/util/ClusterNodeInfo.java81
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/config/util/ClusterRoleInfo.java91
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/config/util/ClusterRoleInfoCollection.java45
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/config/util/ConfigFileObserver.java67
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/dcaeconnector/impl/DcaeMessages.java341
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/dcaeconnector/impl/DcaeProviderClient.java82
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/dcaeconnector/impl/DcaeProviderTask.java50
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/dcaeconnector/impl/DcaeProviderWorker.java83
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/dcaeconnector/impl/DcaeSender.java31
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/dcaeconnector/impl/DcaeSenderImpl.java236
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/devicemonitor/impl/Checker.java48
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/devicemonitor/impl/DeviceMonitorImpl.java208
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/devicemonitor/impl/DeviceMonitorProblems.java57
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/devicemonitor/impl/DeviceMonitorTask.java320
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/devicemonitor/impl/DeviceMonitoredNe.java47
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/DeviceManagerApiServiceImpl.java200
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/DeviceManagerImpl.java633
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/DeviceManagerService.java50
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/ProviderClient.java39
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/ResyncNetworkElementsListener.java35
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/database/service/HtDatabaseEventsService.java228
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/database/types/EsEventBase.java47
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/database/types/EsFaultCurrent.java75
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/database/types/EsFaultLog.java47
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/database/types/EsVersionInfo.java75
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/database/types/equipment/EsEquipment.java92
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/database/types/equipment/EsToplevelEquipment.java46
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/database/types/equipment/ExtendedEquipment.java56
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/listener/MicrowaveEventListener12.java205
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/listener/NetconfChangeListener.java180
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/listener/ODLEventListener.java208
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/xml/AttributeValueChangedNotificationXml.java68
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/xml/GetEventType.java29
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/xml/MwtNotificationBase.java83
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/xml/ObjectCreationNotificationXml.java58
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/xml/ObjectDeletionNotificationXml.java61
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/xml/ProblemNotificationXml.java115
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/xml/WebSocketServiceClient.java31
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/xml/WebSocketServiceClientImpl.java38
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/xml/WebSocketServiceClientImpl2.java68
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/xml/XmlMapper.java49
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/index/impl/IndexConfigService.java58
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/index/impl/IndexMwtnService.java71
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/index/impl/IndexUpdateService.java111
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/maintenance/MaintenanceRPCServiceAPI.java42
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/maintenance/MaintenanceService.java33
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/maintenance/database/types/EsMaintenanceFilter.java227
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/maintenance/database/types/EsMaintenanceFilterDefinition.java97
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/maintenance/database/types/EsMaintenanceMode.java181
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/maintenance/impl/MaintenanceServiceImpl.java269
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/performancemanager/impl/PerformanceManagerImpl.java72
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/performancemanager/impl/PerformanceManagerTask.java238
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/performancemanager/impl/database/service/MicrowaveHistoricalPerformanceWriterService.java104
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/performancemanager/impl/database/types/EsHistoricalPerformance15Minutes.java43
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/performancemanager/impl/database/types/EsHistoricalPerformance24Hours.java36
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/performancemanager/impl/database/types/EsHistoricalPerformanceBase.java165
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/performancemanager/impl/database/types/EsHistoricalPerformanceLogEntry.java92
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/performancemanager/impl/database/types/EsPerformanceData.java444
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/ptp/impl/GeoLocation.java48
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/ptp/impl/LogicalTerminationPoint.java55
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/ptp/impl/Path.java54
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/ptp/impl/PtpManagerImpl.java29
134 files changed, 19235 insertions, 0 deletions
diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/aaiconnector/impl/AaiProviderClient.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/aaiconnector/impl/AaiProviderClient.java
new file mode 100644
index 000000000..d5030c1c7
--- /dev/null
+++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/aaiconnector/impl/AaiProviderClient.java
@@ -0,0 +1,168 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 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.aaiconnector.impl;
+
+import java.util.List;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.http.BaseHTTPResponse;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.internalTypes.InventoryInformation;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.netconf.ONFCoreNetworkElementRepresentation;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.config.HtDevicemanagerConfiguration;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.config.IConfigChangedListener;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.config.impl.AaiConfig;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.DeviceManagerImpl;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class AaiProviderClient implements AutoCloseable {
+
+ private static Logger LOG = LoggerFactory.getLogger(AaiProviderClient.class);
+ private static boolean reloadConfigFlag;
+ private static final IConfigChangedListener configChangedListener = () -> reloadConfigFlag = true;
+
+ private AaiConfig config;
+ private final DeviceManagerImpl deviceManager;
+ private final HtDevicemanagerConfiguration htconfig;
+
+
+ public AaiConfig getConfig() {
+ return this.config;
+ }
+
+
+ public AaiProviderClient(HtDevicemanagerConfiguration cfg, DeviceManagerImpl devMgr) {
+ this.config = cfg.getAai();
+ this.htconfig = cfg;
+ this.htconfig.registerConfigChangedListener(configChangedListener);
+ this.deviceManager = devMgr;
+
+ }
+
+ private void _reload() {
+ if (reloadConfigFlag) {
+ this.config = AaiConfig.reload();
+ LOG.info("config reloaded: {}", config == null ? "null" : config);
+ }
+ reloadConfigFlag = false;
+ }
+
+ public void onDeviceRegistered(String mountPointName) {
+ this._reload();
+ if (this.config.isOff()) {
+ return;
+ }
+ ONFCoreNetworkElementRepresentation ne =
+ this.deviceManager != null ? this.deviceManager.getNeByMountpoint(mountPointName) : null;
+ this.onDeviceRegistered(mountPointName,
+ ne != null ? ne.getInventoryInformation("MWPS") : InventoryInformation.getDefault());
+
+ }
+
+ public void onDeviceRegistered(String mountPointName, InventoryInformation i) {
+ this._reload();
+ if (this.config.isOff()) {
+ return;
+ }
+ new Thread(new AaiCreateRequestRunnable(mountPointName, i.getType(), i.getModel(), i.getVendor(),
+ i.getDeviceIpv4(), i.getInterfaceUuidList())).start();
+ }
+
+ public void onDeviceUnregistered(String mountPointName) {
+ this._reload();
+ if (this.config.isOff()) {
+ return;
+ }
+ if (this.config.doDeleteOnMountPointRemoved()) {
+ new Thread(new AaiDeleteRequestRunnable(mountPointName)).start();
+ } else {
+ LOG.debug("prevent deleting device {} by config", mountPointName);
+ }
+ }
+
+ @Override
+ public void close() throws Exception {
+ this.htconfig.unregisterConfigChangedListener(configChangedListener);
+ }
+
+ private class AaiCreateRequestRunnable implements Runnable {
+
+ private static final int RESPCODE_NOTFOUND = BaseHTTPResponse.CODE404;
+ private static final int RESPCODE_FOUND = BaseHTTPResponse.CODE200;
+ private final AaiWebApiClient mClient;
+ private final String pnfId;
+ private final String type;
+ private final String model;
+ private final String vendor;
+ private final String oamIp;
+ private final List<String> ifaces;
+ private final int timeout;
+
+ public AaiCreateRequestRunnable(String pnfId, String type, String model, String vendor, String oamIp,
+ List<String> ifaces) {
+ this.pnfId = pnfId;
+ this.type = type;
+ this.model = model;
+ this.vendor = vendor;
+ this.oamIp = oamIp;
+ this.ifaces = ifaces;
+ this.timeout = AaiProviderClient.this.config.getConnectionTimeout();
+ this.mClient = new AaiWebApiClient(AaiProviderClient.this.config.getBaseUrl(),
+ AaiProviderClient.this.config.getHeaders(), AaiProviderClient.this.config.getTrustAll(),
+ AaiProviderClient.this.config.getPcks12CertificateFilename(),
+ AaiProviderClient.this.config.getPcks12CertificatePassphrase());
+ }
+
+ @Override
+ public void run() {
+ LOG.debug("check if pnfid {} exists", pnfId);
+ this.mClient.setTimeout(timeout);
+ int responseCode = this.mClient.pnfCheckIfExists(pnfId);
+ if (responseCode == RESPCODE_NOTFOUND) {
+ LOG.debug("do pnfCreate for {}", pnfId);
+ this.mClient.pnfCreate(pnfId, type, model, vendor, oamIp, ifaces);
+ } else if (responseCode == RESPCODE_FOUND) {
+ LOG.debug("pnfid {} found, nothing to do", pnfId);
+ } else {
+ LOG.warn("unhandled response code: {}", responseCode);
+ }
+ }
+ };
+
+ private class AaiDeleteRequestRunnable implements Runnable {
+
+ private final AaiWebApiClient mClient;
+ private final String pnfId;
+ private final int timeout;
+
+
+ public AaiDeleteRequestRunnable(String pnfId) {
+ this.pnfId = pnfId;
+ this.timeout = AaiProviderClient.this.config.getConnectionTimeout();
+ this.mClient = new AaiWebApiClient(AaiProviderClient.this.config.getBaseUrl(),
+ AaiProviderClient.this.config.getHeaders(), AaiProviderClient.this.config.getTrustAll(),
+ AaiProviderClient.this.config.getPcks12CertificateFilename(),
+ AaiProviderClient.this.config.getPcks12CertificatePassphrase());
+ }
+
+ @Override
+ public void run() {
+ this.mClient.setTimeout(this.timeout);
+ this.mClient.pnfDelete(pnfId);
+ }
+ };
+
+}
diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/aaiconnector/impl/AaiWebApiClient.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/aaiconnector/impl/AaiWebApiClient.java
new file mode 100644
index 000000000..6ce4cff67
--- /dev/null
+++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/aaiconnector/impl/AaiWebApiClient.java
@@ -0,0 +1,157 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 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.aaiconnector.impl;
+
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.http.BaseHTTPClient;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.http.BaseHTTPResponse;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class AaiWebApiClient extends BaseHTTPClient {
+
+ private static Logger LOG = LoggerFactory.getLogger(AaiWebApiClient.class);
+ private static final String PNF_JSON_INTERFACE_TEMPLATE = " {\n"
+ + " \"interface-name\": \"@interface@\",\n" + " \"speed-value\": \"300\",\n"
+ + " \"speed-units\": \"MBit/s\",\n"
+ + " \"port-description\": \"Air Interface (MWPS)\",\n"
+ + " \"equipment-identifier\": \"@pnfId@-@interface@\",\n"
+ + " \"interface-role\": \"Wireless\",\n"
+ + " \"interface-type\": \"Air Interface (MWPS)\",\n"
+ + " \"resource-version\": \"@model@\",\n" + " \"relationship-list\": [\n"
+ + " {\n"
+ + " \"related-to\": \"A keyword provided by A&AI to indicate type of node.\",\n"
+ + " \"related-link\": \"URL to the object in A&AI.\",\n"
+ + " \"relationship-data\": [\n" + " {\n"
+ + " \"relationship-key\": \"A keyword provided by A&AI to indicate an attribute.\",\n"
+ + " \"relationship-value\": \"Value of the attribute\"\n"
+ + " }\n" + " ],\n"
+ + " \"related-to-property\": [\n" + " {\n"
+ + " \"property-key\": \"Key part of a key/value pair\",\n"
+ + " \"property-value\": \"Value part of a key/value pair\"\n"
+ + " }\n" + " ]\n" + " }\n" + " ]\n"
+ + " }\n";
+ private static final String PNF_JSON_TEMPLATE = "{\n" + " \"pnf-name\": \"@pnfId@\",\n"
+ + " \"pnf-id\": \"@pnfId@\",\n" + " \"equip-type\": \"@type@\",\n"
+ + " \"equip-model\": \"@model@\",\n" + " \"equip-vendor\": \"@vendor@\",\n"
+ + " \"ipaddress-v4-oam\": \"@oamIp@\",\n" + " \"in-maint\": false,\n"
+ + " \"prov-status\":\"PROV\",\n" + " \"p-interfaces\": @interface-list@\n" + "}\n" + "";
+ private static final String PNF_URI = "network/pnfs/pnf/";
+ private static final String EMPTY_MESSAGE = "";
+
+ private final Map<String, String> headerMap;
+
+
+ public AaiWebApiClient(String baseUrl, Map<String, String> headers, boolean trustAllCerts) {
+ this(baseUrl, headers, trustAllCerts, null, null);
+ }
+
+ public AaiWebApiClient(String baseUrl, Map<String, String> headers, boolean trustAllCerts, String certFilename,
+ String passphrase) {
+ super(baseUrl, trustAllCerts, certFilename, passphrase, BaseHTTPClient.getSslCertPcks());
+
+ this.headerMap = new HashMap<>();
+ this.headerMap.putAll(headers);
+ this.headerMap.put("Content-Type", "application/json");
+ this.headerMap.put("Accept", "application/json");
+ }
+
+ /**
+ * Create and specify defition parametrs of pnf
+ * @param pnfId name
+ * @param type type
+ * @param model model
+ * @param vendor vendor
+ * @param oamIp ip
+ * @param ifaces interfaces
+ * @return true if http response code was 200 or false if not.
+ */
+ public boolean pnfCreate(String pnfId, String type, String model, String vendor, String oamIp,
+ List<String> ifaces) {
+ LOG.debug("registering {} (type={}, model={}, vendor={},ip={})", pnfId, type, model, vendor, oamIp);
+ String message = getPnfTemplateFilled(pnfId, type, model, vendor, oamIp, ifaces);
+ return pnfRequest(pnfId, "PUT", message) == 200;
+ }
+
+ /**
+ * Unregister
+ * @param pnfId name
+ * @return true if http response code was 200 or false if not.
+ */
+ public boolean pnfDelete(String pnfId) {
+ LOG.debug("unregistering {}", pnfId);
+ return pnfRequest(pnfId, "DELETE", EMPTY_MESSAGE) == 200;
+ }
+
+ /**
+ * Send registration request
+ * @param pnfId name
+ * @return error accoring to http response code or -1
+ */
+ public int pnfCheckIfExists(String pnfId) {
+ LOG.debug("check for {}", pnfId);
+ return pnfRequest(pnfId, "GET", EMPTY_MESSAGE);
+ }
+
+ /*
+ * Private classes
+ */
+
+ private int pnfRequest(String pnfId, String method, String message) {
+ BaseHTTPResponse response;
+ try {
+ String uri = PNF_URI + URLParamEncoder.encode(pnfId);
+ response = this.sendRequest(uri, method, message, headerMap);
+ LOG.debug("finished with responsecode {}", response.code);
+ return response.code;
+ } catch (IOException e) {
+ LOG.warn("problem registering {} : {}", pnfId, e.getMessage());
+ return -1;
+ }
+ }
+
+
+ private static String getPnfTemplateFilled(String pnfId, String type, String model, String vendor, String oamIp,
+ List<String> ifaces) {
+ return PNF_JSON_TEMPLATE.replace("@pnfId@", pnfId).replace("@type@", type).replace("@model@", model)
+ .replace("@vendor@", vendor).replace("@oamIp@", oamIp)
+ .replace("@interface-list@", getPnfTemplateInterfaceList(pnfId, ifaces, model));
+ }
+
+ private static String getPnfTemplateInterfaceList(String pnfId, List<String> ifaces, String model) {
+ StringBuffer s = new StringBuffer();
+ s.append("[");
+ if (ifaces != null) {
+ for (int i = 0; i < ifaces.size(); i++) {
+ if (i > 0) {
+ s.append(",");
+ }
+ s.append(PNF_JSON_INTERFACE_TEMPLATE.replace("@interface@", ifaces.get(i)));
+ }
+ }
+ s.append("]");
+
+ return s.toString().replace("@pnfId@", pnfId).replace("@model@", model);
+ }
+
+
+
+}
diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/aaiconnector/impl/URLParamEncoder.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/aaiconnector/impl/URLParamEncoder.java
new file mode 100644
index 000000000..2e8b44fd7
--- /dev/null
+++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/aaiconnector/impl/URLParamEncoder.java
@@ -0,0 +1,46 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 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.aaiconnector.impl;
+
+class URLParamEncoder {
+
+ public static String encode(String input) {
+ StringBuilder resultStr = new StringBuilder();
+ for (char ch : input.toCharArray()) {
+ if (isUnsafe(ch)) {
+ resultStr.append('%');
+ resultStr.append(toHex(ch / 16));
+ resultStr.append(toHex(ch % 16));
+ } else {
+ resultStr.append(ch);
+ }
+ }
+ return resultStr.toString();
+ }
+
+ private static char toHex(int ch) {
+ return (char) (ch < 10 ? '0' + ch : 'A' + ch - 10);
+ }
+
+ private static boolean isUnsafe(char ch) {
+ if (ch > 128 || ch < 0) {
+ return true;
+ }
+ return " %$&+,/:;=?@<>#%".indexOf(ch) >= 0;
+ }
+}
diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/database/EsBaseRequireNetworkElement.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/database/EsBaseRequireNetworkElement.java
new file mode 100644
index 000000000..7c78a4aed
--- /dev/null
+++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/database/EsBaseRequireNetworkElement.java
@@ -0,0 +1,31 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 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.base.database;
+
+public class EsBaseRequireNetworkElement extends EsObject {
+ public static final String ESDATATYPENAME = "required-networkelement";
+
+ public EsBaseRequireNetworkElement() {
+
+ }
+
+ public EsBaseRequireNetworkElement(String mountpountName) {
+ super();
+ this.setEsId(mountpountName);
+ }
+}
diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/database/EsObject.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/database/EsObject.java
new file mode 100644
index 000000000..4b188d1de
--- /dev/null
+++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/database/EsObject.java
@@ -0,0 +1,41 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 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.base.database;
+
+import com.fasterxml.jackson.annotation.JsonIgnore;
+
+/**
+ * @author Herbert
+ *
+ */
+public class EsObject implements IsEsObject {
+
+ @JsonIgnore
+ private String esId;
+
+ @Override
+ public String getEsId() {
+ return esId;
+ }
+
+ @Override
+ public void setEsId(String esId) {
+ this.esId = esId;
+ }
+
+}
diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/database/HtDataBase.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/database/HtDataBase.java
new file mode 100644
index 000000000..856163104
--- /dev/null
+++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/database/HtDataBase.java
@@ -0,0 +1,49 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 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.base.database;
+
+import org.elasticsearch.client.Client;
+import org.elasticsearch.common.bytes.BytesReference;
+import org.elasticsearch.index.query.QueryBuilder;
+import org.elasticsearch.search.SearchHit;
+
+
+/**
+ * Interface, used by access one object
+ * @author Herbert
+ *
+ */
+public interface HtDataBase {
+
+ String getNetworkIndex();
+ void setNetworkIndex(String networkIndex);
+
+ Client getClient();
+ void closeDb();
+
+ public BytesReference doReadJsonData( String dataTypeName, IsEsObject esId );
+ public BytesReference doReadJsonData(String dataTypeName, String esId);
+ public SearchHit[] doReadAllJsonData( int start, int length, String dataTypeName );
+ public SearchHit[] doReadByQueryJsonData( int start, int length, String dataTypeName, QueryBuilder query);
+
+ public String doWriteByteArray( String dataTypeName, IsEsObject esId, byte[] json);
+ public String doWriteJsonString( String dataTypeName, IsEsObject esId, String json);
+
+ public boolean doRemove( String dataTypeName, IsEsObject esId );
+
+}
diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/database/HtDataBaseReaderAndWriter.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/database/HtDataBaseReaderAndWriter.java
new file mode 100644
index 000000000..f13b1066f
--- /dev/null
+++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/database/HtDataBaseReaderAndWriter.java
@@ -0,0 +1,242 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 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.base.database;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import javax.annotation.Nullable;
+
+import org.elasticsearch.index.query.QueryBuilder;
+import org.elasticsearch.search.SearchHit;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Generic class to write lists of model classes to the database.
+ *
+ */
+public class HtDataBaseReaderAndWriter<T extends IsEsObject> {
+
+ private static final Logger log = LoggerFactory.getLogger(HtDataBaseReaderAndWriter.class);
+
+
+ private final HtDataBase db;
+ private final String dataTypeName;
+ private final HtMapper<T> mapper;
+
+ /**
+ * Class specific access to database
+ * @param db ES database descriptor
+ * @param dataTypeName datatype name
+ * @param clazz class of datatype
+ */
+ public HtDataBaseReaderAndWriter(HtDataBase db, String dataTypeName, Class<? extends T> clazz) {
+
+ this.db = db;
+ this.dataTypeName = dataTypeName;
+ this.mapper = new HtMapper<>( clazz );
+
+ }
+
+ /**
+ * Remove Object from database
+ * @param object Object with content
+ * @return true if remove is done
+ */
+ public boolean doRemove( T object) {
+
+ return db.doRemove(dataTypeName, object );
+
+ }
+
+ /**
+ * Remove all data that match the filter
+ * @param query to specify data to be deleted
+ * @return number of removed objects
+ */
+ public int doRemoveByQuery(QueryBuilder query) {
+
+ int idx = 0; //Idx for getAll
+ int iterateLength = 100; //Step width for iterate
+
+ SearchHit hits[];
+ do {
+ hits = db.doReadByQueryJsonData(idx, iterateLength, dataTypeName, query);
+ log.debug("Found: {} elements: {} Failures: {}",dataTypeName,hits.length, mapper.getMappingFailures());
+
+ T object;
+ idx += hits.length;
+ for (SearchHit hit : hits) {
+
+ object = mapper.getObjectFromJson( hit.getSourceRef() );
+
+ log.debug("Mapp Object: {}\nSource: '{}'\nResult: '{}'\n Failures: {}", hit.getId(), hit.getSourceAsString(), object, mapper.getMappingFailures());
+ if (object != null) {
+ object.setEsId( hit.getId() );
+ doRemove(object);
+ } else {
+ log.warn("Mapp result null Object: {}\n Source: '{}'\n : '", hit.getId(), hit.getSourceAsString());
+ }
+ }
+ } while (hits.length == iterateLength); //Do it until end indicated, because less hits than iterateLength allows.
+
+ return idx;
+ }
+
+ /**
+ * Do the mapping for test purpose
+ * @param object object for test purpose
+ * @return json String
+ */
+ public String getJson( T object ) {
+ String json = mapper.objectToJson(object);
+ return json;
+ }
+
+ /**
+ * Write one object into Database
+ * @param object Object with content
+ * @return This object for chained call pattern.
+ */
+ public T doWrite( T object) {
+
+ String json = mapper.objectToJson(object);
+ return doWrite(object, json);
+
+ }
+
+ /**
+ * Write one object into Database
+ * @param object Object with content
+ * @param json string
+ * @return This object for chained call pattern.
+ */
+ public T doWrite( T object, String json) {
+
+ log.debug("doWrite {} {}",object.getClass().getSimpleName(), object.getEsId());
+
+ if (json != null) {
+ String esId = db.doWriteJsonString(dataTypeName, object, json);
+ object.setEsId(esId);
+ log.debug("doWrite done for {} {}",object.getClass().getSimpleName(), object.getEsId());
+ return esId == null ? null : object;
+ } else {
+ log.warn("Can not map object and write to database. {} {}",object.getClass().getSimpleName(), object);
+ return null;
+ }
+
+ }
+
+
+ /**
+ * Write a list of Objects to the database.
+ * @param list Object list with content
+ * @return This object for chained call pattern.
+ */
+ public HtDataBaseReaderAndWriter<T> doWrite( Collection<T> list) {
+
+ int writeError = 0;
+ String indexName = db.getNetworkIndex();
+
+ log.debug("Write to ES database {}, {} Class: {} {} elements",indexName,dataTypeName, mapper.getClazz().getSimpleName(), list.size());
+
+ if (indexName == null) {
+ throw new IllegalArgumentException("Missing Index");
+ }
+
+ if (list != null && !list.isEmpty()) {
+ for( T s : list ) {
+ if ( doWrite(s) == null ) {
+ if ( ++writeError > 5 ) {
+ log.warn("Leave because of to >5 write errors");
+ break;
+ }
+ }
+ }
+
+ }
+
+ return this;
+ }
+
+ /**
+ * Read one object via the object class specific ID
+ * @param object Object refrenced by idString
+ * @return The Object if found or null
+ */
+ public @Nullable T doRead( IsEsObject object ) {
+ T res = mapper.getObjectFromJson( db.doReadJsonData( dataTypeName, object) );
+ if (res != null) {
+ res.setEsId(object.getEsId());
+ }
+ return res;
+ }
+
+ /**
+ * Read one object via the object class specific ID
+ * @param objectEsId Object refrence
+ * @return The Object if found or null
+ */
+ public @Nullable T doRead( String objectEsId ) {
+ T res = mapper.getObjectFromJson( db.doReadJsonData( dataTypeName, objectEsId ) );
+ if (res != null) {
+ res.setEsId(objectEsId);
+ }
+ return res;
+ }
+
+
+ /**
+ * Read all existing objects of a type
+ * @return the list of all objects
+ */
+ public List<T> doReadAll() {
+
+ List<T> res = new ArrayList<>();
+ int idx = 0; //Idx for getAll
+ int iterateLength = 100; //Step width for iterate
+
+ SearchHit hits[];
+
+
+ do {
+ hits = db.doReadAllJsonData(idx, iterateLength, dataTypeName);
+ log.debug("Read: {} elements: {} Failures: {}",dataTypeName,hits.length, mapper.getMappingFailures());
+
+ T object;
+ idx += hits.length;
+ for (SearchHit hit : hits) {
+
+ object = mapper.getObjectFromJson( hit.getSourceRef() );
+
+ log.debug("Mapp Object: {}\nSource: '{}'\nResult: '{}'\n Failures: {}", hit.getId(), hit.getSourceAsString(), object, mapper.getMappingFailures());
+ if (object != null) {
+ object.setEsId( hit.getId() );
+ res.add( object );
+ } else {
+ log.warn("Mapp result null Object: {}\n Source: '{}'\n : '", hit.getId(), hit.getSourceAsString());
+ }
+ }
+ } while (hits.length == iterateLength); //Do it until end indicated, because less hits than iterateLength allows.
+
+ return res;
+ }
+
+}
diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/database/HtDatabaseClientAbstract.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/database/HtDatabaseClientAbstract.java
new file mode 100644
index 000000000..9b7d1159e
--- /dev/null
+++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/database/HtDatabaseClientAbstract.java
@@ -0,0 +1,766 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 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.base.database;
+
+import java.io.IOException;
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
+import org.elasticsearch.ElasticsearchException;
+import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse;
+import org.elasticsearch.action.admin.cluster.node.info.NodesInfoResponse;
+import org.elasticsearch.action.admin.indices.alias.IndicesAliasesResponse;
+import org.elasticsearch.action.admin.indices.create.CreateIndexRequestBuilder;
+import org.elasticsearch.action.admin.indices.create.CreateIndexResponse;
+import org.elasticsearch.action.admin.indices.delete.DeleteIndexRequestBuilder;
+import org.elasticsearch.action.admin.indices.exists.indices.IndicesExistsResponse;
+import org.elasticsearch.action.admin.indices.mapping.put.PutMappingResponse;
+import org.elasticsearch.action.delete.DeleteResponse;
+import org.elasticsearch.action.get.GetResponse;
+import org.elasticsearch.action.index.IndexRequestBuilder;
+import org.elasticsearch.action.index.IndexResponse;
+import org.elasticsearch.action.search.SearchResponse;
+import org.elasticsearch.client.Client;
+import org.elasticsearch.client.transport.TransportClient;
+import org.elasticsearch.cluster.node.DiscoveryNode;
+import org.elasticsearch.common.bytes.BytesReference;
+import org.elasticsearch.common.settings.Settings;
+import org.elasticsearch.common.transport.InetSocketTransportAddress;
+import org.elasticsearch.common.unit.TimeValue;
+import org.elasticsearch.index.query.QueryBuilder;
+import org.elasticsearch.index.query.QueryBuilders;
+import org.elasticsearch.search.SearchHit;
+import org.json.JSONObject;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * @author Herbert
+ *
+ */
+public class HtDatabaseClientAbstract implements HtDataBase, AutoCloseable {
+
+ private final Logger log = LoggerFactory.getLogger(HtDatabaseClientAbstract.class);
+
+ private static int DELAYSECONDS = 10;
+ private final Client client;
+ private String esIndexAlias;
+
+ /**
+ * Full database initialization.
+ *
+ * @param esIndex Database index
+ * @param esNodeserverName Servername or Server-IP that hosts the node.
+ * @param esClusterName Name of the cluster
+ * @param esNodeName Name of the node within the cluster to connect to.
+ * @throws UnknownHostException Servername not known.
+ */
+ public HtDatabaseClientAbstract(String esIndex, String esNodeserverName, String esClusterName, String esNodeName)
+ throws UnknownHostException {
+
+ this.esIndexAlias = esIndex;
+
+ Settings settings =
+ Settings.settingsBuilder().put("cluster.name", esClusterName).put("node.name", esNodeName).build();
+ this.client = getClient(esNodeserverName, settings);
+
+ }
+
+ /**
+ * Do not use the hostname, but use the IP for getting the client
+ *
+ * @param esIndex index to be used by the client
+ * @param esClusterName name of the ES cluster
+ * @param esNodeName name of the node
+ * @throws UnknownHostException if hostname not known
+ */
+ public HtDatabaseClientAbstract(String esIndex, String esClusterName, String esNodeName)
+ throws UnknownHostException {
+
+ this.esIndexAlias = esIndex;
+ Settings settings =
+ Settings.settingsBuilder().put("cluster.name", esClusterName).put("node.name", esNodeName).build();
+ this.client = getClient(null, settings);
+ }
+
+
+ /**
+ * Simple database initialization. Query all ES configuration information from cluster node.
+ *
+ * @param esIndex Database index
+ * @param esNodeserverHostName Servername or Server-IP that hosts the node.
+ * @throws UnknownHostException Servername not known.
+ */
+
+ public HtDatabaseClientAbstract(String esIndex, String esNodeserverHostName) throws UnknownHostException {
+
+ this.esIndexAlias = esIndex;
+
+ Settings settings = Settings.settingsBuilder().put("client.transport.ignore_cluster_name", true)
+ .put("client.transport.sniff", true).build();
+ this.client = getClient(esNodeserverHostName, settings);
+ }
+
+ /**
+ * Simple database initialization. Query all ES configuration information from cluster node.
+ *
+ * @param esIndex Database index
+ * @param database database node descriptor
+ */
+ public HtDatabaseClientAbstract(String esIndex, @Nonnull HtDatabaseNode database) {
+
+ this.esIndexAlias = esIndex;
+ this.client = database.getClient();
+ }
+
+
+ /*----------------------------------
+ * some constructing functions, used by public constructors
+ */
+ /**
+ *
+ * @param esNodeserverName
+ * @param settings
+ * @return
+ * @throws UnknownHostException
+ */
+ private final TransportClient getClient(@Nullable String esNodeserverName, Settings settings)
+ throws UnknownHostException {
+
+ TransportClient newClient = TransportClient.builder().settings(settings).build();
+
+ if (esNodeserverName != null) {
+ InetAddress nodeIp = InetAddress.getByName(esNodeserverName);
+ newClient.addTransportAddress(new InetSocketTransportAddress(nodeIp, 9300));
+ }
+
+ setup(newClient);
+ return newClient;
+ }
+
+ private void setup(TransportClient newClient) {
+ NodesInfoResponse nodeInfos = newClient.admin().cluster().prepareNodesInfo().get();
+ String clusterName = nodeInfos.getClusterName().value();
+
+ // ------ Debug/ Info
+ StringBuffer logInfo = new StringBuffer();
+ logInfo.append("Create ES Client an localhost for Cluster '");
+ logInfo.append(clusterName);
+ logInfo.append("' for index '");
+ logInfo.append(esIndexAlias);
+ logInfo.append("' Nodelist: ");
+ for (DiscoveryNode node : newClient.connectedNodes()) {
+ logInfo.append("(");
+ logInfo.append(node.toString());
+ logInfo.append(") ");
+ }
+ log.info(logInfo.toString());
+ // ------ Debug/ Info
+
+ log.info("Starting Database service. Short wait.");
+
+ ClusterHealthResponse nodeStatus = newClient.admin().cluster().prepareHealth().setWaitForGreenStatus()
+ // .setWaitForYellowStatus()
+ .setTimeout(TimeValue.timeValueSeconds(DELAYSECONDS)).get();
+ log.debug("Elasticsearch client started with status {}", nodeStatus.toString());
+
+
+ List<DiscoveryNode> nodeList = newClient.connectedNodes();
+
+ if (nodeList.isEmpty()) {
+ log.info("ES Client created for nodes: <empty node list>");
+ } else {
+ int t = 0;
+ for (DiscoveryNode dn : nodeList) {
+ log.info("ES Client created for node#{}: {}", t, dn.getName());
+ }
+ }
+
+ Runtime.getRuntime().addShutdownHook(new Thread() {
+ @Override
+ public void run() {
+ log.info("Shutdown node " + HtDatabaseClientAbstract.class.getSimpleName());
+ }
+ });
+
+ log.info("Database service started.");
+
+ }
+
+
+ /*----------------------------------
+ * Getter / Setter
+ */
+
+ @Override
+ public String getNetworkIndex() {
+ return esIndexAlias;
+ }
+
+ @Override
+ public void setNetworkIndex(String es_index) {
+ this.esIndexAlias = es_index;
+ }
+
+ @Override
+ public Client getClient() {
+ return client;
+ }
+
+ /*----------------------------------
+ * Functions
+ */
+
+ /**
+ * Close function
+ */
+ @Override
+ public void close() {
+ client.close();
+ }
+
+ /**
+ * Create an ES index. Delete an existing index.
+ */
+ public void doDeleteIndex() {
+ log.info("Remove index {}", esIndexAlias);
+
+ if (esIndexAlias == null) {
+ throw new IllegalArgumentException("Missing Index");
+ }
+
+ try {
+
+ // Delete index
+ IndicesExistsResponse res = client.admin().indices().prepareExists(esIndexAlias).execute().actionGet();
+
+ if (res.isExists()) {
+ log.info("Delete Index start: {}", esIndexAlias);
+ DeleteIndexRequestBuilder delIdx = client.admin().indices().prepareDelete(esIndexAlias);
+ delIdx.execute().actionGet();
+ log.info("Delete Index done.");
+ }
+
+ } catch (ElasticsearchException e) {
+ log.warn(e.getDetailedMessage());
+ }
+ }
+
+ /**
+ * Verify if index already created
+ *
+ * @return boolean accordingly
+ */
+ public boolean isExistsIndex() {
+
+ if (esIndexAlias == null) {
+ throw new IllegalArgumentException("Missing Index");
+ }
+
+ log.debug("Check status of ES index: {}", esIndexAlias);
+
+ final IndicesExistsResponse indexStatus =
+ client.admin().indices().prepareExists(esIndexAlias).execute().actionGet();
+
+ return indexStatus.isExists();
+
+ }
+
+
+ /**
+ * Create and write the mapping and setting of the index
+ *
+ * @param jsonIndexMappingSetting with mapping and setting definition Object or null for no
+ * configuration
+ */
+ public void doCreateIndexWithMapping(JSONObject jsonIndexMappingSetting) {
+
+ if (esIndexAlias == null) {
+ throw new IllegalArgumentException("Missing Index");
+ }
+
+ try {
+ // Create index with mapping and setting
+ String esIndexName = esIndexAlias + "_v1";
+ log.debug("Create not existing ES index: {} with alias:{}", esIndexName, esIndexAlias);
+
+ doCreateIndexWithMappingsAndSettings(esIndexName, jsonIndexMappingSetting);
+
+ // Set Alias
+ log.debug("Set alias {} to index {}", esIndexAlias, esIndexName);
+ IndicesAliasesResponse setAliasResponse =
+ client.admin().indices().prepareAliases().addAlias(esIndexName, esIndexAlias).execute().actionGet();
+ log.debug("CreateIndex response {}", setAliasResponse);
+
+ } catch (ElasticsearchException e) {
+ log.warn("ElasticsearchException: {}", e.getDetailedMessage());
+ }
+ }
+
+
+ /**
+ * Assign each mapping in the mappings section as separate mapping entry
+ *
+ * @param createIndexRequestBuilder builder for command to ES
+ * @param jsonIndexMappingSetting json with mapping information
+ */
+ private void doCreateIndexWithMappingsAndSettings(String esIndexName, JSONObject jsonIndexMappingSetting) {
+
+ CreateIndexRequestBuilder createIndexRequestBuilder = client.admin().indices().prepareCreate(esIndexName);
+ if (createIndexRequestBuilder == null) {
+ throw new HtDatabaseClientException("No client. Can not create index.", esIndexAlias);
+ }
+
+ if (jsonIndexMappingSetting != null) {
+ try {
+ doAddMappings(createIndexRequestBuilder, jsonIndexMappingSetting);
+ doAddSetting(createIndexRequestBuilder, jsonIndexMappingSetting);
+ log.debug(" doCreateIndexWithMapping");
+ } catch (RuntimeException e) {
+ log.info("Exception during adding mappings or settings to CreateIndexRequestBuilder. ", e);
+ }
+ }
+
+ CreateIndexResponse createResponse = createIndexRequestBuilder.execute().actionGet();
+ log.debug("CreateIndex response {}", createResponse);
+ }
+
+ /**
+ * Add one or more mappings to command
+ *
+ * @param createIndexRequestBuilder to add parameters
+ * @param jsonIndexMappingSetting contains mapping and setting information
+ */
+ private void doAddMappings(CreateIndexRequestBuilder createIndexRequestBuilder,
+ JSONObject jsonIndexMappingSetting) {
+
+ // If there are json information .. verify if they contain mappings
+ JSONObject jsonMapping = jsonIndexMappingSetting.optJSONObject("mappings");
+
+ // Handle optional mappings if requested
+ if (jsonMapping != null) {
+ log.debug("Set mapping for index {} {}", esIndexAlias, jsonMapping);
+
+ // For any reason the function below was not working without iterator
+ Set<String> keys = getStringKeySet(jsonMapping);
+ if (log.isDebugEnabled()) {
+ log.debug("Found length: {} keys: {}", jsonMapping.length(), keys.size());
+ }
+
+ for (String docType : keys) {
+ JSONObject jsonObject = jsonMapping.getJSONObject(docType);
+ if (jsonObject != null) {
+ String jsonObjectString = jsonObject.toString();
+ log.debug("Doctype:{} mapping:{}", docType, jsonObjectString);
+ createIndexRequestBuilder.addMapping(docType, jsonObjectString);
+ log.debug("Mapping created Doctype:{}", docType);
+ } else {
+ log.debug("No jsonObject for docType {}", docType);
+ }
+ }
+ } else {
+ log.debug("No mapping requested for index {}", esIndexAlias);
+ }
+ }
+
+ /**
+ * Add one setting to command
+ *
+ * @param createIndexRequestBuilder to add parameters
+ * @param jsonIndexMappingSetting contains mapping and setting information
+ */
+ private void doAddSetting(CreateIndexRequestBuilder createIndexRequestBuilder, JSONObject jsonIndexMappingSetting) {
+ // Handle optional settings if requested
+ log.debug("Handle settings");
+ JSONObject jsonSettings = jsonIndexMappingSetting.optJSONObject("settings");
+ if (jsonSettings != null) {
+ log.debug("Set setting for index {} {}", esIndexAlias, jsonSettings);
+ createIndexRequestBuilder.setSettings(Settings.settingsBuilder().loadFromSource(jsonSettings.toString()));
+ } else {
+ log.debug("No settings requested for index {}", esIndexAlias);
+ }
+ }
+
+ /**
+ * Create Index with alias according to definition, but no mapping
+ */
+ public void doCreateIndex() {
+ doCreateIndexWithMapping(null);
+ }
+
+ /**
+ * Write a JSON mapping definition for a document from a file to ES Hint: A later change of the
+ * mapping is not possible.
+ *
+ * @param jsonString String with mapping definition in JSON Format
+ */
+
+ public void doWriteMappingJson(String jsonString) {
+
+ if (esIndexAlias == null) {
+ throw new IllegalArgumentException("Missing Index");
+ }
+ if (jsonString == null) {
+ String s = "Mapping string parameter is null";
+ log.warn(s);
+ throw new IllegalArgumentException(s);
+ }
+
+ try {
+ // MAPPING GOES HERE
+ log.debug("Check status of ES index: {}", esIndexAlias);
+
+ final IndicesExistsResponse indexStatus =
+ client.admin().indices().prepareExists(esIndexAlias).execute().actionGet();
+
+ if (indexStatus.isExists()) {
+ log.debug("ES index exists: {}", esIndexAlias);
+ // A change of mapping is not working. This here works only for new datatypes
+
+ PutMappingResponse res = client.admin().indices().preparePutMapping(esIndexAlias).setSource(jsonString)
+ .execute().actionGet();
+ if (log.isDebugEnabled()) {
+ log.debug("Result: {}", res);
+ }
+
+ } else {
+ log.debug("Create not existing ES index: {}", esIndexAlias);
+
+ CreateIndexRequestBuilder createIndexRequestBuilder =
+ client.admin().indices().prepareCreate(esIndexAlias);
+ createIndexRequestBuilder.addMapping(jsonString).execute().actionGet();
+ }
+
+ } catch (ElasticsearchException e) {
+ log.warn(e.getDetailedMessage());
+ }
+ }
+
+ /**
+ * Write a Json mapping definition for a document from a file to ES
+ *
+ * @param fileName Filename with json definition.
+ */
+ public void doWriteMappingFromFile(String fileName) {
+
+
+ log.info("Write mapping from File: {}", fileName);
+
+ if (esIndexAlias == null) {
+ throw new IllegalArgumentException("Missing Index");
+ }
+
+ if (fileName == null) {
+ log.warn("No mapping for {} specified in parameter file.", esIndexAlias);
+ return;
+ }
+
+ String content = null;
+
+ try {
+ content = new String(Files.readAllBytes(Paths.get(fileName)), StandardCharsets.UTF_8);
+ } catch (IOException e1) {
+ log.warn("Problem with file {}: {}", fileName, e1.getMessage());
+ }
+
+ doWriteMappingJson(content);
+
+ }
+
+ /**
+ * Write list with json objects from json files
+ *
+ * @param docTypeAndFileName List with 2 String Array. String[0] Contains the dataType name
+ * String[1] Contains the filename
+ */
+ public void doWriteJsonFiles(List<String[]> docTypeAndFileName) {
+
+ if (docTypeAndFileName != null) {
+ log.debug("Write number of JSONFiles: {}", docTypeAndFileName.size());
+ int t = 1;
+ for (String[] s : docTypeAndFileName) {
+ if (s.length == 2) {
+ writeJsonObjectsFromFile(s[0], s[1]);
+ } else {
+ log.warn("Wrong parameters number. Entry: {}", t);
+ }
+ t++;
+ }
+ }
+ }
+
+ /**
+ * Write one object into Database
+ *
+ * @param esId Database index
+ * @param dataTypeName Name of datatype
+ * @param json String in JSON format.
+ * @return esId of the object
+ */
+ @Override
+ public String doWriteJsonString(String dataTypeName, IsEsObject esId, String json) {
+ return doWriteByteArray(dataTypeName, esId, json.getBytes());
+ }
+
+ /**
+ * Write one object into Database
+ *
+ * @param esId Database index
+ * @param dataTypeName Name of datatype
+ * @param json String in JSON format.
+ * @return esId of the object
+ */
+
+ @Override
+ public String doWriteByteArray(String dataTypeName, IsEsObject esId, byte[] json) {
+ return doWriteRaw(dataTypeName, esId.getEsId(), json);
+ }
+
+ /**
+ * Write one object into Database
+ *
+ * @param dataTypeName Name of datatype
+ * @param id id of the object or null
+ * @param json Object as json
+ * @return esId of the Object
+ */
+ public String doWriteJsonObject(String dataTypeName, String id, JSONObject json) {
+ return doWriteRaw(dataTypeName, id, json.toString().getBytes());
+ }
+
+ /**
+ * Write one object into Database
+ *
+ * @param esId Database index or null
+ * @param dataTypeName Name of datatype
+ * @param json String in JSON format.
+ * @return esId of the object
+ */
+
+ public String doWriteRaw(String dataTypeName, String esId, byte[] json) {
+
+ if (esIndexAlias == null) {
+ throw new IllegalArgumentException("Missing Index");
+ }
+
+ IndexRequestBuilder request = esId == null || esId.isEmpty() ? client.prepareIndex(esIndexAlias, dataTypeName)
+ : client.prepareIndex(esIndexAlias, dataTypeName, esId);
+
+ IndexResponse response = null;
+ try {
+ response = request.setSource(json).execute().actionGet();
+ } catch (ElasticsearchException e) {
+ log.warn("ES Exception {} Json: {}", e.getMessage(), new String(json));
+ }
+
+ if (response == null) {
+ String jsonString = new String(json);
+ log.warn("Response null during write: {} {}", esId, jsonString);
+ return null;
+ } else {
+ return response.getId();
+ }
+ }
+
+ /**
+ * Write JSON Data. First level contains datatype, next level id Example "datatype" : { "id" : { } }
+ * @param json Object
+ */
+ public void doWriteJSONObject(JSONObject json) {
+
+ Set<String> docTypes = getStringKeySet(json);
+ log.debug("Found number of keys: {} keys: {}", json.length(), docTypes.size());
+ for (String docType : docTypes) {
+ JSONObject objects = json.optJSONObject(docType);
+ if (objects == null) {
+ log.debug("Skip json {} with class {}", docType, json.get(docType).getClass());
+ } else {
+ doWriteJsonObjectsWithIds(docType, objects);
+ }
+ }
+ }
+
+ /**
+ * Write object and Id of object for a doctype
+ * @param docType of the objects
+ * @param objects a bunch of objects with ids as object name
+ */
+ private void doWriteJsonObjectsWithIds(String docType, JSONObject objects) {
+ Set<String> ids = getStringKeySet(objects);
+ log.debug("write doctype {} with elements {}", docType, ids.size());
+ for (String id : ids) {
+ JSONObject jsonIdObject = objects.optJSONObject(id);
+ if (jsonIdObject == null) {
+ log.debug("Skip jsonsub {} with class {}", id, objects.get(id).getClass());
+ } else {
+ if (log.isTraceEnabled()) {
+ log.trace("Jsonsub object of id {} '{}'", id, jsonIdObject);
+ }
+ this.doWriteRaw(docType, id, jsonIdObject.toString().getBytes());
+ }
+ }
+ }
+
+ /**
+ * Remove Object from database
+ */
+ @Override
+ public boolean doRemove(String dataTypeName, IsEsObject esId) {
+
+ if (esIndexAlias == null) {
+ throw new IllegalArgumentException("Missing Index");
+ }
+
+ DeleteResponse response =
+ client.prepareDelete(esIndexAlias, dataTypeName, esId.getEsId()).execute().actionGet();
+
+ return response.isFound();
+ }
+
+ /**
+ * Read Json Object from database
+ */
+ @Override
+ public @Nullable BytesReference doReadJsonData(String dataTypeName, IsEsObject esId) {
+
+ if (esId.getEsId() == null) {
+ throw new IllegalArgumentException("Read access to object without database Id");
+ }
+
+ return doReadJsonData(dataTypeName, esId.getEsId());
+ }
+
+ /**
+ * Read Json Object from database
+ */
+ @Override
+ public @Nullable BytesReference doReadJsonData(String dataTypeName, String esId) {
+
+ log.debug("NetworkIndex read: {}", esIndexAlias);
+
+ GetResponse response = client.prepareGet(esIndexAlias, dataTypeName, esId)
+ // .setOperationThreaded(false)
+ .execute().actionGet();
+
+ return response.isExists() ? response.getSourceAsBytesRef() : null;
+ }
+
+
+ @Override
+ public SearchHit[] doReadByQueryJsonData(int start, int length, String dataTypeName, QueryBuilder qb) {
+
+ log.debug("NetworkIndex query and read: {}", esIndexAlias);
+
+ SearchResponse response1 = client.prepareSearch(esIndexAlias).setTypes(dataTypeName).setQuery(qb).setFrom(start)
+ .setSize(length).execute().actionGet();
+
+ return response1.getHits().hits();
+ }
+
+
+ @Override
+ public SearchHit[] doReadAllJsonData(int start, int length, String dataTypeName) {
+ // Use query
+ QueryBuilder qb = QueryBuilders.matchAllQuery();
+ return doReadByQueryJsonData(start, length, dataTypeName, qb);
+ }
+
+ /**
+ * Write Json datetype that is specified by file to ES
+ *
+ * @param dataType ES Datatype name
+ * @param fileName file name
+ */
+ public void writeJsonObjectsFromFile(String dataType, String fileName) {
+
+ log.debug("Start: Index: '{}' ' datatype: '{}' File: '{}'", esIndexAlias, dataType, fileName);
+
+ String content = null;
+
+ try {
+ content = new String(Files.readAllBytes(Paths.get(fileName)), StandardCharsets.UTF_8);
+ } catch (IOException e1) {
+ log.warn("Can not read file: {}", e1.getMessage());
+ }
+
+ if (content != null && content.charAt(0) == 0xfeff) {
+ content = content.substring(1);
+ log.debug("Delete first char {} {}", dataType, fileName);
+ }
+
+ if (content != null) {
+ IndexResponse response = null;
+ try {
+ response = client.prepareIndex(esIndexAlias, dataType).setSource(content).execute().actionGet();
+ } catch (ElasticsearchException e) {
+ log.error("ElasticsearchException during write: for {} from {} from {}", e.getMessage(), dataType, fileName);
+ } catch (Exception e) {
+ log.error("Exception during write: for {} from {} from {}", e.getMessage(), dataType, fileName);
+ }
+
+ if (response != null) {
+ if (!response.isCreated()) {
+ String responseAsString = response.toString();
+ log.warn("Jackson Response not created: {} {} {}", dataType, fileName, responseAsString);
+ } else {
+ log.debug("Created: {}", response.getId());
+ }
+ } else {
+ log.warn("Jackson Response null after write {} {}", dataType, fileName);
+ }
+ }
+
+ }
+
+ @Override
+ public void closeDb() {
+ if (client != null) {
+ client.close();
+ }
+ }
+
+
+ // For any reason the function json.keySet() was not working in Oxygen => replaced by iterator
+ public static @Nonnull Set<String> getStringKeySet(JSONObject json) {
+ Set<String> keys = new HashSet<>();
+ Iterator<?> iterator = json.keys();
+ while (iterator.hasNext()) {
+ keys.add((String) iterator.next());
+ }
+ return keys;
+ }
+
+
+ private static class HtDatabaseClientException extends RuntimeException {
+
+ private static final long serialVersionUID = 1L;
+
+ public HtDatabaseClientException(String string, String esIndexAlias) {
+ super(string + " Effected index: " + "esIndexAlias");
+ }
+ }
+
+}
diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/database/HtDatabaseNode.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/database/HtDatabaseNode.java
new file mode 100644
index 000000000..47d7570e8
--- /dev/null
+++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/database/HtDatabaseNode.java
@@ -0,0 +1,261 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 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.base.database;
+
+import static org.elasticsearch.node.NodeBuilder.nodeBuilder;
+import java.io.File;
+import java.io.IOException;
+import java.net.DatagramSocket;
+import java.net.ServerSocket;
+import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.List;
+import javax.annotation.Nullable;
+import org.apache.lucene.util.Version;
+import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse;
+import org.elasticsearch.client.Client;
+import org.elasticsearch.common.settings.Settings;
+import org.elasticsearch.common.unit.TimeValue;
+import org.elasticsearch.node.Node;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.internalTypes.Resources;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.config.impl.AkkaConfig;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.config.impl.EsConfig;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.config.impl.GeoConfig;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.config.util.ClusterNodeInfo;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class HtDatabaseNode implements AutoCloseable {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(HtDatabaseNode.class);
+ private static final String DBCONFIGFILENAME = "etc/elasticsearch.yml";
+ private static final String RESFOLDER_PLUGIN = "elasticsearch/plugins";
+ private static final String RESFOLDER_PLUGINHEAD = RESFOLDER_PLUGIN + "/head";
+ private static final String RESFOLDER_PLUGINDELETE = RESFOLDER_PLUGIN + "/delete-by-query";
+ private static int MIN_PORT_NUMBER = 1024;
+ private static int MAX_PORT_NUMBER = 65535;
+ private static int ES_PORT = 9200;
+ private static int DELAYSECONDS = 120;
+ private static String PLUGINFOLDER = "etc/elasticsearch-plugins";
+
+ private static HtDatabaseNode oneNode = null;
+ private static Object initializationLock = new Object();
+ private static Integer initializedTarget = 0;
+ private static Integer initializedReached = 0;
+
+ private final Node node;
+
+ private HtDatabaseNode() {
+ LOGGER.debug("Start elasticsearch service");
+
+ LOGGER.debug("Lucine version: " + Version.LATEST);
+
+ node = nodeBuilder().settings(Settings.builder().put("path.home", "etc").put("path.conf", "etc")).node();
+ LOGGER.info("Starting Database service. Wait {} s", DELAYSECONDS);
+ // Wait for orange status for single node without redundancy
+ ClusterHealthResponse nodeStatus = node.client().admin().cluster().prepareHealth().setWaitForYellowStatus()
+ .setTimeout(TimeValue.timeValueSeconds(DELAYSECONDS)).get();
+
+ LOGGER.debug("Elasticsearch service started with status {}", nodeStatus.toString());
+ }
+
+ /**
+ * Close node
+ */
+ @Override
+ public void close() {
+ node.close();
+ oneNode = null; // Release the one instance that was started !
+ }
+
+ /**
+ * Provide indication if all Index initializations are done.
+ *
+ * @return true if all index initializations are ready, false if not
+ */
+ public Boolean getInitialized() {
+ synchronized (initializationLock) {
+ return initializedTarget != 0 && initializedReached == initializedTarget;
+ }
+ }
+
+ public void setInitializedReached() {
+ synchronized (initializationLock) {
+ HtDatabaseNode.initializedReached++;
+ }
+ }
+
+ public void setInitializedTarget() {
+ synchronized (initializationLock) {
+ HtDatabaseNode.initializedTarget++;
+ }
+ }
+
+ public Client getClient() {
+ return node.client();
+ }
+
+
+ /*
+ * --------------------------------------- Static functions below
+ */
+
+
+ // Visibility package for test purpose
+ static void checkorcreateplugins(String pluginFolder) {
+ File f = new File(pluginFolder);
+ if (!f.exists()) {
+ f.mkdir();
+ }
+ Resources.copyFolderInto(RESFOLDER_PLUGINHEAD, PLUGINFOLDER, RESFOLDER_PLUGIN);
+ Resources.copyFolderInto(RESFOLDER_PLUGINDELETE, PLUGINFOLDER, RESFOLDER_PLUGIN);
+ }
+
+ /**
+ * Checks to see if a specific port is available.
+ *
+ * @param port the port to check for availability
+ */
+ private static boolean isPortAvailable(int port) {
+ if (port < MIN_PORT_NUMBER || port > MAX_PORT_NUMBER) {
+ throw new IllegalArgumentException("Invalid start port: " + port);
+ }
+
+ ServerSocket ss = null;
+ DatagramSocket ds = null;
+ try {
+ ss = new ServerSocket(port);
+ ss.setReuseAddress(true);
+ ds = new DatagramSocket(port);
+ ds.setReuseAddress(true);
+ return true;
+ } catch (IOException e) {
+ } finally {
+ if (ds != null) {
+ ds.close();
+ }
+
+ if (ss != null) {
+ try {
+ ss.close();
+ } catch (IOException e) {
+ /* should not be thrown */
+ }
+ }
+ }
+
+ return false;
+ }
+
+ private static void checkorcreateConfigFile(EsConfig config, AkkaConfig akkaConfig, GeoConfig geoConfig) {
+ File f = new File(DBCONFIGFILENAME);
+ if (!f.exists()) {
+ LOGGER.debug("no " + DBCONFIGFILENAME + " found - extracting from resources");
+ if (Resources.extractFileTo("elasticsearch/elasticsearch.yml", f)) {
+ // replace template values
+ LOGGER.debug("replace template values with config:" + config);
+ Charset charset = StandardCharsets.UTF_8;
+ try {
+ Path p = f.toPath();
+ String hostName = "0.0.0.0"; // Default as initialisation value
+ if (akkaConfig != null && akkaConfig.isCluster()) {
+ LOGGER.debug("cluster configuration found");
+ hostName = akkaConfig.getClusterConfig().getHostName(hostName);
+ String clusterDBName = akkaConfig.getClusterConfig().getDBClusterName(null);
+ String nodeName = String.format("node%d.%s", akkaConfig.getClusterConfig().getRoleMemberIndex(),
+ clusterDBName);
+ if (clusterDBName != null) {
+ config.setCluster(clusterDBName);
+ config.setNode(nodeName);
+ config.save();
+ LOGGER.info("set db name to " + clusterDBName + " nodename=" + nodeName);
+ } else {
+ LOGGER.warn("unable to set correct db clustername");
+ }
+ }
+ String content = new String(Files.readAllBytes(p), charset);
+ content = content.replaceAll("\\$clustername", config.getCluster())
+ .replaceAll("\\$nodename", config.getNode()).replaceAll("\\$hostname", hostName);
+
+ // add cluster configuration
+ if (akkaConfig != null && akkaConfig.isCluster()) {
+ List<ClusterNodeInfo> seedNodes = akkaConfig.getClusterConfig().getSeedNodes();
+ String nodesJSONString = "[\"" + seedNodes.get(0).getRemoteAddress() + "\"";
+ for (int i = 1; i < seedNodes.size(); i++) {
+ nodesJSONString += ",\"" + seedNodes.get(i).getRemoteAddress() + "\"";
+ }
+ nodesJSONString += "]";
+ content += System.lineSeparator()
+ + String.format("discovery.zen.ping.unicast.hosts: %s", nodesJSONString);
+
+ if (geoConfig != null) {
+ LOGGER.debug("adding zone configuration");
+ content += System.lineSeparator() + String
+ .format("cluster.routing.allocation.awareness.force.zone.values: zone1,zone2");
+ content += System.lineSeparator()
+ + String.format("cluster.routing.allocation.awareness.attributes: zone");
+ if (geoConfig.isPrimary(akkaConfig.getClusterConfig().getRoleMember())) {
+ content += System.lineSeparator() + String.format("node.zone: zone1");
+ LOGGER.debug("setting zone to zone1");
+ } else {
+ content += System.lineSeparator() + String.format("node.zone: zone2");
+ LOGGER.debug("setting zone to zone2");
+ }
+ }
+ }
+ Files.write(p, content.getBytes(charset));
+ } catch (IOException e) {
+ LOGGER.warn("problem replacing values in file: " + e.getMessage());
+
+ }
+ } else {
+ LOGGER.warn("problem writing database.yml to etc folder from res");
+ }
+ }
+ }
+
+ /**
+ * Start as singleton
+ *
+ * @return the node or null if external node used
+ */
+ public static @Nullable HtDatabaseNode start(EsConfig config) throws IllegalStateException {
+ return start(config, null, null);
+ }
+
+ public static HtDatabaseNode start(EsConfig config, AkkaConfig akkaConfig, GeoConfig geoConfig) {
+ if (isPortAvailable(ES_PORT)) {
+ LOGGER.info("ES Port not in use. Start internal ES.");
+ if (oneNode == null) {
+ checkorcreateplugins(PLUGINFOLDER);
+ checkorcreateConfigFile(config, akkaConfig, geoConfig);
+ oneNode = new HtDatabaseNode();
+ } else {
+ throw new IllegalStateException(
+ "Database is already started, but can only be started once. Stop here.");
+ }
+ } else {
+ LOGGER.info("ES Port in use. External ES used.");
+ }
+
+ return oneNode;
+ }
+
+}
diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/database/HtDatabaseUpdateFile.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/database/HtDatabaseUpdateFile.java
new file mode 100644
index 000000000..f846000b7
--- /dev/null
+++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/database/HtDatabaseUpdateFile.java
@@ -0,0 +1,114 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 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.base.database;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.Enumeration;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipFile;
+
+import org.json.JSONArray;
+import org.json.JSONObject;
+import org.json.JSONTokener;
+
+public class HtDatabaseUpdateFile extends ZipFile {
+
+ public static final String FILENAME_DEFAULT = "elasticsearch_update.zip";
+
+ public class EsUpdateObject {
+ public final String Uri;
+ public final String Method;
+ public final JSONObject Body;
+
+ public EsUpdateObject(JSONObject o) {
+ this.Uri = o.getString("uri");
+ this.Method = o.getString("method");
+ this.Body = o.getJSONObject("body");
+ }
+ }
+
+ public interface FileReadCallback {
+ void read(EsUpdateObject obj,String filename);
+
+ void onerror(String filename,IOException e);
+ }
+
+ private static final Comparator<ZipEntry> byfilenameComparator = new Comparator<ZipEntry>() {
+
+ @Override
+ public int compare(ZipEntry o1, ZipEntry o2) {
+ return o1.getName().compareTo(o2.getName());
+ }
+ };
+
+ public HtDatabaseUpdateFile(String filename) throws IOException {
+ super(filename);
+ }
+
+ private static String readFile(final InputStream s) throws IOException {
+ // read file
+ BufferedReader in = new BufferedReader(new InputStreamReader(s));
+ StringBuilder sb = new StringBuilder();
+ String inputLine;
+ while ((inputLine = in.readLine()) != null) {
+ sb.append(inputLine);
+ }
+ in.close();
+ s.close();
+ return sb.toString();
+ }
+
+ public boolean readFiles(FileReadCallback cb) {
+ boolean r=true;
+ Enumeration<? extends ZipEntry> entries = this.entries();
+ ArrayList<? extends ZipEntry> list = Collections.list(entries);
+ Collections.sort(list, byfilenameComparator);
+ for (ZipEntry entry : list) {
+ if (entry.isDirectory())
+ continue;
+ try {
+ InputStream stream = this.getInputStream(entry);
+ Object data = new JSONTokener(readFile(stream)).nextValue();
+ stream.close();
+ if(data instanceof JSONArray)
+ {
+ JSONArray a=(JSONArray)data;
+ for(int i=0;i<a.length();i++)
+ {
+ cb.read(new EsUpdateObject(a.getJSONObject(i)),entry.getName());
+ }
+ }
+ else if(data instanceof JSONObject)
+ {
+ cb.read(new EsUpdateObject( (JSONObject)data),entry.getName());
+ }
+ } catch (IOException e) {
+ r=false;
+ cb.onerror(entry.getName(),e);
+ }
+ }
+ return r;
+ }
+
+}
diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/database/HtDatabaseWebAPIClient.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/database/HtDatabaseWebAPIClient.java
new file mode 100644
index 000000000..25930791a
--- /dev/null
+++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/database/HtDatabaseWebAPIClient.java
@@ -0,0 +1,98 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 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.base.database;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.HttpURLConnection;
+import java.net.URL;
+import java.net.URLConnection;
+import org.json.JSONObject;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+public class HtDatabaseWebAPIClient {
+
+ private static Logger LOG = LoggerFactory.getLogger(HtDatabaseWebAPIClient.class);
+ private static final int BUFSIZE = 1024;
+ private static final String CHARSET = "UTF-8";
+ private final String host;
+ private final int port;
+
+ public HtDatabaseWebAPIClient() {
+ this.host = "http://localhost";
+ this.port = 9200;
+ }
+
+ public String sendRequest(String uri, String method, JSONObject body) throws IOException {
+ LOG.debug("try to send request with uri=" + uri + " as method=" + method);
+ String sresponse = "";
+ int responseCode = -1;
+
+ if (body != null) {
+ LOG.trace("body: {}", body);
+ InputStream response = null;
+ String surl = String.format("%s:%d%s", this.host, this.port, uri);
+ URL url = new URL(surl);
+ URLConnection urlConnection = url.openConnection();
+ if (urlConnection instanceof HttpURLConnection) {
+ HttpURLConnection http = (HttpURLConnection) urlConnection;
+ http.setRequestMethod(method);
+ http.setDoOutput(true);
+ http.setRequestProperty("Content-Type", "application/json");
+ // send request
+ // Send the message to destination
+ if (!method.equals("GET")) {
+ try (OutputStream output = http.getOutputStream()) {
+ output.write(body.toString().getBytes(CHARSET));
+ }
+ }
+ responseCode = http.getResponseCode();
+ // Receive answer
+ if (responseCode >= 200 && responseCode < 300) {
+ response = http.getInputStream();
+ } else {
+ response = http.getErrorStream();
+ if (response == null) {
+ http.getInputStream();
+ }
+ }
+ }
+ byte[] buffer = new byte[BUFSIZE];
+ int len = 0;
+ if (response != null) {
+ while (true) {
+ len = response.read(buffer, 0, BUFSIZE);
+ if (len <= 0) {
+ break;
+ }
+ sresponse += new String(buffer, 0, len, CHARSET);
+ }
+ response.close();
+ } else {
+ LOG.debug("response is null");
+ }
+ }
+ LOG.debug("ResponseCode: " + responseCode);
+ LOG.trace("Response: " + sresponse);
+
+ return sresponse;
+ }
+}
diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/database/HtMapper.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/database/HtMapper.java
new file mode 100644
index 000000000..64d3fa02a
--- /dev/null
+++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/database/HtMapper.java
@@ -0,0 +1,166 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 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.base.database;
+
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import java.util.List;
+
+import javax.annotation.Nullable;
+
+import org.elasticsearch.common.bytes.BytesReference;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.fasterxml.jackson.core.JsonParseException;
+import com.fasterxml.jackson.databind.JsonMappingException;
+import com.fasterxml.jackson.databind.JsonNode;
+
+/**
+ * @author Herbert
+ *
+ */
+public class HtMapper<T> {
+
+ private static final Logger log = LoggerFactory.getLogger(HtDatabaseClientAbstract.class);
+
+ private final Class<? extends T> clazz;
+
+ private final JsonMapperBase objectMapperRead;
+ private final JsonMapperBase objectMapperWrite;
+
+ private int mappingFailures;
+
+
+ public HtMapper(Class<? extends T> clazz) {
+
+ this.mappingFailures = 0;
+ this.clazz = clazz;
+
+ this.objectMapperRead = new JsonMapperBase();
+ this.objectMapperWrite = this.objectMapperRead;
+ }
+
+ public Class<? extends T> getClazz() {
+ return clazz;
+ }
+
+ public int getMappingFailures() {
+ return mappingFailures;
+ }
+
+ public String objectToJson( T object ) {
+ return objectMapperWrite.objectToJson(object);
+ }
+
+ public String objectListToJson( List<T> objectList ) {
+ return objectMapperWrite.objectListToJson( objectList );
+ }
+
+ public T readValue( JsonNode node ) {
+
+ try {
+ T object = objectMapperRead.readValue(node.traverse(), clazz);
+ return object;
+ } catch (JsonParseException e) {
+ mappingFailures++;
+ log.warn(e.toString());
+ } catch (JsonMappingException e) {
+ mappingFailures++;
+ log.warn(e.toString());
+ } catch (IOException e) {
+ mappingFailures++;
+ log.warn(e.toString());
+ } catch (Exception e) {
+ mappingFailures++;
+ log.warn(e.toString());
+ }
+ log.warn("Can not parse: {} {} ", clazz, node);
+ return null;
+
+ }
+
+ /**
+ * Do the mapping from Json to class
+ * Block further mapping if there is are to many failures
+ * @param json String with Objects JSON representation
+ * @return The Object
+ */
+ public @Nullable T getObjectFromJson(byte[] json) {
+
+ if (json == null)
+ return null;
+ else if (mappingFailures < 10) {
+ try {
+ T object = objectMapperRead.readValue(json, clazz);
+ return object;
+ } catch (JsonParseException e) {
+ mappingFailures++;
+ log.warn(e.toString());
+ } catch (JsonMappingException e) {
+ mappingFailures++;
+ log.warn(e.toString());
+ } catch (IOException e) {
+ mappingFailures++;
+ log.warn(e.toString());
+ } catch (Exception e) {
+ mappingFailures++;
+ log.warn(e.toString());
+ }
+ }
+ log.warn("Problems parsing : {} {}", clazz, json);
+ return null;
+ }
+
+ /**
+ * Do the mapping from Json to class
+ * Block further mapping if there is are to many failures
+ * @param json Byte array with JSON Object representation
+ * @return The Object
+ */
+ public @Nullable T getObjectFromJson(BytesReference json) {
+
+ return json == null ? null : getObjectFromJson(json.toBytes());
+
+ }
+
+ /**
+ * Read json from File.
+ * @param fileName File with JSON text
+ * @return Object Object
+ */
+ public T readJsonObjectFromFile( String fileName ) {
+ byte[] content = null;
+ log.debug("Filename readJsonObjectFromFile: {}",fileName);
+
+ try {
+ content = Files.readAllBytes(Paths.get(fileName));
+ } catch (IOException e1) {
+ log.warn("IO Problem: {}", e1.getMessage());
+ }
+
+ if (content != null) {
+ return getObjectFromJson(content);
+ } else {
+ return null;
+ }
+ }
+
+
+}
diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/database/IndexClientBuilder.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/database/IndexClientBuilder.java
new file mode 100644
index 000000000..facc1c6f7
--- /dev/null
+++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/database/IndexClientBuilder.java
@@ -0,0 +1,141 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 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.base.database;
+
+import java.util.List;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.TimeUnit;
+
+import org.json.JSONObject;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.internalTypes.Resources;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Setup index in the database
+ * @author herbert
+ *
+ */
+public class IndexClientBuilder implements AutoCloseable {
+
+ private static final Logger LOG = LoggerFactory.getLogger(IndexClientBuilder.class);
+
+ /** Index name to be used */
+ private final String index;
+ /** Location of mapping data **/
+ private String mappingSettingFileName = null;
+ /** Location of configuration data **/
+ private String modelDataDirectory = null;
+
+ private final ScheduledExecutorService scheduler;
+ private HtDatabaseClientAbstract client;
+ private HtDatabaseNode databaseNode;
+
+
+ // --- Construct and initialize
+
+ public IndexClientBuilder(String index) {
+ this.index = index;
+ this.databaseNode = null;
+ this.scheduler = Executors.newSingleThreadScheduledExecutor();
+ }
+
+ // Additional setter functions
+
+ public IndexClientBuilder setMappingSettingJsonFileName(String jsonFileName) {
+ this.mappingSettingFileName = jsonFileName;
+ return(this);
+ }
+
+ public IndexClientBuilder setModelDataDirectory(String jsonDirectory) {
+ this.modelDataDirectory = jsonDirectory;
+ return(this);
+ }
+
+ public HtDatabaseClientAbstract create(HtDatabaseNode database) {
+ LOG.info("Create {} start with node", this.getClass().getSimpleName() );
+ this.databaseNode = database;
+ client = new HtDatabaseClientAbstract(index, database);
+ setupIndex();
+ return client;
+ }
+
+
+ public void stop() {
+ this.scheduler.shutdown();
+ }
+
+ @Override
+ public void close() throws Exception {
+ stop();
+ }
+
+ private void setupIndex() {
+ if (! client.isExistsIndex()) {
+ LOG.info("Index not existing ... create index");
+
+ // Initialisation 1
+ if (mappingSettingFileName != null) {
+ JSONObject indexconfigdata=Resources.getJSONFile(mappingSettingFileName);
+ client.doCreateIndexWithMapping(indexconfigdata);
+ } else
+ client.doCreateIndex();
+
+ // Initialisation 2 - start asynchron initialization and let it run
+ scheduler.schedule(fillDatabase, 0, TimeUnit.SECONDS);
+ }
+ }
+
+ private final Runnable fillDatabase = new Runnable() {
+ @Override
+ public void run() {
+ if (databaseNode != null) {
+ databaseNode.setInitializedTarget();
+ }
+ try { //Prevent ending task by exception
+ if (modelDataDirectory != null) {
+ LOG.info("... write initial data for index {}",index);
+ List<JSONObject> dataList=Resources.getJSONFiles(modelDataDirectory, false);
+ LOG.debug("received number of objects: {} of index {}", dataList.size(), index);
+ for (JSONObject da: dataList) {
+ client.doWriteJSONObject(da);
+ }
+ LOG.debug("wrote all objects for index {}", index);
+ } else {
+ LOG.info("No initial data for index {}",index);
+ }
+ } catch (Exception e) {
+ LOG.warn("Problem during initialization of index "+index+" {}", e);
+ }
+ if (databaseNode != null) {
+ databaseNode.setInitializedReached();
+ }
+ }
+ };
+
+ /*---------------------------------------------------------
+ * static files
+ */
+
+ public static IndexClientBuilder getBuilder(String index) {
+ return new IndexClientBuilder(index);
+ }
+
+
+}
diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/database/IsEsObject.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/database/IsEsObject.java
new file mode 100644
index 000000000..7e9db591d
--- /dev/null
+++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/database/IsEsObject.java
@@ -0,0 +1,37 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 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.base.database;
+
+/**
+ * Element is a document in the ES database.
+ */
+public interface IsEsObject {
+
+ /**
+ * Set the ES Id
+ * @param id Set the ID, created by ES for this Object
+ */
+ void setEsId( String id );
+
+ /**
+ * Get Id content as string that is used in ES
+ * @return Related ID, that was specified by set command.
+ */
+ String getEsId();
+
+}
diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/database/JsonMapperBase.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/database/JsonMapperBase.java
new file mode 100644
index 000000000..4a89c9be1
--- /dev/null
+++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/database/JsonMapperBase.java
@@ -0,0 +1,137 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 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.base.database;
+
+import java.io.IOException;
+import java.io.StringWriter;
+import java.util.List;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility;
+import com.fasterxml.jackson.annotation.PropertyAccessor;
+import com.fasterxml.jackson.core.JsonGenerationException;
+import com.fasterxml.jackson.core.JsonGenerator.Feature;
+import com.fasterxml.jackson.databind.DeserializationFeature;
+import com.fasterxml.jackson.databind.JsonMappingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.SerializationFeature;
+
+/**
+ * This class is used to define default for JSON Serialization and Deserialization for the project at a single place
+ */
+public class JsonMapperBase extends ObjectMapper {
+
+ private static final long serialVersionUID = 1L;
+ private static final Logger LOG = LoggerFactory.getLogger(JsonMapperBase.class);
+
+ public JsonMapperBase() {
+
+ setVisibility(PropertyAccessor.ALL, Visibility.NONE);
+ setVisibility(PropertyAccessor.FIELD, Visibility.ANY);
+
+ // Deserialization
+ configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+ configure(DeserializationFeature.READ_UNKNOWN_ENUM_VALUES_AS_NULL, true);
+
+ // Serialization
+ configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false);
+ getFactory().configure(Feature.ESCAPE_NON_ASCII, true);
+ }
+
+ public JsonMapperBase(int t) {
+
+ switch(t) {
+ case 0:
+ break;
+ case 1:
+ setVisibility(PropertyAccessor.ALL, Visibility.NONE);
+ setVisibility(PropertyAccessor.FIELD, Visibility.DEFAULT);
+ break;
+ case 2:
+ setVisibility(PropertyAccessor.ALL, Visibility.NONE);
+ setVisibility(PropertyAccessor.FIELD, Visibility.PROTECTED_AND_PUBLIC);
+ break;
+ case 3:
+ setVisibility(PropertyAccessor.ALL, Visibility.NONE);
+ setVisibility(PropertyAccessor.GETTER, Visibility.ANY);
+ setVisibility(PropertyAccessor.IS_GETTER, Visibility.ANY);
+ break;
+ default:
+ setVisibility(PropertyAccessor.ALL, Visibility.NONE);
+ setVisibility(PropertyAccessor.FIELD, Visibility.ANY);
+ break;
+
+ }
+
+ // Deserialization
+ configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+ configure(DeserializationFeature.READ_UNKNOWN_ENUM_VALUES_AS_NULL, true);
+
+ // Serialization
+ configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false);
+ getFactory().configure(Feature.ESCAPE_NON_ASCII, true);
+ }
+
+
+
+ public String objectToJson( Object object ) {
+ String res = null;
+
+ try {
+
+ res = writeValueAsString(object);
+
+ } catch (JsonGenerationException e) {
+ LOG.debug(e.toString());
+ } catch (JsonMappingException e) {
+ LOG.debug(e.toString());
+ } catch (IOException e) {
+ LOG.debug(e.toString());
+ } catch (Exception e) {
+ LOG.debug(e.toString());
+ }
+
+ return res;
+ }
+
+ public String objectListToJson( List<? extends Object> objectList ) {
+ String res = null;
+
+ try {
+
+ StringWriter stringEmp = new StringWriter();
+ writeValue(stringEmp, objectList);
+ res = stringEmp.toString();
+ stringEmp.close();
+
+ } catch (JsonGenerationException e) {
+ LOG.debug(e.toString());
+ } catch (JsonMappingException e) {
+ LOG.debug(e.toString());
+ } catch (IOException e) {
+ LOG.debug(e.toString());
+ } catch (Exception e) {
+ LOG.debug(e.toString());
+ }
+
+ return res;
+ }
+
+}
diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/http/BaseHTTPClient.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/http/BaseHTTPClient.java
new file mode 100644
index 000000000..b0404eed6
--- /dev/null
+++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/http/BaseHTTPClient.java
@@ -0,0 +1,325 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 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.base.http;
+
+import java.io.ByteArrayInputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.HttpURLConnection;
+import java.net.URL;
+import java.net.URLConnection;
+import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.security.KeyFactory;
+import java.security.KeyManagementException;
+import java.security.KeyStore;
+import java.security.KeyStoreException;
+import java.security.NoSuchAlgorithmException;
+import java.security.UnrecoverableKeyException;
+import java.security.cert.Certificate;
+import java.security.cert.CertificateException;
+import java.security.cert.CertificateFactory;
+import java.security.cert.X509Certificate;
+import java.security.interfaces.RSAPrivateKey;
+import java.security.spec.InvalidKeySpecException;
+import java.security.spec.PKCS8EncodedKeySpec;
+import java.util.Base64;
+import java.util.Map;
+import javax.annotation.Nonnull;
+import javax.net.ssl.HostnameVerifier;
+import javax.net.ssl.HttpsURLConnection;
+import javax.net.ssl.KeyManager;
+import javax.net.ssl.KeyManagerFactory;
+import javax.net.ssl.SSLContext;
+import javax.net.ssl.TrustManager;
+import javax.xml.bind.DatatypeConverter;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class BaseHTTPClient {
+
+ private static Logger LOG = LoggerFactory.getLogger(BaseHTTPClient.class);
+ private static final int SSLCERT_NONE = -1;
+ private static final int SSLCERT_PCKS = 0;
+ private static final int SSLCERT_PEM = 1;
+ private static final int BUFSIZE = 1024;
+ private static final Charset CHARSET = StandardCharsets.UTF_8;
+ private static final String SSLCONTEXT = "TLSv1.2";
+ private static final int DEFAULT_HTTP_TIMEOUT_MS = 30000; // in ms
+
+ private final boolean trustAll;
+ private final String baseUrl;
+
+ private int timeout = DEFAULT_HTTP_TIMEOUT_MS;
+ private SSLContext sc = null;
+
+ public BaseHTTPClient(String base) {
+ this(base, false);
+ }
+
+ public BaseHTTPClient(String base, boolean trustAllCerts) {
+ this(base, trustAllCerts, null, null, SSLCERT_NONE);
+ }
+
+ public BaseHTTPClient(String base, boolean trustAllCerts, String certFilename, String passphrase, int sslCertType) {
+ this.baseUrl = base;
+ this.trustAll = trustAllCerts;
+ try {
+ sc = setupSsl(trustAll, certFilename, passphrase, sslCertType);
+ } catch (KeyManagementException | NoSuchAlgorithmException | UnrecoverableKeyException | CertificateException
+ | KeyStoreException | IOException | InvalidKeySpecException e) {
+ LOG.warn("problem ssl setup: " + e.getMessage());
+ }
+ }
+
+ protected @Nonnull BaseHTTPResponse sendRequest(String uri, String method, String body, Map<String, String> headers)
+ throws IOException {
+ return this.sendRequest(uri, method, body != null ? body.getBytes(CHARSET) : null, headers);
+ }
+
+ protected @Nonnull BaseHTTPResponse sendRequest(String uri, String method, byte[] body, Map<String, String> headers)
+ throws IOException {
+ if (uri == null) {
+ uri = "";
+ }
+ String surl = this.baseUrl;
+ if (!surl.endsWith("/") && uri.length() > 0) {
+ surl += "/";
+ }
+ if (uri.startsWith("/")) {
+ uri = uri.substring(1);
+ }
+ surl += uri;
+ LOG.debug("try to send request with url=" + this.baseUrl + uri + " as method=" + method);
+ LOG.trace("body:" + (body == null ? "null" : new String(body, CHARSET)));
+ URL url = new URL(surl);
+ URLConnection http = url.openConnection();
+ http.setConnectTimeout(this.timeout);
+ if (surl.toString().startsWith("https")) {
+ if (sc != null) {
+ ((HttpsURLConnection) http).setSSLSocketFactory(sc.getSocketFactory());
+ if (trustAll) {
+ LOG.debug("trusting all certs");
+ HostnameVerifier allHostsValid = (hostname, session) -> true;
+ ((HttpsURLConnection) http).setHostnameVerifier(allHostsValid);
+ }
+ } else // Should never happen
+ {
+ LOG.warn("No SSL context available");
+ return new BaseHTTPResponse(-1, "");
+ }
+ }
+ ((HttpURLConnection) http).setRequestMethod(method);
+ http.setDoOutput(true);
+ if (headers != null && headers.size() > 0) {
+ for (String key : headers.keySet()) {
+ http.setRequestProperty(key, headers.get(key));
+ LOG.trace("set http header " + key + ": " + headers.get(key));
+ }
+ }
+ byte[] buffer = new byte[BUFSIZE];
+ int len = 0, lensum = 0;
+ // send request
+ // Send the message to destination
+ if (!method.equals("GET") && body != null && body.length > 0) {
+ try (OutputStream output = http.getOutputStream()) {
+ output.write(body);
+ }
+ }
+ // Receive answer
+ int responseCode = ((HttpURLConnection) http).getResponseCode();
+ String sresponse = "";
+ InputStream response = null;
+ try {
+ if (responseCode >= 200 && responseCode < 300) {
+ response = http.getInputStream();
+ } else {
+ response = ((HttpURLConnection) http).getErrorStream();
+ if (response == null) {
+ response = http.getInputStream();
+ }
+ }
+ if (response != null) {
+ while (true) {
+ len = response.read(buffer, 0, BUFSIZE);
+ if (len <= 0) {
+ break;
+ }
+ lensum += len;
+ sresponse += new String(buffer, 0, len, CHARSET);
+ }
+ } else {
+ LOG.debug("response is null");
+ }
+ } catch (Exception e) {
+ LOG.debug("No response. ", e);
+ } finally {
+ if (response != null) {
+ response.close();
+ }
+ }
+ LOG.debug("ResponseCode: " + responseCode);
+ LOG.trace("Response (len:{}): {}", String.valueOf(lensum), sresponse);
+ return new BaseHTTPResponse(responseCode, sresponse);
+ }
+
+ public static SSLContext setupSsl(boolean trustall)
+ throws NoSuchAlgorithmException, KeyManagementException, CertificateException, FileNotFoundException,
+ IOException, UnrecoverableKeyException, KeyStoreException, InvalidKeySpecException {
+
+ return setupSsl(trustall, null, null, SSLCERT_NONE);
+ }
+
+ /**
+ * @param keyFilename filename for key file
+ * @param certFilename filename for cert file
+ * @throws NoSuchAlgorithmException
+ * @throws KeyManagementException
+ * @throws IOException
+ * @throws FileNotFoundException
+ * @throws CertificateException
+ * @throws KeyStoreException
+ * @throws UnrecoverableKeyException
+ * @throws InvalidKeySpecException
+ */
+ /**
+ * Setup of SSLContext
+ *
+ * @param trustall true to switch of certificate verification
+ * @param certFilename filename for certificate file
+ * @param passPhrase for certificate
+ * @param certType of certificate
+ * @return SSL Context according to parameters
+ * @throws NoSuchAlgorithmException according name
+ * @throws KeyManagementException according name
+ * @throws CertificateException according name
+ * @throws FileNotFoundException according name
+ * @throws IOException according name
+ * @throws UnrecoverableKeyException according name
+ * @throws KeyStoreException according name
+ * @throws InvalidKeySpecException according name
+ */
+ public static SSLContext setupSsl(boolean trustall, String certFilename, String passPhrase, int certType)
+ throws NoSuchAlgorithmException, KeyManagementException, CertificateException, FileNotFoundException,
+ IOException, UnrecoverableKeyException, KeyStoreException, InvalidKeySpecException {
+
+ SSLContext sc = SSLContext.getInstance(SSLCONTEXT);
+ TrustManager[] trustCerts = null;
+ if (trustall) {
+ trustCerts = new TrustManager[] {new javax.net.ssl.X509TrustManager() {
+ @Override
+ public java.security.cert.X509Certificate[] getAcceptedIssuers() {
+ return null;
+ }
+
+ @Override
+ public void checkClientTrusted(java.security.cert.X509Certificate[] certs, String authType) {}
+
+ @Override
+ public void checkServerTrusted(java.security.cert.X509Certificate[] certs, String authType) {}
+ }};
+
+ }
+ KeyManager[] kms = null;
+ if (certFilename != null && passPhrase != null && !certFilename.isEmpty() && !passPhrase.isEmpty()) {
+ if (certType == SSLCERT_PCKS) {
+ LOG.debug("try to load pcks file " + certFilename + " with passphrase=" + passPhrase);
+ KeyStore keyStore = KeyStore.getInstance("PKCS12");
+ FileInputStream fileInputStream = new FileInputStream(certFilename);
+ keyStore.load(fileInputStream, passPhrase.toCharArray());
+ KeyManagerFactory kmf = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
+ kmf.init(keyStore, passPhrase.toCharArray());
+ kms = kmf.getKeyManagers();
+ fileInputStream.close();
+ LOG.debug("successful");
+
+ } else if (certType == SSLCERT_PEM) {
+ LOG.debug("try to load pem files cert=" + certFilename + " key=" + passPhrase);
+ File fCert = new File(certFilename);
+ File fKey = new File(passPhrase);
+ KeyStore keyStore = KeyStore.getInstance("JKS");
+ keyStore.load(null);
+ byte[] certBytes = parseDERFromPEM(Files.readAllBytes(fCert.toPath()), "-----BEGIN CERTIFICATE-----",
+ "-----END CERTIFICATE-----");
+ byte[] keyBytes = parseDERFromPEM(Files.readAllBytes(fKey.toPath()), "-----BEGIN PRIVATE KEY-----",
+ "-----END PRIVATE KEY-----");
+
+ X509Certificate cert = generateCertificateFromDER(certBytes);
+ RSAPrivateKey key = generatePrivateKeyFromDER(keyBytes);
+ keyStore.setCertificateEntry("cert-alias", cert);
+ keyStore.setKeyEntry("key-alias", key, "changeit".toCharArray(), new Certificate[] {cert});
+
+ KeyManagerFactory kmf = KeyManagerFactory.getInstance("SunX509");
+ kmf.init(keyStore, "changeit".toCharArray());
+ kms = kmf.getKeyManagers();
+ LOG.debug("successful");
+ }
+ }
+ // Init the SSLContext with a TrustManager[] and SecureRandom()
+ sc.init(kms, trustCerts, new java.security.SecureRandom());
+ return sc;
+ }
+
+ protected static byte[] parseDERFromPEM(byte[] pem, String beginDelimiter, String endDelimiter) {
+ String data = new String(pem);
+ String[] tokens = data.split(beginDelimiter);
+ tokens = tokens[1].split(endDelimiter);
+ return DatatypeConverter.parseBase64Binary(tokens[0]);
+ }
+
+ protected static RSAPrivateKey generatePrivateKeyFromDER(byte[] keyBytes)
+ throws InvalidKeySpecException, NoSuchAlgorithmException {
+ PKCS8EncodedKeySpec spec = new PKCS8EncodedKeySpec(keyBytes);
+
+ KeyFactory factory = KeyFactory.getInstance("RSA");
+
+ return (RSAPrivateKey) factory.generatePrivate(spec);
+ }
+
+ protected static X509Certificate generateCertificateFromDER(byte[] certBytes) throws CertificateException {
+ CertificateFactory factory = CertificateFactory.getInstance("X.509");
+
+ return (X509Certificate) factory.generateCertificate(new ByteArrayInputStream(certBytes));
+ }
+
+ public static String getAuthorizationHeaderValue(String username, String password) {
+ return "Basic " + new String(Base64.getEncoder().encode((username + ":" + password).getBytes()));
+ }
+
+ public void setTimeout(int timeout) {
+ this.timeout = timeout;
+ }
+
+ public static int getSslCertPcks() {
+ return SSLCERT_PCKS;
+ }
+
+ public static int getSslCertNone() {
+ return SSLCERT_NONE;
+ }
+
+ public static int getSslCertPEM() {
+ return SSLCERT_PEM;
+ }
+
+}
diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/http/BaseHTTPResponse.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/http/BaseHTTPResponse.java
new file mode 100644
index 000000000..ddadd1149
--- /dev/null
+++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/http/BaseHTTPResponse.java
@@ -0,0 +1,38 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 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.base.http;
+
+public class BaseHTTPResponse {
+
+ public static final int CODE404 = 404;
+ public static final int CODE200 = 200;
+ public static final BaseHTTPResponse UNKNOWN = new BaseHTTPResponse(-1, "");
+ public final int code;
+ public final String body;
+
+ public BaseHTTPResponse(int code,String body)
+ {
+ this.code=code;
+ this.body=body;
+ }
+
+ @Override
+ public String toString() {
+ return "BaseHTTPResponse [code=" + code + ", body=" + body + "]";
+ }
+}
diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/internalTypes/Environment.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/internalTypes/Environment.java
new file mode 100644
index 000000000..b56fe12b3
--- /dev/null
+++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/internalTypes/Environment.java
@@ -0,0 +1,46 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 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.base.internalTypes;
+
+import java.net.Inet4Address;
+import java.net.UnknownHostException;
+import java.util.Map;
+
+public class Environment {
+
+ public static String getVar(String v)
+ {
+ if(v.equals("$HOSTNAME"))
+ {
+ String s=null;
+ try {
+ s = Inet4Address.getLocalHost().getHostName();
+ } catch (UnknownHostException e) {
+
+ }
+ if(s!=null && s.length()>0)
+ return s;
+ }
+ Map<String, String> env = System.getenv();
+ for (String envName : env.keySet()) {
+ if(envName!=null && envName.equals(v))
+ return env.get(envName);
+ }
+ return null;
+ }
+}
diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/internalTypes/FileWatchdog.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/internalTypes/FileWatchdog.java
new file mode 100644
index 000000000..90bb8432a
--- /dev/null
+++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/internalTypes/FileWatchdog.java
@@ -0,0 +1,128 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 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==========================================================================
+ ******************************************************************************/
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
+ * agreements. See the NOTICE file distributed with this work for additional information regarding
+ * copyright ownership. The ASF licenses this file to You 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.
+ */
+
+package org.onap.ccsdk.features.sdnr.wt.devicemanager.base.internalTypes;
+
+import java.io.File;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Check every now and then that a certain file has not changed. If it has, then call the
+ * {@link #doOnChange} method.
+ *
+ * @author JunHo Yoon
+ * @since 3.1.1
+ */
+public abstract class FileWatchdog extends Thread {
+ private static final Logger LOGGER = LoggerFactory.getLogger(FileWatchdog.class);
+ /**
+ * The default delay between every file modification check, set to 60 seconds.
+ */
+ public static final long DEFAULT_DELAY = 60000;
+ /**
+ * The name of the file to observe for changes.
+ */
+ private final String filename;
+
+ /**
+ * The delay to observe between every check. By default set {@link #DEFAULT_DELAY}.
+ */
+ private long delay = DEFAULT_DELAY;
+
+ private final File file;
+ private long lastModified = 0;
+ private boolean warnedAlready = false;
+
+ protected FileWatchdog(String filename) {
+ this.filename = filename;
+ file = new File(filename);
+ setDaemon(true);
+ checkAndConfigure();
+ }
+
+ /**
+ * Set the delay to observe between each check of the file changes.
+ *
+ * @param delay the frequency of file watch.
+ */
+ public void setDelay(long delay) {
+ this.delay = delay;
+ }
+
+ /**
+ * abstract method to be run when the file is changed.
+ */
+ protected abstract void doOnChange();
+
+ protected void checkAndConfigure() {
+ boolean fileExists;
+ try {
+ fileExists = file.exists();
+ } catch (SecurityException e) {
+ LOGGER.warn("Was not allowed to read check file existence, file:[{}].",filename);
+ this.interrupt(); // there is no point in continuing
+ return;
+ }
+
+ if (fileExists) {
+ long l = file.lastModified(); // this can also throw a
+ if (lastModified == 0) {
+ lastModified = l; // is very unlikely.
+ }
+ if (l > lastModified) { // however, if we reached this point this
+ lastModified = l; // is very unlikely.
+ doOnChange();
+ warnedAlready = false;
+ }
+ } else {
+ if (!warnedAlready) {
+ LOGGER.debug("[{}] does not exist.", filename);
+ warnedAlready = true;
+ }
+ }
+ }
+
+ @Override
+ public void run() {
+ while (!isInterrupted()) {
+ checkAndConfigure();
+ try {
+ Thread.sleep(delay);
+ } catch (InterruptedException e) {
+ LOGGER.debug("Interrupted sleep. {}", e.getMessage());
+ Thread.currentThread().interrupt();
+ }
+ }
+ LOGGER.debug("Stoppen file watchdog for file {}", filename);
+ }
+}
diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/internalTypes/IniConfigurationFile.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/internalTypes/IniConfigurationFile.java
new file mode 100644
index 000000000..8fe64b5ca
--- /dev/null
+++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/internalTypes/IniConfigurationFile.java
@@ -0,0 +1,397 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 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.base.internalTypes;
+
+import java.io.BufferedReader;
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileReader;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map.Entry;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class IniConfigurationFile {
+
+ private static final Logger LOG = LoggerFactory.getLogger(IniConfigurationFile.class);
+
+ private static final String SECTIONNAME_ROOT = "";
+ private static final String DELIMITER = "=";
+ private static final String COMMENTCHARS[] = {"#", ";"};
+ private static final String LR = "\n";
+
+ private final File mFile;
+ private final List<Section> sections;
+
+ public IniConfigurationFile(File f) {
+ this.mFile = f;
+ this.sections = new ArrayList<>();
+ this.sections.add(new Section(SECTIONNAME_ROOT));
+ }
+
+ public void load() throws ConfigurationException {
+ String curSectionName = SECTIONNAME_ROOT;
+ LOG.debug("loading file");
+ BufferedReader br = null;
+ try {
+ br = new BufferedReader(new FileReader(this.mFile));
+ for (String line; (line = br.readLine()) != null;) {
+ line = line.trim();
+ if (line.isEmpty()) {
+ continue;
+ }
+ if (line.startsWith("[") && line.endsWith("]")) {
+ curSectionName = line.substring(1, line.length() - 1);
+ this.addSection(curSectionName);
+ } else {
+ this.getSection(curSectionName).addLine(line);
+ }
+ }
+
+ } catch (Exception e) {
+ throw new ConfigurationException(e.getMessage());
+ } finally {
+ try {
+ if (br != null) {
+ br.close();
+ }
+ } catch (IOException e) {
+ }
+ }
+ LOG.debug("finished loading file");
+ LOG.debug("start parsing sections");
+ for (Section section : this.sections) {
+ section.parseLines();
+ }
+ LOG.debug("finished parsing " + this.sections.size() + " sections");
+ }
+
+ private Section getSection(String name) {
+ for (Section s : this.sections) {
+ if (s.Name.equals(name)) {
+ return s;
+ }
+ }
+ return this.addSection(name);
+
+ }
+
+ private Section addSection(String name) {
+
+ Section s = new Section(name);
+ this.sections.add(s);
+ return s;
+ }
+
+ public void reLoad() throws ConfigurationException {
+ this.sections.clear();
+ this.sections.add(new Section(SECTIONNAME_ROOT));
+ this.load();
+ }
+
+ public String getProperty(String key, String defValue) {
+ Section s;
+ if (key.contains(".")) {
+ s = this.getSection(key.substring(0, key.indexOf(".")));
+ key = key.substring(key.indexOf(".") + 1);
+ } else {
+ s = this.getSection(SECTIONNAME_ROOT);
+ }
+
+ String v = s.getProperty(key);
+ if (v == null || v.isEmpty()) {
+ return defValue;
+ }
+ return v;
+ }
+
+ public void setProperty(String key, String value) {
+ Section s;
+ if (key.contains(".")) {
+ s = this.getSection(key.substring(0, key.indexOf(".")));
+ key = key.substring(key.indexOf(".") + 1);
+ } else {
+ s = this.getSection(SECTIONNAME_ROOT);
+ }
+ s.setProperty(key, value);
+ }
+
+ public int getProperty(String key, int defValue) throws ConversionException {
+ Section s;
+ if (key.contains(".")) {
+ s = this.getSection(key.substring(0, key.indexOf(".")));
+ key = key.substring(key.indexOf(".") + 1);
+ } else {
+ s = this.getSection(SECTIONNAME_ROOT);
+ }
+
+ return s.getInt(key, defValue);
+ }
+
+ public void setProperty(String key, int value) {
+ Section s;
+ if (key.contains(".")) {
+ s = this.getSection(key.substring(0, key.indexOf(".")));
+ key = key.substring(key.indexOf(".") + 1);
+ } else {
+ s = this.getSection(SECTIONNAME_ROOT);
+ }
+ s.setProperty(key, String.format("%d", value));
+ }
+
+ public boolean getProperty(String key, boolean defValue) throws ConversionException {
+ Section s;
+ if (key.contains(".")) {
+ s = this.getSection(key.substring(0, key.indexOf(".")));
+ key = key.substring(key.indexOf(".") + 1);
+ } else {
+ s = this.getSection(SECTIONNAME_ROOT);
+ }
+
+ return s.getBoolean(key, defValue);
+ }
+
+ public void setProperty(String key, boolean value) {
+ Section s;
+ if (key.contains(".")) {
+ s = this.getSection(key.substring(0, key.indexOf(".")));
+ key = key.substring(key.indexOf(".") + 1);
+ } else {
+ s = this.getSection(SECTIONNAME_ROOT);
+ }
+ s.setProperty(key, value ? "true" : "false");
+ }
+
+ public void setProperty(String key, Object value) {
+ this.setProperty(key, value == null ? "null" : value.toString());
+ }
+
+ public void save() {
+ try (BufferedWriter bw = new BufferedWriter(new FileWriter(this.mFile, false))) {
+ for (Section section : this.sections) {
+ if (section.hasValues()) {
+ bw.write(String.join(LR, section.toLines()) + LR + LR);
+ }
+ }
+ bw.close();
+ } catch (Exception e) {
+ LOG.warn("problem saving value: " + e.getMessage());
+ }
+ }
+
+ public Section subset(String section) {
+ return this.getSection(section);
+ }
+
+ public static class ConfigurationException extends Exception {
+
+ private static final long serialVersionUID = 733061908616404383L;
+
+ public ConfigurationException(String m) {
+ super(m);
+ }
+ }
+
+ public static class ConversionException extends Exception {
+ private static final long serialVersionUID = 5179891576029923079L;
+
+ public ConversionException(String m) {
+ super(m);
+ }
+ }
+
+ private static class SectionValue {
+ private String Value;
+ private final List<String> Comments;
+ private boolean IsUncommented;
+
+ public SectionValue(String value) {
+ this(value, new ArrayList<String>(), false);
+ }
+
+ public SectionValue(String value, List<String> commentsForValue, boolean isuncommented) {
+ this.Comments = commentsForValue;
+ this.Value = value;
+ this.IsUncommented = isuncommented;
+ }
+ }
+
+ public static class Section {
+ private final String Name;
+ private final List<String> rawLines;
+ private final LinkedHashMap<String, SectionValue> values;
+
+ public Section(String name) {
+ LOG.debug("new section created:" + name);
+ this.Name = name;
+ this.rawLines = new ArrayList<>();
+ this.values = new LinkedHashMap<>();
+ }
+
+ public void addLine(String line) {
+ LOG.trace("adding raw line:" + line);
+ this.rawLines.add(line);
+ }
+
+ public String getProperty(String key) {
+ return this.getProperty(key, null);
+ }
+
+ public String getProperty(String key, String defValue) {
+ if (values.containsKey(key)) {
+ return values.get(key).Value;
+ }
+ return defValue;
+ }
+
+ public void setProperty(String key, String value) {
+ boolean isuncommented = this.isCommentLine(key);
+ if (isuncommented) {
+ key = key.substring(1);
+ }
+ if (this.values.containsKey(key)) {
+ this.values.get(key).Value = value;
+ this.values.get(key).IsUncommented = isuncommented;
+ } else {
+ SectionValue sv = new SectionValue(value);
+ sv.IsUncommented = isuncommented;
+ this.values.put(key, sv);
+ }
+ }
+
+ public void parseLines() {
+ this.values.clear();
+ List<String> commentsForValue = new ArrayList<>();
+ boolean uncommented = false;
+ for (String line : rawLines) {
+
+ if (this.isCommentLine(line)) {
+ if (!line.contains(DELIMITER)) {
+ commentsForValue.add(line);
+ continue;
+ } else {
+ uncommented = true;
+ line = line.substring(1);
+ }
+ }
+ if (!line.contains(DELIMITER)) {
+ continue;
+ }
+ String hlp[] = line.split(DELIMITER);
+ if (hlp.length > 1) {
+ String key = hlp[0];
+ String value =
+ line.length() > (key + DELIMITER).length() ? line.substring((key + DELIMITER).length())
+ : "";
+ if (this.values.containsKey(key)) {
+ this.values.get(key).Value = value;
+ } else {
+ this.values.put(key, new SectionValue(value, commentsForValue, uncommented));
+ commentsForValue = new ArrayList<>();
+ }
+ } else {
+ LOG.warn("ignoring unknown formatted line:" + line);
+ }
+ uncommented = false;
+ }
+ }
+
+ private boolean isCommentLine(String line) {
+ for (String c : COMMENTCHARS) {
+ if (line.startsWith(c)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public String[] toLines() {
+ List<String> lines = new ArrayList<>();
+ if (!this.Name.isEmpty()) {
+ lines.add("[" + this.Name + "]");
+ }
+ for (Entry<String, SectionValue> entry : this.values.entrySet()) {
+ if (entry.getValue().Comments.size() > 0) {
+ for (String comment : entry.getValue().Comments) {
+ lines.add(comment);
+ }
+ }
+ lines.add((entry.getValue().IsUncommented ? COMMENTCHARS[0] : "") + entry.getKey() + DELIMITER
+ + entry.getValue().Value);
+ }
+ String[] alines = new String[lines.size()];
+ return lines.toArray(alines);
+ }
+
+ public String getString(String key, String def) {
+ return this.getProperty(key, def);
+ }
+
+ public boolean getBoolean(String key, boolean def) throws ConversionException {
+ String v = this.getProperty(key);
+ if (v == null || v.isEmpty()) {
+ return def;
+ }
+ if (v.equals("true")) {
+ return true;
+ }
+ if (v.equals("false")) {
+ return false;
+ }
+ throw new ConversionException("invalid value for key " + key);
+ }
+
+ public int getInt(String key, int def) throws ConversionException {
+ String v = this.getProperty(key);
+ if (v == null || v.isEmpty()) {
+ return def;
+ }
+ try {
+ return Integer.parseInt(v);
+ } catch (NumberFormatException e) {
+ throw new ConversionException(e.getMessage());
+ }
+ }
+
+ public long getLong(String key, long def) throws ConversionException {
+ String v = this.getProperty(key);
+ if (v == null || v.isEmpty()) {
+ return def;
+ }
+ try {
+ return Long.parseLong(v);
+ } catch (NumberFormatException e) {
+ throw new ConversionException(e.getMessage());
+ }
+ }
+
+ public boolean hasValues() {
+ return this.values.size() > 0;
+ }
+
+ public boolean hasKey(String key) {
+ return this.values.containsKey(key);
+ }
+
+ }
+
+}
diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/internalTypes/InternalDateAndTime.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/internalTypes/InternalDateAndTime.java
new file mode 100644
index 000000000..cc5b8316d
--- /dev/null
+++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/internalTypes/InternalDateAndTime.java
@@ -0,0 +1,103 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 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.base.internalTypes;
+
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.netconf.util.NetconfTimeStamp;
+import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.DateAndTime;
+
+/**
+ * Converts time stamps into internal format according to ONF1.2 and ISO 8601.
+ * @author herbert
+ *
+ */
+public class InternalDateAndTime {
+
+ private static final NetconfTimeStamp NETCONFTIME_CONVERTER = NetconfTimeStamp.getConverter();
+
+ private static final InternalDateAndTime TESTPATTERN = new InternalDateAndTime("2017-01-01T00:00:00.0Z");
+
+ String internalDateAndTime;
+
+ /**
+ * Static builder ONF1.2
+ * @param time in ONF1.2 yang format
+ * @return InternalDateAndTime
+ */
+ public static InternalDateAndTime valueOf(DateAndTime time) {
+ return new InternalDateAndTime(time);
+ }
+
+ /**
+ * Static builder ONF1.0
+ * @param time in ONF1.0 yang format
+ * @return InternalDateAndTime
+ */
+
+ public static InternalDateAndTime valueOf(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DateAndTime time) {
+ return new InternalDateAndTime(time);
+ }
+
+ /**
+ * @return Getter with String representation
+ */
+ public String getValue() {
+ return internalDateAndTime;
+ }
+
+ /*----------------------------------------------------------------
+ * Private constructors and functions
+ */
+
+ /**
+ * Convert ONF 1.2 DateAndTime to String
+ * @param time as input
+ */
+ private InternalDateAndTime(DateAndTime time) {
+ internalDateAndTime = NETCONFTIME_CONVERTER.getTimeStampFromNetconf(time.getValue());
+ }
+
+ /**
+ * Convert ONF 1.2 DateAndTime to String
+ * @param time as input
+ */
+ private InternalDateAndTime(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DateAndTime time) {
+ internalDateAndTime = NETCONFTIME_CONVERTER.getTimeStampFromNetconf(time.getValue());
+ }
+
+ /**
+ * Setup static TEST
+ * @param internalDateAndTime
+ */
+ private InternalDateAndTime(String internalDateAndTime) {
+ this.internalDateAndTime = internalDateAndTime;
+ }
+
+ /**
+ * Get a testpattern
+ * @return testpattern
+ */
+ public static InternalDateAndTime getTestpattern() {
+ return TESTPATTERN;
+ }
+
+
+
+}
diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/internalTypes/InternalSeverity.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/internalTypes/InternalSeverity.java
new file mode 100644
index 000000000..20c3193b1
--- /dev/null
+++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/internalTypes/InternalSeverity.java
@@ -0,0 +1,125 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 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==========================================================================
+ ******************************************************************************/
+/**
+ * @author herbert
+ *
+ */
+package org.onap.ccsdk.features.sdnr.wt.devicemanager.base.internalTypes;
+
+public enum InternalSeverity {
+
+ NonAlarmed,
+ Warning,
+ Minor,
+ Major,
+ Critical;
+
+ public boolean isNoAlarmIndication() {
+ return this == NonAlarmed;
+ }
+
+ public String getValueAsString() {
+ return this.name();
+ }
+
+ @Override
+ public String toString() {
+ return this.name();
+ }
+
+ public String toNetconfString()
+ {
+ switch(this)
+ {
+ case NonAlarmed:
+ return "non-alarmed";
+ case Warning:
+ return "warning";
+ case Minor:
+ return "minor";
+ case Major:
+ return "major";
+ case Critical:
+ return "critical";
+ }
+ return "not-specified";
+ }
+
+ /**
+ * convert ONF 1.2 Severity
+ * @param severity as input
+ * @return String with related output
+ */
+ public static InternalSeverity valueOf(org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.SeverityType severity ) {
+ switch( severity ) {
+ case NonAlarmed:
+ return InternalSeverity.NonAlarmed;
+ case Warning:
+ return InternalSeverity.Warning;
+ case Minor:
+ return InternalSeverity.Minor;
+ case Major:
+ return InternalSeverity.Major;
+ case Critical:
+ return InternalSeverity.Critical;
+ }
+ return null;
+ }
+
+ /**
+ * convert ONF 1.2.1.1 Severity
+ * @param severity as input
+ * @return String with related output
+ */
+ public static InternalSeverity valueOf(org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.SeverityType severity ) {
+ switch( severity ) {
+ case NonAlarmed:
+ return InternalSeverity.NonAlarmed;
+ case Warning:
+ return InternalSeverity.Warning;
+ case Minor:
+ return InternalSeverity.Minor;
+ case Major:
+ return InternalSeverity.Major;
+ case Critical:
+ return InternalSeverity.Critical;
+ }
+ return null;
+ }
+
+ /**
+ * convert ONF 1.2.1.1p Severity
+ * @param severity as input
+ * @return String with related output
+ */
+ public static InternalSeverity valueOf(org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.SeverityType severity ) {
+ switch( severity ) {
+ case NonAlarmed:
+ return InternalSeverity.NonAlarmed;
+ case Warning:
+ return InternalSeverity.Warning;
+ case Minor:
+ return InternalSeverity.Minor;
+ case Major:
+ return InternalSeverity.Major;
+ case Critical:
+ return InternalSeverity.Critical;
+ }
+ return null;
+ }
+}
diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/internalTypes/InventoryInformation.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/internalTypes/InventoryInformation.java
new file mode 100644
index 000000000..e4ce4afa7
--- /dev/null
+++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/internalTypes/InventoryInformation.java
@@ -0,0 +1,130 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 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.base.internalTypes;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class InventoryInformation {
+
+ private static final String UNKNOWN = "unknown";
+ private static final List<String> EMPTY = new ArrayList<>();
+ private static final InventoryInformation DEFAULT = new InventoryInformation();
+
+ private String type;
+ private String model;
+ private String vendor;
+ private String deviceIpv4;
+ private String deviceIpv6;
+ private List<String> interfaceUuidList;
+
+ public InventoryInformation()
+ {
+ this.type=UNKNOWN;
+ this.model=UNKNOWN;
+ this.vendor=UNKNOWN;
+ this.deviceIpv4=UNKNOWN;
+ this.deviceIpv6=UNKNOWN;
+ this.interfaceUuidList=EMPTY;
+ }
+
+ public InventoryInformation(InventoryInformation inventoryInformation) {
+ this.type=inventoryInformation.type;
+ this.model=inventoryInformation.model;
+ this.vendor=inventoryInformation.vendor;
+ this.deviceIpv4=inventoryInformation.deviceIpv4;
+ this.deviceIpv6=inventoryInformation.deviceIpv6;
+ this.interfaceUuidList=new ArrayList<>(inventoryInformation.interfaceUuidList);
+ }
+
+ public InventoryInformation(
+ String type, String model, String vendor, String deviceIpv4,
+ String deviceIpv6, List<String> interfaceUuidList) {
+ setType(type);
+ setModel(model);
+ setVendor(vendor);
+ setDeviceIpv4(deviceIpv4);
+ setDeviceIpv6(deviceIpv6);
+ setInterfaceUuidList(interfaceUuidList);
+ }
+
+ public String getType() {
+ return type;
+ }
+
+ public String getModel() {
+ return model;
+ }
+
+ public String getVendor() {
+ return vendor;
+ }
+
+ public String getDeviceIpv4() {
+ return deviceIpv4;
+ }
+
+ public String getDeviceIpv6() {
+ return deviceIpv6;
+ }
+
+ public List<String> getInterfaceUuidList() {
+ return interfaceUuidList;
+ }
+
+ public InventoryInformation setType(String type) {
+ this.type = type != null ? type : UNKNOWN;
+ return this;
+ }
+
+ public InventoryInformation setModel(String model) {
+ this.model = model != null ? model : UNKNOWN;
+ return this;
+ }
+
+ public InventoryInformation setVendor(String vendor) {
+ this.vendor = vendor != null ? vendor : UNKNOWN;
+ return this;
+ }
+
+ public InventoryInformation setDeviceIpv4(String deviceIpv4) {
+ this.deviceIpv4 = deviceIpv4 != null ? deviceIpv4 : UNKNOWN;
+ return this;
+ }
+
+ public InventoryInformation setDeviceIpv6(String deviceIpv6) {
+ this.deviceIpv6 = deviceIpv6 != null ? deviceIpv6 : UNKNOWN ;
+ return this;
+ }
+
+ public InventoryInformation setInterfaceUuidList(List<String> interfaceUuidList) {
+ this.interfaceUuidList = interfaceUuidList != null ? interfaceUuidList : EMPTY;
+ return this;
+ }
+
+ public static InventoryInformation getDefault() {
+ return DEFAULT;
+ }
+
+ @Override
+ public String toString() {
+ return "InventoryInformation [type=" + type + ", model=" + model + ", vendor=" + vendor + ", deviceIpv4="
+ + deviceIpv4 + ", deviceIpv6=" + deviceIpv6 + ", interfaceUuidList=" + interfaceUuidList + "]";
+ }
+
+}
diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/internalTypes/Resources.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/internalTypes/Resources.java
new file mode 100644
index 000000000..b4fec083a
--- /dev/null
+++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/internalTypes/Resources.java
@@ -0,0 +1,336 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 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.base.internalTypes;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileFilter;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.OutputStream;
+import java.net.MalformedURLException;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.List;
+import org.json.JSONException;
+import org.json.JSONObject;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.FrameworkUtil;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class Resources {
+
+ private static final Logger LOG = LoggerFactory.getLogger(Resources.class);
+
+ private static final String RESSOURCEROOT = "src/main/resources";
+
+ private static URL getFileURL(String resFile) {
+ Bundle b = FrameworkUtil.getBundle(Resources.class);
+ URL u = null;
+ LOG.debug("try to get file {}", resFile);
+ if (b == null) {
+ LOG.info("Load resource as file: {}", resFile);
+ u = getUrlForRessource(resFile);
+ } else {
+ LOG.info("Load resource from bundle: {}", resFile);
+ u = b.getEntry(resFile);
+ }
+ return u;
+ }
+
+ private static File getFile(String resFile) {
+ Bundle b = FrameworkUtil.getBundle(Resources.class);
+ File f = null;
+ LOG.debug("try to get file {}", resFile);
+ if (b == null) {
+ LOG.warn("cannot load bundle resources");
+ f = new File(RESSOURCEROOT + resFile);
+ } else {
+ try {
+
+ f = new File(b.getEntry(resFile).toURI());
+ } catch (URISyntaxException e) {
+
+ }
+ }
+ return f;
+ }
+
+ private static String readFile(final URL u) throws IOException {
+ return readFile(u.openStream());
+ }
+
+ private static String readFile(final InputStream s) throws IOException {
+ // read file
+ BufferedReader in = new BufferedReader(new InputStreamReader(s));
+ StringBuilder sb = new StringBuilder();
+ String inputLine;
+ while ((inputLine = in.readLine()) != null) {
+ sb.append(inputLine);
+ }
+ in.close();
+ s.close();
+ return sb.toString();
+ }
+
+ public static List<URL> getFileURLs(String folder, final String filter, final boolean recursive)
+ throws IOException {
+ Bundle b = FrameworkUtil.getBundle(Resources.class);
+ List<URL> list = new ArrayList<>();
+ if (b == null) {
+ FileFilter ff = pathname -> {
+ if (pathname.isFile()) {
+ return pathname.getName().contains(filter);
+ } else {
+ return true;
+ }
+ };
+ File ffolder = getFile(folder);
+ if (ffolder != null && ffolder.isDirectory()) {
+ File[] files = ffolder.listFiles(ff);
+ if (files != null && files.length > 0) {
+ for (File f : files) {
+ if (f.isFile()) {
+ list.add(f.toURI().toURL());
+ } else if (f.isDirectory() && recursive) {
+ getFileURLsRecursive(f, ff, list);
+ }
+ }
+ }
+ }
+ } else {
+ getResourceURLsTreeRecurse(b, filter, b.getEntryPaths(folder), recursive, list);
+ }
+ return list;
+ }
+
+ private static void getFileURLsRecursive(File root, FileFilter ff, List<URL> list) throws MalformedURLException {
+ if (root != null && root.isDirectory()) {
+ File[] files = root.listFiles(ff);
+ if (files != null && files.length > 0) {
+ for (File f : files) {
+ if (f.isFile()) {
+ list.add(f.toURI().toURL());
+ } else if (f.isDirectory()) {
+ getFileURLsRecursive(f, ff, list);
+ }
+ }
+ }
+ }
+
+ }
+
+ private static void getResourceURLsTreeRecurse(Bundle b, String filter, Enumeration<String> resource,
+ boolean recursive, List<URL> outp) throws IOException {
+ while (resource.hasMoreElements()) {
+ String name = resource.nextElement();
+ Enumeration<String> list = b.getEntryPaths(name);
+ if (list != null) {
+ if (recursive) {
+ getResourceURLsTreeRecurse(b, filter, list, recursive, outp);
+ }
+ } else {
+ // Read
+ if (name.contains(filter)) {
+ LOG.debug("add {} to list", name);
+ outp.add(b.getEntry(name));
+ } else {
+ LOG.debug("filtered out {}", name);
+ }
+ }
+ }
+ }
+
+ public static List<JSONObject> getJSONFiles(String folder, boolean recursive) {
+ List<JSONObject> list = new ArrayList<>();
+ List<URL> urls;
+ try {
+ urls = getFileURLs(folder, ".json", recursive);
+ LOG.debug("found {} files", urls.size());
+ } catch (IOException e1) {
+ urls = new ArrayList<>();
+ LOG.warn("failed to get urls from resfolder {} : {}", folder, e1.getMessage());
+ }
+ for (URL u : urls) {
+ LOG.debug("try to parse " + u.toString());
+ try {
+ JSONObject o = new JSONObject(readFile(u));
+ list.add(o);
+ } catch (JSONException | IOException e) {
+ LOG.warn("problem reading/parsing file {} : {}", u, e.getMessage());
+ }
+ }
+ return list;
+ }
+
+ public static JSONObject getJSONFile(String resFile) {
+ LOG.debug("loading json file {} from res", resFile);
+ URL u = getFileURL(resFile);
+ if (u == null) {
+ LOG.warn("cannot find resfile: {}", resFile);
+ return null;
+ }
+ JSONObject o = null;
+ try {
+ // parse to jsonobject
+ o = new JSONObject(readFile(u));
+ } catch (Exception e) {
+ LOG.warn("problem reading/parsing file: {}", e.getMessage());
+ }
+ return o;
+ }
+
+ /**
+ * Used for reading plugins from resource files
+ * /elasticsearch/plugins/head
+ * /etc/elasticsearch-plugins
+ * /elasticsearch/plugins
+ * @param resFolder resource folder pointing to the related files
+ * @param dstFolder destination
+ * @param rootDirToRemove part from full path to remove
+ * @return true if files could be extracted
+ */
+ public static boolean copyFolderInto(String resFolder, String dstFolder, String rootDirToRemove) {
+
+ Enumeration<URL> urls = null;
+ Bundle b = FrameworkUtil.getBundle(Resources.class);
+ if (b == null) {
+ LOG.info("Running in file text.");
+ urls = getResourceFolderFiles(resFolder);
+ } else {
+ urls = b.findEntries(resFolder, "*", true);
+ }
+
+ boolean success = true;
+ URL srcUrl;
+ String srcFilename;
+ String dstFilename;
+ while (urls.hasMoreElements()) {
+ srcUrl = urls.nextElement();
+ srcFilename = srcUrl.getFile();
+
+ if (srcFilename.endsWith("/")) {
+ LOG.warn("Skip directory: {}", srcFilename);
+ continue;
+ }
+
+ LOG.debug("try to copy res {} to {}", srcFilename, dstFolder);
+ if (rootDirToRemove != null) {
+ srcFilename = srcFilename
+ .substring(srcFilename.indexOf(rootDirToRemove) + rootDirToRemove.length() + 1);
+ LOG.debug("dstfilename trimmed to {}", srcFilename);
+ }
+ dstFilename = dstFolder + "/" + srcFilename;
+ try {
+ if (!extractFileTo(srcUrl, new File(dstFilename))) {
+ success = false;
+ }
+ } catch (Exception e) {
+ LOG.warn("problem copying res {} to {}: {}", srcFilename, dstFilename, e.getMessage());
+ }
+ }
+
+ return success;
+
+ }
+ private static Enumeration<URL> getResourceFolderFiles (String folder) {
+ LOG.info("Get ressource: {}", folder);
+ URL url = getUrlForRessource(folder);
+ String path = url.getPath();
+ File[] files = new File(path).listFiles();
+ Collection<URL> urlCollection = new ArrayList<>();
+
+ if (files != null) {
+ for (File f : files) {
+ try {
+ if (f.isDirectory()) {
+ urlCollection.addAll(Collections.list(getResourceFolderFiles(folder+"/"+f.getName())));
+ } else {
+ urlCollection.add(f.toURI().toURL());
+ }
+ } catch (MalformedURLException e) {
+ LOG.error("Can not read ressources", e);
+ break;
+ }
+ }
+ }
+
+ Enumeration<URL> urls = Collections.enumeration(urlCollection);
+ return urls;
+ }
+
+ private static URL getUrlForRessource (String fileOrDirectory) {
+ ClassLoader loader = Thread.currentThread().getContextClassLoader();
+ URL url = loader.getResource(fileOrDirectory);
+ return url;
+ }
+
+ public static boolean extractFileTo(String resFile, File oFile) {
+ if (oFile == null) {
+ return false;
+ }
+ LOG.debug("try to copy {} from res to {}", resFile, oFile.getAbsolutePath());
+ URL u = getFileURL(resFile);
+ if (u == null) {
+ LOG.warn("cannot find resfile: {}", resFile);
+ return false;
+ }
+ return extractFileTo(u, oFile);
+ }
+
+ public static boolean extractFileTo(URL u, File oFile) {
+
+ if (oFile.isDirectory()) {
+ oFile.mkdirs();
+ return true;
+ } else {
+ oFile.getParentFile().mkdirs();
+ }
+
+ if (!oFile.exists()) {
+ try {
+ oFile.createNewFile();
+ } catch (IOException e) {
+ LOG.warn("problem creating file {}: {}", oFile.getAbsoluteFile(), e.getMessage());
+ }
+ }
+ try (InputStream in = u.openStream(); OutputStream outStream = new FileOutputStream(oFile);) {
+
+ int theInt;
+ while ((theInt = in.read()) >= 0) {
+ outStream.write(theInt);
+ }
+ in.close();
+ outStream.flush();
+ outStream.close();
+ LOG.debug("file written successfully");
+ } catch (IOException e) {
+ LOG.error("problem writing file: {}", e.getMessage());
+ return false;
+ }
+ return true;
+ }
+
+}
diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/internalTypes/TemplateFile.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/internalTypes/TemplateFile.java
new file mode 100644
index 000000000..3703e18a6
--- /dev/null
+++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/internalTypes/TemplateFile.java
@@ -0,0 +1,84 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 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.base.internalTypes;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileReader;
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+
+public class TemplateFile {
+
+ protected final HashMap<String, Object> mKeyValuePairs;
+ private final String mContent;
+
+ public TemplateFile(String content) {
+ this.mKeyValuePairs = new HashMap<>();
+ this.mContent = content;
+
+ }
+
+ public TemplateFile(File f) throws IOException {
+ this(initialize(f));
+ }
+
+ public void addValue(String key, Object value) {
+ this.mKeyValuePairs.put(key, value);
+ }
+
+ public void removeValue(String key) {
+ this.mKeyValuePairs.remove(key);
+ }
+
+ private String replace() {
+ String s = this.mContent;
+ String key;
+ Object value;
+ for (Map.Entry<String, Object> entry : this.mKeyValuePairs.entrySet()) {
+ key = entry.getKey();
+ value = entry.getValue();
+ if (value != null) {
+ s = s.replace(key, value.toString());
+ }
+ }
+ return s;
+ }
+
+ @Override
+ public String toString() {
+ return this.replace();
+ }
+
+ private static String initialize(File f) throws FileNotFoundException, IOException {
+ StringBuilder sb = new StringBuilder();
+ try (BufferedReader br = new BufferedReader(new FileReader(f));) {
+ String line = br.readLine();
+
+ while (line != null) {
+ sb.append(line);
+ line = br.readLine();
+ }
+ br.close();
+ }
+ return sb.toString();
+ }
+
+}
diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/internalTypes/TimeSpan.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/internalTypes/TimeSpan.java
new file mode 100644
index 000000000..551955d45
--- /dev/null
+++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/internalTypes/TimeSpan.java
@@ -0,0 +1,650 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 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==========================================================================
+ ******************************************************************************/
+/*
+ * SoSy-Lab Common is a library of useful utilities.
+ * This file is part of SoSy-Lab Common.
+ *
+ * Copyright (C) 2007-2015 Dirk Beyer
+ * 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.
+ */
+package org.onap.ccsdk.features.sdnr.wt.devicemanager.base.internalTypes;
+
+import static com.google.common.base.Preconditions.checkArgument;
+import static com.google.common.base.Preconditions.checkNotNull;
+import static java.util.concurrent.TimeUnit.DAYS;
+import static java.util.concurrent.TimeUnit.HOURS;
+import static java.util.concurrent.TimeUnit.MICROSECONDS;
+import static java.util.concurrent.TimeUnit.MILLISECONDS;
+import static java.util.concurrent.TimeUnit.MINUTES;
+import static java.util.concurrent.TimeUnit.NANOSECONDS;
+import static java.util.concurrent.TimeUnit.SECONDS;
+
+import com.google.common.annotations.VisibleForTesting;
+import com.google.common.base.Ascii;
+import com.google.common.collect.EnumHashBiMap;
+import com.google.common.collect.ImmutableSortedSet;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Ordering;
+import com.google.common.math.LongMath;
+import com.google.common.primitives.Longs;
+
+import java.io.Serializable;
+import java.util.Arrays;
+import java.util.EnumSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Locale;
+import java.util.concurrent.TimeUnit;
+import java.util.function.Function;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+import javax.annotation.CheckReturnValue;
+import javax.annotation.Nullable;
+
+/**
+ * This is an immutable representation of some time span, using a {@link TimeUnit} and a value.
+ *
+ * <p>The value may be positive or negative. All operations check for overflows and underflows, the
+ * behavior on overflow and underflow differs and is documented for each method.
+ *
+ * <p>Two instances are considered equal if they represent the exact same time span regardless of
+ * their unit, for example, 60s and 1min are considered equal.
+ */
+
+public final class TimeSpan implements Comparable<TimeSpan>, Serializable {
+
+ private static final long serialVersionUID = -4013592312989551009L;
+
+ private static final ImmutableSortedSet<TimeUnit> ALL_UNITS =
+ ImmutableSortedSet.copyOf(EnumSet.allOf(TimeUnit.class));
+
+ static {
+ assert ALL_UNITS.higher(SECONDS).equals(MINUTES); // assert expected order of set
+ }
+
+ private static final EnumHashBiMap<TimeUnit, String> TIME_UNITS =
+ EnumHashBiMap.create(TimeUnit.class);
+
+ static {
+ TIME_UNITS.put(NANOSECONDS, "ns");
+ TIME_UNITS.put(MICROSECONDS, "µs");
+ TIME_UNITS.put(MILLISECONDS, "ms");
+ TIME_UNITS.put(SECONDS, "s");
+ TIME_UNITS.put(MINUTES, "min");
+ TIME_UNITS.put(HOURS, "h");
+ TIME_UNITS.put(DAYS, "d");
+ }
+
+ private static final Pattern ONLY_DIGITS = Pattern.compile(" *([0-9]+) *");
+
+ private enum CharType {
+ BEGIN,
+ END,
+ LETTER,
+ DIGIT,
+ WHITESPACE
+ }
+
+ private final long span;
+ private final TimeUnit unit;
+
+ private TimeSpan(long pSpan, TimeUnit pUnit) {
+ span = pSpan;
+ unit = checkNotNull(pUnit);
+ }
+
+ public static TimeSpan of(long pSpan, TimeUnit pUnit) {
+ return new TimeSpan(pSpan, pUnit);
+ }
+
+ public static TimeSpan ofSeconds(long pSeconds) {
+ return new TimeSpan(pSeconds, SECONDS);
+ }
+
+ public static TimeSpan ofMillis(long pMillis) {
+ return new TimeSpan(pMillis, MILLISECONDS);
+ }
+
+ public static TimeSpan ofNanos(long pNanos) {
+ return new TimeSpan(pNanos, NANOSECONDS);
+ }
+
+ public static TimeSpan empty() {
+ return new TimeSpan(0, DAYS);
+ }
+
+ /**
+ * Converts the given {@link String} into a {@link TimeSpan} object. Supported units are day,
+ * hour, minute and second.
+ *
+ * @param input the {@link String} to convert
+ * @return a {@link TimeSpan} represented by the given {@link String}
+ * @throws IllegalArgumentException if the input is not a valid string representation of a {@link
+ * TimeSpan}.
+ */
+ public static TimeSpan valueOf(String input) {
+
+ // only seconds: use simple regex
+ Matcher secondMatcher = ONLY_DIGITS.matcher(input);
+ if (secondMatcher.matches()) {
+ return ofSeconds(Long.parseLong(secondMatcher.group(1)));
+ }
+
+ // values with units: more elaborate parsing necessary
+ List<String> tokens = splitIntoTokens(input);
+
+ long days = 0;
+ long hours = 0;
+ long minutes = 0;
+ long seconds = 0;
+
+ Iterator<String> it = tokens.iterator();
+
+ while (it.hasNext()) {
+ // first: value
+ String nextString = it.next();
+ long value = Long.parseLong(nextString);
+
+ // second: unit
+ if (!it.hasNext()) {
+ throw new IllegalArgumentException("Value " + nextString + " has no unit.");
+ }
+
+ String unit = it.next();
+ switch (unit) {
+ case "day":
+ case "days":
+ case "d":
+ if (days != 0) {
+ throw new IllegalArgumentException("Days set twice: " + unit);
+ }
+ days = value;
+ break;
+
+ case "h":
+ case "hour":
+ case "hours":
+ if (hours != 0) {
+ throw new IllegalArgumentException("Hours set twice: " + unit);
+ }
+ hours = value;
+ break;
+
+ case "min":
+ case "m":
+ if (minutes != 0) {
+ throw new IllegalArgumentException("Minutes set twice: " + unit);
+ }
+ minutes = value;
+ break;
+
+ case "s":
+ if (seconds != 0) {
+ throw new IllegalArgumentException("Seconds set twice: " + unit);
+ }
+ seconds = value;
+ break;
+
+ default:
+ throw new IllegalArgumentException("Unknown unit: " + unit);
+ }
+ }
+
+ return sum(of(seconds, SECONDS), of(minutes, MINUTES), of(hours, HOURS), of(days, DAYS));
+ }
+
+ private static List<String> splitIntoTokens(String input) {
+ List<String> tokens = Lists.newArrayList();
+ CharType previous = CharType.BEGIN;
+ int pos = 0;
+
+ for (int i = 0; i <= input.length(); ++i) {
+
+ CharType current;
+ if (i == input.length()) {
+ current = CharType.END;
+ } else {
+ char currentChar = input.charAt(i);
+ if (Character.isLetter(currentChar)) {
+ current = CharType.LETTER;
+ } else if (Character.isDigit(currentChar)) {
+ current = CharType.DIGIT;
+ } else if (Character.isWhitespace(currentChar)) {
+ current = CharType.WHITESPACE;
+ } else {
+ throw new IllegalArgumentException(
+ "Unreconized character '" + currentChar + "' when parsing " + input);
+ }
+ }
+
+ if (current != previous) {
+ // we want to use the previous token
+ if (previous == CharType.LETTER || previous == CharType.DIGIT) {
+ tokens.add(input.substring(pos, i));
+ }
+
+ if (current == CharType.LETTER || current == CharType.DIGIT) {
+ pos = i;
+ }
+
+ previous = current;
+ }
+ }
+
+ return tokens;
+ }
+
+ /**
+ * Get the value of this TimeSpan represented in the given unit. If the given unit is larger than
+ * the current unit, precision may be lost.
+ *
+ * @throws ArithmeticException If the value cannot be represented in the given unit due to
+ * overflow.
+ */
+ public long getChecked(TimeUnit dest) {
+ if (dest.compareTo(unit) < 0) {
+ // Example case: we have seconds, but we want milliseconds (can overflow)
+ long factor = dest.convert(1, unit);
+ assert factor > 1;
+ return LongMath.checkedMultiply(span, factor);
+ }
+
+ // Example case: we have nanoseconds, but we want seconds (cannot overflow)
+ return dest.convert(span, unit);
+ }
+
+ /**
+ * Get the value of this TimeSpan represented in the given unit. If the given unit is larger than
+ * the current unit, precision may be lost. If the value cannot be represented in the given unit
+ * due to overflow, Long.MAX_VALUE/Long.MIN_VALUE is returned.
+ */
+ public long getSaturated(TimeUnit dest) {
+ return dest.convert(span, unit);
+ }
+
+ /**
+ * Return a TimeSpan that represents (approximately) the same time span, but whose unit is the
+ * given unit. If the given unit is larger than the current unit, precision may be lost.
+ *
+ * @throws ArithmeticException If the value cannot be represented in the given unit
+ */
+ public TimeSpan toChecked(TimeUnit dest) {
+ if (dest.equals(unit)) {
+ return this;
+ }
+ return new TimeSpan(getChecked(dest), dest);
+ }
+
+ /**
+ * Return a TimeSpan that represents (approximately) the same time span, but whose unit is the
+ * given unit. If the given unit is larger than the current unit, precision may be lost. If the
+ * value cannot be represented in the given unit due to overflow, Long.MAX_VALUE/Long.MIN_VALUE is
+ * returned.
+ */
+ public TimeSpan toSaturated(TimeUnit dest) {
+ if (dest.equals(unit)) {
+ return this;
+ }
+ return new TimeSpan(getSaturated(dest), dest);
+ }
+
+ /**
+ * Return a TimeSpan that represents (approximately) the same time span, but whose unit is the
+ * given unit, if possible. If the given unit is larger than the current unit, precision may be
+ * lost. If the value cannot be represented in the given unit due to overflow, the resulting
+ * TimeSpan does not use the given unit, but the closest unit one that still allows to hold the
+ * exact value.
+ */
+ @VisibleForTesting
+ TimeSpan toIfPossible(TimeUnit dest) {
+ if (dest.equals(unit)) {
+ return this;
+ }
+ if (dest.compareTo(unit) < 0) {
+ // Example case: we have seconds, but we want milliseconds (can overflow).
+ // Overflow is expected to be very rare.
+ // Loop will terminate because at one time "dest" becomes equal to "this.unit"
+ // and then toChecked succeeds for sure.
+ while (true) {
+ try {
+ return toChecked(dest);
+ } catch (ArithmeticException e) {
+ dest = checkNotNull(ALL_UNITS.higher(dest));
+ }
+ }
+
+ } else {
+ // Example case: we have nanoseconds, but we want seconds (cannot overflow).
+ return new TimeSpan(getSaturated(dest), dest);
+ }
+ }
+
+ /**
+ * Get the value of this TimeSpan as seconds. If the current unit is smaller than seconds,
+ * precision may be lost.
+ *
+ * @throws ArithmeticException If the value cannot be represented as seconds due to overflow.
+ */
+ public long asSeconds() {
+ return getChecked(SECONDS);
+ }
+
+ /**
+ * Get the value of this TimeSpan as milliseconds. If the current unit is smaller than
+ * milliseconds, precision may be lost.
+ *
+ * @throws ArithmeticException If the value cannot be represented as milliseconds due to overflow.
+ */
+ public long asMillis() {
+ return getChecked(MILLISECONDS);
+ }
+
+ /**
+ * Get the value of this TimeSpan as nanoseconds.
+ *
+ * @throws ArithmeticException If the value cannot be represented as milliseconds due to overflow.
+ */
+ public long asNanos() {
+ return getChecked(NANOSECONDS);
+ }
+
+ public TimeUnit getUnit() {
+ return unit;
+ }
+
+ /**
+ * Return a strings that represents (approximately) this time span, in the given unit if possible.
+ * If the given unit is larger than the current unit, precision may be lost. If the value cannot
+ * be represented in the given unit due to overflow, the result does not use the given unit, but
+ * the closest unit one that still allows to hold the exact value.
+ */
+ public String formatAs(TimeUnit dest) {
+ if (dest.compareTo(unit) <= 0) {
+ // Example case: we have seconds, but we want milliseconds
+ return toIfPossible(dest).toString();
+ }
+
+ // Example case: we have nanoseconds, but we want seconds
+ long scaleFactor = unit.convert(1L, dest);
+ assert scaleFactor > 0;
+ return String.format(Locale.US, "%9.3f%s", (double) span / scaleFactor, TIME_UNITS.get(dest));
+ }
+
+ /** Check whether this time span is empty, i.e., represents 0ns (or 0ms or 0s or ...). */
+ public boolean isEmpty() {
+ return span == 0;
+ }
+
+ @Override
+ public boolean equals(@Nullable Object obj) {
+ if (obj == this) {
+ return true;
+ }
+ if (!(obj instanceof TimeSpan)) {
+ return false;
+ }
+ TimeSpan other = (TimeSpan) obj;
+ if (this.unit == other.unit) {
+ return this.span == other.span;
+ }
+ TimeUnit leastCommonUnit = leastCommonUnit(this, other);
+ try {
+ return this.getChecked(leastCommonUnit) == other.getChecked(leastCommonUnit);
+ } catch (ArithmeticException e) {
+ // In case of overflow, both values cannot be the same.
+ return false;
+ }
+ }
+
+ @Override
+ public int hashCode() {
+ // Need to use a fixed unit here to be consistent with equals:
+ // 60s and 1min need to have the same hashCode.
+ // Saturation is ok, all really large values just have the same hash code.
+ return Longs.hashCode(getSaturated(NANOSECONDS));
+ }
+
+ @Override
+ public int compareTo(TimeSpan other) {
+ if (this.unit == other.unit) {
+ return Long.compare(this.span, other.span);
+ }
+ TimeUnit leastCommonUnit = leastCommonUnit(this, other);
+ try {
+ return Long.compare(this.getChecked(leastCommonUnit), other.getChecked(leastCommonUnit));
+ } catch (ArithmeticException e) {
+ // Only one of the two calls can overflow,
+ // and it has to be the one with the larger unit.
+ // Thus in case of overflow the TimeSpan with the larger unit also has the larger value.
+ return this.unit.compareTo(other.unit);
+ }
+ }
+
+ private static TimeUnit leastCommonUnit(TimeSpan a, TimeSpan b) {
+ return Ordering.natural().min(a.unit, b.unit);
+ }
+
+ @Override
+ public String toString() {
+ return DEFAULT_FORMAT.apply(this);
+ }
+
+ /**
+ * Create a new time span that is the sum of two time spans. The unit of the returned time span is
+ * the more precise one if possible, otherwise the closest unit that still allows to hold both
+ * input values and the result. Note that this can loose precision when adding a very large and a
+ * very small value.
+ *
+ * @throws ArithmeticException If no unit is large enough to represent the result value.
+ */
+ public static TimeSpan sum(TimeSpan a, TimeSpan b) {
+ TimeUnit leastCommonUnit = leastCommonUnit(a, b);
+ while (true) {
+ try {
+ return new TimeSpan(
+ LongMath.checkedAdd(a.getChecked(leastCommonUnit), b.getChecked(leastCommonUnit)),
+ leastCommonUnit);
+ } catch (ArithmeticException e) {
+ // Overflow is expected to be very rare, thus handle exception case instead of checking.
+ // Try again with next unit.
+ leastCommonUnit = ALL_UNITS.higher(leastCommonUnit);
+ if (leastCommonUnit == null) {
+ // overflow from addition
+ throw e;
+ }
+ }
+ }
+ }
+
+ /**
+ * Create a new time span that is the sum of several time spans. The unit of the returned time
+ * span is the most precise one if possible, otherwise the closest unit that still allows to hold
+ * input values and the result. Note that this can loose precision when adding very large and very
+ * small values.
+ *
+ * @throws ArithmeticException If no unit is large enough to represent the result value.
+ */
+ public static TimeSpan sum(Iterable<TimeSpan> timeSpans) {
+ Iterator<TimeSpan> it = timeSpans.iterator();
+ checkArgument(it.hasNext());
+
+ TimeSpan result = it.next();
+ // TODO Summing in loop looses more precision than necessary.
+ while (it.hasNext()) {
+ result = sum(result, it.next());
+ }
+ return result;
+ }
+
+ /**
+ * Create a new time span that is the sum of several time spans. The unit of the returned time
+ * span is the most precise one.
+ */
+ public static TimeSpan sum(TimeSpan... t) {
+ return sum(Arrays.asList(t));
+ }
+
+ /**
+ * Create a new time span that is the difference of two time spans. The unit of the returned time
+ * span is the more precise one if possible, otherwise the closest unit that still allows to hold
+ * both input values and the result. Note that this can loose precision when subtracting a very
+ * large and a very small value.
+ */
+ public static TimeSpan difference(TimeSpan a, TimeSpan b) {
+ TimeUnit leastCommonUnit = leastCommonUnit(a, b);
+ while (true) {
+ try {
+ return new TimeSpan(
+ LongMath.checkedSubtract(a.getChecked(leastCommonUnit), b.getChecked(leastCommonUnit)),
+ leastCommonUnit);
+ } catch (ArithmeticException e) {
+ // Overflow is expected to be very rare, thus handle exception case instead of checking.
+ // Try again with next unit.
+ leastCommonUnit = ALL_UNITS.higher(leastCommonUnit);
+ if (leastCommonUnit == null) {
+ // overflow from subtraction
+ throw e;
+ }
+ }
+ }
+ }
+
+ /**
+ * Create a new time span that is the current one multiplied by a non-negative integral factor.
+ * The unit of the returned time span is the same as the current one if possible, otherwise the
+ * closest unit that still allows to the result. Note that this can loose precision.
+ */
+ @CheckReturnValue
+ public TimeSpan multiply(int factor) {
+ checkArgument(factor >= 0, "Cannot multiply TimeSpan with negative value %s", factor);
+ TimeUnit dest = unit;
+ while (true) {
+ try {
+ return new TimeSpan(LongMath.checkedMultiply(getChecked(dest), factor), dest);
+ } catch (ArithmeticException e) {
+ // Overflow is expected to be very rare, thus handle exception case instead of checking.
+ // Try again with next unit.
+ dest = ALL_UNITS.higher(dest);
+ if (dest == null) {
+ // overflow from multiplication
+ throw e;
+ }
+ }
+ }
+ }
+
+ /**
+ * Create a new time span that is the current one divided by a non-negative integral value. The
+ * result of the division is rounded down (integer division). The unit of the returned time span
+ * is the same as the current one.
+ */
+ @CheckReturnValue
+ public TimeSpan divide(int divisor) {
+ checkArgument(divisor >= 0, "Cannot divide TimeSpan by negative value %s", divisor);
+ return new TimeSpan(span / divisor, unit);
+ }
+
+ // Code for formatting as string
+
+ private static final Function<TimeSpan, String> FORMAT_SIMPLE =
+ pInput -> pInput.span + TIME_UNITS.get(pInput.unit);
+
+ @VisibleForTesting
+ static final Function<TimeSpan, String> FORMAT_HUMAN_READABLE_LARGE =
+ pInput -> {
+ TimeUnit unit = pInput.getUnit();
+ StringBuilder result = new StringBuilder();
+ boolean started = false;
+
+ long years = pInput.getChecked(DAYS) / 365;
+ if (years > 0) {
+ started = true;
+ result.append(years).append("a ");
+ }
+
+ long days = pInput.getChecked(DAYS) - years * 365;
+ if (started || days > 0) {
+ started = true;
+ result.append(days).append("d ");
+ }
+ if (unit.equals(DAYS)) {
+ return result.toString().trim();
+ }
+
+ long hours = pInput.getChecked(HOURS) - years * 365 * 24 - days * 24;
+ if (started || hours > 0) {
+ started = true;
+ result.append(String.format("%02dh ", hours));
+ }
+ if (unit.equals(HOURS)) {
+ return result.toString().trim();
+ }
+
+ long minutes =
+ pInput.getChecked(MINUTES) - years * 365 * 24 * 60 - days * 24 * 60 - hours * 60;
+ if (started || minutes > 0) {
+ result.append(String.format("%02dmin ", minutes));
+ }
+ if (unit.equals(MINUTES)) {
+ started = true;
+ return result.toString().trim();
+ }
+
+ long seconds =
+ pInput.getChecked(SECONDS)
+ - years * 365 * 24 * 60 * 60
+ - days * 24 * 60 * 60
+ - hours * 60 * 60
+ - minutes * 60;
+ result.append(String.format("%02ds", seconds));
+
+ return result.toString();
+ };
+
+ private static final String DEFAULT_FORMAT_PROPERTY_NAME =
+ TimeSpan.class.getCanonicalName() + ".defaultFormat";
+
+ private static final Function<TimeSpan, String> DEFAULT_FORMAT;
+
+ static {
+ String format =
+ Ascii.toUpperCase(System.getProperty(DEFAULT_FORMAT_PROPERTY_NAME, "SIMPLE").trim());
+ switch (format) {
+ case "HUMAN_READABLE_LARGE":
+ DEFAULT_FORMAT = FORMAT_HUMAN_READABLE_LARGE;
+ break;
+ case "SIMPLE":
+ DEFAULT_FORMAT = FORMAT_SIMPLE;
+ break;
+ default:
+ DEFAULT_FORMAT = FORMAT_SIMPLE;
+ }
+ }
+}
diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/NotificationActor.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/NotificationActor.java
new file mode 100644
index 000000000..7daf7c9c5
--- /dev/null
+++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/NotificationActor.java
@@ -0,0 +1,24 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 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.base.netconf;
+
+public interface NotificationActor<T> {
+
+ public void notificationActor(T item);
+
+}
diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/NotificationWorker.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/NotificationWorker.java
new file mode 100644
index 000000000..b6e0ca23c
--- /dev/null
+++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/NotificationWorker.java
@@ -0,0 +1,81 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 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.base.netconf;
+
+import java.util.concurrent.BlockingQueue;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.LinkedBlockingQueue;
+
+public class NotificationWorker<T> implements AutoCloseable {
+
+ private final BlockingQueue<T> workQueue;
+ private final ExecutorService service;
+ private final NotificationActor<T> actor;
+
+ public NotificationWorker(int numWorkers, int workQueueSize, NotificationActor<T> actorObject) {
+ workQueue = new LinkedBlockingQueue<T>(workQueueSize);
+ service = Executors.newFixedThreadPool(numWorkers);
+ actor = actorObject;
+
+ for (int i=0; i < numWorkers; i++) {
+ service.submit(new Worker<T>(workQueue, actor));
+ }
+ }
+
+ public void put(T item) {
+ try {
+ workQueue.put(item);
+ } catch (InterruptedException ex) {
+ Thread.currentThread().interrupt();
+ }
+ }
+
+ @Override
+ public void close() throws Exception {
+ // TODO Auto-generated method stub
+ }
+
+ private static class Worker<T> implements Runnable {
+ private final BlockingQueue<T> workQueue;
+ private final NotificationActor<T> actor;
+
+
+ public Worker(BlockingQueue<T> workQueue, NotificationActor<T> actor) {
+ this.workQueue = workQueue;
+ this.actor = actor;
+ }
+
+ @Override
+ public void run() {
+ while (!Thread.currentThread().isInterrupted()) {
+ try {
+ T item = workQueue.take();
+ actor.notificationActor(item);
+ // Process item
+ } catch (InterruptedException ex) {
+ Thread.currentThread().interrupt();
+ break;
+ }
+ }
+ }
+ }
+
+
+
+}
diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/ONFCOreNetworkElementCoreData.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/ONFCOreNetworkElementCoreData.java
new file mode 100644
index 000000000..265a3db84
--- /dev/null
+++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/ONFCOreNetworkElementCoreData.java
@@ -0,0 +1,29 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 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.base.netconf;
+
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.NetworkElement;
+
+public interface ONFCOreNetworkElementCoreData {
+
+ public String getMountpoint();
+ public DataBroker getDataBroker();
+ public NetworkElement getOptionalNetworkElement();
+
+}
diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/ONFCoreEmpty.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/ONFCoreEmpty.java
new file mode 100644
index 000000000..00393d967
--- /dev/null
+++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/ONFCoreEmpty.java
@@ -0,0 +1,111 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 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.base.netconf;
+
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.internalTypes.InventoryInformation;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.netconf.container.AllPm;
+import org.opendaylight.controller.md.sal.binding.api.MountPoint;
+
+/**
+ * @author herbert
+ *
+ */
+public class ONFCoreEmpty implements ONFCoreNetworkElementRepresentation {
+
+ private String mountPointNodeName = "";
+
+
+ ONFCoreEmpty(String mountPointNodeName) {
+ this.mountPointNodeName = mountPointNodeName;
+ }
+
+ @Override
+ public void initialReadFromNetworkElement() {
+ }
+
+ @Override
+ public String getMountPointNodeName() {
+ return mountPointNodeName;
+ }
+
+ @Override
+ public void resetPMIterator() {
+ }
+
+ @Override
+ public boolean hasNext() {
+ return false;
+ }
+
+ @Override
+ public void next() {
+ }
+
+ @Override
+ public AllPm getHistoricalPM() {
+ return AllPm.getEmpty();
+ }
+
+ @Override
+ public String pmStatusToString() {
+ return "ONFCoreEmpty";
+ }
+
+ @Override
+ public int removeAllCurrentProblemsOfNode() {
+ return 0;
+ }
+
+ @Override
+ public void doRegisterMicrowaveEventListener(MountPoint mointPoint) {
+ //Do nothing
+ }
+
+ @Override
+ public void prepareCheck() {
+ //Do nothing here
+ }
+
+ @Override
+ public boolean checkIfConnectionToMediatorIsOk() {
+ return false;
+ }
+
+ @Override
+ public boolean checkIfConnectionToNeIsOk() {
+ return false;
+ }
+
+ @Override
+ public void initSynchronizationExtension() {
+ }
+
+ @Override
+ public InventoryInformation getInventoryInformation() {
+ return InventoryInformation.getDefault();
+ }
+
+ @Override
+ public InventoryInformation getInventoryInformation(String layerProtocolFilter) {
+ return InventoryInformation.getDefault();
+ }
+
+}
diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/ONFCoreInterfacePac.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/ONFCoreInterfacePac.java
new file mode 100644
index 000000000..1c9c8e073
--- /dev/null
+++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/ONFCoreInterfacePac.java
@@ -0,0 +1,37 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 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.base.netconf;
+
+/**
+ * @author herbert
+ *
+ */
+public class ONFCoreInterfacePac<T> {
+
+
+ Class<T> myClass;
+
+ ONFCoreInterfacePac( Class<T> myClass ) {
+ this.myClass = myClass;
+ }
+
+
+}
diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/ONFCoreNetworkElement12.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/ONFCoreNetworkElement12.java
new file mode 100644
index 000000000..de43e5760
--- /dev/null
+++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/ONFCoreNetworkElement12.java
@@ -0,0 +1,741 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 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.base.netconf;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.internalTypes.InternalDateAndTime;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.internalTypes.InternalSeverity;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.netconf.container.AllPm;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.netconf.container.Capabilities;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.netconf.container.ONFLayerProtocolName;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.netconf.util.GenericTransactionUtils;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.netconf.wrapperc.OnfMicrowaveModel;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.netconf.wrapperc.WrapperMicrowaveModelRev170324;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.netconf.wrapperc.WrapperMicrowaveModelRev180907;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.netconf.wrapperc.WrapperMicrowaveModelRev181010;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.toggleAlarmFilter.NotificationDelayService;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.ProviderClient;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.database.service.HtDatabaseEventsService;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.listener.MicrowaveEventListener12;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.xml.AttributeValueChangedNotificationXml;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.xml.ProblemNotificationXml;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.xml.WebSocketServiceClient;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.maintenance.MaintenanceService;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.performancemanager.impl.database.types.EsHistoricalPerformance15Minutes;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.performancemanager.impl.database.types.EsHistoricalPerformance24Hours;
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.controller.md.sal.binding.api.MountPoint;
+import org.opendaylight.controller.md.sal.binding.api.NotificationService;
+import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.NetworkElement;
+import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.UniversalId;
+import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.extension.g.Extension;
+import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.logical.termination.point.g.Lp;
+import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.network.element.Ltp;
+import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.g._874._1.model.rev170320.GranularityPeriodType;
+import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.g._874._1.model.rev170320.OtnHistoryDataG;
+import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.onf.core.model.conditional.packages.rev170402.NetworkElementPac;
+import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.onf.core.model.conditional.packages.rev170402.network.element.pac.NetworkElementCurrentProblems;
+import org.opendaylight.yangtools.concepts.ListenerRegistration;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.opendaylight.yangtools.yang.binding.NotificationListener;
+import org.opendaylight.yangtools.yang.common.QName;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import com.google.common.base.Optional;
+
+/**
+ * Get information over NETCONF device according to ONF Coremodel. Read networkelement and
+ * conditional packages.
+ *
+ * Get conditional packages from Networkelement Possible interfaces are: MWPS, LTP(MWPS-TTP),
+ * MWAirInterfacePac, MicrowaveModel-ObjectClasses-AirInterface ETH-CTP,LTP(Client),
+ * MW_EthernetContainer_Pac MWS, LTP(MWS-CTP-xD), MWAirInterfaceDiversityPac,
+ * MicrowaveModel-ObjectClasses-AirInterfaceDiversity MWS, LTP(MWS-TTP),
+ * ,MicrowaveModel-ObjectClasses-HybridMwStructure MWS, LTP(MWS-TTP),
+ * ,MicrowaveModel-ObjectClasses-PureEthernetStructure
+ *
+ * @author herbert
+ *
+ */
+public class ONFCoreNetworkElement12 extends ONFCoreNetworkElement12Base
+ implements ONFCoreNetworkElementCallback, NotificationActor<AttributeValueChangedNotificationXml> {
+
+ private static final Logger LOG = LoggerFactory.getLogger(ONFCoreNetworkElement12.class);
+
+ /*-----------------------------------------------------------------------------
+ * Class members
+ */
+ private final @Nonnull MicrowaveEventListener12 microwaveEventListener;
+ private final @Nonnull OnfMicrowaveModel microwaveModel;
+ private final NotificationWorker<AttributeValueChangedNotificationXml> notificationQueue;
+
+ private ListenerRegistration<NotificationListener> listenerRegistrationresult = null;
+
+ /*-----------------------------------------------------------------------------
+ * Construction
+ */
+
+ /**
+ * Constructor
+ *
+ * @param mountPointNodeName as String
+ * @param capabilities of the specific network element
+ * @param netconfNodeDataBroker for the network element specific data
+ * @param webSocketService to forward event notifications
+ * @param databaseService to access the database
+ * @param dcaeProvider to forward problem / change notifications
+ */
+ private ONFCoreNetworkElement12(String mountPointNodeName, Capabilities capabilities,
+ DataBroker netconfNodeDataBroker, WebSocketServiceClient webSocketService,
+ HtDatabaseEventsService databaseService, ProviderClient dcaeProvider, @Nullable ProviderClient aotsmClient,
+ MaintenanceService maintenanceService,
+ NotificationDelayService<ProblemNotificationXml> notificationDelayService,
+ OnfMicrowaveModel onfMicrowaveModel) {
+
+ super(mountPointNodeName, netconfNodeDataBroker, capabilities);
+
+ this.microwaveModel = onfMicrowaveModel;
+ this.microwaveModel.setCoreData(this);
+
+ // Create MicrowaveService here
+ this.microwaveEventListener = new MicrowaveEventListener12(mountPointNodeName, webSocketService,
+ databaseService, dcaeProvider, aotsmClient, maintenanceService, notificationDelayService, this);
+ this.microwaveModel.setOnfMicrowaveModelListener(microwaveEventListener);
+
+ this.notificationQueue = new NotificationWorker<>(1, 100, this);
+
+ // ->Below shifted to super class
+ // this.isNetworkElementCurrentProblemsSupporting12 =
+ // capabilities.isSupportingNamespaceAndRevision(NetworkElementPac.QNAME);
+ // LOG.debug("support necurrent-problem-list=" + this.isNetworkElementCurrentProblemsSupporting12);
+ // LOG.info("Create NE instance {}", InstanceList.QNAME.getLocalName());
+
+ }
+
+ /**
+ * Check capabilities are matching the this specific implementation and create network element
+ * representation if so.
+ *
+ * @param mountPointNodeName as String
+ * @param capabilities of the specific network element
+ * @param netconfNodeDataBroker for the network element specific data
+ * @param webSocketService to forward event notifications
+ * @param databaseService to access the database
+ * @param dcaeProvider to forward problem / change notifications
+ * @return created Object if conditions are OK or null if not.
+ */
+ public static @Nullable ONFCoreNetworkElement12 build(String mountPointNodeName, Capabilities capabilities,
+ DataBroker netconfNodeDataBroker, WebSocketServiceClient webSocketService,
+ HtDatabaseEventsService databaseService, ProviderClient dcaeProvider, @Nullable ProviderClient aotsmClient,
+ MaintenanceService maintenanceService,
+ NotificationDelayService<ProblemNotificationXml> notificationDelayService) {
+
+ if (capabilities.isSupportingNamespaceAndRevision(NetworkElement.QNAME)) {
+ OnfMicrowaveModel onfMicrowaveModel = null;
+
+ if (capabilities.isSupportingNamespaceAndRevision(WrapperMicrowaveModelRev170324.QNAME)) {
+ onfMicrowaveModel = new WrapperMicrowaveModelRev170324();
+ } else if (capabilities.isSupportingNamespaceAndRevision(WrapperMicrowaveModelRev180907.QNAME)) {
+ onfMicrowaveModel = new WrapperMicrowaveModelRev180907();
+ } else if (capabilities.isSupportingNamespaceAndRevision(WrapperMicrowaveModelRev181010.QNAME)) {
+ onfMicrowaveModel = new WrapperMicrowaveModelRev181010();
+ }
+
+ if (onfMicrowaveModel != null) {
+ return new ONFCoreNetworkElement12(mountPointNodeName, capabilities, netconfNodeDataBroker,
+ webSocketService, databaseService, dcaeProvider, aotsmClient, maintenanceService,
+ notificationDelayService, onfMicrowaveModel);
+ }
+ }
+ return null;
+
+ }
+
+ /*-----------------------------------------------------------------------------
+ * Functions
+ */
+
+ /**
+ * DeviceMonitor Prepare check by updating NE state and reading all interfaces.
+ */
+ @Override
+ public void prepareCheck() {
+ synchronized (dmLock) {
+ boolean change = readNetworkElementAndInterfaces();
+ if (change) {
+ int problems = microwaveEventListener.removeAllCurrentProblemsOfNode();
+ List<ProblemNotificationXml> resultList = readAllCurrentProblemsOfNode();
+ microwaveEventListener.initCurrentProblemStatus(resultList);
+ LOG.info("Resync mountpoint {} for device {}. Removed {}. Current problems: {}", getMountPointNodeName(),
+ getUuId(), problems, resultList.size());
+ }
+ }
+ }
+
+ // public boolean checkIfConnectionToMediatorIsOk() -> Shifted to super class
+ // public boolean checkIfConnectionToNeIsOk() -> Shifted to super class
+
+ /*-----------------------------------------------------------------------------
+ * Synchronization
+ */
+
+ // public void initSynchronizationExtension() -> Shifted to super class
+ // private InstanceList readPTPClockInstances() -> Shifted to super class
+
+ /*-----------------------------------------------------------------------------
+ * Services for NE/Device synchronization
+ */
+
+ /**
+ * Handling of specific Notifications from NE, indicating changes and need for synchronization.
+ *
+ * <attribute-value-changed-notification xmlns="urn:onf:params:xml:ns:yang:microwave-model">
+ * <attribute-name>/equipment-pac/equipment-current-problems</attribute-name>
+ * <object-id-ref>CARD-1.1.1.0</object-id-ref> <new-value></new-value>
+ * </attribute-value-changed-notification>
+ * <attribute-value-changed-notification xmlns="urn:onf:params:xml:ns:yang:microwave-model">
+ * <attribute-name>/network-element/extension[value-name="top-level-equipment"]/value</attribute-name>
+ * <object-id-ref>Hybrid-Z</object-id-ref>
+ * <new-value>SHELF-1.1.0.0,IDU-1.55.0.0,ODU-1.56.0.0,IDU-1.65.0.0</new-value>
+ * </attribute-value-changed-notification>
+ */
+
+
+ @Override
+ public void notificationFromNeListener(AttributeValueChangedNotificationXml notificationXml) {
+ notificationQueue.put(notificationXml);
+ }
+
+ @Override
+ public void notificationActor(AttributeValueChangedNotificationXml notificationXml) {
+
+ LOG.debug("Enter change notification listener");
+ if (LOG.isTraceEnabled()) {
+ LOG.trace("Notification: {}", notificationXml);
+ }
+ if (notificationXml.getAttributeName().equals("/equipment-pac/equipment-current-problems")) {
+ syncEquipmentPac(notificationXml.getObjectId());
+ } else if (notificationXml.getAttributeName()
+ .equals("/network-element/extension[value-name=\"top-level-equipment\"]/value")) {
+ initialReadFromNetworkElement();
+ }
+ LOG.debug("Leave change notification listener");
+ }
+
+ /**
+ * Synchronize problems for a specific equipment-pac
+ *
+ * @param uuidString of the equipment-pac
+ */
+ private synchronized void syncEquipmentPac(String uuidString) {
+
+ int problems = microwaveEventListener.removeObjectsCurrentProblemsOfNode(uuidString);
+ LOG.debug("Removed {} problems for uuid {}", problems, uuidString);
+
+ List<ProblemNotificationXml> resultList = equipment.addProblemsofNodeObject(uuidString);
+ microwaveEventListener.initCurrentProblemStatus(resultList);
+ LOG.debug("Added {} problems for uuid {}", resultList.size(), uuidString);
+
+ }
+
+
+ /*-----------------------------------------------------------------------------
+ * Problem/Fault related functions
+ */
+
+ /**
+ * Read during startup all relevant structure and status parameters from device
+ */
+ @Override
+ public synchronized void initialReadFromNetworkElement() {
+ // optionalNe.getLtp().get(0).getLp();
+ LOG.debug("Get info about {}", getMountPointNodeName());
+
+ int problems = microwaveEventListener.removeAllCurrentProblemsOfNode();
+ LOG.debug("Removed all {} problems from database at registration", problems);
+
+ // Step 2.1: access data broker within this mount point
+ LOG.debug("DBRead start");
+
+ // Step 2.2: read ne from data store
+ readNetworkElementAndInterfaces();
+ equipment.readNetworkElementEquipment();
+
+ // Step 2.3: read the existing faults and add to DB
+ List<ProblemNotificationXml> resultList = readAllCurrentProblemsOfNode();
+ equipment.addProblemsofNode(resultList);
+
+ microwaveEventListener.initCurrentProblemStatus(resultList);
+
+ microwaveEventListener.writeEquipment(equipment);
+
+ LOG.info("Found info at {} for device {} number of problems: {}", getMountPointNodeName(), getUuId(),
+ resultList.size());
+ }
+
+ /**
+ * LOG the newly added problems of the interface pac
+ *
+ * @param idxStart
+ * @param uuid
+ * @param resultList
+ */
+ private void debugResultList(String uuid, List<ProblemNotificationXml> resultList, int idxStart) {
+ if (LOG.isDebugEnabled()) {
+ StringBuffer sb = new StringBuffer();
+ int idx = 0;
+ for (int t = idxStart; t < resultList.size(); t++) {
+ sb.append(idx++);
+ sb.append(":{");
+ sb.append(resultList.get(t));
+ sb.append('}');
+ }
+ LOG.debug("Found problems {} {}", uuid, sb.toString());
+ }
+ }
+
+ /**
+ * Read from NetworkElement and verify LTPs have changed. If the NE has changed, update to the new
+ * structure. From initial state it changes also.
+ */
+ private synchronized boolean readNetworkElementAndInterfaces() {
+
+ LOG.debug("Update mountpoint if changed {}", getMountPointNodeName());
+
+ optionalNe = GenericTransactionUtils.readData(getNetconfNodeDataBroker(), LogicalDatastoreType.OPERATIONAL,
+ NETWORKELEMENT_IID);;
+ synchronized (pmLock) {
+ boolean change = false;
+
+ if (optionalNe == null) {
+ LOG.debug("Unable to read NE data for mountpoint {}", getMountPointNodeName());
+ if (!interfaceList.isEmpty()) {
+ interfaceList.clear();
+ interfaceListIterator = null;
+ change = true;
+ }
+
+ } else {
+ LOG.debug("Mountpoint '{}' NE-Name '{}'", getMountPointNodeName(), optionalNe.getName().toString());
+ List<Lp> actualInterfaceList = getLtpList(optionalNe);
+ if (!interfaceList.equals(actualInterfaceList)) {
+ LOG.debug("Mountpoint '{}' Update LTP List. Elements {}", getMountPointNodeName(),
+ actualInterfaceList.size());
+ interfaceList.clear();
+ interfaceList.addAll(actualInterfaceList);
+ interfaceListIterator = null;
+ change = true;
+ }
+ }
+ return change;
+ }
+ }
+
+ /**
+ * Read current problems of AirInterfaces and EthernetContainer according to NE status into DB
+ *
+ * @return List with all problems
+ */
+ private List<ProblemNotificationXml> readAllCurrentProblemsOfNode() {
+
+ // Step 2.3: read the existing faults and add to DB
+ List<ProblemNotificationXml> resultList = new ArrayList<>();
+ int idxStart; // Start index for debug messages
+ UniversalId uuid;
+
+ synchronized (pmLock) {
+ for (Lp ltp : interfaceList) {
+
+ idxStart = resultList.size();
+ uuid = ltp.getUuid();
+ Class<?> lpClass = getLpExtension(ltp);
+
+ ONFLayerProtocolName lpName = ONFLayerProtocolName.valueOf(ltp.getLayerProtocolName());
+
+ microwaveModel.readTheFaultsOfMicrowaveModel(lpName, lpClass, uuid, resultList);
+
+ debugResultList(uuid.getValue(), resultList, idxStart);
+
+ }
+ }
+
+ // Step 2.4: Read other problems from mountpoint
+ if (isNetworkElementCurrentProblemsSupporting12) {
+ idxStart = resultList.size();
+ readNetworkElementCurrentProblems12(resultList);
+ debugResultList("CurrentProblems12", resultList, idxStart);
+ }
+
+ return resultList;
+
+ }
+
+ /**
+ * Get uuid of Optional NE.
+ *
+ * @return Uuid or EMPTY String if optionNE is not available
+ */
+ private String getUuId() {
+ String uuid = EMPTY;
+
+ try {
+ uuid = optionalNe != null ? optionalNe.getUuid() != null ? optionalNe.getUuid().getValue() : EMPTY : EMPTY;
+ } catch (NullPointerException e) {
+ // Unfortunately throws null pointer if not definied
+ }
+ return uuid;
+ }
+
+ /**
+ * Read the NetworkElement part from database.
+ *
+ * @return Optional with NetworkElement or empty
+ */
+ @Nullable
+ private NetworkElement readNetworkElement() {
+ // Step 2.2: construct data and the relative iid
+ // The schema path to identify an instance is
+ // <i>CoreModel-CoreNetworkModule-ObjectClasses/NetworkElement</i>
+ // Read to the config data store
+ return GenericTransactionUtils.readData(getNetconfNodeDataBroker(), LogicalDatastoreType.OPERATIONAL,
+ NETWORKELEMENT_IID);
+ }
+
+ /**
+ * Get from LayProtocolExtensions the related generated ONF Interface PAC class which represents it.
+ *
+ * @param ltp logical termination point
+ * @return Class of InterfacePac
+ */
+ @Nullable
+ private Class<?> getLpExtension(@Nullable Lp ltp) {
+
+ String capability = EMPTY;
+ String revision = EMPTY;
+ String conditionalPackage = EMPTY;
+ Class<?> res = null;
+
+ if (ltp != null) {
+ for (Extension e : getExtensionList(ltp)) {
+ if (e.getValueName().contentEquals("capability")) {
+ capability = e.getValue();
+ int idx = capability.indexOf("?");
+ if (idx != -1) {
+ capability = capability.substring(0, idx);
+ }
+ }
+ if (e.getValueName().contentEquals("revision")) {
+ revision = e.getValue();
+ }
+ if (e.getValueName().contentEquals("conditional-package")) {
+ conditionalPackage = e.getValue();
+ }
+ }
+ }
+ // QName qName =
+ // org.opendaylight.yangtools.yang.common.QName.create("urn:onf:params:xml:ns:yang:microwave-model",
+ // "2017-03-24", "mw-air-interface-pac").intern();
+ LOG.info("LpExtension capability={} revision={} conditionalPackage={}", capability, revision,
+ conditionalPackage);
+ if (!capability.isEmpty() && !revision.isEmpty() && !conditionalPackage.isEmpty()) {
+ try {
+ QName qName = QName.create(capability, revision, conditionalPackage);
+ res = this.microwaveModel.getClassForLtpExtension(qName);
+ } catch (IllegalArgumentException e) {
+ LOG.debug("Can not create QName from ({}{}{}): {}", capability, revision, conditionalPackage,
+ e.getMessage());
+ }
+ }
+ return res;
+ }
+
+ /**
+ * Read element from class that could be not available
+ *
+ * @param ltp layer termination point
+ * @return List with extension parameters or empty list
+ */
+ @Nonnull
+ private static List<Extension> getExtensionList(@Nullable Lp ltp) {
+ if (ltp != null && ltp.getExtension() != null) {
+ return ltp.getExtension();
+ } else {
+ return EMPTYLTPEXTENSIONLIST;
+ }
+ }
+
+ /**
+ * Get List of UUIDs for conditional packages from Networkelement<br>
+ * Possible interfaces are:<br>
+ * MWPS, LTP(MWPS-TTP), MWAirInterfacePac, MicrowaveModel-ObjectClasses-AirInterface<br>
+ * ETH-CTP,LTP(Client), MW_EthernetContainer_Pac<br>
+ * MWS, LTP(MWS-CTP-xD), MWAirInterfaceDiversityPac,
+ * MicrowaveModel-ObjectClasses-AirInterfaceDiversity<br>
+ * MWS, LTP(MWS-TTP), ,MicrowaveModel-ObjectClasses-HybridMwStructure<br>
+ * MWS, LTP(MWS-TTP), ,MicrowaveModel-ObjectClasses-PureEthernetStructure<br>
+ *
+ * @param ne Networkelement
+ * @return Id List, never null.
+ */
+ private static List<Lp> getLtpList(@Nullable NetworkElement ne) {
+
+ List<Lp> res = Collections.synchronizedList(new ArrayList<Lp>());
+
+ if (ne != null) {
+ List<Ltp> ltpRefList = ne.getLtp();
+ if (ltpRefList == null) {
+ LOG.debug("DBRead NE-Interfaces: null");
+ } else {
+ for (Ltp ltRefListE : ltpRefList) {
+ List<Lp> lpList = ltRefListE.getLp();
+ if (lpList == null) {
+ LOG.debug("DBRead NE-Interfaces Reference List: null");
+ } else {
+ for (Lp ltp : lpList) {
+ //// LayerProtocolName layerProtocolName = lpListE.getLayerProtocolName();
+ // UniversalId uuId = lpListE.getUuid();
+ res.add(ltp);
+ }
+ }
+ }
+ }
+ } else {
+ LOG.debug("DBRead NE: null");
+ }
+
+ // ---- Debug
+ if (LOG.isDebugEnabled()) {
+ StringBuffer strBuf = new StringBuffer();
+ for (Lp ltp : res) {
+ if (strBuf.length() > 0) {
+ strBuf.append(", ");
+ }
+ strBuf.append(ltp.getLayerProtocolName().getValue());
+ strBuf.append(':');
+ strBuf.append(ltp.getUuid().getValue());
+ }
+ LOG.debug("DBRead NE-Interfaces: {}", strBuf.toString());
+ }
+ // ---- Debug end
+
+ return res;
+ }
+
+
+ @Nonnull
+ private List<? extends OtnHistoryDataG> readTheHistoricalPerformanceData(Lp lp) {
+ ONFLayerProtocolName lpName = ONFLayerProtocolName.valueOf(lp.getLayerProtocolName());
+
+ return this.microwaveModel.readTheHistoricalPerformanceData(lpName, lp);
+ /*
+ * switch (lpName) { case MWAirInterface: return
+ * readTheHistoricalPerformanceDataOfMwAirInterfacePac(lp);
+ *
+ * case EthernetContainer12: return readTheHistoricalPerformanceDataOfEthernetContainer(lp);
+ *
+ * case EthernetContainer10: case EthernetPhysical: case Ethernet: case TDMContainer: case
+ * Structure: case Unknown: LOG.debug("Do not read HistoricalPM data for {} {}", lpName,
+ * lp.getUuid().getValue()); break; } return new ArrayList<>();
+ */
+ }
+
+ @Override
+ public AllPm getHistoricalPM() {
+
+ synchronized (pmLock) {
+ if (pmLp != null) {
+ LOG.debug("Enter query PM");
+ AllPm allPm = new AllPm();
+ Lp lp = pmLp;
+
+ List<? extends OtnHistoryDataG> resultList = readTheHistoricalPerformanceData(lp);
+ LOG.debug("Got records: {}", resultList.size());
+ // org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.g._874._1.model.rev170320.GranularityPeriodType
+ GranularityPeriodType granularityPeriod;
+ for (OtnHistoryDataG perf : resultList) {
+
+ granularityPeriod = perf.getGranularityPeriod();
+ if (granularityPeriod == null) {
+ granularityPeriod = GranularityPeriodType.Unknown;
+ }
+
+ switch (granularityPeriod) {
+ case Period15Min: {
+ EsHistoricalPerformance15Minutes pm =
+ new EsHistoricalPerformance15Minutes(getMountPointNodeName(), lp)
+ .setHistoricalRecord15Minutes(perf);
+ allPm.add(pm);
+ }
+ break;
+
+ case Period24Hours: {
+ EsHistoricalPerformance24Hours pm =
+ new EsHistoricalPerformance24Hours(getMountPointNodeName(), lp)
+ .setHistoricalRecord24Hours(perf);
+ LOG.debug("Write 24h write to DB");
+ allPm.add(pm);
+ }
+ break;
+
+ default:
+ LOG.warn("Unknown granularity {}", perf.getGranularityPeriod());
+ break;
+
+ }
+ }
+ LOG.debug("Deliver normalized records: {}", allPm.size());
+ return allPm;
+ } else {
+ LOG.debug("Deliver empty, no LTP");
+ return AllPm.getEmpty();
+ }
+ }
+ }
+
+ @Override
+ public void resetPMIterator() {
+ synchronized (pmLock) {
+ interfaceListIterator = interfaceList.iterator();
+ }
+ LOG.debug("PM reset iterator");
+ }
+
+ @Override
+ public boolean hasNext() {
+ boolean res;
+ synchronized (pmLock) {
+ res = interfaceListIterator != null ? interfaceListIterator.hasNext() : false;
+ }
+ LOG.debug("PM hasNext LTP {}", res);
+ return res;
+ }
+
+ @Override
+ public void next() {
+ synchronized (pmLock) {
+ if (interfaceListIterator == null) {
+ pmLp = null;
+ LOG.debug("PM next LTP null");
+ } else {
+ pmLp = interfaceListIterator.next();
+ LOG.debug("PM next LTP {}", pmLp.getLayerProtocolName().getValue());
+ }
+ }
+ }
+
+ @Override
+ public String pmStatusToString() {
+ StringBuffer res = new StringBuffer();
+ synchronized (pmLock) {
+ res.append(pmLp == null ? "no interface" : pmLp.getLayerProtocolName().getValue());
+ for (Lp lp : interfaceList) {
+ res.append("IF:");
+ res.append(lp.getLayerProtocolName().getValue());
+ res.append(" ");
+ }
+ }
+ return res.toString();
+ }
+
+ /**
+ * Remove all entries from list
+ */
+ @Override
+ public int removeAllCurrentProblemsOfNode() {
+ return microwaveEventListener.removeAllCurrentProblemsOfNode();
+ }
+
+ /**
+ * Register the listener
+ */
+ @Override
+ public void doRegisterMicrowaveEventListener(MountPoint mountPoint) {
+ LOG.info("End registration listener for Mountpoint {}", mountPoint.getIdentifier().toString());
+ final Optional<NotificationService> optionalNotificationService =
+ mountPoint.getService(NotificationService.class);
+ final NotificationService notificationService = optionalNotificationService.get();
+ // notificationService.registerNotificationListener(microwaveEventListener);
+ listenerRegistrationresult =
+ notificationService.registerNotificationListener(microwaveModel.getNotificationListener());
+ LOG.info("End registration listener for Mountpoint {} Listener: {} Result: {}",
+ mountPoint.getIdentifier().toString(), optionalNotificationService, listenerRegistrationresult);
+ }
+
+
+ /*------------------------------------------------------------
+ * private function to access database
+ */
+
+ /*-----------------------------------------------------------------------------
+ * Reading problems for the networkElement V1.2
+ */
+
+ private List<ProblemNotificationXml> readNetworkElementCurrentProblems12(List<ProblemNotificationXml> resultList) {
+
+ LOG.info("DBRead Get {} NetworkElementCurrentProblems12", getMountPointNodeName());
+
+ InstanceIdentifier<org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.onf.core.model.conditional.packages.rev170402.NetworkElementPac> networkElementCurrentProblemsIID =
+ InstanceIdentifier.builder(
+ org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.onf.core.model.conditional.packages.rev170402.NetworkElementPac.class)
+ .build();
+
+ // Step 2.3: read to the config data store
+ NetworkElementPac problemPac;
+ NetworkElementCurrentProblems problems;
+ try {
+ problemPac = GenericTransactionUtils.readData(getNetconfNodeDataBroker(), LogicalDatastoreType.OPERATIONAL,
+ networkElementCurrentProblemsIID);
+ problems = problemPac.getNetworkElementCurrentProblems();
+ if (problems == null) {
+ LOG.debug("DBRead no NetworkElementCurrentProblems12");
+ } else if (problems.getCurrentProblemList() == null) {
+ LOG.debug("DBRead empty CurrentProblemList12");
+ } else {
+ for (org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.onf.core.model.conditional.packages.rev170402.network.element.current.problems.g.CurrentProblemList problem : problems
+ .getCurrentProblemList()) {
+ resultList.add(new ProblemNotificationXml(getMountPointNodeName(), problem.getObjectReference(),
+ problem.getProblemName(), InternalSeverity.valueOf(problem.getProblemSeverity()),
+ problem.getSequenceNumber().toString(),
+ InternalDateAndTime.valueOf(problem.getTimeStamp())));
+ }
+ }
+ } catch (Exception e) {
+ LOG.warn("DBRead {} NetworkElementCurrentProblems12 not supported. Message '{}' ", getMountPointNodeName(),
+ e.getMessage());
+ }
+ return resultList;
+
+ }
+
+ @Override
+ public void close() throws Exception {
+ super.close();
+ if (listenerRegistrationresult != null) {
+ listenerRegistrationresult.close();
+ }
+ }
+
+
+
+
+}
diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/ONFCoreNetworkElement12Base.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/ONFCoreNetworkElement12Base.java
new file mode 100644
index 000000000..8fc4c3308
--- /dev/null
+++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/ONFCoreNetworkElement12Base.java
@@ -0,0 +1,232 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 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.base.netconf;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+import java.util.concurrent.CopyOnWriteArrayList;
+
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.internalTypes.InventoryInformation;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.netconf.container.Capabilities;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.netconf.util.GenericTransactionUtils;
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ptp.dataset.rev170208.InstanceList;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ptp.dataset.rev170208.InstanceListKey;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ptp.dataset.rev170208.PortDsEntry;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ptp.dataset.rev170208.instance.list.PortDsList;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ptp.dataset.rev170208.port.ds.entry.PortIdentity;
+import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.NetworkElement;
+import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.extension.g.Extension;
+import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.logical.termination.point.g.Lp;
+import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.onf.core.model.conditional.packages.rev170402.NetworkElementPac;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+
+/**
+ * This class contains the ONF Core model Version 1.2 related functions.
+ * It should import
+ */
+public abstract class ONFCoreNetworkElement12Base extends ONFCoreNetworkElementBase implements ONFCOreNetworkElementCoreData {
+
+ private static final Logger LOG = LoggerFactory.getLogger(ONFCoreNetworkElement12Base.class);
+
+ protected static final List<Extension> EMPTYLTPEXTENSIONLIST = new ArrayList<>();
+ // private static final List<Ltp> EMPTYLTPLIST = new ArrayList<>();
+
+ protected static final InstanceIdentifier<NetworkElement> NETWORKELEMENT_IID = InstanceIdentifier
+ .builder(NetworkElement.class).build();
+
+ protected static final InstanceIdentifier<InstanceList> PTPINSTANCES_IID = InstanceIdentifier
+ .builder(InstanceList.class, new InstanceListKey(1)).build();
+
+ /*-----------------------------------------------------------------------------
+ * Class members
+ */
+
+ // Non specific part. Used by all functions.
+ /** interfaceList is used by PM task and should be synchronized */
+ protected final @Nonnull List<Lp> interfaceList = Collections.synchronizedList(new CopyOnWriteArrayList<>());
+ protected @Nullable NetworkElement optionalNe = null;
+
+ // Performance monitoring specific part
+ /** Lock for the PM access specific elements that could be null */
+ protected final @Nonnull Object pmLock = new Object();
+ protected @Nullable Iterator<Lp> interfaceListIterator = null;
+ /** Actual pmLp used during iteration over interfaces */
+ protected @Nullable Lp pmLp = null;
+
+ // Device monitoring specific part
+ /** Lock for the DM access specific elements that could be null */
+ protected final @Nonnull Object dmLock = new Object();
+
+ protected final boolean isNetworkElementCurrentProblemsSupporting12;
+
+ protected final ONFCoreNetworkElement12Equipment equipment;
+
+ /*
+ * Constructor
+ */
+
+ protected ONFCoreNetworkElement12Base(String mountPointNodeName, DataBroker netconfNodeDataBroker,
+ Capabilities capabilities) {
+ super(mountPointNodeName, netconfNodeDataBroker, capabilities);
+ // TODO Auto-generated constructor stub
+ this.isNetworkElementCurrentProblemsSupporting12 = capabilities.isSupportingNamespaceAndRevision(NetworkElementPac.QNAME);
+ this.equipment = new ONFCoreNetworkElement12Equipment(this, capabilities);
+ LOG.debug("support necurrent-problem-list=" + this.isNetworkElementCurrentProblemsSupporting12);
+ LOG.info("Create NE instance {}", InstanceList.QNAME.getLocalName());
+ }
+
+ /*---------------------------------------------------------------
+ * Getter/ Setter
+ */
+
+ @Override
+ public NetworkElement getOptionalNetworkElement() {
+ return optionalNe;
+ }
+
+
+ /*---------------------------------------------------------------
+ * Device Monitor
+ */
+
+ @Override
+ public boolean checkIfConnectionToMediatorIsOk() {
+ synchronized (dmLock) {
+ return optionalNe != null;
+ }
+ }
+
+ /*
+ * New implementation to interpret status with empty LTP List as notConnected => return false
+ * 30.10.2018 Since this behavior is very specific and implicit for specific NE Types
+ * it needs to be activated by extension or configuration. Change to be disabled at the moment
+ */
+ @Override
+ public boolean checkIfConnectionToNeIsOk() {
+ return true;
+ }
+
+ /*---------------------------------------------------------------
+ * Synchronization
+ */
+
+ /**
+ * Query synchronization information out of NE
+ */
+
+ @Override
+ public void initSynchronizationExtension() {
+ // ClockIdentityType vv;
+ try {
+ if (!getCapabilities().isSupportingNamespaceAndRevision(InstanceList.QNAME)) {
+ LOG.debug("Mountpoint {} does not support PTP", getMountPointNodeName());
+ } else {
+ StringBuffer sb = new StringBuffer();
+ sb.append("NE " + getMountPointNodeName() + " does support synchronisation.\n");
+ InstanceList ptpInstance = readPTPClockInstances();
+ if (ptpInstance != null) {
+ List<PortDsList> dsList = ptpInstance.getPortDsList();
+ if (dsList != null) {
+ int t = 0;
+ for (PortDsEntry portDs : ptpInstance.getPortDsList()) {
+ PortIdentity portId = portDs.getPortIdentity();
+ if (portId != null) {
+ sb.append("Port[");
+ sb.append(portId.getPortNumber());
+ sb.append("]{ ClockId: ");
+ sb.append(portId.getClockIdentity());
+ sb.append(", Portstate: ");
+ sb.append(portDs.getPortState());
+ sb.append("}, ");
+ } else {
+ sb.append("Incomplete port #" + t + ", ");
+ }
+ t++;
+ }
+ } else {
+ sb.append("dsList contains null");
+ }
+ } else {
+ sb.append("ptpInstance equals null");
+ }
+ LOG.trace(sb.toString());
+ }
+ } catch (Exception e) {
+ LOG.info("Inconsistent synchronisation structure: " + e.getMessage());
+ }
+
+ }
+
+ @Nullable
+ private InstanceList readPTPClockInstances() {
+ return GenericTransactionUtils.readData(getNetconfNodeDataBroker(), LogicalDatastoreType.OPERATIONAL,
+ PTPINSTANCES_IID);
+ }
+
+ /*---------------------------------------------------------------
+ * Equipment related functions
+ */
+
+
+ @Override
+ public InventoryInformation getInventoryInformation() {
+ return this.getInventoryInformation(null);
+ }
+
+
+ @Override
+ public @Nonnull InventoryInformation getInventoryInformation(String layerProtocolFilter) {
+ LOG.debug("request inventory information. filter:" + layerProtocolFilter);
+ return this.equipment.getInventoryInformation(getFilteredInterfaceUuidsAsStringList(layerProtocolFilter));
+ }
+
+ /*---------------------------------------------------------------
+ * Other
+ */
+
+ @Override
+ protected List<String> getFilteredInterfaceUuidsAsStringList(String layerProtocolFilter) {
+ List<String> uuids = new ArrayList<>();
+
+ LOG.debug("request inventory information. filter:" + layerProtocolFilter);
+ if (optionalNe != null) {
+ // uuids
+ for (Lp lp : this.interfaceList) {
+ if (layerProtocolFilter == null || layerProtocolFilter.isEmpty()) {
+ uuids.add(lp.getUuid().getValue());
+ } else if (lp.getLayerProtocolName() != null && lp.getLayerProtocolName().getValue() != null
+ && lp.getLayerProtocolName().getValue().equals(layerProtocolFilter)) {
+ uuids.add(lp.getUuid().getValue());
+ }
+ }
+ }
+ LOG.debug("uuids found: {}", uuids);
+ return uuids;
+ }
+
+}
diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/ONFCoreNetworkElement12Equipment.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/ONFCoreNetworkElement12Equipment.java
new file mode 100644
index 000000000..205afc0d3
--- /dev/null
+++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/ONFCoreNetworkElement12Equipment.java
@@ -0,0 +1,293 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 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.base.netconf;
+
+import java.util.ArrayList;
+import java.util.List;
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.internalTypes.InventoryInformation;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.netconf.container.Capabilities;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.netconf.container.ValueNameList;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.netconf.util.GenericTransactionUtils;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.netconf.wrapperc.OnfInterfacePac;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.netconf.wrapperc.WrapperEquipmentPacRev170402;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.database.types.equipment.ExtendedEquipment;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.xml.ProblemNotificationXml;
+import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.Equipment;
+import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.EquipmentKey;
+import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.NetworkElement;
+import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.UniversalId;
+import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.equipment.g.ContainedHolder;
+import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.manufactured.thing.g.EquipmentType;
+import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.manufactured.thing.g.ManufacturerProperties;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Contains equipment related information of ONFCore Network Element
+ */
+public class ONFCoreNetworkElement12Equipment {
+
+ private static final Logger LOG = LoggerFactory.getLogger(ONFCoreNetworkElement12Equipment.class);
+
+ private static final UniversalId EQUIPMENTROOT = new UniversalId("network-element");
+ private static final int EQUIPMENTROOTLEVEL = 0;
+
+ private final ONFCOreNetworkElementCoreData coreData;
+ private final OnfInterfacePac equipmentPac;
+
+ private final ValueNameList extensionList;
+ private final List<UniversalId> topLevelEqUuidList;
+ private final List<ProblemNotificationXml> globalProblemList;
+ private final List<ExtendedEquipment> globalEquipmentList;
+
+ public ONFCoreNetworkElement12Equipment(ONFCOreNetworkElementCoreData coreData, Capabilities capabilities) {
+ LOG.debug("Initialize " + ONFCoreNetworkElement12Equipment.class.getName());
+ this.coreData = coreData;
+ if (capabilities.isSupportingNamespaceAndRevision(WrapperEquipmentPacRev170402.QNAME)) {
+ this.equipmentPac = new WrapperEquipmentPacRev170402(coreData);
+ LOG.debug("Equipement pac supported {}", WrapperEquipmentPacRev170402.QNAME);
+ } else {
+ this.equipmentPac = null;
+ LOG.debug("Equipement pac not supported {}", WrapperEquipmentPacRev170402.QNAME);
+ }
+
+ extensionList = new ValueNameList();
+ topLevelEqUuidList = new ArrayList<>();
+ globalProblemList = new ArrayList<>();
+ globalEquipmentList = new ArrayList<>();
+
+ initClassVars();
+ }
+
+ public void addProblemsofNode(List<ProblemNotificationXml> resultList) {
+ resultList.addAll(globalProblemList);
+ }
+
+ public List<ProblemNotificationXml> addProblemsofNodeObject(String uuidString) {
+ List<ProblemNotificationXml> res = new ArrayList<>();
+
+ if (this.equipmentPac != null) {
+ this.equipmentPac.readTheFaults(new UniversalId(uuidString), res);
+ }
+ return res;
+ }
+
+ public @Nonnull InventoryInformation getInventoryInformation(List<String> uuids) {
+ return getInventoryInformation(this.extensionList, uuids);
+ }
+
+ protected void readNetworkElementEquipment() {
+ doSyncNetworkElementEquipmentToClassVars();
+ }
+
+ public String getMountpoint() {
+ return coreData.getMountpoint();
+ }
+
+ public OnfInterfacePac getEquipmentPac() {
+ return equipmentPac;
+ }
+
+ public List<UniversalId> getTopLevelEqUuidList() {
+ return topLevelEqUuidList;
+ }
+
+ public List<ExtendedEquipment> getEquipmentList() {
+ return globalEquipmentList;
+ }
+
+ public List<Equipment> getEquipmentAll() {
+ List<Equipment> equipmentListAll = new ArrayList<>();
+
+ Equipment equipment = readEquipmentAll();
+ equipmentListAll.add(equipment);
+
+ return equipmentListAll;
+ }
+
+
+ /*
+ * --------------------------------------------------------------------------------- private
+ * functions
+ */
+
+ private void initClassVars() {
+ this.globalProblemList.clear();
+ this.globalEquipmentList.clear();
+ this.extensionList.clear();
+ this.topLevelEqUuidList.clear();
+ }
+
+ private void doSyncNetworkElementEquipmentToClassVars() {
+
+ NetworkElement optionalNe = coreData.getOptionalNetworkElement();
+ initClassVars();
+
+ if (optionalNe != null) {
+ // extract Inventory
+ extensionList.put(optionalNe.getExtension());
+
+ if (!extensionList.isEmpty()) {
+
+ /*
+ * Loop through network element extension to get "top-level-equipment" <extension>
+ * <value-name>top-level-equipment</value-name> <value>1.0.BKP,1.0.WCS</value> </extension> "ipv4"
+ * address
+ */
+ extensionList.getAsUniversalIdList("top-level-equipment", topLevelEqUuidList);
+
+ // If top-level-equipment exists get further information
+ if (topLevelEqUuidList.isEmpty()) {
+ LOG.debug("no top level equipment found");
+ } else {
+ // Read equipment and problems
+ for (UniversalId uuid : topLevelEqUuidList) {
+ recurseReadEquipmentProblems(uuid, EQUIPMENTROOT, EQUIPMENTROOTLEVEL, globalProblemList,
+ globalEquipmentList);
+ }
+ }
+ } else {
+ LOG.debug("extension list is null");
+ }
+ }
+ }
+
+ private void recurseReadEquipmentProblems(UniversalId uuid, UniversalId parentUuid, int treeLevel,
+ List<ProblemNotificationXml> problemList, List<ExtendedEquipment> equipmentList) {
+
+ if (uuid != null) {
+
+ Equipment equipment = this.readEquipment(uuid);
+
+ if (equipment != null) {
+ equipmentList.add(new ExtendedEquipment(parentUuid.getValue(), equipment, treeLevel));
+
+ if (this.equipmentPac != null) {
+ this.equipmentPac.readTheFaults(uuid, problemList);
+
+ List<ContainedHolder> containedHolderListe = equipment.getContainedHolder();
+ if (containedHolderListe != null) {
+ for (ContainedHolder containedHolder : containedHolderListe) {
+ recurseReadEquipmentProblems(containedHolder.getOccupyingFru(), uuid, treeLevel + 1,
+ problemList, equipmentList);
+ }
+ }
+ }
+ }
+ }
+ }
+
+ private @Nonnull InventoryInformation getInventoryInformation(ValueNameList extensions, List<String> uuids) {
+
+ InventoryInformation inventoryInformation = new InventoryInformation();
+
+ // uuids
+ inventoryInformation.setInterfaceUuidList(uuids);
+
+ if (!extensions.isEmpty()) {
+
+ inventoryInformation.setDeviceIpv4(extensions.getOrNull("neIpAddress"));
+
+ // If top-level-equipment exists get further information
+ if (topLevelEqUuidList.isEmpty()) {
+ LOG.debug("no top level equipment found");
+ } else {
+ //
+ if (!globalEquipmentList.isEmpty()) {
+ Equipment e = globalEquipmentList.get(0).getEquipment();
+ if (e.getManufacturedThing() != null) {
+ EquipmentType et;
+ if ((et = e.getManufacturedThing().getEquipmentType()) != null) {
+ inventoryInformation.setType(et.getTypeName());
+ inventoryInformation.setModel(et.getModelIdentifier());
+ }
+ ManufacturerProperties em;
+ if ((em = e.getManufacturedThing().getManufacturerProperties()) != null) {
+ inventoryInformation.setVendor(em.getManufacturerIdentifier());
+ }
+ }
+ }
+ }
+ } else {
+ LOG.debug("extension list is null");
+ }
+
+ LOG.debug("Inventory: {}", inventoryInformation);
+ return inventoryInformation;
+
+ }
+
+
+ /**
+ * Read equipment information
+ *
+ * @param interfacePacUuid uuid as key for Equipment.
+ * @return Equipment or null
+ */
+ private @Nullable Equipment readEquipment(UniversalId interfacePacUuid) {
+
+ final Class<?> clazzPac = Equipment.class;
+
+ LOG.info("DBRead Get equipment for class {} from mountpoint {} for uuid {}", clazzPac.getSimpleName(),
+ coreData.getMountpoint(), interfacePacUuid.getValue());
+
+ InstanceIdentifier<Equipment> equipmentIID =
+ InstanceIdentifier.builder(Equipment.class, new EquipmentKey(interfacePacUuid)).build();
+
+ Equipment res = GenericTransactionUtils.readData(coreData.getDataBroker(), LogicalDatastoreType.OPERATIONAL,
+ equipmentIID);
+
+ return res;
+ }
+
+ /**
+ * Read equipment information
+ *
+ * @param interfacePacUuid uuid as key for Equipment.
+ * @return Equipment or null
+ */
+ private @Nullable Equipment readEquipmentAll() {
+
+ final Class<?> clazzPac = Equipment.class;
+
+ LOG.info("DBRead Get all equipment for class {} from mountpoint {}", clazzPac.getSimpleName(),
+ coreData.getMountpoint());
+
+ InstanceIdentifier<Equipment> equipmentIID = InstanceIdentifier.builder(Equipment.class).build();
+
+ Equipment res = GenericTransactionUtils.readData(coreData.getDataBroker(), LogicalDatastoreType.OPERATIONAL,
+ equipmentIID);
+
+ return res;
+ }
+
+ /**
+ * specific toString()
+ */
+ @Override
+ public String toString() {
+ return "ONFCoreNetworkElement12Equipment [coreData=" + coreData + ", equipmentPac=" + equipmentPac
+ + ", extensions=" + extensionList + ", topLevelEqUuidList=" + topLevelEqUuidList + ", problemList="
+ + globalProblemList + ", equipmentList=" + globalEquipmentList + "]";
+ }
+
+}
diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/ONFCoreNetworkElementBase.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/ONFCoreNetworkElementBase.java
new file mode 100644
index 000000000..e49ff6591
--- /dev/null
+++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/ONFCoreNetworkElementBase.java
@@ -0,0 +1,127 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 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.base.netconf;
+
+import java.util.List;
+import javax.annotation.Nonnull;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.internalTypes.InventoryInformation;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.netconf.container.Capabilities;
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * @author herbert
+ *
+ */
+public abstract class ONFCoreNetworkElementBase implements AutoCloseable, ONFCoreNetworkElementRepresentation {
+
+ private static final Logger LOG = LoggerFactory.getLogger(ONFCoreNetworkElementBase.class);
+
+ protected static final String EMPTY = "";
+
+ private final String mountPointNodeName;
+ private final DataBroker netconfNodeDataBroker;
+ private final Capabilities capabilities;
+ private final boolean isNetworkElementCurrentProblemsSupporting10;
+
+ private @Nonnull InventoryInformation inventoryInformation = new InventoryInformation();
+
+
+ protected ONFCoreNetworkElementBase(String mountPointNodeName, DataBroker netconfNodeDataBroker,
+ Capabilities capabilities) {
+ LOG.info("Create ONFCoreNetworkElementBase");
+ this.mountPointNodeName = mountPointNodeName;
+ this.netconfNodeDataBroker = netconfNodeDataBroker;
+ this.capabilities = capabilities;
+
+ this.isNetworkElementCurrentProblemsSupporting10 = false;
+
+ }
+
+ @Override
+ public String getMountPointNodeName() {
+ return mountPointNodeName;
+ }
+
+ /**
+ * @return the netconfNodeDataBroker
+ */
+ public DataBroker getNetconfNodeDataBroker() {
+ return netconfNodeDataBroker;
+ }
+
+ /**
+ * @return the capabilities
+ */
+ public Capabilities getCapabilities() {
+ return capabilities;
+ }
+
+ /**
+ * @return the isNetworkElementCurrentProblemsSupporting10
+ */
+ public boolean isNetworkElementCurrentProblemsSupporting10() {
+ return isNetworkElementCurrentProblemsSupporting10;
+ }
+
+ public void setInventoryInformation(InventoryInformation newInventoryInformation) {
+ this.inventoryInformation = newInventoryInformation;
+ }
+
+ @Override
+ public InventoryInformation getInventoryInformation() {
+ return getInventoryInformation(null);
+ }
+
+ @Override
+ public InventoryInformation getInventoryInformation(String layerProtocolFilter) {
+ InventoryInformation res = new InventoryInformation(inventoryInformation);
+ res.setInterfaceUuidList(getFilteredInterfaceUuidsAsStringList(layerProtocolFilter));
+
+ return res;
+ }
+
+ @Override
+ public void close() throws Exception {}
+
+ /*---------------------------------------------------------------
+ * Getter/ Setter
+ */
+
+ public String getMountpoint() {
+ return mountPointNodeName;
+ }
+
+ public DataBroker getDataBroker() {
+ return netconfNodeDataBroker;
+ }
+
+ /*-----------------------------------------------------------------------------
+ * Sychronization
+ */
+
+ @Override
+ public void initSynchronizationExtension() {}
+
+ protected @Nonnull abstract List<String> getFilteredInterfaceUuidsAsStringList(String layerProtocolFilter);
+
+}
diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/ONFCoreNetworkElementCallback.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/ONFCoreNetworkElementCallback.java
new file mode 100644
index 000000000..e681ee0a0
--- /dev/null
+++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/ONFCoreNetworkElementCallback.java
@@ -0,0 +1,26 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 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.base.netconf;
+
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.xml.AttributeValueChangedNotificationXml;
+
+public interface ONFCoreNetworkElementCallback {
+
+ public void notificationFromNeListener(AttributeValueChangedNotificationXml notificationXml);
+
+}
diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/ONFCoreNetworkElementFactory.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/ONFCoreNetworkElementFactory.java
new file mode 100644
index 000000000..3fc8b133f
--- /dev/null
+++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/ONFCoreNetworkElementFactory.java
@@ -0,0 +1,87 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 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.base.netconf;
+
+import com.google.common.base.Optional;
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.netconf.container.Capabilities;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.toggleAlarmFilter.NotificationDelayService;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.ProviderClient;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.database.service.HtDatabaseEventsService;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.xml.ProblemNotificationXml;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.xml.WebSocketServiceClient;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.maintenance.MaintenanceService;
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction;
+import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.NetconfNode;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.NetconfNodeConnectionStatus.ConnectionStatus;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Create a Network Element representation according to the capability
+ * information. The capabilities are more than an ODL-QName. After the ? other
+ * terms than "revision" are provided.
+ *
+ */
+public class ONFCoreNetworkElementFactory {
+
+ private static final Logger LOG = LoggerFactory.getLogger(ONFCoreNetworkElementFactory.class);
+
+ @SuppressWarnings("deprecation")
+ public static @Nonnull ONFCoreNetworkElementRepresentation create(String mountPointNodeName, DataBroker dataBroker,
+ WebSocketServiceClient webSocketService, HtDatabaseEventsService databaseService,
+ InstanceIdentifier<Node> instanceIdentifier, DataBroker mountpointDataBroker, ProviderClient dcaeProvider,
+ @Nullable ProviderClient aotsmClient, MaintenanceService maintenanceService,
+ NotificationDelayService<ProblemNotificationXml> notificationDelayService) {
+
+ ONFCoreNetworkElementRepresentation res = null;
+ try (ReadOnlyTransaction tx = dataBroker.newReadOnlyTransaction();){
+ Optional<Node> nodeOption = tx.read(LogicalDatastoreType.OPERATIONAL, instanceIdentifier).checkedGet();
+ if (nodeOption.isPresent()) {
+ Node node = nodeOption.get();
+ NetconfNode nnode = node.augmentation(NetconfNode.class);
+ if (nnode != null) {
+ ConnectionStatus csts = nnode.getConnectionStatus();
+ if (csts == ConnectionStatus.Connected) {
+ Capabilities capabilities = new Capabilities(nnode);
+ LOG.info("Mountpoint {} capabilities {}", mountPointNodeName, capabilities);
+ res = ONFCoreNetworkElement12.build(mountPointNodeName, capabilities, mountpointDataBroker,
+ webSocketService, databaseService, dcaeProvider, aotsmClient, maintenanceService,
+ notificationDelayService);
+ LOG.info("ONFCoreNetworkElementRepresentation12 value is not null? " + (res != null));
+ }
+ }
+ }
+ tx.close();
+ } catch (ReadFailedException | IllegalArgumentException e) {
+ LOG.warn("Can not generate specific NE Version representation. ", e);
+ }
+ if (res == null) {
+ res = new ONFCoreEmpty(mountPointNodeName);
+ }
+ LOG.info("Mointpoint {} started as {}", mountPointNodeName, res.getClass().getSimpleName());
+ return res;
+ }
+
+}
diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/ONFCoreNetworkElementRepresentation.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/ONFCoreNetworkElementRepresentation.java
new file mode 100644
index 000000000..c4fc9d01f
--- /dev/null
+++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/ONFCoreNetworkElementRepresentation.java
@@ -0,0 +1,55 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 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.base.netconf;
+
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.internalTypes.InventoryInformation;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.netconf.container.AllPm;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.devicemonitor.impl.DeviceMonitoredNe;
+import org.opendaylight.controller.md.sal.binding.api.MountPoint;
+
+public interface ONFCoreNetworkElementRepresentation extends DeviceMonitoredNe {
+
+ /**
+ * Read during startup all relevant structure and status parameters from device.
+ * Remove all currentAlarms, read structure from networkElement with all interfacePacs, read current alarm status
+ */
+ public void initialReadFromNetworkElement();
+
+ public String getMountPointNodeName();
+
+ public void resetPMIterator();
+
+ public boolean hasNext();
+
+ public void next();
+
+ public AllPm getHistoricalPM();
+
+ public String pmStatusToString();
+
+ public int removeAllCurrentProblemsOfNode();
+
+ public void doRegisterMicrowaveEventListener(MountPoint mountPoint);
+
+ public void initSynchronizationExtension();
+
+ public InventoryInformation getInventoryInformation();
+
+ public InventoryInformation getInventoryInformation(String layerProtocolFilter);
+
+}
diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/container/AllPm.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/container/AllPm.java
new file mode 100644
index 000000000..196493cde
--- /dev/null
+++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/container/AllPm.java
@@ -0,0 +1,59 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 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.base.netconf.container;
+
+import java.util.ArrayList;
+import java.util.List;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.performancemanager.impl.database.types.EsHistoricalPerformance15Minutes;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.performancemanager.impl.database.types.EsHistoricalPerformance24Hours;
+
+public class AllPm {
+
+ private final static AllPm EMPTY = new AllPm();
+
+ private final List<EsHistoricalPerformance15Minutes> pm15 = new ArrayList<>();
+ private final List<EsHistoricalPerformance24Hours> pm24 = new ArrayList<>();
+
+ public void add(EsHistoricalPerformance15Minutes pm) {
+ pm15.add(pm);
+ }
+
+ public void add(EsHistoricalPerformance24Hours pm) {
+ pm24.add(pm);
+ }
+
+ public List<EsHistoricalPerformance15Minutes> getPm15() {
+ return pm15;
+ }
+
+ public List<EsHistoricalPerformance24Hours> getPm24() {
+ return pm24;
+ }
+
+ public Object size() {
+ return pm15.size()+pm24.size();
+ }
+
+ public static AllPm getEmpty() {
+ return EMPTY;
+ }
+
+}
diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/container/Capabilities.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/container/Capabilities.java
new file mode 100644
index 000000000..008a8fae7
--- /dev/null
+++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/container/Capabilities.java
@@ -0,0 +1,173 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 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==========================================================================
+ ******************************************************************************/
+/**
+ * Convert capabilities of netconfnode into internal format. Boron and Carbon are providing
+ * different versions
+ */
+package org.onap.ccsdk.features.sdnr.wt.devicemanager.base.netconf.container;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Date;
+import java.util.List;
+import java.util.Optional;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.NetconfNode;
+import org.opendaylight.yangtools.yang.common.QName;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class Capabilities {
+
+ private static final Logger LOG = LoggerFactory.getLogger(Capabilities.class);
+ private static final String INTERFACE_AVAILABLECAPABILITY =
+ "org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.netconf.node.connection.status.available.capabilities.AvailableCapability";
+
+ private final List<String> capabilities = new ArrayList<>();
+ private final DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
+
+ public Capabilities() {
+
+ }
+
+ public Capabilities(NetconfNode nnode) {
+ LOG.info("Create Capabilities constructor");
+
+ if (nnode != null) {
+ constructor(nnode.getAvailableCapabilities().getAvailableCapability());
+ }
+ }
+
+ /**
+ * Does all construction steps
+ *
+ * @param pcapabilities with a list of capabilities. <br>
+ * Type could be <br>
+ * - Boron: List<code><String></code> <br>
+ * - Carbon: List<AvailableCapability>
+ */
+ private void constructor(List<?> pcapabilities) {
+ for (Object capability : pcapabilities) {
+ if (LOG.isTraceEnabled()) {
+ LOG.trace("capability class: {} Interfaces: {}", capability.getClass().getName(),
+ Arrays.toString(capability.getClass().getInterfaces()));
+ }
+ if (capability instanceof String) { // ODL Boron specific
+ this.capabilities.add((String) capability);
+ } else if (hasInterface(capability, INTERFACE_AVAILABLECAPABILITY)) { // Carbon specific part .. handled via
+ // generic
+ try {
+ Method method = capability.getClass().getDeclaredMethod("getCapability");
+ this.capabilities.add(method.invoke(capability).toString());
+ } catch (NoSuchMethodException | SecurityException | IllegalAccessException | IllegalArgumentException
+ | InvocationTargetException e) {
+ LOG.warn("Unknown capability class leads to a problem", e);
+ }
+ } else {
+ LOG.warn("Unknown capability class: {}", capability.getClass(),
+ Arrays.toString(capability.getClass().getInterfaces()));
+ }
+ }
+ }
+
+ /**
+ * check if namespace is supported by given capabilites
+ *
+ * @param theCapability Capability to search
+ * @return true if available
+ */
+ @Deprecated
+ public boolean isSupportingNamespace(QName theCapability) {
+ String theNameSpace = theCapability.getNamespace().toString();
+ for (String capability : capabilities) {
+ if (capability.contains(theNameSpace)) {
+ LOG.trace("Check {} against {}", capability, theNameSpace);
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ * check if the namespace and its revision are supported by the given capabilities
+ *
+ * @param qCapability capability from the model
+ * @return true if supporting the model
+ */
+ public boolean isSupportingNamespaceAndRevision(QName qCapability) {
+ String namespace = qCapability.getNamespace().toString();
+ String revision;
+ Object revisionObject = qCapability.getRevision();
+ if (revisionObject instanceof Optional) {
+ if (((Optional<?>) revisionObject).isPresent()) {
+ revisionObject = ((Optional<?>) revisionObject).get();
+ LOG.info("Unwrapp Optional: {}", revisionObject.getClass());
+ }
+ }
+ if (revisionObject instanceof String) {
+ revision = (String) revisionObject;
+ } else if (revisionObject instanceof Date) {
+ revision = formatter.format((Date) revisionObject);
+ } else {
+ revision = revisionObject.toString();
+ LOG.warn("Revision number type not supported. Class:{} String:{}", revisionObject.getClass().getName(),
+ revisionObject);
+ }
+ for (String capability : capabilities) {
+ if (capability.contains(namespace) && capability.contains(revision)) {
+ LOG.trace("Model namespace {}?[revision {}]", namespace, revision);
+ return true;
+ }
+ }
+ return false;
+ }
+
+
+ public void add(String qname) {
+ capabilities.add(qname);
+ }
+
+ @Override
+ public String toString() {
+ return "Capabilities [capabilities=" + capabilities + "]";
+ }
+
+ /**
+ * Check if object is proxy and has specific interface
+ *
+ * @param object Name of the object to verify
+ * @param interfaceName is the name of the interface
+ * @return boolean accordingly
+ */
+ static boolean hasInterface(Object object, String interfaceName) {
+ if (object instanceof Proxy) {
+ Class<?>[] interfaces = object.getClass().getInterfaces();
+ for (Class<?> i : interfaces) {
+ if (i.getName().equals(interfaceName)) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+}
diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/container/ExtendedAirInterfaceHistoricalPerformanceType12.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/container/ExtendedAirInterfaceHistoricalPerformanceType12.java
new file mode 100644
index 000000000..470ddab80
--- /dev/null
+++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/container/ExtendedAirInterfaceHistoricalPerformanceType12.java
@@ -0,0 +1,105 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 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.base.netconf.container;
+
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.netconf.util.LinkIdentifyingObject;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DateAndTime;
+import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.g._874._1.model.rev170320.GranularityPeriodType;
+import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.g._874._1.model.rev170320.ObjectIdentifier;
+import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.g._874._1.model.rev170320.OtnHistoryDataG;
+import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.AirInterfaceConfigurationG;
+import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.AirInterfaceHistoricalPerformanceTypeG;
+import org.opendaylight.yangtools.yang.binding.DataContainer;
+
+public class ExtendedAirInterfaceHistoricalPerformanceType12 implements OtnHistoryDataG, LinkIdentifyingObject {
+
+ private final AirInterfaceHistoricalPerformanceTypeG airInterfaceHistoricalPerformanceType;
+ private final AirInterfaceConfigurationG airInterfaceConfiguration;
+
+ public ExtendedAirInterfaceHistoricalPerformanceType12(AirInterfaceHistoricalPerformanceTypeG data, AirInterfaceConfigurationG conf) {
+ this.airInterfaceHistoricalPerformanceType = data;
+ this.airInterfaceConfiguration = conf;
+ }
+
+
+ public AirInterfaceHistoricalPerformanceTypeG getAirInterfaceHistoricalPerformanceType() {
+ return airInterfaceHistoricalPerformanceType;
+ }
+
+
+ public AirInterfaceConfigurationG getAirInterfaceConfiguration() {
+ return airInterfaceConfiguration;
+ }
+
+
+ @Override
+ public Class<? extends DataContainer> getImplementedInterface() {
+ return airInterfaceHistoricalPerformanceType.getImplementedInterface();
+ }
+
+ @Override
+ public String getHistoryDataId() {
+ return airInterfaceHistoricalPerformanceType.getHistoryDataId();
+ }
+
+ @Override
+ public DateAndTime getPeriodEndTime() {
+ return airInterfaceHistoricalPerformanceType.getPeriodEndTime();
+ }
+
+
+ @Override
+ public GranularityPeriodType getGranularityPeriod() {
+ return airInterfaceHistoricalPerformanceType.getGranularityPeriod();
+ }
+
+
+ @Override
+ public ObjectIdentifier getObjectClass() {
+ return airInterfaceHistoricalPerformanceType.getObjectClass();
+ }
+
+
+ @Override
+ public ObjectIdentifier getNameBinding() {
+ return airInterfaceHistoricalPerformanceType.getNameBinding();
+ }
+
+ @Override
+ public Boolean isSuspectIntervalFlag() {
+ return airInterfaceHistoricalPerformanceType.isSuspectIntervalFlag();
+ }
+
+ @Override
+ public String getSignalId() {
+ return airInterfaceConfiguration.getRadioSignalId();
+ }
+
+
+ @Override
+ public String toString() {
+ return "ExtendedAirInterfaceHistoricalPerformanceType [airInterfaceHistoricalPerformanceType="
+ + airInterfaceHistoricalPerformanceType + ", airInterfaceConfiguration=" + airInterfaceConfiguration
+ + "]";
+ }
+
+
+
+
+
+}
diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/container/ExtendedAirInterfaceHistoricalPerformanceType1211.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/container/ExtendedAirInterfaceHistoricalPerformanceType1211.java
new file mode 100644
index 000000000..115e20e17
--- /dev/null
+++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/container/ExtendedAirInterfaceHistoricalPerformanceType1211.java
@@ -0,0 +1,106 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 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.base.netconf.container;
+
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.netconf.util.LinkIdentifyingObject;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DateAndTime;
+import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.g._874._1.model.rev170320.GranularityPeriodType;
+import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.g._874._1.model.rev170320.ObjectIdentifier;
+import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.g._874._1.model.rev170320.OtnHistoryDataG;
+import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.AirInterfaceConfigurationG;
+import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.AirInterfaceHistoricalPerformanceTypeG;
+import org.opendaylight.yangtools.yang.binding.DataContainer;
+
+public class ExtendedAirInterfaceHistoricalPerformanceType1211 implements OtnHistoryDataG, LinkIdentifyingObject {
+
+ private final AirInterfaceHistoricalPerformanceTypeG airInterfaceHistoricalPerformanceType;
+ private final AirInterfaceConfigurationG airInterfaceConfiguration;
+
+ public ExtendedAirInterfaceHistoricalPerformanceType1211(AirInterfaceHistoricalPerformanceTypeG data, AirInterfaceConfigurationG conf) {
+ this.airInterfaceHistoricalPerformanceType = data;
+ this.airInterfaceConfiguration = conf;
+ }
+
+
+ public AirInterfaceHistoricalPerformanceTypeG getAirInterfaceHistoricalPerformanceType() {
+ return airInterfaceHistoricalPerformanceType;
+ }
+
+
+ public AirInterfaceConfigurationG getAirInterfaceConfiguration() {
+ return airInterfaceConfiguration;
+ }
+
+
+ @Override
+ public Class<? extends DataContainer> getImplementedInterface() {
+ return airInterfaceHistoricalPerformanceType.getImplementedInterface();
+ }
+
+ @Override
+ public String getHistoryDataId() {
+ return airInterfaceHistoricalPerformanceType.getHistoryDataId();
+ }
+
+ @Override
+ public DateAndTime getPeriodEndTime() {
+ return airInterfaceHistoricalPerformanceType.getPeriodEndTime();
+ }
+
+
+ @Override
+ public GranularityPeriodType getGranularityPeriod() {
+ return airInterfaceHistoricalPerformanceType.getGranularityPeriod();
+ }
+
+
+ @Override
+ public ObjectIdentifier getObjectClass() {
+ return airInterfaceHistoricalPerformanceType.getObjectClass();
+ }
+
+
+ @Override
+ public ObjectIdentifier getNameBinding() {
+ return airInterfaceHistoricalPerformanceType.getNameBinding();
+ }
+
+ @Override
+ public Boolean isSuspectIntervalFlag() {
+ return airInterfaceHistoricalPerformanceType.isSuspectIntervalFlag();
+ }
+
+ @SuppressWarnings("deprecation")
+ @Override
+ public String getSignalId() {
+ return airInterfaceConfiguration.getRadioSignalId();
+ }
+
+
+ @Override
+ public String toString() {
+ return "ExtendedAirInterfaceHistoricalPerformanceType [airInterfaceHistoricalPerformanceType="
+ + airInterfaceHistoricalPerformanceType + ", airInterfaceConfiguration=" + airInterfaceConfiguration
+ + "]";
+ }
+
+
+
+
+
+}
diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/container/ExtendedAirInterfaceHistoricalPerformanceType1211p.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/container/ExtendedAirInterfaceHistoricalPerformanceType1211p.java
new file mode 100644
index 000000000..abac75fed
--- /dev/null
+++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/container/ExtendedAirInterfaceHistoricalPerformanceType1211p.java
@@ -0,0 +1,106 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 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.base.netconf.container;
+
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.netconf.util.LinkIdentifyingObject;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DateAndTime;
+import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.g._874._1.model.rev170320.GranularityPeriodType;
+import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.g._874._1.model.rev170320.ObjectIdentifier;
+import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.g._874._1.model.rev170320.OtnHistoryDataG;
+import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.AirInterfaceConfigurationG;
+import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.AirInterfaceHistoricalPerformanceTypeG;
+import org.opendaylight.yangtools.yang.binding.DataContainer;
+
+public class ExtendedAirInterfaceHistoricalPerformanceType1211p implements OtnHistoryDataG, LinkIdentifyingObject {
+
+ private final AirInterfaceHistoricalPerformanceTypeG airInterfaceHistoricalPerformanceType;
+ private final AirInterfaceConfigurationG airInterfaceConfiguration;
+
+ public ExtendedAirInterfaceHistoricalPerformanceType1211p(AirInterfaceHistoricalPerformanceTypeG data, AirInterfaceConfigurationG conf) {
+ this.airInterfaceHistoricalPerformanceType = data;
+ this.airInterfaceConfiguration = conf;
+ }
+
+
+ public AirInterfaceHistoricalPerformanceTypeG getAirInterfaceHistoricalPerformanceType() {
+ return airInterfaceHistoricalPerformanceType;
+ }
+
+
+ public AirInterfaceConfigurationG getAirInterfaceConfiguration() {
+ return airInterfaceConfiguration;
+ }
+
+
+ @Override
+ public Class<? extends DataContainer> getImplementedInterface() {
+ return airInterfaceHistoricalPerformanceType.getImplementedInterface();
+ }
+
+ @Override
+ public String getHistoryDataId() {
+ return airInterfaceHistoricalPerformanceType.getHistoryDataId();
+ }
+
+ @Override
+ public DateAndTime getPeriodEndTime() {
+ return airInterfaceHistoricalPerformanceType.getPeriodEndTime();
+ }
+
+
+ @Override
+ public GranularityPeriodType getGranularityPeriod() {
+ return airInterfaceHistoricalPerformanceType.getGranularityPeriod();
+ }
+
+
+ @Override
+ public ObjectIdentifier getObjectClass() {
+ return airInterfaceHistoricalPerformanceType.getObjectClass();
+ }
+
+
+ @Override
+ public ObjectIdentifier getNameBinding() {
+ return airInterfaceHistoricalPerformanceType.getNameBinding();
+ }
+
+ @Override
+ public Boolean isSuspectIntervalFlag() {
+ return airInterfaceHistoricalPerformanceType.isSuspectIntervalFlag();
+ }
+
+ @SuppressWarnings("deprecation")
+ @Override
+ public String getSignalId() {
+ return airInterfaceConfiguration.getRadioSignalId();
+ }
+
+
+ @Override
+ public String toString() {
+ return "ExtendedAirInterfaceHistoricalPerformanceType [airInterfaceHistoricalPerformanceType="
+ + airInterfaceHistoricalPerformanceType + ", airInterfaceConfiguration=" + airInterfaceConfiguration
+ + "]";
+ }
+
+
+
+
+
+}
diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/container/ONFLayerProtocolName.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/container/ONFLayerProtocolName.java
new file mode 100644
index 000000000..ece7e7aa1
--- /dev/null
+++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/container/ONFLayerProtocolName.java
@@ -0,0 +1,57 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 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.base.netconf.container;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public enum ONFLayerProtocolName {
+
+ MWAirInterface("MWPS"), //V1.0 + V1.2
+ EthernetContainer10("ETH-CTP"), //V1.0
+ EthernetContainer12("ETC"), //V1.2 + V1.2.1.1
+ EthernetPhysical("ETY"), //V1.2
+ TDMContainer("TDM"), //V1.2
+ Structure("MWS"), //V1.0 + V1.2
+ Ethernet("ETH"), //V1.2
+ Unknown("");
+
+ private static final Logger LOG = LoggerFactory.getLogger(ONFLayerProtocolName.class);
+
+ private final String myLayerProtocolName;
+
+ ONFLayerProtocolName( String myLayerProtocolName ) {
+ this.myLayerProtocolName = myLayerProtocolName;
+ }
+
+ public boolean is( org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.LayerProtocolName onfName ) {
+ return myLayerProtocolName.equals(onfName.getValue());
+ }
+
+ public static ONFLayerProtocolName valueOf( org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.LayerProtocolName onfName ) {
+ for (ONFLayerProtocolName protocol : ONFLayerProtocolName.values()) {
+ if (protocol.is(onfName)) {
+ return protocol;
+ }
+ }
+ LOG.info("Can not map {}. Use Unknown",onfName.getValue() );
+ return Unknown;
+ }
+
+}
+
diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/container/ValueNameList.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/container/ValueNameList.java
new file mode 100644
index 000000000..1e0156c20
--- /dev/null
+++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/container/ValueNameList.java
@@ -0,0 +1,84 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 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.base.netconf.container;
+
+import java.util.HashMap;
+import java.util.List;
+
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
+
+import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.UniversalId;
+import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.extension.g.Extension;
+
+/**
+ * ValueNameList is an access Wrapper to NETCONF Extension lists
+ * Class is a specialized HashMap.
+ */
+public class ValueNameList extends HashMap<String, String> {
+
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * Create ValueNameList for NETCONF extensions
+ * @param extensionList Parameters as received from device. Could be null.
+ */
+ public void put(@Nullable List<Extension> extensionList) {
+
+ if (extensionList != null) {
+ String name;
+ String value;
+
+ for (Extension e : extensionList) {
+ name = e.getValueName();
+ value = e.getValue();
+ if (name != null && value != null) {
+ put(name, value);
+ }
+ }
+ }
+ }
+
+ /**
+ * Return value or null
+ * @param name key for element
+ * @return value if key exists; if not nul
+ */
+ public String getOrNull(String name) {
+ return containsKey(name) ? get(name) : null;
+ }
+
+ /**
+ * Get element as id list
+ * @param name key of element
+ * @param topLevelEqUuidList as input to add elements
+ * @return List<UniversalId>
+ */
+ public @Nonnull List<UniversalId> getAsUniversalIdList(String name, List<UniversalId> topLevelEqUuidList) {
+ if (containsKey(name)) {
+ String[] result = get(name).split(",\\s*");
+ if (result.length > 0) {
+ for (String e : result) {
+ topLevelEqUuidList.add(new UniversalId(e));
+ }
+ }
+ }
+ return topLevelEqUuidList;
+ }
+
+}
diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/util/GenericTransactionUtils.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/util/GenericTransactionUtils.java
new file mode 100644
index 000000000..83063a05a
--- /dev/null
+++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/util/GenericTransactionUtils.java
@@ -0,0 +1,164 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 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.base.netconf.util;
+
+import java.util.NoSuchElementException;
+import java.util.concurrent.CancellationException;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.concurrent.atomic.AtomicReference;
+import javax.annotation.Nullable;
+import org.apache.commons.lang3.exception.ExceptionUtils;
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction;
+import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
+import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
+import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
+import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import com.google.common.base.Optional;
+import com.google.common.base.Preconditions;
+import com.google.common.util.concurrent.CheckedFuture;
+
+@SuppressWarnings("deprecation")
+public final class GenericTransactionUtils {
+ static final Logger LOG = LoggerFactory.getLogger(GenericTransactionUtils.class);
+
+ public static <T extends DataObject> boolean writeData(DataBroker dataBroker,
+ LogicalDatastoreType logicalDatastoreType, InstanceIdentifier<T> iid, T dataObject, boolean isAdd) {
+ Preconditions.checkNotNull(dataBroker);
+ WriteTransaction modification = dataBroker.newWriteOnlyTransaction();
+ if (isAdd) {
+ if (dataObject == null) {
+ LOG.warn("Invalid attempt to add a non-existent object to path {}", iid);
+ return false;
+ }
+ modification.merge(logicalDatastoreType, iid, dataObject, true /* createMissingParents */);
+ } else {
+ modification.delete(LogicalDatastoreType.CONFIGURATION, iid);
+ }
+ CheckedFuture<Void, TransactionCommitFailedException> commitFuture = modification.submit();
+ try {
+ commitFuture.checkedGet();
+ LOG.debug("Transaction success for {} of object {}", isAdd ? "add" : "delete", dataObject);
+ return true;
+ } catch (Exception e) {
+ LOG.warn("Transaction failed with error {} for {} of object {}", e.getMessage(), isAdd ? "add" : "delete",
+ dataObject);
+ modification.cancel();
+ return false;
+ }
+ }
+
+ /**
+ * Deliver the data back or null. Warning
+ *
+ * @param <T> SubType of the DataObject to be handled
+ * @param dataBroker for accessing data
+ * @param dataStoreType to address datastore
+ * @param iid id to access data
+ * @return null or object
+ */
+ @Nullable
+ public static <T extends DataObject> T readData(DataBroker dataBroker, LogicalDatastoreType dataStoreType,
+ InstanceIdentifier<T> iid) {
+
+ AtomicBoolean noErrorIndication = new AtomicBoolean();
+ AtomicReference<String> statusText = new AtomicReference<>();
+
+ T obj = readDataOptionalWithStatus(dataBroker, dataStoreType, iid, noErrorIndication, statusText);
+
+ if (!noErrorIndication.get()) {
+ LOG.warn("Read transaction for identifier " + iid + " failed with status " + statusText.get());
+ }
+
+ return obj;
+ }
+
+ /**
+ * Deliver the data back or null
+ *
+ * @param <T> SubType of the DataObject to be handled
+ * @param dataBroker for accessing data
+ * @param dataStoreType to address datastore
+ * @param iid id to access data
+ * @param noErrorIndication (Output) true if data could be read and are available and is not null
+ * @param statusIndicator (Output) String with status indications during the read.
+ * @return null or object
+ */
+ @Nullable
+ public static <T extends DataObject> T readDataOptionalWithStatus(DataBroker dataBroker,
+ LogicalDatastoreType dataStoreType, InstanceIdentifier<T> iid, AtomicBoolean noErrorIndication,
+ AtomicReference<String> statusIndicator) {
+
+ T data = null;
+ noErrorIndication.set(false);
+
+ statusIndicator.set("Preconditions");
+ Preconditions.checkNotNull(dataBroker);
+
+ int retry = 0;
+ int retryDelayMilliseconds = 2000;
+ int maxRetries = 5; // 0 no Retry
+
+ do {
+ if (retry > 0) {
+ try {
+ LOG.debug("Sleep {}ms", retryDelayMilliseconds);
+ Thread.sleep(retryDelayMilliseconds);
+ } catch (InterruptedException e) {
+ LOG.debug("Sleep interrupted", e);
+ Thread.currentThread().interrupt();
+ }
+ }
+
+ LOG.debug("Sending message with retry {} ", retry);
+ statusIndicator.set("Create Read Transaction");
+
+ try (ReadOnlyTransaction readTransaction = dataBroker.newReadOnlyTransaction();) {
+ CheckedFuture<Optional<T>, ReadFailedException> od = readTransaction.read(dataStoreType, iid);
+ statusIndicator.set("Read done");
+ if (od != null) {
+ statusIndicator.set("Unwrap checkFuture done");
+ Optional<T> optionalData = od.get();
+ if (optionalData != null) {
+ statusIndicator.set("Unwrap optional done");
+ data = optionalData.orNull();
+ statusIndicator.set("Read transaction done");
+ noErrorIndication.set(true);
+ }
+ }
+
+ readTransaction.close();
+ } catch (CancellationException | ExecutionException | InterruptedException | NoSuchElementException e) {
+ statusIndicator.set(ExceptionUtils.getStackTrace(e));
+ if (e instanceof InterruptedException) {
+ Thread.currentThread().interrupt();
+ }
+ }
+
+ } while (noErrorIndication.get() == false && retry++ < maxRetries);
+
+ return data;
+ }
+
+
+}
diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/util/LinkIdentifyingObject.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/util/LinkIdentifyingObject.java
new file mode 100644
index 000000000..7c4f7e102
--- /dev/null
+++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/util/LinkIdentifyingObject.java
@@ -0,0 +1,24 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 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.base.netconf.util;
+
+public interface LinkIdentifyingObject {
+
+ public String getSignalId();
+
+}
diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/util/NetconfTimeStamp.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/util/NetconfTimeStamp.java
new file mode 100644
index 000000000..a9e451a39
--- /dev/null
+++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/util/NetconfTimeStamp.java
@@ -0,0 +1,255 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 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.base.netconf.util;
+
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.TimeZone;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DateAndTime;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Function is handling the NETCONF and the format used by database and restconf communication.
+ *
+ * Input supported for the formats used in NETCONF messages:
+ *
+ * Format1 ISO 8601 2017-01-18T11:44:49.482-05:00
+ *
+ * Format2 NETCONF - pattern from ietf-yang-types "2013-07-15" Pattern:
+ * "\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d+)?(Z|[\+\-](\d{2}):(\d{2}))"
+ *
+ * Format3 NETCONF DateAndTime CoreModel-CoreFoundationModule-TypeDefinitions vom
+ * 2016-07-01 Example1: 20170118114449.1Z Example2: 20170118114449.1-0500 Pattern:
+ * "\d{4}\d{2}\d{2}\d{2}\d{2}\d{2}.\d+?(Z|[\+\-](\d{2})(\d{2}))" typedef DateAndTime { description
+ * "This primitive type defines the date and time according to the following structure:
+ * 'yyyyMMddhhmmss.s[Z|{+|-}HHMm]' where: yyyy '0000'..'9999' year MM '01'..'12' month dd '01'..'31'
+ * day hh '00'..'23' hour mm '00'..'59' minute ss '00'..'59' second s '.0'..'.9' tenth of second
+ * (set to '.0' if EMS or NE cannot support this granularity) Z 'Z' indicates UTC (rather than local
+ * time) {+|-} '+' or '-' delta from UTC HH '00'..'23' time zone difference in hours Mm '00'..'59'
+ * time zone difference in minutes."; type string; } Format4 E/// specific Example1:
+ * 2017-01-23T13:32:38-05:00 Example2: 2017-01-23T13:32-05:00
+ *
+ * Input formats netconfTime as String according the formats given above
+ *
+ * Return format is String in ISO8601 Format for database and presentation.
+ *
+ * Example formats:
+ * 1) ISO8601. Example 2017-01-18T11:44:49.482-05:00
+ * 2) Microwave ONF. Examples 20170118114449.1Z, 20170118114449.1-0500
+ * 3.1) Ericson. Example: 2017-01-23T13:32:38-05:00
+ * 3.2) Ericson. Example: 2017-01-23T13:32-05:00
+ * Always 10 Groups,
+ * 1:Year 2:Month 3:day 4:Hour 5:minute 6:optional sec 7:optional ms 8:optional Z or 9:offset
+ * signedhour 10:min
+ *
+ * Template:
+ * private static final NetconfTimeStamp NETCONFTIME_CONVERTER = NetconfTimeStamp.getConverter();
+ */
+
+public class NetconfTimeStamp {
+ private static final Logger LOG = LoggerFactory.getLogger(NetconfTimeStamp.class);
+
+ private static final NetconfTimeStamp CONVERTER = new NetconfTimeStamp();
+
+ private final SimpleDateFormat dateFormatResult = init("yyyy-MM-dd'T'HH:mm:ss.S'Z'", TimeZone.getTimeZone("GMT"));
+ private final SimpleDateFormat dateFormatConvert = init("yyyy-MM-dd HH:mm:ss.S", TimeZone.getTimeZone("GMT"));
+ private static int MILLISECONDSDIGITS = 3; // Digits of milliseconds in dateFormatResult
+ private static String MILLISECONDZEROS = "000"; // String with zeros for milliseconds in dateFormatResult
+ private static final Pattern dateNetconfPatter = Pattern.compile(
+ "(\\d{4})-?(\\d{2})-?(\\d{2})T?(\\d{2}):?(\\d{2})(?:(?::?)(\\d{2}))?(?:.(\\d+))?(?:(Z)|([+-]\\d{2}):?(\\d{2}))");
+
+ /*
+ * ------------------------------------ Public function
+ */
+
+ /**
+ * Use static access
+ */
+ private NetconfTimeStamp() {
+ }
+
+ /**
+ * Use this function to get the converter
+ * @return global converter
+ */
+ public static NetconfTimeStamp getConverter() {
+ return CONVERTER;
+ }
+
+ /**
+ * Get actual timestamp as NETCONF specific type NETCONF/YANG 1.0 Format
+ *
+ * @return String with Date in NETCONF/YANG Format Version 1.0.
+ */
+ public String getTimeStampAsNetconfString() {
+ return getRightFormattedDate(new Date().getTime());
+ }
+
+ /**
+ * Get actual timestamp as NETCONF specific type NETCONF/YANG 1.0 Format in GMT
+ *
+ * @return DateAndTime Type 1.0. Date in NETCONF/YANG Format Version 1.0.
+ */
+ public DateAndTime getTimeStamp() {
+ return DateAndTime.getDefaultInstance(getTimeStampAsNetconfString());
+ }
+
+
+ /**
+ * Return the String with a NETCONF time converted to long
+ *
+ * @param netconfTime as String according the formats given above
+ * @return Epoch milliseconds
+ * @throws IllegalArgumentException In case of no compliant time format definition for the string
+ * @throws ParseException Time parsing failed
+ */
+ public long getTimeStampFromNetconfAsMilliseconds(String netconfTime)
+ throws IllegalArgumentException, ParseException {
+ Matcher m = dateNetconfPatter.matcher(netconfTime);
+ // According to spezified matches there have to be 10 parameter
+ if (m.matches() && m.groupCount() == 10) {
+ // Convert now
+ long utcMillis = dateFormatConvert.parse(getTimeAsNormalizedString(m, m.group(6), m.group(7))).getTime()
+ - getTimezoneOffsetMilliseconds(m.group(9), m.group(10));
+ return utcMillis;
+ } else {
+ throw new IllegalArgumentException("No pattern for NETCONF data string: " + netconfTime);
+ }
+ }
+
+ /**
+ * Deliver String result.
+ *
+ * @param netconfTime as String according the formats given above
+ * @return If successful: String in ISO8601 Format for database and presentation. If "wrong formed
+ * input" the Input string with the prefix "Mailformed date" is delivered back.
+ */
+ public String getTimeStampFromNetconf(String netconfTime) {
+ Matcher m = dateNetconfPatter.matcher(netconfTime);
+ // According to spezified matches there have to be 10 parameter
+ if (m.matches() && m.groupCount() == 10) {
+ // Convert now
+ try {
+ long utcMillis = dateFormatConvert.parse(getTimeAsNormalizedString(m, m.group(6), m.group(7))).getTime()
+ - getTimezoneOffsetMilliseconds(m.group(9), m.group(10));
+ return getRightFormattedDate(utcMillis);
+ } catch (ParseException e) {
+ LOG.info(e.getMessage());
+ } catch (IllegalArgumentException e) {
+ LOG.info(e.getMessage());
+ }
+ }
+ LOG.debug("No pattern for NETCONF data string: {}", netconfTime);
+ return "Malformed date: " + netconfTime; // Error handling
+ }
+
+ /*-------------------------------------------
+ * Private and static functions
+ */
+ /**
+ * Convert timeZone parameter in format [+-]/d/d:/d/d into milliseconds
+ *
+ * @param m Index 9 with "+/-" and hour string or null for UTZ, Index 10 with minutes
+ * @return long milliseconds of TimeZoneOffset
+ * @throws IllegalArgumentException If parameters are wrong
+ */
+ private static long getTimezoneOffsetMilliseconds(String timeZoneHour, String timeZoneMinute)
+ throws IllegalArgumentException {
+ // -- Calculate timezone specific offset
+ long timeZoneOffsetMilliseconds = 0;
+ if (timeZoneHour != null) {
+ // Time zone offset in hours and minutes
+ int tzHour = 0;
+ int tzMinutes = 0;
+ tzHour = Integer.valueOf(timeZoneHour);
+ if (timeZoneMinute != null) {
+ tzMinutes = Integer.valueOf(timeZoneMinute);
+ } else {
+ throw new IllegalArgumentException("Problem in Netconf Time format timeZone minutes parameter.");
+ }
+ timeZoneOffsetMilliseconds = (tzHour * 60 + (tzHour > 0 ? tzMinutes : -tzMinutes)) * 60000L;
+ }
+ return timeZoneOffsetMilliseconds;
+ }
+
+ /**
+ * Convert parameters to String with year .. minutes and optional Seconds and .. milliseconds
+ *
+ * @param m Matcher with parsed date
+ * @param secString Seconds as String or null
+ * @param msString Milliseconds as String or null
+ * @return Normalized time string
+ */
+ private static String getTimeAsNormalizedString(Matcher m, String secString, String msString) {
+ // -- Create time as normalized string
+ StringBuffer sb = new StringBuffer();
+ sb.append(m.group(1)); // year
+ sb.append('-');
+ sb.append(m.group(2)); // Month
+ sb.append('-');
+ sb.append(m.group(3)); // Day
+ sb.append(' ');
+ sb.append(m.group(4)); // Hour 0-23
+ sb.append(':');
+ sb.append(m.group(5)); // Minute
+ sb.append(':');
+ sb.append(secString != null ? secString : "00"); // Seconds (optional)
+ sb.append('.');
+ if (msString == null) { // Milliseconds optional
+ sb.append(MILLISECONDZEROS);
+ } else if (msString.length() <= MILLISECONDSDIGITS) {
+ sb.append(msString); // Millisecond
+ sb.append(MILLISECONDZEROS.substring(0, MILLISECONDSDIGITS - msString.length()));
+ } else {
+ sb.append(msString.substring(0, MILLISECONDSDIGITS)); // Only first Three
+ }
+ return sb.toString();
+ }
+
+ /**
+ * Deliver format in a way that milliseconds are correct.
+ *
+ * @param dateMillis Date as milliseconds in Java definition
+ * @return String
+ */
+ private String getRightFormattedDate(long dateMillis) {
+ long tenthOfSeconds = dateMillis % 1000 / 100L; // Extract 100 milliseconds
+ long base = dateMillis / 1000L * 1000L; // Cut milliseconds to 000
+ Date newDate = new Date(base + tenthOfSeconds);
+ return dateFormatResult.format(newDate);
+ }
+
+ /**
+ * Static initialization
+ */
+ private static SimpleDateFormat init(String format, TimeZone zone) {
+ if (zone == null) {
+ throw new ExceptionInInitializerError();
+ } else {
+ SimpleDateFormat dateFormat;
+ dateFormat = new SimpleDateFormat(format);
+ dateFormat.setTimeZone(zone);
+ return dateFormat;
+ }
+ }
+
+}
diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/wrapperc/OnfInterfacePac.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/wrapperc/OnfInterfacePac.java
new file mode 100644
index 000000000..e26d997a0
--- /dev/null
+++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/wrapperc/OnfInterfacePac.java
@@ -0,0 +1,39 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 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.base.netconf.wrapperc;
+
+import java.util.List;
+
+import javax.annotation.Nullable;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.xml.ProblemNotificationXml;
+import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.UniversalId;
+
+public interface OnfInterfacePac {
+
+ /**
+ * Read problems of specific interfaces. TODO Goal for future implementation
+ * without usage of explicit new. Key is generated by newInstance() function
+ * here to verify this approach.
+ *
+ * @param interfacePacUuid Universal index of Interfacepac
+ * @param resultList List to add fault. If null new list is created.
+ * @return list of alarms
+ */
+ public List<ProblemNotificationXml> readTheFaults(UniversalId interfacePacUuid, @Nullable List<ProblemNotificationXml> resultList);
+
+}
diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/wrapperc/OnfMicrowaveModel.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/wrapperc/OnfMicrowaveModel.java
new file mode 100644
index 000000000..637caa44b
--- /dev/null
+++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/wrapperc/OnfMicrowaveModel.java
@@ -0,0 +1,45 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 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.base.netconf.wrapperc;
+
+import java.util.List;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.netconf.ONFCOreNetworkElementCoreData;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.netconf.container.ONFLayerProtocolName;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.xml.ProblemNotificationXml;
+import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.UniversalId;
+import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.logical.termination.point.g.Lp;
+import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.g._874._1.model.rev170320.OtnHistoryDataG;
+import org.opendaylight.yangtools.yang.binding.NotificationListener;
+import org.opendaylight.yangtools.yang.common.QName;
+
+public interface OnfMicrowaveModel {
+
+ public void setCoreData(ONFCOreNetworkElementCoreData coreData);
+
+ public void readTheFaultsOfMicrowaveModel(ONFLayerProtocolName lpName, Class<?> lpClass, UniversalId uuid,
+ List<ProblemNotificationXml> resultList);
+
+ public List<? extends OtnHistoryDataG> readTheHistoricalPerformanceData(ONFLayerProtocolName lpName, Lp lp);
+
+ public Class<?> getClassForLtpExtension(QName qName);
+
+ public <T extends NotificationListener> T getNotificationListener();
+
+ public void setOnfMicrowaveModelListener(OnfMicrowaveModelNotification microwaveModelListener);
+
+}
diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/wrapperc/OnfMicrowaveModelNotification.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/wrapperc/OnfMicrowaveModelNotification.java
new file mode 100644
index 000000000..2c7aead70
--- /dev/null
+++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/wrapperc/OnfMicrowaveModelNotification.java
@@ -0,0 +1,38 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 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.base.netconf.wrapperc;
+
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.xml.AttributeValueChangedNotificationXml;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.xml.ObjectCreationNotificationXml;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.xml.ObjectDeletionNotificationXml;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.xml.ProblemNotificationXml;
+
+/**
+ * Abstraction of YANG specified notifications
+ * Each method converts from internal specific class to model unspecific class
+ * @author herbert
+ *
+ */
+public interface OnfMicrowaveModelNotification {
+
+ void onObjectCreationNotification(ObjectCreationNotificationXml notificationXml);
+ void onObjectDeletionNotification(ObjectDeletionNotificationXml notificationXml);
+ void onProblemNotification(ProblemNotificationXml notificationXml);
+ void onAttributeValueChangedNotification(AttributeValueChangedNotificationXml notificationXml);
+
+}
diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/wrapperc/WrapperEquipmentPacRev170402.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/wrapperc/WrapperEquipmentPacRev170402.java
new file mode 100644
index 000000000..03e830e5a
--- /dev/null
+++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/wrapperc/WrapperEquipmentPacRev170402.java
@@ -0,0 +1,127 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 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.base.netconf.wrapperc;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+import java.util.ArrayList;
+import java.util.List;
+import javax.annotation.Nullable;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.internalTypes.InternalDateAndTime;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.internalTypes.InternalSeverity;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.netconf.ONFCOreNetworkElementCoreData;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.netconf.util.GenericTransactionUtils;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.xml.ProblemNotificationXml;
+import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.UniversalId;
+import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.onf.core.model.conditional.packages.rev170402.CurrentProblemTypeG;
+import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.onf.core.model.conditional.packages.rev170402.EquipmentPac;
+import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.onf.core.model.conditional.packages.rev170402.EquipmentPacKey;
+import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.onf.core.model.conditional.packages.rev170402.equipment.pac.EquipmentCurrentProblems;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.opendaylight.yangtools.yang.common.QName;
+
+public class WrapperEquipmentPacRev170402 implements OnfInterfacePac {
+
+ private static final Logger LOG = LoggerFactory.getLogger(WrapperEquipmentPacRev170402.class);
+ public static final QName QNAME = EquipmentPac.QNAME;
+
+ ONFCOreNetworkElementCoreData coreData;
+
+ public WrapperEquipmentPacRev170402(ONFCOreNetworkElementCoreData coreData) {
+ this.coreData = coreData;
+ }
+
+ /**
+ * Read problems of specific interfaces. TODO Goal for future implementation without usage of
+ * explicit new. Key is generated by newInstance() function here to verify this approach.
+ *
+ * @param interfacePacUuid Universal index of onf interface-pac
+ * @param resultList list to add, or null for new list.
+ * @return list of alarms
+ */
+ @Override
+ public List<ProblemNotificationXml> readTheFaults(UniversalId interfacePacUuid,
+ List<ProblemNotificationXml> resultList) {
+
+ final Class<EquipmentPac> clazzPac = EquipmentPac.class;
+ final Class<EquipmentPacKey> clazzPacKey = EquipmentPacKey.class;
+ final Class<EquipmentCurrentProblems> clazzProblems = EquipmentCurrentProblems.class;
+ // final Class<ContainerCurrentProblemTypeG> clazzProblem =
+ // ContainerCurrentProblemTypeG.class;
+
+ LOG.info("DBRead Get problems for class {} from mountpoint {} for uuid {}", clazzPac.getSimpleName(),
+ coreData.getMountpoint(), interfacePacUuid.getValue());
+
+ try {
+ if (resultList == null) {
+ resultList = new ArrayList<>();
+ }
+ // -- Specific part 1
+ Constructor<EquipmentPacKey> cons = clazzPacKey.getConstructor(UniversalId.class); // Avoid new()
+ InstanceIdentifier<EquipmentCurrentProblems> interfaceIID = InstanceIdentifier
+ .builder(clazzPac, cons.newInstance(interfacePacUuid)).child(clazzProblems).build();
+
+ // -- Specific part 2
+ EquipmentCurrentProblems problems = GenericTransactionUtils.readData(coreData.getDataBroker(),
+ LogicalDatastoreType.OPERATIONAL, interfaceIID);
+ if (problems == null) {
+ LOG.debug("DBRead Id {} no {}", interfacePacUuid, clazzProblems, clazzProblems.getName());
+ } else if (problems.getCurrentProblemList() == null) {
+ LOG.debug("DBRead Id {} no list {}", interfacePacUuid, clazzProblems.getName());
+ } else {
+ // -- Specific part 3
+ for (CurrentProblemTypeG problem : problems.getCurrentProblemList()) {
+ resultList.add(new ProblemNotificationXml(coreData.getMountpoint(), interfacePacUuid.getValue(),
+ problem.getProblemName(), InternalSeverity.valueOf(problem.getProblemSeverity()),
+ problem.getSequenceNumber().toString(),
+ InternalDateAndTime.valueOf(problem.getTimeStamp())));
+ }
+ }
+ } catch (NoSuchMethodException | SecurityException | InstantiationException | IllegalAccessException
+ | IllegalArgumentException | InvocationTargetException e) {
+ LOG.warn("Could not reade instance of MwTdmContainerPacKey: ", e);
+ }
+ return resultList;
+ }
+
+ /**
+ * Read problems of specific interfaces
+ *
+ * @param interfacePacUuid Universal index of Equipmentpac
+ * @return EquipmentPac or null
+ */
+ public @Nullable EquipmentPac readEquipmentPac(UniversalId interfacePacUuid) {
+
+ final Class<?> clazzPac = EquipmentPac.class;
+
+ LOG.info("DBRead Get problems for class {} from mountpoint {} for uuid {}", clazzPac.getSimpleName(),
+ coreData.getMountpoint(), interfacePacUuid.getValue());
+
+ InstanceIdentifier<EquipmentPac> equipmentIID =
+ InstanceIdentifier.builder(EquipmentPac.class, new EquipmentPacKey(interfacePacUuid)).build();
+
+ EquipmentPac res = GenericTransactionUtils.readData(coreData.getDataBroker(), LogicalDatastoreType.OPERATIONAL,
+ equipmentIID);
+
+ return res;
+ }
+
+}
diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/wrapperc/WrapperMicrowaveModelRev170324.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/wrapperc/WrapperMicrowaveModelRev170324.java
new file mode 100644
index 000000000..b62940109
--- /dev/null
+++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/wrapperc/WrapperMicrowaveModelRev170324.java
@@ -0,0 +1,593 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 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.base.netconf.wrapperc;
+
+
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+import java.util.ArrayList;
+import java.util.List;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.internalTypes.InternalDateAndTime;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.internalTypes.InternalSeverity;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.netconf.ONFCOreNetworkElementCoreData;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.netconf.ONFCoreNetworkElement12;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.netconf.container.ExtendedAirInterfaceHistoricalPerformanceType12;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.netconf.container.ONFLayerProtocolName;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.netconf.util.GenericTransactionUtils;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.xml.AttributeValueChangedNotificationXml;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.xml.ObjectCreationNotificationXml;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.xml.ObjectDeletionNotificationXml;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.xml.ProblemNotificationXml;
+import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.UniversalId;
+import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.logical.termination.point.g.Lp;
+import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.g._874._1.model.rev170320.OtnHistoryDataG;
+import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.AirInterfaceCurrentProblemTypeG;
+import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.AirInterfaceDiversityCurrentProblemTypeG;
+import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.AirInterfaceHistoricalPerformanceTypeG;
+import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.AttributeValueChangedNotification;
+import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.ContainerCurrentProblemTypeG;
+import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.ContainerHistoricalPerformanceTypeG;
+import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.MicrowaveModelListener;
+import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.MwAirInterfaceDiversityPac;
+import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.MwAirInterfaceDiversityPacKey;
+import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.MwAirInterfacePac;
+import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.MwAirInterfacePacKey;
+import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.MwEthernetContainerPac;
+import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.MwEthernetContainerPacKey;
+import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.MwHybridMwStructurePac;
+import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.MwHybridMwStructurePacKey;
+import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.MwPureEthernetStructurePac;
+import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.MwPureEthernetStructurePacKey;
+import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.MwTdmContainerPac;
+import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.MwTdmContainerPacKey;
+import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.ObjectCreationNotification;
+import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.ObjectDeletionNotification;
+import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.ProblemNotification;
+import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.StructureCurrentProblemTypeG;
+import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.mw.air._interface.diversity.pac.AirInterfaceDiversityCurrentProblems;
+import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.mw.air._interface.pac.AirInterfaceConfiguration;
+import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.mw.air._interface.pac.AirInterfaceCurrentProblems;
+import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.mw.air._interface.pac.AirInterfaceHistoricalPerformances;
+import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.mw.ethernet.container.pac.EthernetContainerCurrentProblems;
+import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.mw.ethernet.container.pac.EthernetContainerHistoricalPerformances;
+import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.mw.hybrid.mw.structure.pac.HybridMwStructureCurrentProblems;
+import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.mw.pure.ethernet.structure.pac.PureEthernetStructureCurrentProblems;
+import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.mw.tdm.container.pac.TdmContainerCurrentProblems;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.opendaylight.yangtools.yang.binding.NotificationListener;
+import org.opendaylight.yangtools.yang.common.QName;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+public class WrapperMicrowaveModelRev170324 implements OnfMicrowaveModel, MicrowaveModelListener {
+
+ private static final Logger LOG = LoggerFactory.getLogger(ONFCoreNetworkElement12.class);
+
+ public static final QName QNAME = MwAirInterfacePac.QNAME;
+
+
+ private ONFCOreNetworkElementCoreData coreData;
+ private OnfMicrowaveModelNotification microwaveModelListener;
+
+ /*-----------------------------------------------------------------------------
+ * Setter/Getter
+ */
+
+ public void setCoreData(ONFCOreNetworkElementCoreData coreData) {
+ this.coreData = coreData;
+ }
+
+ public ONFCOreNetworkElementCoreData getCoreData() {
+ return coreData;
+ }
+
+ @Override
+ public void setOnfMicrowaveModelListener(OnfMicrowaveModelNotification microwaveModelListener) {
+ this.microwaveModelListener = microwaveModelListener;
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public <T extends NotificationListener> T getNotificationListener() {
+ return (T)this;
+ }
+
+ /*-----------------------------------------------------------------------------
+ * Interfacefunctions
+ */
+
+ public void readTheFaultsOfMicrowaveModel(ONFLayerProtocolName lpName, Class<?> lpClass, UniversalId uuid,
+ List<ProblemNotificationXml> resultList) {
+
+ switch (lpName) {
+ case MWAirInterface:
+ readTheFaultsOfMwAirInterfacePac(uuid, resultList);
+ break;
+
+ case EthernetContainer12:
+ readTheFaultsOfMwEthernetContainerPac(uuid, resultList);
+ break;
+
+ case TDMContainer:
+ readTheFaultsOfMwTdmContainerPac(uuid, resultList);
+ break;
+
+ case Structure:
+ if (lpClass == MwHybridMwStructurePac.class) {
+ readTheFaultsOfMwHybridMwStructurePac(uuid, resultList);
+
+ } else if (lpClass == MwAirInterfaceDiversityPac.class) {
+ readTheFaultsOfMwAirInterfaceDiversityPac(uuid, resultList);
+
+ } else if (lpClass == MwPureEthernetStructurePac.class) {
+ readTheFaultsOfMwPureEthernetStructurePac(uuid, resultList);
+
+ } else {
+ LOG.warn("Unassigned lp model {} class {}", lpName, lpClass);
+ }
+ break;
+ case Ethernet:
+ // No alarms supported
+ break;
+ case EthernetContainer10:
+ default:
+ LOG.warn("Unassigned or not expected lp in model {}", lpName);
+ }
+ }
+
+ public List<? extends OtnHistoryDataG> readTheHistoricalPerformanceData(ONFLayerProtocolName lpName, Lp lp) {
+ switch (lpName) {
+ case MWAirInterface:
+ return readTheHistoricalPerformanceDataOfMwAirInterfacePac(lp);
+
+ case EthernetContainer12:
+ return readTheHistoricalPerformanceDataOfEthernetContainer(lp);
+
+ case EthernetContainer10:
+ case EthernetPhysical:
+ case Ethernet:
+ case TDMContainer:
+ case Structure:
+ case Unknown:
+ LOG.debug("Do not read HistoricalPM data for {} {}", lpName, lp.getUuid().getValue());
+ break;
+ }
+ return new ArrayList<>();
+ }
+
+ public Class<?> getClassForLtpExtension(QName qName) {
+ Class<?> res = null;
+ if (qName.equals(MwAirInterfacePac.QNAME)) {
+ res = MwAirInterfacePac.class;
+ } else if (qName.equals(MwAirInterfaceDiversityPac.QNAME)) {
+ res = MwAirInterfaceDiversityPac.class;
+ } else if (qName.equals(MwPureEthernetStructurePac.QNAME)) {
+ res = MwPureEthernetStructurePac.class;
+ } else if (qName.equals(MwHybridMwStructurePac.QNAME)) {
+ res = MwHybridMwStructurePac.class;
+ } else if (qName.equals(MwEthernetContainerPac.QNAME)) {
+ res = MwEthernetContainerPac.class;
+ } else if (qName.equals(MwTdmContainerPac.QNAME)) {
+ res = MwTdmContainerPac.class;
+ }
+ LOG.info("Found QName {} mapped to {}", String.valueOf(qName), String.valueOf(res));
+ return res;
+ }
+
+ /*-----------------------------------------------------------------------------
+ * Reading problems for specific interface pacs
+ */
+
+ /**
+ * Read problems of specific interfaces
+ *
+ * @param uuId Universal Id String of the interface
+ * @return number of alarms
+ */
+ private List<ProblemNotificationXml> readTheFaultsOfMwAirInterfacePac(UniversalId interfacePacUuid,
+ List<ProblemNotificationXml> resultList) {
+
+ final Class<MwAirInterfacePac> clazzPac = MwAirInterfacePac.class;
+ // final Class<MwAirInterfacePacKey> clazzPacKey = MwAirInterfacePacKey.class;
+ // final Class<AirInterfaceCurrentProblems> clazzProblems =
+ // AirInterfaceCurrentProblems.class;
+ // final Class<AirInterfaceCurrentProblemTypeG> clazzProblem =
+ // AirInterfaceCurrentProblemTypeG.class;
+
+ LOG.info("DBRead Get problems for class {} from mountpoint {} for uuid {}", clazzPac.getSimpleName(),
+ coreData.getMountpoint(), interfacePacUuid.getValue());
+
+ // Step 2.2: construct data and the relative iid
+ InstanceIdentifier<AirInterfaceCurrentProblems> mwAirInterfaceIID = InstanceIdentifier
+ .builder(MwAirInterfacePac.class, new MwAirInterfacePacKey(interfacePacUuid))
+ .child(AirInterfaceCurrentProblems.class).build();
+
+ // Step 2.3: read to the config data store
+ AirInterfaceCurrentProblems problems = GenericTransactionUtils.readData(coreData.getDataBroker(),
+ LogicalDatastoreType.OPERATIONAL, mwAirInterfaceIID);
+
+ if (problems == null) {
+ LOG.debug("DBRead Id {} no AirInterfaceCurrentProblems", interfacePacUuid);
+ } else if (problems.getCurrentProblemList() == null) {
+ LOG.debug("DBRead Id {} empty CurrentProblemList", interfacePacUuid);
+ } else {
+ for (AirInterfaceCurrentProblemTypeG problem : problems.getCurrentProblemList()) {
+ resultList.add(new ProblemNotificationXml(coreData.getMountpoint(), interfacePacUuid.getValue(),
+ problem.getProblemName(), InternalSeverity.valueOf(problem.getProblemSeverity()),
+ problem.getSequenceNumber().toString(), InternalDateAndTime.valueOf(problem.getTimeStamp())));
+ }
+ }
+ return resultList;
+ }
+
+ /**
+ * Read problems of specific interfaces
+ *
+ * @param uuId Universal index of Interfacepac
+ * @return number of alarms
+ */
+ private List<ProblemNotificationXml> readTheFaultsOfMwEthernetContainerPac(UniversalId interfacePacUuid,
+ List<ProblemNotificationXml> resultList) {
+
+ final Class<MwEthernetContainerPac> clazzPac = MwEthernetContainerPac.class;
+ // final Class<MwEthernetContainerPacKey> clazzPacKey =
+ // MwEthernetContainerPacKey.class;
+ // final Class<EthernetContainerCurrentProblems> clazzProblems =
+ // EthernetContainerCurrentProblems.class;
+ // final Class<ContainerCurrentProblemTypeG> clazzProblem =
+ // ContainerCurrentProblemTypeG.class;
+
+ LOG.info("DBRead Get problems for class {} from mountpoint {} for uuid {}", clazzPac.getSimpleName(),
+ coreData.getMountpoint(), interfacePacUuid.getValue());
+
+ InstanceIdentifier<EthernetContainerCurrentProblems> mwEthInterfaceIID = InstanceIdentifier
+ .builder(MwEthernetContainerPac.class, new MwEthernetContainerPacKey(interfacePacUuid))
+ .child(EthernetContainerCurrentProblems.class).build();
+
+ EthernetContainerCurrentProblems problems = GenericTransactionUtils.readData(coreData.getDataBroker(),
+ LogicalDatastoreType.OPERATIONAL, mwEthInterfaceIID);
+ if (problems == null) {
+ LOG.debug("DBRead Id {} no EthernetContainerCurrentProblems", interfacePacUuid);
+ } else if (problems.getCurrentProblemList() == null) {
+ LOG.debug("DBRead Id {} empty CurrentProblemsList", interfacePacUuid);
+ } else {
+ for (ContainerCurrentProblemTypeG problem : problems.getCurrentProblemList()) {
+ resultList.add(new ProblemNotificationXml(coreData.getMountpoint(), interfacePacUuid.getValue(),
+ problem.getProblemName(), InternalSeverity.valueOf(problem.getProblemSeverity()),
+ problem.getSequenceNumber().toString(), InternalDateAndTime.valueOf(problem.getTimeStamp())));
+ }
+ }
+ return resultList;
+ }
+
+ /**
+ * Read problems of specific interfaces
+ *
+ * @param uuId Universal index of Interfacepac
+ * @return number of alarms
+ */
+ private List<ProblemNotificationXml> readTheFaultsOfMwAirInterfaceDiversityPac(UniversalId interfacePacUuid,
+ List<ProblemNotificationXml> resultList) {
+
+ final Class<MwAirInterfaceDiversityPac> clazzPac = MwAirInterfaceDiversityPac.class;
+ // final Class<MwAirInterfaceDiversityPacKey> clazzPacKey =
+ // MwAirInterfaceDiversityPacKey.class;
+ final Class<AirInterfaceDiversityCurrentProblems> clazzProblems = AirInterfaceDiversityCurrentProblems.class;
+ // final Class<AirInterfaceDiversityCurrentProblemTypeG> clazzProblem =
+ // AirInterfaceDiversityCurrentProblemTypeG.class;
+
+ LOG.info("DBRead Get problems for class {} from mountpoint {} for uuid {}", clazzPac.getSimpleName(),
+ coreData.getMountpoint(), interfacePacUuid.getValue());
+
+ InstanceIdentifier<AirInterfaceDiversityCurrentProblems> mwEthInterfaceIID = InstanceIdentifier
+ .builder(clazzPac, new MwAirInterfaceDiversityPacKey(interfacePacUuid)).child(clazzProblems).build();
+
+ AirInterfaceDiversityCurrentProblems problems = GenericTransactionUtils.readData(coreData.getDataBroker(),
+ LogicalDatastoreType.OPERATIONAL, mwEthInterfaceIID);
+ if (problems == null) {
+ LOG.debug("DBRead Id {} no AirInterfaceDiversityCurrentProblems", interfacePacUuid);
+ } else if (problems.getCurrentProblemList() == null) {
+ LOG.debug("DBRead Id {} empty CurrentProblemList", interfacePacUuid);
+ } else {
+ for (AirInterfaceDiversityCurrentProblemTypeG problem : problems.getCurrentProblemList()) {
+ resultList.add(new ProblemNotificationXml(coreData.getMountpoint(), interfacePacUuid.getValue(),
+ problem.getProblemName(), InternalSeverity.valueOf(problem.getProblemSeverity()),
+ problem.getSequenceNumber().toString(), InternalDateAndTime.valueOf(problem.getTimeStamp())));
+ }
+ }
+ return resultList;
+ }
+
+ /**
+ * Read problems of specific interfaces
+ *
+ * @param uuId Universal index of Interfacepac
+ * @return number of alarms
+ */
+ private List<ProblemNotificationXml> readTheFaultsOfMwPureEthernetStructurePac(UniversalId interfacePacUuid,
+ List<ProblemNotificationXml> resultList) {
+
+ final Class<MwPureEthernetStructurePac> clazzPac = MwPureEthernetStructurePac.class;
+ // final Class<MwPureEthernetStructurePacKey> clazzPacKey =
+ // MwPureEthernetStructurePacKey.class;
+ final Class<PureEthernetStructureCurrentProblems> clazzProblems = PureEthernetStructureCurrentProblems.class;
+ // final Class<StructureCurrentProblemTypeG> clazzProblem =
+ // StructureCurrentProblemTypeG.class;
+
+ LOG.info("DBRead Get problems for class {} from mountpoint {} for uuid {}", clazzPac.getSimpleName(),
+ coreData.getMountpoint(), interfacePacUuid.getValue());
+
+ InstanceIdentifier<PureEthernetStructureCurrentProblems> mwEthInterfaceIID = InstanceIdentifier
+ .builder(clazzPac, new MwPureEthernetStructurePacKey(interfacePacUuid)).child(clazzProblems).build();
+
+ PureEthernetStructureCurrentProblems problems = GenericTransactionUtils.readData(coreData.getDataBroker(),
+ LogicalDatastoreType.OPERATIONAL, mwEthInterfaceIID);
+ if (problems == null) {
+ LOG.debug("DBRead Id {} no PureEthernetStructureCurrentProblems", interfacePacUuid);
+ } else if (problems.getCurrentProblemList() == null) {
+ LOG.debug("DBRead Id {} empty CurrentProblemsList", interfacePacUuid);
+ } else {
+ for (StructureCurrentProblemTypeG problem : problems.getCurrentProblemList()) {
+ resultList.add(new ProblemNotificationXml(coreData.getMountpoint(), interfacePacUuid.getValue(),
+ problem.getProblemName(), InternalSeverity.valueOf(problem.getProblemSeverity()),
+ problem.getSequenceNumber().toString(), InternalDateAndTime.valueOf(problem.getTimeStamp())));
+ }
+ }
+ return resultList;
+ }
+
+ /**
+ * Read problems of specific interfaces
+ *
+ * @param uuId Universal index of Interfacepac
+ * @return number of alarms
+ */
+ private List<ProblemNotificationXml> readTheFaultsOfMwHybridMwStructurePac(UniversalId interfacePacUuid,
+ List<ProblemNotificationXml> resultList) {
+
+ final Class<MwHybridMwStructurePac> clazzPac = MwHybridMwStructurePac.class;
+ // final Class<MwHybridMwStructurePacKey> clazzPacKey =
+ // MwHybridMwStructurePacKey.class;
+ final Class<HybridMwStructureCurrentProblems> clazzProblems = HybridMwStructureCurrentProblems.class;
+ // final Class<HybridMwStructureCurrentProblemsG> clazzProblem =
+ // HybridMwStructureCurrentProblemsG.class;
+
+ LOG.info("DBRead Get problems for class {} from mountpoint {} for uuid {}", clazzPac.getSimpleName(),
+ coreData.getMountpoint(), interfacePacUuid.getValue());
+
+ InstanceIdentifier<HybridMwStructureCurrentProblems> mwEthInterfaceIID = InstanceIdentifier
+ .builder(clazzPac, new MwHybridMwStructurePacKey(interfacePacUuid)).child(clazzProblems).build();
+
+ HybridMwStructureCurrentProblems problems = GenericTransactionUtils.readData(coreData.getDataBroker(),
+ LogicalDatastoreType.OPERATIONAL, mwEthInterfaceIID);
+ if (problems == null) {
+ LOG.debug("DBRead Id {} no HybridMwStructureCurrentProblems", interfacePacUuid);
+ } else if (problems.getCurrentProblemList() == null) {
+ LOG.debug("DBRead Id {} empty CurrentProblemsList", interfacePacUuid);
+ } else {
+ for (StructureCurrentProblemTypeG problem : problems.getCurrentProblemList()) {
+ resultList.add(new ProblemNotificationXml(coreData.getMountpoint(), interfacePacUuid.getValue(),
+ problem.getProblemName(), InternalSeverity.valueOf(problem.getProblemSeverity()),
+ problem.getSequenceNumber().toString(), InternalDateAndTime.valueOf(problem.getTimeStamp())));
+ }
+ }
+ return resultList;
+ }
+
+ /**
+ * Read problems of specific interfaces. TODO Goal for future implementation
+ * without usage of explicit new. Key is generated by newInstance() function
+ * here to verify this approach.
+ *
+ * @param uuId Universal index of Interfacepac
+ * @return number of alarms
+ * @throws SecurityException
+ * @throws NoSuchMethodException
+ * @throws InvocationTargetException
+ * @throws IllegalArgumentException
+ * @throws IllegalAccessException
+ * @throws InstantiationException
+ */
+ private List<ProblemNotificationXml> readTheFaultsOfMwTdmContainerPac(UniversalId interfacePacUuid,
+ List<ProblemNotificationXml> resultList) {
+
+ final Class<MwTdmContainerPac> clazzPac = MwTdmContainerPac.class;
+ final Class<MwTdmContainerPacKey> clazzPacKey = MwTdmContainerPacKey.class;
+ final Class<TdmContainerCurrentProblems> clazzProblems = TdmContainerCurrentProblems.class;
+ // final Class<ContainerCurrentProblemTypeG> clazzProblem =
+ // ContainerCurrentProblemTypeG.class;
+
+ LOG.info("DBRead Get problems for class {} from mountpoint {} for uuid {}", clazzPac.getSimpleName(),
+ coreData.getMountpoint(), interfacePacUuid.getValue());
+
+ try {
+ // -- Specific part 1
+ Constructor<MwTdmContainerPacKey> cons = clazzPacKey.getConstructor(UniversalId.class); // Avoid new()
+ InstanceIdentifier<TdmContainerCurrentProblems> mwEthInterfaceIID = InstanceIdentifier
+ .builder(clazzPac, cons.newInstance(interfacePacUuid)).child(clazzProblems).build();
+
+ // -- Specific part 2
+ TdmContainerCurrentProblems problems = GenericTransactionUtils.readData(coreData.getDataBroker(),
+ LogicalDatastoreType.OPERATIONAL, mwEthInterfaceIID);
+ if (problems == null) {
+ LOG.debug("DBRead Id {} no TdmContainerCurrentProblems", interfacePacUuid);
+ } else if (problems.getCurrentProblemList() == null) {
+ LOG.debug("DBRead Id {} empty CurrentProblemsList", interfacePacUuid);
+ } else {
+ // -- Specific part 3
+ for (ContainerCurrentProblemTypeG problem : problems.getCurrentProblemList()) {
+ resultList.add(new ProblemNotificationXml(coreData.getMountpoint(), interfacePacUuid.getValue(),
+ problem.getProblemName(), InternalSeverity.valueOf(problem.getProblemSeverity()),
+ problem.getSequenceNumber().toString(),
+ InternalDateAndTime.valueOf(problem.getTimeStamp())));
+ }
+ }
+ } catch (NoSuchMethodException | SecurityException | InstantiationException | IllegalAccessException
+ | IllegalArgumentException | InvocationTargetException e) {
+ LOG.warn("Could not reade instance of MwTdmContainerPacKey: ", e);
+ }
+ return resultList;
+ }
+
+ /*-----------------------------------------------------------------------------
+ * Performance related data
+ */
+
+ /**
+ * PM MwAirInterfacePac
+ *
+ * @param lp
+ * @return
+ */
+ private List<ExtendedAirInterfaceHistoricalPerformanceType12> readTheHistoricalPerformanceDataOfMwAirInterfacePac(
+ Lp lp) {
+
+ String uuId = lp.getUuid().getValue();
+
+ List<ExtendedAirInterfaceHistoricalPerformanceType12> resultList = new ArrayList<>();
+ LOG.debug("DBRead Get {} MWAirInterfacePac: {}", coreData.getMountpoint(), uuId);
+ // ----
+ UniversalId mwAirInterfacePacuuId = new UniversalId(uuId);
+ // Step 2.1: construct data and the relative iid
+ InstanceIdentifier<AirInterfaceConfiguration> mwAirInterfaceConfigurationIID = InstanceIdentifier
+ .builder(MwAirInterfacePac.class, new MwAirInterfacePacKey(mwAirInterfacePacuuId))
+ .child(AirInterfaceConfiguration.class).build();
+ AirInterfaceConfiguration airConfiguration = GenericTransactionUtils.readData(coreData.getDataBroker(),
+ LogicalDatastoreType.OPERATIONAL, mwAirInterfaceConfigurationIID);
+
+ if (airConfiguration == null) {
+ LOG.debug("DBRead MWAirInterfacePac Id {} no AirInterfaceConfiguration", mwAirInterfacePacuuId);
+
+ } else {
+ // Step 2.2: construct data and the relative iid
+ InstanceIdentifier<AirInterfaceHistoricalPerformances> mwAirInterfaceHistoricalPerformanceIID = InstanceIdentifier
+ .builder(MwAirInterfacePac.class, new MwAirInterfacePacKey(mwAirInterfacePacuuId))
+ .child(AirInterfaceHistoricalPerformances.class).build();
+
+ // Step 2.3: read to the config data store
+ AirInterfaceHistoricalPerformances airHistoricalPerformanceData = GenericTransactionUtils.readData(
+ coreData.getDataBroker(), LogicalDatastoreType.OPERATIONAL, mwAirInterfaceHistoricalPerformanceIID);
+
+ if (airHistoricalPerformanceData == null) {
+ LOG.debug("DBRead MWAirInterfacePac Id {} no AirInterfaceHistoricalPerformances",
+ mwAirInterfacePacuuId);
+ } else {
+ // org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170320.air._interface.historical.performances.g.HistoricalPerformanceDataList
+ List<org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.air._interface.historical.performances.g.HistoricalPerformanceDataList> airHistPMList = airHistoricalPerformanceData
+ .getHistoricalPerformanceDataList();
+ LOG.debug("DBRead MWAirInterfacePac Id {} Records intermediate: {}", mwAirInterfacePacuuId,
+ airHistPMList.size());
+ if (airHistPMList != null) {
+ for (AirInterfaceHistoricalPerformanceTypeG pmRecord : airHistoricalPerformanceData
+ .getHistoricalPerformanceDataList()) {
+ resultList.add(new ExtendedAirInterfaceHistoricalPerformanceType12(pmRecord, airConfiguration));
+ }
+ }
+ }
+ }
+ LOG.debug("DBRead MWAirInterfacePac Id {} Records result: {}", mwAirInterfacePacuuId, resultList.size());
+ return resultList;
+ }
+
+ private List<ContainerHistoricalPerformanceTypeG> readTheHistoricalPerformanceDataOfEthernetContainer(Lp lp) {
+
+ final String myName = "MWEthernetContainerPac";
+ String uuId = lp.getUuid().getValue();
+
+ List<ContainerHistoricalPerformanceTypeG> resultList = new ArrayList<>();
+ LOG.debug("DBRead Get {} : {}", coreData.getMountpoint(), myName, uuId);
+ // ----
+ UniversalId ethContainerPacuuId = new UniversalId(uuId);
+ // Step 2.2: construct data and the relative iid
+ InstanceIdentifier<EthernetContainerHistoricalPerformances> ethContainerIID = InstanceIdentifier
+ .builder(MwEthernetContainerPac.class, new MwEthernetContainerPacKey(ethContainerPacuuId))
+ .child(EthernetContainerHistoricalPerformances.class).build();
+
+ // Step 2.3: read to the config data store
+ EthernetContainerHistoricalPerformances ethContainerHistoricalPerformanceData = GenericTransactionUtils
+ .readData(coreData.getDataBroker(), LogicalDatastoreType.OPERATIONAL, ethContainerIID);
+
+ if (ethContainerHistoricalPerformanceData == null) {
+ LOG.debug("DBRead {} Id {} no HistoricalPerformances", myName, ethContainerPacuuId);
+ } else {
+ // import
+ // org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170320.ethernet.container.historical.performances.g.HistoricalPerformanceDataList
+ // org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.ethernet.container.historical.performances.g.HistoricalPerformanceDataList
+ List<org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.ethernet.container.historical.performances.g.HistoricalPerformanceDataList> airHistPMList = ethContainerHistoricalPerformanceData
+ .getHistoricalPerformanceDataList();
+ LOG.debug("DBRead {} Id {} Records intermediate: {}", myName, ethContainerPacuuId, airHistPMList.size());
+ if (airHistPMList != null) {
+ for (ContainerHistoricalPerformanceTypeG pmRecord : airHistPMList) {
+ resultList.add(pmRecord);
+ }
+ }
+ }
+ LOG.debug("DBRead {} Id {} Records result: {}", myName, ethContainerPacuuId, resultList.size());
+ return resultList;
+ }
+
+ @Override
+ public void onObjectCreationNotification(ObjectCreationNotification notification) {
+ LOG.debug("Got event of type :: {}", ObjectCreationNotification.class.getSimpleName());
+
+ ObjectCreationNotificationXml notificationXml = new ObjectCreationNotificationXml(coreData.getMountpoint(),
+ notification.getCounter().toString(),
+ InternalDateAndTime.valueOf(notification.getTimeStamp()),
+ notification.getObjectIdRef().getValue());
+ microwaveModelListener.onObjectCreationNotification(notificationXml);
+ }
+
+ @Override
+ public void onObjectDeletionNotification(ObjectDeletionNotification notification) {
+ LOG.debug("Got event of type :: {}", ObjectDeletionNotification.class.getSimpleName());
+
+ ObjectDeletionNotificationXml notificationXml = new ObjectDeletionNotificationXml(coreData.getMountpoint(),
+ notification.getCounter().toString(),
+ InternalDateAndTime.valueOf(notification.getTimeStamp()),
+ notification.getObjectIdRef().getValue()
+ );
+ microwaveModelListener.onObjectDeletionNotification(notificationXml);
+ }
+
+ public void onProblemNotification(ProblemNotification notification) {
+
+ LOG.debug("Got event of type :: {}", ProblemNotification.class.getSimpleName());
+
+ ProblemNotificationXml notificationXml = new ProblemNotificationXml(coreData.getMountpoint(), notification.getObjectIdRef().getValue(),
+ notification.getProblem(), InternalSeverity.valueOf(notification.getSeverity()),
+ notification.getCounter().toString(), InternalDateAndTime.valueOf(notification.getTimeStamp()));
+
+ microwaveModelListener.onProblemNotification(notificationXml);
+ }
+
+ @Override
+ public void onAttributeValueChangedNotification(AttributeValueChangedNotification notification) {
+ LOG.debug("Got event of type :: {}", AttributeValueChangedNotification.class.getSimpleName());
+
+ AttributeValueChangedNotificationXml notificationXml = new AttributeValueChangedNotificationXml(coreData.getMountpoint(),
+ String.valueOf(notification.getCounter()), InternalDateAndTime.valueOf(notification.getTimeStamp()),
+ notification.getObjectIdRef().getValue(), notification.getAttributeName(), notification.getNewValue());
+
+ microwaveModelListener.onAttributeValueChangedNotification(notificationXml);
+ }
+
+
+}
diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/wrapperc/WrapperMicrowaveModelRev180907.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/wrapperc/WrapperMicrowaveModelRev180907.java
new file mode 100644
index 000000000..d35115fd9
--- /dev/null
+++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/wrapperc/WrapperMicrowaveModelRev180907.java
@@ -0,0 +1,596 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 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.base.netconf.wrapperc;
+
+
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.opendaylight.yangtools.yang.binding.NotificationListener;
+import org.opendaylight.yangtools.yang.common.QName;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.internalTypes.InternalDateAndTime;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.internalTypes.InternalSeverity;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.netconf.ONFCOreNetworkElementCoreData;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.netconf.ONFCoreNetworkElement12;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.netconf.container.ExtendedAirInterfaceHistoricalPerformanceType1211;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.netconf.container.ONFLayerProtocolName;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.netconf.util.GenericTransactionUtils;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.xml.AttributeValueChangedNotificationXml;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.xml.ObjectCreationNotificationXml;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.xml.ObjectDeletionNotificationXml;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.xml.ProblemNotificationXml;
+import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+
+import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.logical.termination.point.g.Lp;
+import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.g._874._1.model.rev170320.OtnHistoryDataG;
+import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.UniversalId;
+import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.AirInterfaceCurrentProblemTypeG;
+import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.AirInterfaceDiversityCurrentProblemTypeG;
+import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.AirInterfaceHistoricalPerformanceTypeG;
+import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.ContainerCurrentProblemTypeG;
+import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.ContainerHistoricalPerformanceTypeG;
+import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.MicrowaveModelListener;
+import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.MwAirInterfaceDiversityPac;
+import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.MwAirInterfaceDiversityPacKey;
+import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.MwAirInterfacePac;
+import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.MwAirInterfacePacKey;
+import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.MwEthernetContainerPac;
+import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.MwEthernetContainerPacKey;
+import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.MwHybridMwStructurePac;
+import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.MwHybridMwStructurePacKey;
+import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.MwPureEthernetStructurePac;
+import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.MwPureEthernetStructurePacKey;
+import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.MwTdmContainerPac;
+import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.MwTdmContainerPacKey;
+import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.StructureCurrentProblemTypeG;
+import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.mw.air._interface.diversity.pac.AirInterfaceDiversityCurrentProblems;
+import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.mw.air._interface.pac.AirInterfaceConfiguration;
+import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.mw.air._interface.pac.AirInterfaceCurrentProblems;
+import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.mw.air._interface.pac.AirInterfaceHistoricalPerformances;
+import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.mw.ethernet.container.pac.EthernetContainerCurrentProblems;
+import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.mw.ethernet.container.pac.EthernetContainerHistoricalPerformances;
+import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.mw.hybrid.mw.structure.pac.HybridMwStructureCurrentProblems;
+import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.mw.pure.ethernet.structure.pac.PureEthernetStructureCurrentProblems;
+import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.mw.tdm.container.pac.TdmContainerCurrentProblems;
+import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.AttributeValueChangedNotification;
+import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.ObjectCreationNotification;
+import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.ObjectDeletionNotification;
+import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.ProblemNotification;
+
+
+public class WrapperMicrowaveModelRev180907 implements OnfMicrowaveModel, MicrowaveModelListener {
+
+ private static final Logger LOG = LoggerFactory.getLogger(ONFCoreNetworkElement12.class);
+
+ public static final QName QNAME = MwAirInterfacePac.QNAME;
+
+
+ private ONFCOreNetworkElementCoreData coreData;
+
+ private OnfMicrowaveModelNotification microwaveModelListener;
+
+
+ /*-----------------------------------------------------------------------------
+ * Setter/Getter
+ */
+
+ public void setCoreData(ONFCOreNetworkElementCoreData coreData) {
+ this.coreData = coreData;
+ }
+
+ public ONFCOreNetworkElementCoreData getCoreData() {
+ return coreData;
+ }
+
+ @Override
+ public void setOnfMicrowaveModelListener(OnfMicrowaveModelNotification microwaveModelListener) {
+ this.microwaveModelListener = microwaveModelListener;
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public <T extends NotificationListener> T getNotificationListener() {
+ return (T) this;
+ }
+
+ /*-----------------------------------------------------------------------------
+ * Interfacefunctions
+ */
+
+ public void readTheFaultsOfMicrowaveModel(ONFLayerProtocolName lpName, Class<?> lpClass, UniversalId uuid,
+ List<ProblemNotificationXml> resultList) {
+
+ switch (lpName) {
+ case MWAirInterface:
+ readTheFaultsOfMwAirInterfacePac(uuid, resultList);
+ break;
+
+ case EthernetContainer12:
+ readTheFaultsOfMwEthernetContainerPac(uuid, resultList);
+ break;
+
+ case TDMContainer:
+ readTheFaultsOfMwTdmContainerPac(uuid, resultList);
+ break;
+
+ case Structure:
+ if (lpClass == MwHybridMwStructurePac.class) {
+ readTheFaultsOfMwHybridMwStructurePac(uuid, resultList);
+
+ } else if (lpClass == MwAirInterfaceDiversityPac.class) {
+ readTheFaultsOfMwAirInterfaceDiversityPac(uuid, resultList);
+
+ } else if (lpClass == MwPureEthernetStructurePac.class) {
+ readTheFaultsOfMwPureEthernetStructurePac(uuid, resultList);
+
+ } else {
+ LOG.warn("Unassigned lp model {} class {}", lpName, lpClass);
+ }
+ break;
+ case Ethernet:
+ // No alarms supported
+ break;
+ case EthernetContainer10:
+ default:
+ LOG.warn("Unassigned or not expected lp in model {}", lpName);
+ }
+ }
+
+ public List<? extends OtnHistoryDataG> readTheHistoricalPerformanceData(ONFLayerProtocolName lpName, Lp lp) {
+ switch (lpName) {
+ case MWAirInterface:
+ return readTheHistoricalPerformanceDataOfMwAirInterfacePac(lp);
+
+ case EthernetContainer12:
+ return readTheHistoricalPerformanceDataOfEthernetContainer(lp);
+
+ case EthernetContainer10:
+ case EthernetPhysical:
+ case Ethernet:
+ case TDMContainer:
+ case Structure:
+ case Unknown:
+ LOG.debug("Do not read HistoricalPM data for {} {}", lpName, lp.getUuid().getValue());
+ break;
+ }
+ return new ArrayList<>();
+ }
+
+ public Class<?> getClassForLtpExtension(QName qName) {
+ Class<?> res = null;
+ if (qName.equals(MwAirInterfacePac.QNAME)) {
+ res = MwAirInterfacePac.class;
+ } else if (qName.equals(MwAirInterfaceDiversityPac.QNAME)) {
+ res = MwAirInterfaceDiversityPac.class;
+ } else if (qName.equals(MwPureEthernetStructurePac.QNAME)) {
+ res = MwPureEthernetStructurePac.class;
+ } else if (qName.equals(MwHybridMwStructurePac.QNAME)) {
+ res = MwHybridMwStructurePac.class;
+ } else if (qName.equals(MwEthernetContainerPac.QNAME)) {
+ res = MwEthernetContainerPac.class;
+ } else if (qName.equals(MwTdmContainerPac.QNAME)) {
+ res = MwTdmContainerPac.class;
+ }
+ LOG.info("Found QName {} mapped to {}", String.valueOf(qName), String.valueOf(res));
+ return res;
+ }
+
+ /*-----------------------------------------------------------------------------
+ * Reading problems for specific interface pacs
+ */
+
+ /**
+ * Read problems of specific interfaces
+ *
+ * @param uuId Universal Id String of the interface
+ * @return number of alarms
+ */
+ private List<ProblemNotificationXml> readTheFaultsOfMwAirInterfacePac(UniversalId interfacePacUuid,
+ List<ProblemNotificationXml> resultList) {
+
+ final Class<MwAirInterfacePac> clazzPac = MwAirInterfacePac.class;
+ // final Class<MwAirInterfacePacKey> clazzPacKey = MwAirInterfacePacKey.class;
+ // final Class<AirInterfaceCurrentProblems> clazzProblems =
+ // AirInterfaceCurrentProblems.class;
+ // final Class<AirInterfaceCurrentProblemTypeG> clazzProblem =
+ // AirInterfaceCurrentProblemTypeG.class;
+
+ LOG.info("DBRead Get problems for class {} from mountpoint {} for uuid {}", clazzPac.getSimpleName(),
+ coreData.getMountpoint(), interfacePacUuid.getValue());
+
+ // Step 2.2: construct data and the relative iid
+ InstanceIdentifier<AirInterfaceCurrentProblems> mwAirInterfaceIID = InstanceIdentifier
+ .builder(MwAirInterfacePac.class, new MwAirInterfacePacKey(interfacePacUuid))
+ .child(AirInterfaceCurrentProblems.class).build();
+
+ // Step 2.3: read to the config data store
+ AirInterfaceCurrentProblems problems = GenericTransactionUtils.readData(coreData.getDataBroker(),
+ LogicalDatastoreType.OPERATIONAL, mwAirInterfaceIID);
+
+ if (problems == null) {
+ LOG.debug("DBRead Id {} no AirInterfaceCurrentProblems", interfacePacUuid);
+ } else if (problems.getCurrentProblemList() == null) {
+ LOG.debug("DBRead Id {} empty CurrentProblemList", interfacePacUuid);
+ } else {
+ for (AirInterfaceCurrentProblemTypeG problem : problems.getCurrentProblemList()) {
+ resultList.add(new ProblemNotificationXml(coreData.getMountpoint(), interfacePacUuid.getValue(),
+ problem.getProblemName(), InternalSeverity.valueOf(problem.getProblemSeverity()),
+ problem.getSequenceNumber().toString(), InternalDateAndTime.valueOf(problem.getTimeStamp())));
+ }
+ }
+ return resultList;
+ }
+
+ /**
+ * Read problems of specific interfaces
+ *
+ * @param uuId Universal index of Interfacepac
+ * @return number of alarms
+ */
+ private List<ProblemNotificationXml> readTheFaultsOfMwEthernetContainerPac(UniversalId interfacePacUuid,
+ List<ProblemNotificationXml> resultList) {
+
+ final Class<MwEthernetContainerPac> clazzPac = MwEthernetContainerPac.class;
+ // final Class<MwEthernetContainerPacKey> clazzPacKey =
+ // MwEthernetContainerPacKey.class;
+ // final Class<EthernetContainerCurrentProblems> clazzProblems =
+ // EthernetContainerCurrentProblems.class;
+ // final Class<ContainerCurrentProblemTypeG> clazzProblem =
+ // ContainerCurrentProblemTypeG.class;
+
+ LOG.info("DBRead Get problems for class {} from mountpoint {} for uuid {}", clazzPac.getSimpleName(),
+ coreData.getMountpoint(), interfacePacUuid.getValue());
+
+ InstanceIdentifier<EthernetContainerCurrentProblems> mwEthInterfaceIID = InstanceIdentifier
+ .builder(MwEthernetContainerPac.class, new MwEthernetContainerPacKey(interfacePacUuid))
+ .child(EthernetContainerCurrentProblems.class).build();
+
+ EthernetContainerCurrentProblems problems = GenericTransactionUtils.readData(coreData.getDataBroker(),
+ LogicalDatastoreType.OPERATIONAL, mwEthInterfaceIID);
+ if (problems == null) {
+ LOG.debug("DBRead Id {} no EthernetContainerCurrentProblems", interfacePacUuid);
+ } else if (problems.getCurrentProblemList() == null) {
+ LOG.debug("DBRead Id {} empty CurrentProblemsList", interfacePacUuid);
+ } else {
+ for (ContainerCurrentProblemTypeG problem : problems.getCurrentProblemList()) {
+ resultList.add(new ProblemNotificationXml(coreData.getMountpoint(), interfacePacUuid.getValue(),
+ problem.getProblemName(), InternalSeverity.valueOf(problem.getProblemSeverity()),
+ problem.getSequenceNumber().toString(), InternalDateAndTime.valueOf(problem.getTimeStamp())));
+ }
+ }
+ return resultList;
+ }
+
+ /**
+ * Read problems of specific interfaces
+ *
+ * @param uuId Universal index of Interfacepac
+ * @return number of alarms
+ */
+ private List<ProblemNotificationXml> readTheFaultsOfMwAirInterfaceDiversityPac(UniversalId interfacePacUuid,
+ List<ProblemNotificationXml> resultList) {
+
+ final Class<MwAirInterfaceDiversityPac> clazzPac = MwAirInterfaceDiversityPac.class;
+ // final Class<MwAirInterfaceDiversityPacKey> clazzPacKey =
+ // MwAirInterfaceDiversityPacKey.class;
+ final Class<AirInterfaceDiversityCurrentProblems> clazzProblems = AirInterfaceDiversityCurrentProblems.class;
+ // final Class<AirInterfaceDiversityCurrentProblemTypeG> clazzProblem =
+ // AirInterfaceDiversityCurrentProblemTypeG.class;
+
+ LOG.info("DBRead Get problems for class {} from mountpoint {} for uuid {}", clazzPac.getSimpleName(),
+ coreData.getMountpoint(), interfacePacUuid.getValue());
+
+ InstanceIdentifier<AirInterfaceDiversityCurrentProblems> mwEthInterfaceIID = InstanceIdentifier
+ .builder(clazzPac, new MwAirInterfaceDiversityPacKey(interfacePacUuid)).child(clazzProblems).build();
+
+ AirInterfaceDiversityCurrentProblems problems = GenericTransactionUtils.readData(coreData.getDataBroker(),
+ LogicalDatastoreType.OPERATIONAL, mwEthInterfaceIID);
+ if (problems == null) {
+ LOG.debug("DBRead Id {} no AirInterfaceDiversityCurrentProblems", interfacePacUuid);
+ } else if (problems.getCurrentProblemList() == null) {
+ LOG.debug("DBRead Id {} empty CurrentProblemList", interfacePacUuid);
+ } else {
+ for (AirInterfaceDiversityCurrentProblemTypeG problem : problems.getCurrentProblemList()) {
+ resultList.add(new ProblemNotificationXml(coreData.getMountpoint(), interfacePacUuid.getValue(),
+ problem.getProblemName(), InternalSeverity.valueOf(problem.getProblemSeverity()),
+ problem.getSequenceNumber().toString(), InternalDateAndTime.valueOf(problem.getTimeStamp())));
+ }
+ }
+ return resultList;
+ }
+
+ /**
+ * Read problems of specific interfaces
+ *
+ * @param uuId Universal index of Interfacepac
+ * @return number of alarms
+ */
+ private List<ProblemNotificationXml> readTheFaultsOfMwPureEthernetStructurePac(UniversalId interfacePacUuid,
+ List<ProblemNotificationXml> resultList) {
+
+ final Class<MwPureEthernetStructurePac> clazzPac = MwPureEthernetStructurePac.class;
+ // final Class<MwPureEthernetStructurePacKey> clazzPacKey =
+ // MwPureEthernetStructurePacKey.class;
+ final Class<PureEthernetStructureCurrentProblems> clazzProblems = PureEthernetStructureCurrentProblems.class;
+ // final Class<StructureCurrentProblemTypeG> clazzProblem =
+ // StructureCurrentProblemTypeG.class;
+
+ LOG.info("DBRead Get problems for class {} from mountpoint {} for uuid {}", clazzPac.getSimpleName(),
+ coreData.getMountpoint(), interfacePacUuid.getValue());
+
+ InstanceIdentifier<PureEthernetStructureCurrentProblems> mwEthInterfaceIID = InstanceIdentifier
+ .builder(clazzPac, new MwPureEthernetStructurePacKey(interfacePacUuid)).child(clazzProblems).build();
+
+ PureEthernetStructureCurrentProblems problems = GenericTransactionUtils.readData(coreData.getDataBroker(),
+ LogicalDatastoreType.OPERATIONAL, mwEthInterfaceIID);
+ if (problems == null) {
+ LOG.debug("DBRead Id {} no PureEthernetStructureCurrentProblems", interfacePacUuid);
+ } else if (problems.getCurrentProblemList() == null) {
+ LOG.debug("DBRead Id {} empty CurrentProblemsList", interfacePacUuid);
+ } else {
+ for (StructureCurrentProblemTypeG problem : problems.getCurrentProblemList()) {
+ resultList.add(new ProblemNotificationXml(coreData.getMountpoint(), interfacePacUuid.getValue(),
+ problem.getProblemName(), InternalSeverity.valueOf(problem.getProblemSeverity()),
+ problem.getSequenceNumber().toString(), InternalDateAndTime.valueOf(problem.getTimeStamp())));
+ }
+ }
+ return resultList;
+ }
+
+ /**
+ * Read problems of specific interfaces
+ *
+ * @param uuId Universal index of Interfacepac
+ * @return number of alarms
+ */
+ private List<ProblemNotificationXml> readTheFaultsOfMwHybridMwStructurePac(UniversalId interfacePacUuid,
+ List<ProblemNotificationXml> resultList) {
+
+ final Class<MwHybridMwStructurePac> clazzPac = MwHybridMwStructurePac.class;
+ // final Class<MwHybridMwStructurePacKey> clazzPacKey =
+ // MwHybridMwStructurePacKey.class;
+ final Class<HybridMwStructureCurrentProblems> clazzProblems = HybridMwStructureCurrentProblems.class;
+ // final Class<HybridMwStructureCurrentProblemsG> clazzProblem =
+ // HybridMwStructureCurrentProblemsG.class;
+
+ LOG.info("DBRead Get problems for class {} from mountpoint {} for uuid {}", clazzPac.getSimpleName(),
+ coreData.getMountpoint(), interfacePacUuid.getValue());
+
+ InstanceIdentifier<HybridMwStructureCurrentProblems> mwEthInterfaceIID = InstanceIdentifier
+ .builder(clazzPac, new MwHybridMwStructurePacKey(interfacePacUuid)).child(clazzProblems).build();
+
+ HybridMwStructureCurrentProblems problems = GenericTransactionUtils.readData(coreData.getDataBroker(),
+ LogicalDatastoreType.OPERATIONAL, mwEthInterfaceIID);
+ if (problems == null) {
+ LOG.debug("DBRead Id {} no HybridMwStructureCurrentProblems", interfacePacUuid);
+ } else if (problems.getCurrentProblemList() == null) {
+ LOG.debug("DBRead Id {} empty CurrentProblemsList", interfacePacUuid);
+ } else {
+ for (StructureCurrentProblemTypeG problem : problems.getCurrentProblemList()) {
+ resultList.add(new ProblemNotificationXml(coreData.getMountpoint(), interfacePacUuid.getValue(),
+ problem.getProblemName(), InternalSeverity.valueOf(problem.getProblemSeverity()),
+ problem.getSequenceNumber().toString(), InternalDateAndTime.valueOf(problem.getTimeStamp())));
+ }
+ }
+ return resultList;
+ }
+
+ /**
+ * Read problems of specific interfaces. TODO Goal for future implementation
+ * without usage of explicit new. Key is generated by newInstance() function
+ * here to verify this approach.
+ *
+ * @param uuId Universal index of Interfacepac
+ * @return number of alarms
+ * @throws SecurityException
+ * @throws NoSuchMethodException
+ * @throws InvocationTargetException
+ * @throws IllegalArgumentException
+ * @throws IllegalAccessException
+ * @throws InstantiationException
+ */
+ private List<ProblemNotificationXml> readTheFaultsOfMwTdmContainerPac(UniversalId interfacePacUuid,
+ List<ProblemNotificationXml> resultList) {
+
+ final Class<MwTdmContainerPac> clazzPac = MwTdmContainerPac.class;
+ final Class<MwTdmContainerPacKey> clazzPacKey = MwTdmContainerPacKey.class;
+ final Class<TdmContainerCurrentProblems> clazzProblems = TdmContainerCurrentProblems.class;
+ // final Class<ContainerCurrentProblemTypeG> clazzProblem =
+ // ContainerCurrentProblemTypeG.class;
+
+ LOG.info("DBRead Get problems for class {} from mountpoint {} for uuid {}", clazzPac.getSimpleName(),
+ coreData.getMountpoint(), interfacePacUuid.getValue());
+
+ try {
+ // -- Specific part 1
+ Constructor<MwTdmContainerPacKey> cons = clazzPacKey.getConstructor(UniversalId.class); // Avoid new()
+ InstanceIdentifier<TdmContainerCurrentProblems> mwEthInterfaceIID = InstanceIdentifier
+ .builder(clazzPac, cons.newInstance(interfacePacUuid)).child(clazzProblems).build();
+
+ // -- Specific part 2
+ TdmContainerCurrentProblems problems = GenericTransactionUtils.readData(coreData.getDataBroker(),
+ LogicalDatastoreType.OPERATIONAL, mwEthInterfaceIID);
+ if (problems == null) {
+ LOG.debug("DBRead Id {} no TdmContainerCurrentProblems", interfacePacUuid);
+ } else if (problems.getCurrentProblemList() == null) {
+ LOG.debug("DBRead Id {} empty CurrentProblemsList", interfacePacUuid);
+ } else {
+ // -- Specific part 3
+ for (ContainerCurrentProblemTypeG problem : problems.getCurrentProblemList()) {
+ resultList.add(new ProblemNotificationXml(coreData.getMountpoint(), interfacePacUuid.getValue(),
+ problem.getProblemName(), InternalSeverity.valueOf(problem.getProblemSeverity()),
+ problem.getSequenceNumber().toString(),
+ InternalDateAndTime.valueOf(problem.getTimeStamp())));
+ }
+ }
+ } catch (NoSuchMethodException | SecurityException | InstantiationException | IllegalAccessException
+ | IllegalArgumentException | InvocationTargetException e) {
+ LOG.warn("Could not reade instance of MwTdmContainerPacKey: ", e);
+ }
+ return resultList;
+ }
+
+ /*-----------------------------------------------------------------------------
+ * Performance related data
+ */
+
+ /**
+ * PM MwAirInterfacePac
+ *
+ * @param lp
+ * @return
+ */
+ private List<ExtendedAirInterfaceHistoricalPerformanceType1211> readTheHistoricalPerformanceDataOfMwAirInterfacePac(
+ Lp lp) {
+
+ String uuId = lp.getUuid().getValue();
+
+ List<ExtendedAirInterfaceHistoricalPerformanceType1211> resultList = new ArrayList<>();
+ LOG.debug("DBRead Get {} MWAirInterfacePac: {}", coreData.getMountpoint(), uuId);
+ // ----
+ UniversalId mwAirInterfacePacuuId = new UniversalId(uuId);
+ // Step 2.1: construct data and the relative iid
+ InstanceIdentifier<AirInterfaceConfiguration> mwAirInterfaceConfigurationIID = InstanceIdentifier
+ .builder(MwAirInterfacePac.class, new MwAirInterfacePacKey(mwAirInterfacePacuuId))
+ .child(AirInterfaceConfiguration.class).build();
+ AirInterfaceConfiguration airConfiguration = GenericTransactionUtils.readData(coreData.getDataBroker(),
+ LogicalDatastoreType.OPERATIONAL, mwAirInterfaceConfigurationIID);
+
+ if (airConfiguration == null) {
+ LOG.debug("DBRead MWAirInterfacePac Id {} no AirInterfaceConfiguration", mwAirInterfacePacuuId);
+
+ } else {
+ // Step 2.2: construct data and the relative iid
+ InstanceIdentifier<AirInterfaceHistoricalPerformances> mwAirInterfaceHistoricalPerformanceIID = InstanceIdentifier
+ .builder(MwAirInterfacePac.class, new MwAirInterfacePacKey(mwAirInterfacePacuuId))
+ .child(AirInterfaceHistoricalPerformances.class).build();
+
+ // Step 2.3: read to the config data store
+ AirInterfaceHistoricalPerformances airHistoricalPerformanceData = GenericTransactionUtils.readData(
+ coreData.getDataBroker(), LogicalDatastoreType.OPERATIONAL, mwAirInterfaceHistoricalPerformanceIID);
+
+ if (airHistoricalPerformanceData == null) {
+ LOG.debug("DBRead MWAirInterfacePac Id {} no AirInterfaceHistoricalPerformances",
+ mwAirInterfacePacuuId);
+ } else {
+ // org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170320.air._interface.historical.performances.g.HistoricalPerformanceDataList
+ List<org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.air._interface.historical.performances.g.HistoricalPerformanceDataList> airHistPMList = airHistoricalPerformanceData
+ .getHistoricalPerformanceDataList();
+ LOG.debug("DBRead MWAirInterfacePac Id {} Records intermediate: {}", mwAirInterfacePacuuId,
+ airHistPMList.size());
+ if (airHistPMList != null) {
+ for (AirInterfaceHistoricalPerformanceTypeG pmRecord : airHistoricalPerformanceData
+ .getHistoricalPerformanceDataList()) {
+ resultList.add(new ExtendedAirInterfaceHistoricalPerformanceType1211(pmRecord, airConfiguration));
+ }
+ }
+ }
+ }
+ LOG.debug("DBRead MWAirInterfacePac Id {} Records result: {}", mwAirInterfacePacuuId, resultList.size());
+ return resultList;
+ }
+
+ private List<ContainerHistoricalPerformanceTypeG> readTheHistoricalPerformanceDataOfEthernetContainer(Lp lp) {
+
+ final String myName = "MWEthernetContainerPac";
+ String uuId = lp.getUuid().getValue();
+
+ List<ContainerHistoricalPerformanceTypeG> resultList = new ArrayList<>();
+ LOG.debug("DBRead Get {} : {}", coreData.getMountpoint(), myName, uuId);
+ // ----
+ UniversalId ethContainerPacuuId = new UniversalId(uuId);
+ // Step 2.2: construct data and the relative iid
+ InstanceIdentifier<EthernetContainerHistoricalPerformances> ethContainerIID = InstanceIdentifier
+ .builder(MwEthernetContainerPac.class, new MwEthernetContainerPacKey(ethContainerPacuuId))
+ .child(EthernetContainerHistoricalPerformances.class).build();
+
+ // Step 2.3: read to the config data store
+ EthernetContainerHistoricalPerformances ethContainerHistoricalPerformanceData = GenericTransactionUtils
+ .readData(coreData.getDataBroker(), LogicalDatastoreType.OPERATIONAL, ethContainerIID);
+
+ if (ethContainerHistoricalPerformanceData == null) {
+ LOG.debug("DBRead {} Id {} no HistoricalPerformances", myName, ethContainerPacuuId);
+ } else {
+ // import
+ // org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170320.ethernet.container.historical.performances.g.HistoricalPerformanceDataList
+ List<org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.ethernet.container.historical.performances.g.HistoricalPerformanceDataList> airHistPMList = ethContainerHistoricalPerformanceData
+ .getHistoricalPerformanceDataList();
+ LOG.debug("DBRead {} Id {} Records intermediate: {}", myName, ethContainerPacuuId, airHistPMList.size());
+ if (airHistPMList != null) {
+ for (ContainerHistoricalPerformanceTypeG pmRecord : airHistPMList) {
+ resultList.add(pmRecord);
+ }
+ }
+ }
+ LOG.debug("DBRead {} Id {} Records result: {}", myName, ethContainerPacuuId, resultList.size());
+ return resultList;
+ }
+
+ @Override
+ public void onObjectCreationNotification(ObjectCreationNotification notification) {
+ LOG.debug("Got event of type :: {}", ObjectCreationNotification.class.getSimpleName());
+
+ ObjectCreationNotificationXml notificationXml = new ObjectCreationNotificationXml(coreData.getMountpoint(),
+ notification.getCounter().toString(),
+ InternalDateAndTime.valueOf(notification.getTimeStamp()),
+ notification.getObjectIdRef().getValue());
+ microwaveModelListener.onObjectCreationNotification(notificationXml);
+ }
+
+ @Override
+ public void onObjectDeletionNotification(ObjectDeletionNotification notification) {
+ LOG.debug("Got event of type :: {}", ObjectDeletionNotification.class.getSimpleName());
+
+ ObjectDeletionNotificationXml notificationXml = new ObjectDeletionNotificationXml(coreData.getMountpoint(),
+ notification.getCounter().toString(),
+ InternalDateAndTime.valueOf(notification.getTimeStamp()),
+ notification.getObjectIdRef().getValue()
+ );
+ microwaveModelListener.onObjectDeletionNotification(notificationXml);
+ }
+
+ public void onProblemNotification(ProblemNotification notification) {
+
+ LOG.debug("Got event of type :: {}", ProblemNotification.class.getSimpleName());
+
+ ProblemNotificationXml notificationXml = new ProblemNotificationXml(coreData.getMountpoint(), notification.getObjectIdRef().getValue(),
+ notification.getProblem(), InternalSeverity.valueOf(notification.getSeverity()),
+ notification.getCounter().toString(), InternalDateAndTime.valueOf(notification.getTimeStamp()));
+
+ microwaveModelListener.onProblemNotification(notificationXml);
+ }
+
+ @Override
+ public void onAttributeValueChangedNotification(AttributeValueChangedNotification notification) {
+ LOG.debug("Got event of type :: {}", AttributeValueChangedNotification.class.getSimpleName());
+
+ AttributeValueChangedNotificationXml notificationXml = new AttributeValueChangedNotificationXml(coreData.getMountpoint(),
+ String.valueOf(notification.getCounter()), InternalDateAndTime.valueOf(notification.getTimeStamp()),
+ notification.getObjectIdRef().getValue(), notification.getAttributeName(), notification.getNewValue());
+
+ microwaveModelListener.onAttributeValueChangedNotification(notificationXml);
+ }
+
+}
diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/wrapperc/WrapperMicrowaveModelRev181010.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/wrapperc/WrapperMicrowaveModelRev181010.java
new file mode 100644
index 000000000..c3970a8d4
--- /dev/null
+++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/wrapperc/WrapperMicrowaveModelRev181010.java
@@ -0,0 +1,594 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 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.base.netconf.wrapperc;
+
+
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.opendaylight.yangtools.yang.binding.NotificationListener;
+import org.opendaylight.yangtools.yang.common.QName;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.internalTypes.InternalDateAndTime;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.internalTypes.InternalSeverity;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.netconf.ONFCOreNetworkElementCoreData;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.netconf.ONFCoreNetworkElement12;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.netconf.container.ExtendedAirInterfaceHistoricalPerformanceType1211p;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.netconf.container.ONFLayerProtocolName;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.netconf.util.GenericTransactionUtils;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.xml.AttributeValueChangedNotificationXml;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.xml.ObjectCreationNotificationXml;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.xml.ObjectDeletionNotificationXml;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.xml.ProblemNotificationXml;
+import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+
+import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.logical.termination.point.g.Lp;
+import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.g._874._1.model.rev170320.OtnHistoryDataG;
+import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.UniversalId;
+import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.AirInterfaceCurrentProblemTypeG;
+import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.AirInterfaceDiversityCurrentProblemTypeG;
+import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.AirInterfaceHistoricalPerformanceTypeG;
+import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.ContainerCurrentProblemTypeG;
+import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.ContainerHistoricalPerformanceTypeG;
+import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.MicrowaveModelListener;
+import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.MwAirInterfaceDiversityPac;
+import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.MwAirInterfaceDiversityPacKey;
+import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.MwAirInterfacePac;
+import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.MwAirInterfacePacKey;
+import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.MwEthernetContainerPac;
+import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.MwEthernetContainerPacKey;
+import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.MwHybridMwStructurePac;
+import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.MwHybridMwStructurePacKey;
+import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.MwPureEthernetStructurePac;
+import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.MwPureEthernetStructurePacKey;
+import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.MwTdmContainerPac;
+import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.MwTdmContainerPacKey;
+import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.StructureCurrentProblemTypeG;
+import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.mw.air._interface.diversity.pac.AirInterfaceDiversityCurrentProblems;
+import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.mw.air._interface.pac.AirInterfaceConfiguration;
+import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.mw.air._interface.pac.AirInterfaceCurrentProblems;
+import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.mw.air._interface.pac.AirInterfaceHistoricalPerformances;
+import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.mw.ethernet.container.pac.EthernetContainerCurrentProblems;
+import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.mw.ethernet.container.pac.EthernetContainerHistoricalPerformances;
+import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.mw.hybrid.mw.structure.pac.HybridMwStructureCurrentProblems;
+import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.mw.pure.ethernet.structure.pac.PureEthernetStructureCurrentProblems;
+import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.mw.tdm.container.pac.TdmContainerCurrentProblems;
+import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.AttributeValueChangedNotification;
+import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.ObjectCreationNotification;
+import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.ObjectDeletionNotification;
+import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.ProblemNotification;
+
+
+public class WrapperMicrowaveModelRev181010 implements OnfMicrowaveModel, MicrowaveModelListener {
+
+ private static final Logger LOG = LoggerFactory.getLogger(ONFCoreNetworkElement12.class);
+
+ public static final QName QNAME = MwAirInterfacePac.QNAME;
+
+
+ private ONFCOreNetworkElementCoreData coreData;
+
+ private OnfMicrowaveModelNotification microwaveModelListener;
+
+ /*-----------------------------------------------------------------------------
+ * Setter/Getter
+ */
+
+ public void setCoreData(ONFCOreNetworkElementCoreData coreData) {
+ this.coreData = coreData;
+ }
+
+ public ONFCOreNetworkElementCoreData getCoreData() {
+ return coreData;
+ }
+
+ @Override
+ public void setOnfMicrowaveModelListener(OnfMicrowaveModelNotification microwaveModelListener) {
+ this.microwaveModelListener = microwaveModelListener;
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public <T extends NotificationListener> T getNotificationListener() {
+ return (T) this;
+ }
+
+ /*-----------------------------------------------------------------------------
+ * Interfacefunctions
+ */
+
+ public void readTheFaultsOfMicrowaveModel(ONFLayerProtocolName lpName, Class<?> lpClass, UniversalId uuid,
+ List<ProblemNotificationXml> resultList) {
+
+ switch (lpName) {
+ case MWAirInterface:
+ readTheFaultsOfMwAirInterfacePac(uuid, resultList);
+ break;
+
+ case EthernetContainer12:
+ readTheFaultsOfMwEthernetContainerPac(uuid, resultList);
+ break;
+
+ case TDMContainer:
+ readTheFaultsOfMwTdmContainerPac(uuid, resultList);
+ break;
+
+ case Structure:
+ if (lpClass == MwHybridMwStructurePac.class) {
+ readTheFaultsOfMwHybridMwStructurePac(uuid, resultList);
+
+ } else if (lpClass == MwAirInterfaceDiversityPac.class) {
+ readTheFaultsOfMwAirInterfaceDiversityPac(uuid, resultList);
+
+ } else if (lpClass == MwPureEthernetStructurePac.class) {
+ readTheFaultsOfMwPureEthernetStructurePac(uuid, resultList);
+
+ } else {
+ LOG.warn("Unassigned lp model {} class {}", lpName, lpClass);
+ }
+ break;
+ case Ethernet:
+ // No alarms supported
+ break;
+ case EthernetContainer10:
+ default:
+ LOG.warn("Unassigned or not expected lp in model {}", lpName);
+ }
+ }
+
+ public List<? extends OtnHistoryDataG> readTheHistoricalPerformanceData(ONFLayerProtocolName lpName, Lp lp) {
+ switch (lpName) {
+ case MWAirInterface:
+ return readTheHistoricalPerformanceDataOfMwAirInterfacePac(lp);
+
+ case EthernetContainer12:
+ return readTheHistoricalPerformanceDataOfEthernetContainer(lp);
+
+ case EthernetContainer10:
+ case EthernetPhysical:
+ case Ethernet:
+ case TDMContainer:
+ case Structure:
+ case Unknown:
+ LOG.debug("Do not read HistoricalPM data for {} {}", lpName, lp.getUuid().getValue());
+ break;
+ }
+ return new ArrayList<>();
+ }
+
+ public Class<?> getClassForLtpExtension(QName qName) {
+ Class<?> res = null;
+ if (qName.equals(MwAirInterfacePac.QNAME)) {
+ res = MwAirInterfacePac.class;
+ } else if (qName.equals(MwAirInterfaceDiversityPac.QNAME)) {
+ res = MwAirInterfaceDiversityPac.class;
+ } else if (qName.equals(MwPureEthernetStructurePac.QNAME)) {
+ res = MwPureEthernetStructurePac.class;
+ } else if (qName.equals(MwHybridMwStructurePac.QNAME)) {
+ res = MwHybridMwStructurePac.class;
+ } else if (qName.equals(MwEthernetContainerPac.QNAME)) {
+ res = MwEthernetContainerPac.class;
+ } else if (qName.equals(MwTdmContainerPac.QNAME)) {
+ res = MwTdmContainerPac.class;
+ }
+ LOG.info("Found QName {} mapped to {}", String.valueOf(qName), String.valueOf(res));
+ return res;
+ }
+
+ /*-----------------------------------------------------------------------------
+ * Reading problems for specific interface pacs
+ */
+
+ /**
+ * Read problems of specific interfaces
+ *
+ * @param uuId Universal Id String of the interface
+ * @return number of alarms
+ */
+ private List<ProblemNotificationXml> readTheFaultsOfMwAirInterfacePac(UniversalId interfacePacUuid,
+ List<ProblemNotificationXml> resultList) {
+
+ final Class<MwAirInterfacePac> clazzPac = MwAirInterfacePac.class;
+ // final Class<MwAirInterfacePacKey> clazzPacKey = MwAirInterfacePacKey.class;
+ // final Class<AirInterfaceCurrentProblems> clazzProblems =
+ // AirInterfaceCurrentProblems.class;
+ // final Class<AirInterfaceCurrentProblemTypeG> clazzProblem =
+ // AirInterfaceCurrentProblemTypeG.class;
+
+ LOG.info("DBRead Get problems for class {} from mountpoint {} for uuid {}", clazzPac.getSimpleName(),
+ coreData.getMountpoint(), interfacePacUuid.getValue());
+
+ // Step 2.2: construct data and the relative iid
+ InstanceIdentifier<AirInterfaceCurrentProblems> mwAirInterfaceIID = InstanceIdentifier
+ .builder(MwAirInterfacePac.class, new MwAirInterfacePacKey(interfacePacUuid))
+ .child(AirInterfaceCurrentProblems.class).build();
+
+ // Step 2.3: read to the config data store
+ AirInterfaceCurrentProblems problems = GenericTransactionUtils.readData(coreData.getDataBroker(),
+ LogicalDatastoreType.OPERATIONAL, mwAirInterfaceIID);
+
+ if (problems == null) {
+ LOG.debug("DBRead Id {} no AirInterfaceCurrentProblems", interfacePacUuid);
+ } else if (problems.getCurrentProblemList() == null) {
+ LOG.debug("DBRead Id {} empty CurrentProblemList", interfacePacUuid);
+ } else {
+ for (AirInterfaceCurrentProblemTypeG problem : problems.getCurrentProblemList()) {
+ resultList.add(new ProblemNotificationXml(coreData.getMountpoint(), interfacePacUuid.getValue(),
+ problem.getProblemName(), InternalSeverity.valueOf(problem.getProblemSeverity()),
+ problem.getSequenceNumber().toString(), InternalDateAndTime.valueOf(problem.getTimeStamp())));
+ }
+ }
+ return resultList;
+ }
+
+ /**
+ * Read problems of specific interfaces
+ *
+ * @param uuId Universal index of Interfacepac
+ * @return number of alarms
+ */
+ private List<ProblemNotificationXml> readTheFaultsOfMwEthernetContainerPac(UniversalId interfacePacUuid,
+ List<ProblemNotificationXml> resultList) {
+
+ final Class<MwEthernetContainerPac> clazzPac = MwEthernetContainerPac.class;
+ // final Class<MwEthernetContainerPacKey> clazzPacKey =
+ // MwEthernetContainerPacKey.class;
+ // final Class<EthernetContainerCurrentProblems> clazzProblems =
+ // EthernetContainerCurrentProblems.class;
+ // final Class<ContainerCurrentProblemTypeG> clazzProblem =
+ // ContainerCurrentProblemTypeG.class;
+
+ LOG.info("DBRead Get problems for class {} from mountpoint {} for uuid {}", clazzPac.getSimpleName(),
+ coreData.getMountpoint(), interfacePacUuid.getValue());
+
+ InstanceIdentifier<EthernetContainerCurrentProblems> mwEthInterfaceIID = InstanceIdentifier
+ .builder(MwEthernetContainerPac.class, new MwEthernetContainerPacKey(interfacePacUuid))
+ .child(EthernetContainerCurrentProblems.class).build();
+
+ EthernetContainerCurrentProblems problems = GenericTransactionUtils.readData(coreData.getDataBroker(),
+ LogicalDatastoreType.OPERATIONAL, mwEthInterfaceIID);
+ if (problems == null) {
+ LOG.debug("DBRead Id {} no EthernetContainerCurrentProblems", interfacePacUuid);
+ } else if (problems.getCurrentProblemList() == null) {
+ LOG.debug("DBRead Id {} empty CurrentProblemsList", interfacePacUuid);
+ } else {
+ for (ContainerCurrentProblemTypeG problem : problems.getCurrentProblemList()) {
+ resultList.add(new ProblemNotificationXml(coreData.getMountpoint(), interfacePacUuid.getValue(),
+ problem.getProblemName(), InternalSeverity.valueOf(problem.getProblemSeverity()),
+ problem.getSequenceNumber().toString(), InternalDateAndTime.valueOf(problem.getTimeStamp())));
+ }
+ }
+ return resultList;
+ }
+
+ /**
+ * Read problems of specific interfaces
+ *
+ * @param uuId Universal index of Interfacepac
+ * @return number of alarms
+ */
+ private List<ProblemNotificationXml> readTheFaultsOfMwAirInterfaceDiversityPac(UniversalId interfacePacUuid,
+ List<ProblemNotificationXml> resultList) {
+
+ final Class<MwAirInterfaceDiversityPac> clazzPac = MwAirInterfaceDiversityPac.class;
+ // final Class<MwAirInterfaceDiversityPacKey> clazzPacKey =
+ // MwAirInterfaceDiversityPacKey.class;
+ final Class<AirInterfaceDiversityCurrentProblems> clazzProblems = AirInterfaceDiversityCurrentProblems.class;
+ // final Class<AirInterfaceDiversityCurrentProblemTypeG> clazzProblem =
+ // AirInterfaceDiversityCurrentProblemTypeG.class;
+
+ LOG.info("DBRead Get problems for class {} from mountpoint {} for uuid {}", clazzPac.getSimpleName(),
+ coreData.getMountpoint(), interfacePacUuid.getValue());
+
+ InstanceIdentifier<AirInterfaceDiversityCurrentProblems> mwEthInterfaceIID = InstanceIdentifier
+ .builder(clazzPac, new MwAirInterfaceDiversityPacKey(interfacePacUuid)).child(clazzProblems).build();
+
+ AirInterfaceDiversityCurrentProblems problems = GenericTransactionUtils.readData(coreData.getDataBroker(),
+ LogicalDatastoreType.OPERATIONAL, mwEthInterfaceIID);
+ if (problems == null) {
+ LOG.debug("DBRead Id {} no AirInterfaceDiversityCurrentProblems", interfacePacUuid);
+ } else if (problems.getCurrentProblemList() == null) {
+ LOG.debug("DBRead Id {} empty CurrentProblemList", interfacePacUuid);
+ } else {
+ for (AirInterfaceDiversityCurrentProblemTypeG problem : problems.getCurrentProblemList()) {
+ resultList.add(new ProblemNotificationXml(coreData.getMountpoint(), interfacePacUuid.getValue(),
+ problem.getProblemName(), InternalSeverity.valueOf(problem.getProblemSeverity()),
+ problem.getSequenceNumber().toString(), InternalDateAndTime.valueOf(problem.getTimeStamp())));
+ }
+ }
+ return resultList;
+ }
+
+ /**
+ * Read problems of specific interfaces
+ *
+ * @param uuId Universal index of Interfacepac
+ * @return number of alarms
+ */
+ private List<ProblemNotificationXml> readTheFaultsOfMwPureEthernetStructurePac(UniversalId interfacePacUuid,
+ List<ProblemNotificationXml> resultList) {
+
+ final Class<MwPureEthernetStructurePac> clazzPac = MwPureEthernetStructurePac.class;
+ // final Class<MwPureEthernetStructurePacKey> clazzPacKey =
+ // MwPureEthernetStructurePacKey.class;
+ final Class<PureEthernetStructureCurrentProblems> clazzProblems = PureEthernetStructureCurrentProblems.class;
+ // final Class<StructureCurrentProblemTypeG> clazzProblem =
+ // StructureCurrentProblemTypeG.class;
+
+ LOG.info("DBRead Get problems for class {} from mountpoint {} for uuid {}", clazzPac.getSimpleName(),
+ coreData.getMountpoint(), interfacePacUuid.getValue());
+
+ InstanceIdentifier<PureEthernetStructureCurrentProblems> mwEthInterfaceIID = InstanceIdentifier
+ .builder(clazzPac, new MwPureEthernetStructurePacKey(interfacePacUuid)).child(clazzProblems).build();
+
+ PureEthernetStructureCurrentProblems problems = GenericTransactionUtils.readData(coreData.getDataBroker(),
+ LogicalDatastoreType.OPERATIONAL, mwEthInterfaceIID);
+ if (problems == null) {
+ LOG.debug("DBRead Id {} no PureEthernetStructureCurrentProblems", interfacePacUuid);
+ } else if (problems.getCurrentProblemList() == null) {
+ LOG.debug("DBRead Id {} empty CurrentProblemsList", interfacePacUuid);
+ } else {
+ for (StructureCurrentProblemTypeG problem : problems.getCurrentProblemList()) {
+ resultList.add(new ProblemNotificationXml(coreData.getMountpoint(), interfacePacUuid.getValue(),
+ problem.getProblemName(), InternalSeverity.valueOf(problem.getProblemSeverity()),
+ problem.getSequenceNumber().toString(), InternalDateAndTime.valueOf(problem.getTimeStamp())));
+ }
+ }
+ return resultList;
+ }
+
+ /**
+ * Read problems of specific interfaces
+ *
+ * @param uuId Universal index of Interfacepac
+ * @return number of alarms
+ */
+ private List<ProblemNotificationXml> readTheFaultsOfMwHybridMwStructurePac(UniversalId interfacePacUuid,
+ List<ProblemNotificationXml> resultList) {
+
+ final Class<MwHybridMwStructurePac> clazzPac = MwHybridMwStructurePac.class;
+ // final Class<MwHybridMwStructurePacKey> clazzPacKey =
+ // MwHybridMwStructurePacKey.class;
+ final Class<HybridMwStructureCurrentProblems> clazzProblems = HybridMwStructureCurrentProblems.class;
+ // final Class<HybridMwStructureCurrentProblemsG> clazzProblem =
+ // HybridMwStructureCurrentProblemsG.class;
+
+ LOG.info("DBRead Get problems for class {} from mountpoint {} for uuid {}", clazzPac.getSimpleName(),
+ coreData.getMountpoint(), interfacePacUuid.getValue());
+
+ InstanceIdentifier<HybridMwStructureCurrentProblems> mwEthInterfaceIID = InstanceIdentifier
+ .builder(clazzPac, new MwHybridMwStructurePacKey(interfacePacUuid)).child(clazzProblems).build();
+
+ HybridMwStructureCurrentProblems problems = GenericTransactionUtils.readData(coreData.getDataBroker(),
+ LogicalDatastoreType.OPERATIONAL, mwEthInterfaceIID);
+ if (problems == null) {
+ LOG.debug("DBRead Id {} no HybridMwStructureCurrentProblems", interfacePacUuid);
+ } else if (problems.getCurrentProblemList() == null) {
+ LOG.debug("DBRead Id {} empty CurrentProblemsList", interfacePacUuid);
+ } else {
+ for (StructureCurrentProblemTypeG problem : problems.getCurrentProblemList()) {
+ resultList.add(new ProblemNotificationXml(coreData.getMountpoint(), interfacePacUuid.getValue(),
+ problem.getProblemName(), InternalSeverity.valueOf(problem.getProblemSeverity()),
+ problem.getSequenceNumber().toString(), InternalDateAndTime.valueOf(problem.getTimeStamp())));
+ }
+ }
+ return resultList;
+ }
+
+ /**
+ * Read problems of specific interfaces. TODO Goal for future implementation
+ * without usage of explicit new. Key is generated by newInstance() function
+ * here to verify this approach.
+ *
+ * @param uuId Universal index of Interfacepac
+ * @return number of alarms
+ * @throws SecurityException
+ * @throws NoSuchMethodException
+ * @throws InvocationTargetException
+ * @throws IllegalArgumentException
+ * @throws IllegalAccessException
+ * @throws InstantiationException
+ */
+ private List<ProblemNotificationXml> readTheFaultsOfMwTdmContainerPac(UniversalId interfacePacUuid,
+ List<ProblemNotificationXml> resultList) {
+
+ final Class<MwTdmContainerPac> clazzPac = MwTdmContainerPac.class;
+ final Class<MwTdmContainerPacKey> clazzPacKey = MwTdmContainerPacKey.class;
+ final Class<TdmContainerCurrentProblems> clazzProblems = TdmContainerCurrentProblems.class;
+ // final Class<ContainerCurrentProblemTypeG> clazzProblem =
+ // ContainerCurrentProblemTypeG.class;
+
+ LOG.info("DBRead Get problems for class {} from mountpoint {} for uuid {}", clazzPac.getSimpleName(),
+ coreData.getMountpoint(), interfacePacUuid.getValue());
+
+ try {
+ // -- Specific part 1
+ Constructor<MwTdmContainerPacKey> cons = clazzPacKey.getConstructor(UniversalId.class); // Avoid new()
+ InstanceIdentifier<TdmContainerCurrentProblems> mwEthInterfaceIID = InstanceIdentifier
+ .builder(clazzPac, cons.newInstance(interfacePacUuid)).child(clazzProblems).build();
+
+ // -- Specific part 2
+ TdmContainerCurrentProblems problems = GenericTransactionUtils.readData(coreData.getDataBroker(),
+ LogicalDatastoreType.OPERATIONAL, mwEthInterfaceIID);
+ if (problems == null) {
+ LOG.debug("DBRead Id {} no TdmContainerCurrentProblems", interfacePacUuid);
+ } else if (problems.getCurrentProblemList() == null) {
+ LOG.debug("DBRead Id {} empty CurrentProblemsList", interfacePacUuid);
+ } else {
+ // -- Specific part 3
+ for (ContainerCurrentProblemTypeG problem : problems.getCurrentProblemList()) {
+ resultList.add(new ProblemNotificationXml(coreData.getMountpoint(), interfacePacUuid.getValue(),
+ problem.getProblemName(), InternalSeverity.valueOf(problem.getProblemSeverity()),
+ problem.getSequenceNumber().toString(),
+ InternalDateAndTime.valueOf(problem.getTimeStamp())));
+ }
+ }
+ } catch (NoSuchMethodException | SecurityException | InstantiationException | IllegalAccessException
+ | IllegalArgumentException | InvocationTargetException e) {
+ LOG.warn("Could not reade instance of MwTdmContainerPacKey: ", e);
+ }
+ return resultList;
+ }
+
+ /*-----------------------------------------------------------------------------
+ * Performance related data
+ */
+
+ /**
+ * PM MwAirInterfacePac
+ *
+ * @param lp
+ * @return
+ */
+ private List<ExtendedAirInterfaceHistoricalPerformanceType1211p> readTheHistoricalPerformanceDataOfMwAirInterfacePac(
+ Lp lp) {
+
+ String uuId = lp.getUuid().getValue();
+
+ List<ExtendedAirInterfaceHistoricalPerformanceType1211p> resultList = new ArrayList<>();
+ LOG.debug("DBRead Get {} MWAirInterfacePac: {}", coreData.getMountpoint(), uuId);
+ // ----
+ UniversalId mwAirInterfacePacuuId = new UniversalId(uuId);
+ // Step 2.1: construct data and the relative iid
+ InstanceIdentifier<AirInterfaceConfiguration> mwAirInterfaceConfigurationIID = InstanceIdentifier
+ .builder(MwAirInterfacePac.class, new MwAirInterfacePacKey(mwAirInterfacePacuuId))
+ .child(AirInterfaceConfiguration.class).build();
+ AirInterfaceConfiguration airConfiguration = GenericTransactionUtils.readData(coreData.getDataBroker(),
+ LogicalDatastoreType.OPERATIONAL, mwAirInterfaceConfigurationIID);
+
+ if (airConfiguration == null) {
+ LOG.debug("DBRead MWAirInterfacePac Id {} no AirInterfaceConfiguration", mwAirInterfacePacuuId);
+
+ } else {
+ // Step 2.2: construct data and the relative iid
+ InstanceIdentifier<AirInterfaceHistoricalPerformances> mwAirInterfaceHistoricalPerformanceIID = InstanceIdentifier
+ .builder(MwAirInterfacePac.class, new MwAirInterfacePacKey(mwAirInterfacePacuuId))
+ .child(AirInterfaceHistoricalPerformances.class).build();
+
+ // Step 2.3: read to the config data store
+ AirInterfaceHistoricalPerformances airHistoricalPerformanceData = GenericTransactionUtils.readData(
+ coreData.getDataBroker(), LogicalDatastoreType.OPERATIONAL, mwAirInterfaceHistoricalPerformanceIID);
+
+ if (airHistoricalPerformanceData == null) {
+ LOG.debug("DBRead MWAirInterfacePac Id {} no AirInterfaceHistoricalPerformances",
+ mwAirInterfacePacuuId);
+ } else {
+ // org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170320.air._interface.historical.performances.g.HistoricalPerformanceDataList
+ List<org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.air._interface.historical.performances.g.HistoricalPerformanceDataList> airHistPMList = airHistoricalPerformanceData
+ .getHistoricalPerformanceDataList();
+ LOG.debug("DBRead MWAirInterfacePac Id {} Records intermediate: {}", mwAirInterfacePacuuId,
+ airHistPMList.size());
+ if (airHistPMList != null) {
+ for (AirInterfaceHistoricalPerformanceTypeG pmRecord : airHistoricalPerformanceData
+ .getHistoricalPerformanceDataList()) {
+ resultList.add(new ExtendedAirInterfaceHistoricalPerformanceType1211p(pmRecord, airConfiguration));
+ }
+ }
+ }
+ }
+ LOG.debug("DBRead MWAirInterfacePac Id {} Records result: {}", mwAirInterfacePacuuId, resultList.size());
+ return resultList;
+ }
+
+ private List<ContainerHistoricalPerformanceTypeG> readTheHistoricalPerformanceDataOfEthernetContainer(Lp lp) {
+
+ final String myName = "MWEthernetContainerPac";
+ String uuId = lp.getUuid().getValue();
+
+ List<ContainerHistoricalPerformanceTypeG> resultList = new ArrayList<>();
+ LOG.debug("DBRead Get {} : {}", coreData.getMountpoint(), myName, uuId);
+ // ----
+ UniversalId ethContainerPacuuId = new UniversalId(uuId);
+ // Step 2.2: construct data and the relative iid
+ InstanceIdentifier<EthernetContainerHistoricalPerformances> ethContainerIID = InstanceIdentifier
+ .builder(MwEthernetContainerPac.class, new MwEthernetContainerPacKey(ethContainerPacuuId))
+ .child(EthernetContainerHistoricalPerformances.class).build();
+
+ // Step 2.3: read to the config data store
+ EthernetContainerHistoricalPerformances ethContainerHistoricalPerformanceData = GenericTransactionUtils
+ .readData(coreData.getDataBroker(), LogicalDatastoreType.OPERATIONAL, ethContainerIID);
+
+ if (ethContainerHistoricalPerformanceData == null) {
+ LOG.debug("DBRead {} Id {} no HistoricalPerformances", myName, ethContainerPacuuId);
+ } else {
+ // import
+ // org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170320.ethernet.container.historical.performances.g.HistoricalPerformanceDataList
+ List<org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.ethernet.container.historical.performances.g.HistoricalPerformanceDataList> airHistPMList = ethContainerHistoricalPerformanceData
+ .getHistoricalPerformanceDataList();
+ LOG.debug("DBRead {} Id {} Records intermediate: {}", myName, ethContainerPacuuId, airHistPMList.size());
+ if (airHistPMList != null) {
+ for (ContainerHistoricalPerformanceTypeG pmRecord : airHistPMList) {
+ resultList.add(pmRecord);
+ }
+ }
+ }
+ LOG.debug("DBRead {} Id {} Records result: {}", myName, ethContainerPacuuId, resultList.size());
+ return resultList;
+ }
+
+ public void onObjectCreationNotification(ObjectCreationNotification notification) {
+ LOG.debug("Got event of type :: {}", ObjectCreationNotification.class.getSimpleName());
+
+ ObjectCreationNotificationXml notificationXml = new ObjectCreationNotificationXml(coreData.getMountpoint(),
+ notification.getCounter().toString(),
+ InternalDateAndTime.valueOf(notification.getTimeStamp()),
+ notification.getObjectIdRef().getValue());
+ microwaveModelListener.onObjectCreationNotification(notificationXml);
+ }
+
+ @Override
+ public void onObjectDeletionNotification(ObjectDeletionNotification notification) {
+ LOG.debug("Got event of type :: {}", ObjectDeletionNotification.class.getSimpleName());
+
+ ObjectDeletionNotificationXml notificationXml = new ObjectDeletionNotificationXml(coreData.getMountpoint(),
+ notification.getCounter().toString(),
+ InternalDateAndTime.valueOf(notification.getTimeStamp()),
+ notification.getObjectIdRef().getValue()
+ );
+ microwaveModelListener.onObjectDeletionNotification(notificationXml);
+ }
+
+ public void onProblemNotification(ProblemNotification notification) {
+
+ LOG.debug("Got event of type :: {}", ProblemNotification.class.getSimpleName());
+
+ ProblemNotificationXml notificationXml = new ProblemNotificationXml(coreData.getMountpoint(), notification.getObjectIdRef().getValue(),
+ notification.getProblem(), InternalSeverity.valueOf(notification.getSeverity()),
+ notification.getCounter().toString(), InternalDateAndTime.valueOf(notification.getTimeStamp()));
+
+ microwaveModelListener.onProblemNotification(notificationXml);
+ }
+
+ @Override
+ public void onAttributeValueChangedNotification(AttributeValueChangedNotification notification) {
+ LOG.debug("Got event of type :: {}", AttributeValueChangedNotification.class.getSimpleName());
+
+ AttributeValueChangedNotificationXml notificationXml = new AttributeValueChangedNotificationXml(coreData.getMountpoint(),
+ String.valueOf(notification.getCounter()), InternalDateAndTime.valueOf(notification.getTimeStamp()),
+ notification.getObjectIdRef().getValue(), notification.getAttributeName(), notification.getNewValue());
+
+ microwaveModelListener.onAttributeValueChangedNotification(notificationXml);
+ }
+
+}
diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/toggleAlarmFilter/NotificationDelayFilter.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/toggleAlarmFilter/NotificationDelayFilter.java
new file mode 100644
index 000000000..fecdd3b53
--- /dev/null
+++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/toggleAlarmFilter/NotificationDelayFilter.java
@@ -0,0 +1,162 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 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.base.toggleAlarmFilter;
+
+import java.util.Map.Entry;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.TimeUnit;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class NotificationDelayFilter<T> implements AutoCloseable {
+
+ private static final Logger LOG = LoggerFactory.getLogger(NotificationDelayFilter.class);
+
+ private final ConcurrentHashMap <String, NotificationWithServerTimeStamp<T>> problemItems;
+// private final HashMap<String, NotificationWithServerTimeStamp<T>> nonProblemItems;
+ private final NotificationDelayedListener<T> timeoutListener;
+
+ private static long delay;
+ private static boolean enabled;
+
+ public static void setDelay(long l) {
+ NotificationDelayFilter.delay = l;
+ }
+
+ public static long getDelay() {
+ return NotificationDelayFilter.delay;
+ }
+
+ public static boolean isEnabled() {
+ return NotificationDelayFilter.enabled;
+ }
+
+ public static void setEnabled(boolean enabled) {
+ NotificationDelayFilter.enabled = enabled;
+ }
+
+ private final ScheduledExecutorService scheduler;
+ private final Runnable timerRunner = () -> onTick();
+
+ private final String nodeName;
+
+ public NotificationDelayFilter(String nodeName, NotificationDelayedListener<T> timeoutListener) {
+ this.nodeName = nodeName;
+ this.timeoutListener = timeoutListener;
+ this.problemItems = new ConcurrentHashMap <>();
+ this.scheduler = Executors.newScheduledThreadPool(1);
+ this.startTimer();
+ }
+
+ /**
+ * Push notification with a specific severity (everything except non-alarmed)
+ * @param problemName key
+ * @param notification related notification
+ */
+ public void pushAlarmNotification(String problemName, T notification) {
+ synchronized (problemItems) {
+
+ boolean cp = this.problemItems.containsKey(problemName);
+ if (!cp) {
+ // no alarm in entries => create entry and push the alarm currently
+ NotificationWithServerTimeStamp<T> item = new NotificationWithServerTimeStamp<>(
+ notification);
+ LOG.debug("add event into list for node " + this.nodeName + " for alarm " + problemName + ": "
+ + item.toString());
+ this.problemItems.put(problemName, item);
+ if (this.timeoutListener != null) {
+ this.timeoutListener.onNotificationDelay(notification);
+ }
+ } else {
+ LOG.debug("clear contra event for node " + this.nodeName + " for alarm " + problemName);
+ this.problemItems.get(problemName).clrContraEvent();
+ }
+
+ }
+ }
+
+ /**
+ * Push notification with severity non-alarmed
+ * @param problemName key
+ * @param notification related notification
+ */
+ public void clearAlarmNotification(String problemName, T notification) {
+ synchronized (problemItems) {
+
+ boolean cp = this.problemItems.containsKey(problemName);
+ if (cp) {
+ LOG.debug("set contra event for alarm " + problemName);
+ this.problemItems.get(problemName).setContraEvent(notification);
+ } else {
+ // not in list => push directly through
+ if (this.timeoutListener != null) {
+ this.timeoutListener.onNotificationDelay(notification);
+ }
+ }
+ }
+ }
+
+ private void startTimer() {
+ scheduler.scheduleAtFixedRate(timerRunner, 0, 1, TimeUnit.SECONDS);
+ }
+
+ private void stopTimer() {
+ scheduler.shutdown();
+ }
+
+ /**
+ * check for clearing item out of the list
+ */
+ private void onTick() {
+ long now = System.currentTimeMillis();
+ try {
+
+ synchronized (problemItems) {
+
+ for (Entry<String, NotificationWithServerTimeStamp<T>> entry : problemItems
+ .entrySet()) {
+ NotificationWithServerTimeStamp<T> value = entry.getValue();
+ if (value.isStable(now)) {
+ // send contra Alarm if exists
+ if (value.getContraAlarmNotification() != null) {
+ if (this.timeoutListener != null) {
+ this.timeoutListener.onNotificationDelay(value.getContraAlarmNotification());
+ }
+ }
+ problemItems.remove(entry.getKey());
+ LOG.debug("removing entry for "+this.nodeName+" for alarm " + entry.getKey());
+ } else {
+ LOG.trace("currently state is still unstable for alarm " + entry.getKey());
+ }
+ }
+
+ }
+ } catch (Exception e) {
+ //Prevent stopping the task
+ LOG.warn("Exception during NotificationDelayFilter Task", e);
+ }
+ }
+
+ @Override
+ public void close() throws Exception {
+ this.stopTimer();
+ }
+
+}
diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/toggleAlarmFilter/NotificationDelayService.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/toggleAlarmFilter/NotificationDelayService.java
new file mode 100644
index 000000000..47482b248
--- /dev/null
+++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/toggleAlarmFilter/NotificationDelayService.java
@@ -0,0 +1,64 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 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.base.toggleAlarmFilter;
+
+import java.util.HashMap;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.config.HtDevicemanagerConfiguration;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.config.IConfigChangedListener;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.config.impl.ToggleAlarmConfig;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class NotificationDelayService<T> implements AutoCloseable {
+ private static final Logger LOG = LoggerFactory.getLogger(NotificationDelayService.class);
+
+ private final HashMap<String, NotificationDelayFilter<T>> filters;
+
+ public NotificationDelayFilter<T> getInstance(String nodeName, NotificationDelayedListener<T> eventListener) {
+ NotificationDelayFilter<T> filter = filters.getOrDefault(nodeName, null);
+
+ LOG.trace("nodeName={}, filter!=null? {}", nodeName, filter != null);
+ if (filter == null) {
+ filter = new NotificationDelayFilter<>(nodeName, eventListener);
+ this.filters.put(nodeName, filter);
+ }
+ return filter;
+ }
+
+ public NotificationDelayService(HtDevicemanagerConfiguration htconfig) {
+ this.filters = new HashMap<>();
+ htconfig.registerConfigChangedListener(configChangedListener);
+ NotificationDelayFilter.setDelay(htconfig.getToggleAlarm().getDelay());
+ NotificationDelayFilter.setEnabled(htconfig.getToggleAlarm().isEnabled());
+ }
+
+ private final IConfigChangedListener configChangedListener = () -> {
+ ToggleAlarmConfig cfg = ToggleAlarmConfig.reload();
+ NotificationDelayFilter.setDelay(cfg.getDelay());
+ NotificationDelayFilter.setEnabled(cfg.isEnabled());
+ };
+
+ @Override
+ public void close() throws Exception {
+ // close all filters
+ for (NotificationDelayFilter<T> filter : this.filters.values()) {
+ filter.close();
+ }
+ }
+
+}
diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/toggleAlarmFilter/NotificationDelayedListener.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/toggleAlarmFilter/NotificationDelayedListener.java
new file mode 100644
index 000000000..04276c999
--- /dev/null
+++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/toggleAlarmFilter/NotificationDelayedListener.java
@@ -0,0 +1,25 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 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.base.toggleAlarmFilter;
+
+public interface NotificationDelayedListener<T> {
+
+ public void onNotificationDelay(T notification);
+
+}
+
diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/toggleAlarmFilter/NotificationWithServerTimeStamp.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/toggleAlarmFilter/NotificationWithServerTimeStamp.java
new file mode 100644
index 000000000..6631cbedf
--- /dev/null
+++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/toggleAlarmFilter/NotificationWithServerTimeStamp.java
@@ -0,0 +1,78 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 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.base.toggleAlarmFilter;
+
+public class NotificationWithServerTimeStamp<T2> {
+ private final T2 alarmNotification;
+ private T2 contraAlarmNotification;
+ private final long timestampStart;
+ private long timestamp;
+
+ public NotificationWithServerTimeStamp(T2 n) {
+ this(n, System.currentTimeMillis());
+ }
+
+ public NotificationWithServerTimeStamp(T2 n, long ts) {
+ this.alarmNotification = n;
+ this.contraAlarmNotification = null;
+ this.timestamp = ts;
+ this.timestampStart=ts;
+ }
+
+ @SuppressWarnings("unused")
+ public long getStartTime() {
+ return this.timestampStart;
+ }
+ public void refresh() {
+ this.refresh(System.currentTimeMillis());
+ }
+
+ public void refresh(long ts) {
+ this.timestamp = ts;
+ }
+
+ public void setContraEvent(T2 notification) {
+ this.contraAlarmNotification = notification;
+ this.refresh();
+ }
+
+ public void clrContraEvent() {
+ this.contraAlarmNotification = null;
+ this.refresh();
+ }
+
+ public boolean isStable(long now) {
+ return this.timestamp + NotificationDelayFilter.getDelay() < now;
+ }
+
+ @SuppressWarnings("unused")
+ public T2 getAlarmNotification() {
+ return this.alarmNotification;
+ }
+
+ public T2 getContraAlarmNotification() {
+ return this.contraAlarmNotification;
+ }
+
+ @Override
+ public String toString() {
+ return "NotificationWithServerTimeStamp [alarmNotification=" + alarmNotification
+ + ", contraAlarmNotification=" + contraAlarmNotification + ", timestampStart=" + timestampStart
+ + ", timestamp=" + timestamp + "]";
+ }
+}
diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/config/BaseSubConfig.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/config/BaseSubConfig.java
new file mode 100644
index 000000000..88dde506c
--- /dev/null
+++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/config/BaseSubConfig.java
@@ -0,0 +1,127 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 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.config;
+
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.internalTypes.IniConfigurationFile;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.internalTypes.IniConfigurationFile.ConversionException;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.internalTypes.IniConfigurationFile.Section;
+
+public class BaseSubConfig {
+
+ private final Section subconfig;
+ private final ISubConfigHandler configHandler;
+ private final IniConfigurationFile config;
+
+ protected Section getSubConfig() {
+ return this.subconfig;
+ }
+ protected ISubConfigHandler getConfigHandler() {
+ return this.configHandler;
+ }
+ protected IniConfigurationFile getConfig() {
+ return this.config;
+ }
+ public BaseSubConfig()
+ {
+ this.config=null;
+ this.subconfig=null;
+ this.configHandler=null;
+ }
+ public BaseSubConfig(IniConfigurationFile config, ISubConfigHandler configHandler,String section) {
+ this.config = config;
+ this.subconfig = config.subset(section);
+ this.configHandler = configHandler;
+ }
+ protected boolean hasKey(String key)
+ {
+ if(this.subconfig==null) {
+ return false;
+ }
+ return this.subconfig.hasKey(key);
+ }
+ protected String getString(String key,String def)
+ {
+ if(this.subconfig==null) {
+ return def;
+ }
+ String s;
+ //try
+ {
+ s=this.subconfig.getString(key, def);
+ if(s.isEmpty()) {
+ s=def;
+ }
+ }
+ /*catch(ConversionException e)
+ {
+ s=def;
+ }
+ */
+ return s;
+ }
+ protected boolean getBoolean(String key, boolean def) {
+ if(this.subconfig==null) {
+ return def;
+ }
+ boolean s;
+ try {
+ s=this.subconfig.getBoolean(key, def);
+ }
+ catch(ConversionException e)
+ {
+ s=def;
+ }
+ return s;
+ }
+ protected int getInt(String key, int def) {
+ if(this.subconfig==null) {
+ return def;
+ }
+ int s;
+ try {
+ s=this.subconfig.getInt(key, def);
+ }
+ catch(ConversionException e)
+ {
+ s=def;
+ }
+ return s;
+ }
+ protected long getLong(String key, long def) {
+ if(this.subconfig==null) {
+ return def;
+ }
+ long s;
+ try {
+ s=this.subconfig.getLong(key, def);
+ }
+ catch(ConversionException e)
+ {
+ s=def;
+ }
+ return s;
+ }
+ protected void save()
+ {
+ if(this.configHandler!=null) {
+ this.configHandler.save();
+ }
+ }
+
+
+}
diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/config/HtDevicemanagerConfiguration.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/config/HtDevicemanagerConfiguration.java
new file mode 100644
index 000000000..6167248f0
--- /dev/null
+++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/config/HtDevicemanagerConfiguration.java
@@ -0,0 +1,147 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 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.config;
+
+import java.io.File;
+import java.io.IOException;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.internalTypes.IniConfigurationFile;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.internalTypes.IniConfigurationFile.ConfigurationException;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.config.impl.AaiConfig;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.config.impl.DcaeConfig;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.config.impl.EsConfig;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.config.impl.PmConfig;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.config.impl.ToggleAlarmConfig;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.config.util.ConfigFileObserver;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class HtDevicemanagerConfiguration {
+
+ private static final long FILE_POLL_INTERVAL_MS = 1000;
+
+ private static final Logger LOG = LoggerFactory.getLogger(HtDevicemanagerConfiguration.class);
+
+ private static final String CONFIGURATIONFILE = "etc/devicemanager.properties";
+ private static final String CONFIGURATIONTESTFILE = "test.properties"; // for
+ // testing
+
+ private static HtDevicemanagerConfiguration mObj;
+ private static HtDevicemanagerConfiguration mObjTest;
+ private static IniConfigurationFile mConfig;
+ private final ISubConfigHandler subconfigHandler = () -> mConfig.save();
+
+ private final ConfigFileObserver fileObserver;
+ private File mFile;
+
+ private HtDevicemanagerConfiguration(String filename) {
+
+ try {
+ this.mFile = new File(filename);
+ if (!this.mFile.exists()) {
+ if (!this.mFile.createNewFile()) {
+ LOG.error("Can not create file {}", filename);
+ }
+ }
+ if (mConfig == null) {
+ mConfig = new IniConfigurationFile(this.mFile);
+ }
+ mConfig.load();
+
+ } catch (ConfigurationException e) {
+ LOG.error("Problem loading config values: {}", e.getMessage());
+ } catch (IOException e) {
+ LOG.error("Problem loading config file {} : {}", filename, e.getMessage());
+ }
+
+ this.fileObserver = new ConfigFileObserver(filename, FILE_POLL_INTERVAL_MS, mConfig);
+ this.fileObserver.start();
+ }
+
+
+ public static HtDevicemanagerConfiguration getConfiguration() {
+ if (mObj == null) {
+ mObj = new HtDevicemanagerConfiguration(CONFIGURATIONFILE);
+ }
+ return mObj;
+ }
+
+ public static HtDevicemanagerConfiguration getTestConfiguration() {
+ return getTestConfiguration(CONFIGURATIONTESTFILE);
+ }
+
+ public static HtDevicemanagerConfiguration getTestConfiguration(final String filename) {
+ if (mObjTest == null) {
+ mObjTest = new HtDevicemanagerConfiguration(filename);
+ }
+ return mObjTest;
+ }
+
+ public IniConfigurationFile getMConfig() {
+ return mConfig;
+ }
+
+ public void registerConfigChangedListener(IConfigChangedListener l) {
+ this.fileObserver.registerConfigChangedListener(l);
+ }
+
+ public void unregisterConfigChangedListener(IConfigChangedListener l) {
+ this.fileObserver.unregisterConfigChangedListener(l);
+ }
+
+ @Override
+ protected void finalize() throws Throwable {
+ if (this.fileObserver != null) {
+ this.fileObserver.interrupt();
+ }
+ super.finalize();
+ }
+
+ public DcaeConfig getDcae() {
+ return DcaeConfig.getDcae(mConfig, this.subconfigHandler);
+ }
+
+ public AaiConfig getAai() {
+ return AaiConfig.getAai(mConfig, this.subconfigHandler);
+ }
+
+ public EsConfig getEs() {
+ return EsConfig.getEs(mConfig, this.subconfigHandler);
+ }
+
+ public PmConfig getPm() {
+ return PmConfig.getPm(mConfig, this.subconfigHandler);
+ }
+
+ public ToggleAlarmConfig getToggleAlarm() {
+ return ToggleAlarmConfig.getTa(mConfig, this.subconfigHandler);
+ }
+
+ public ISubConfigHandler getSubconfigHandler() {
+ return subconfigHandler;
+ }
+
+ public static void clear() {
+ mObj = null;
+ mObjTest = null;
+ DcaeConfig.clear();
+ AaiConfig.clear();
+ EsConfig.clear();
+ PmConfig.clear();
+ ToggleAlarmConfig.clear();
+ }
+}
diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/config/IConfigChangedListener.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/config/IConfigChangedListener.java
new file mode 100644
index 000000000..704841ce7
--- /dev/null
+++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/config/IConfigChangedListener.java
@@ -0,0 +1,22 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 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.config;
+
+public interface IConfigChangedListener {
+ void onConfigChanged();
+}
diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/config/ISubConfigHandler.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/config/ISubConfigHandler.java
new file mode 100644
index 000000000..c1f67f0a3
--- /dev/null
+++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/config/ISubConfigHandler.java
@@ -0,0 +1,22 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 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.config;
+
+public interface ISubConfigHandler {
+ void save();
+}
diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/config/impl/AaiClientPropertiesFile.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/config/impl/AaiClientPropertiesFile.java
new file mode 100644
index 000000000..7912f047b
--- /dev/null
+++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/config/impl/AaiClientPropertiesFile.java
@@ -0,0 +1,74 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 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.config.impl;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.util.Properties;
+
+public class AaiClientPropertiesFile{
+
+ private final File mFile;
+ private String mPCKS12CertFilename;
+ private String mPCKS12Passphrase;
+ private boolean mTrustInsecureSSL;
+ private String mApplicationIdentifier;
+ private String mRemoteUrl;
+ private int mConnectionTimeout;
+ private int mReadTimeout;
+
+ public String getFilename()
+ { return this.mFile.getAbsolutePath(); }
+ public String getPCKS12CertFilename()
+ {return this.mPCKS12CertFilename;}
+ public String getPCKS12Passphrase()
+ {return this.mPCKS12Passphrase; }
+ public boolean trustInsecureSSL()
+ {return this.mTrustInsecureSSL;}
+ public String getApplicationIdentifier()
+ {return this.mApplicationIdentifier;}
+ public String getRemoteUrl()
+ {return this.mRemoteUrl;}
+ public int getConnectionTimeout()
+ {return this.mConnectionTimeout;}
+ public int getReadTimeout()
+ {return this.mReadTimeout;}
+
+ public boolean exists()
+ {return this.mFile.exists();}
+ public AaiClientPropertiesFile(String filename)
+ {
+ this.mFile=new File(filename);
+ }
+ public void load() throws IOException,NumberFormatException
+ {
+ Properties defaultProps = new Properties();
+ FileInputStream in = new FileInputStream(this.mFile);
+ defaultProps.load(in);
+ this.mPCKS12CertFilename=defaultProps.getProperty("org.onap.ccsdk.sli.adaptors.aai.ssl.key",null);
+ this.mPCKS12Passphrase=defaultProps.getProperty("org.onap.ccsdk.sli.adaptors.aai.ssl.key.psswd",null);
+ this.mTrustInsecureSSL=defaultProps.getProperty("org.onap.ccsdk.sli.adaptors.aai.host.certificate.ignore","false").equals("true");
+ this.mApplicationIdentifier=defaultProps.getProperty("org.onap.ccsdk.sli.adaptors.aai.application",null);
+ this.mRemoteUrl=defaultProps.getProperty("org.onap.ccsdk.sli.adaptors.aai.uri",null);
+ this.mConnectionTimeout=Integer.parseInt(defaultProps.getProperty("connection.timeout","60000"));
+ this.mReadTimeout=Integer.parseInt(defaultProps.getProperty("read.timeout","60000"));
+ in.close();
+ }
+
+}
diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/config/impl/AaiConfig.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/config/impl/AaiConfig.java
new file mode 100644
index 000000000..b30b3271d
--- /dev/null
+++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/config/impl/AaiConfig.java
@@ -0,0 +1,467 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 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.config.impl;
+
+import java.io.IOException;
+import java.util.Base64;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Map.Entry;
+import javax.annotation.Nullable;
+import org.json.JSONArray;
+import org.json.JSONException;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.internalTypes.IniConfigurationFile;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.internalTypes.IniConfigurationFile.ConfigurationException;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.config.BaseSubConfig;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.config.ISubConfigHandler;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class AaiConfig extends BaseSubConfig {
+
+ private static final Logger LOG = LoggerFactory.getLogger(AaiConfig.class);
+
+ private static final String SECTION_MARKER_AAI = "aai";
+
+ private static final String PROPERTY_KEY_AAIPROP_FILE ="aaiPropertiesFile";
+ private static final String PROPERTY_KEY_BASEURL = "aaiUrl";
+ private static final String PROPERTY_KEY_USERCREDENTIALS = "aaiUserCredentials";
+ private static final String PROPERTY_KEY_HEADERS = "aaiHeaders";
+ private static final String PROPERTY_KEY_DELETEONMOUNTPOINTREMOVED = "aaiDeleteOnMountpointRemove";
+ private static final String PROPERTY_KEY_TRUSTALLCERTS = "aaiTrustAllCerts";
+ private static final String PROPERTY_KEY_APIVERSION = "aaiApiVersion";
+ private static final String PROPERTY_KEY_PCKS12CERTFILENAME = "aaiPcks12ClientCertFile";
+ private static final String PROPERTY_KEY_PCKS12PASSPHRASE = "aaiPcks12ClientCertPassphrase";
+ private static final String PROPERTY_KEY_CONNECTIONTIMEOUT = "aaiClientConnectionTimeout";
+ private static final String PROPERTY_KEY_APPLICATIONID = "aaiApplicationId";
+
+ private static final String DEFAULT_VALUE_AAIPROP_FILE ="null";
+ private static final String DEFAULT_VALUE_BASEURL = "off";
+ private static final String DEFAULT_VALUE_APPLICATION = "SDNR";
+ private static final String DEFAULT_VALUE_USERNAME = "";
+ private static final String DEFAULT_VALUE_USERPASSWORD = "";
+ private static final String DEFAULT_VALUE_USERCREDENTIALS = "";
+ private static final String DEFAULT_VALUE_HEADERS = "[\"X-TransactionId: 9999\"]";
+ private static final boolean DEFAULT_VALUE_DELETEONMOUNTPOINTREMOVED = false;
+ private static final boolean DEFAULT_VALUE_TRUSTALLCERTS = false;
+ private static final int DEFAULT_VALUE_CONNECTION_TIMEOUT = 30000; //in ms
+ private static final String DEFAULT_VALUE_APIVERSION = "aai/v13";
+ private static final String DEFAULT_VALUE_PCKS12CERTFILENAME ="";
+ private static final String DEFAULT_VALUE_PCKS12PASSPHRASE = "";
+ private static final String DEFAULT_VALUE_APPLICATIONID = "SDNR";
+
+ private static final String HEADER_KEY_APPLICATION = "X-FromAppId";
+
+
+ private static AaiConfig aaiConfig;
+
+ private final String aaiPropFile;
+ private final String baseUrl;
+ private String apiVersion;
+ private String applicationIdentifier;
+ private String username;
+ private String password;
+ private String pcks12CertificateFilename;
+ private String pcks12CertificatePassphrase;
+ private int connectionTimeout;
+ private final boolean deleteOnMountPointRemoved;
+ private final boolean trustAllCerts;
+
+ public boolean doDeleteOnMountPointRemoved() {
+ return this.deleteOnMountPointRemoved;
+ }
+
+ private Map<String, String> headers;
+
+
+ private AaiConfig() {
+ super();
+ this.aaiPropFile = DEFAULT_VALUE_AAIPROP_FILE;
+ this.apiVersion=DEFAULT_VALUE_APIVERSION;
+ this.applicationIdentifier = DEFAULT_VALUE_APPLICATION;
+ this.baseUrl = DEFAULT_VALUE_BASEURL;
+ this.username = DEFAULT_VALUE_USERNAME;
+ this.password = DEFAULT_VALUE_USERPASSWORD;
+ this.deleteOnMountPointRemoved = DEFAULT_VALUE_DELETEONMOUNTPOINTREMOVED;
+ this.trustAllCerts=DEFAULT_VALUE_TRUSTALLCERTS;
+ this.applicationIdentifier=DEFAULT_VALUE_APPLICATIONID;
+ }
+
+ public AaiConfig(IniConfigurationFile config, ISubConfigHandler configHandler) throws ConfigurationException {
+ this(config, configHandler, true);
+ }
+
+ public AaiConfig(IniConfigurationFile config, ISubConfigHandler configHandler, boolean save)
+ throws ConfigurationException {
+ super(config, configHandler, SECTION_MARKER_AAI);
+ // load
+ this.aaiPropFile=this.getString(PROPERTY_KEY_AAIPROP_FILE, "");
+ AaiClientPropertiesFile aaiProperties = new AaiClientPropertiesFile(this.aaiPropFile);
+ String defBaseUrl=DEFAULT_VALUE_BASEURL;
+ String defPCKSCertFilename=DEFAULT_VALUE_PCKS12CERTFILENAME;
+ String defPCKSPassphrase=DEFAULT_VALUE_PCKS12PASSPHRASE;
+ String defApplicationId=DEFAULT_VALUE_APPLICATION;
+ int defconnectionTimeout=DEFAULT_VALUE_CONNECTION_TIMEOUT;
+ boolean loaded=false;
+ if(aaiProperties.exists())
+ {
+ LOG.debug("found another aaiclient.properties file");
+ try
+ {
+ aaiProperties.load();
+ loaded=true;
+ LOG.debug("loaded successfully");
+ }
+ catch(IOException|NumberFormatException e)
+ {
+ LOG.warn("problem loading external properties file "+aaiProperties.getFilename()+": "+e.getMessage());
+ }
+ if(loaded) //preload new default values
+ {
+ String value;
+ value = aaiProperties.getRemoteUrl();
+ if (value != null) {
+ defBaseUrl = value;
+ }
+ value = aaiProperties.getPCKS12CertFilename();
+ if (value != null) {
+ defPCKSCertFilename = value;
+ }
+ value = aaiProperties.getPCKS12Passphrase();
+ if (value != null) {
+ defPCKSPassphrase = value;
+ }
+ value = aaiProperties.getApplicationIdentifier();
+ if (value != null) {
+ defApplicationId = value;
+ }
+ }
+ } else {
+ LOG.debug("no aaiclient.properties file found");
+ }
+
+
+ this.baseUrl = this.getString(PROPERTY_KEY_BASEURL, defBaseUrl);
+ this.apiVersion=this.getString(PROPERTY_KEY_APIVERSION,DEFAULT_VALUE_APIVERSION);
+ String credentials = this.getString(PROPERTY_KEY_USERCREDENTIALS, DEFAULT_VALUE_USERCREDENTIALS);
+ if (credentials.contains(":")) {
+ try {
+ this.username = credentials.split(":")[0];
+ this.password = credentials.split(":")[1];
+ } catch (Exception e) {
+ this.username = DEFAULT_VALUE_USERNAME;
+ this.password = DEFAULT_VALUE_USERPASSWORD;
+ }
+ } else {
+ this.username = DEFAULT_VALUE_USERNAME;
+ this.password = DEFAULT_VALUE_USERPASSWORD;
+ }
+ this.headers = _parseHeadersMap(this.getString(PROPERTY_KEY_HEADERS, DEFAULT_VALUE_HEADERS));
+ this.applicationIdentifier = this.getString(PROPERTY_KEY_APPLICATIONID, defApplicationId);
+ this.pcks12CertificateFilename=this.getString(PROPERTY_KEY_PCKS12CERTFILENAME, defPCKSCertFilename);
+ this.pcks12CertificatePassphrase=this.getString(PROPERTY_KEY_PCKS12PASSPHRASE, defPCKSPassphrase);
+ this.connectionTimeout = this.getInt(PROPERTY_KEY_CONNECTIONTIMEOUT, defconnectionTimeout);
+ this.deleteOnMountPointRemoved = this.getBoolean(PROPERTY_KEY_DELETEONMOUNTPOINTREMOVED,
+ DEFAULT_VALUE_DELETEONMOUNTPOINTREMOVED);
+ this.trustAllCerts = this.getBoolean(PROPERTY_KEY_TRUSTALLCERTS, DEFAULT_VALUE_TRUSTALLCERTS);
+
+ boolean missing=!this.hasKey(PROPERTY_KEY_APPLICATIONID)|| !this.hasKey(PROPERTY_KEY_CONNECTIONTIMEOUT)||
+ !this.hasKey(PROPERTY_KEY_TRUSTALLCERTS) || !this.hasKey(PROPERTY_KEY_PCKS12CERTFILENAME) ||
+ !this.hasKey(PROPERTY_KEY_PCKS12PASSPHRASE);
+ if(missing) {
+ LOG.debug("some params missing in config file");
+ }
+ //re-save if external aaiproperties file changed to show that params are submitted internally
+ if(missing || aaiConfig!=null && aaiConfig!=this && (
+ !propertyEquals(aaiConfig.aaiPropFile, this.aaiPropFile) ||
+ !propertyEquals(aaiConfig.pcks12CertificateFilename, this.pcks12CertificateFilename) ||
+ !propertyEquals(aaiConfig.pcks12CertificatePassphrase, this.pcks12CertificatePassphrase) ||
+ !propertyEquals(aaiConfig.connectionTimeout, this.connectionTimeout)
+
+ ))
+ {
+ LOG.debug("force saving because of reload changes from remote file");
+ save=true;
+ }
+ if (save) {
+ config.setProperty(SECTION_MARKER_AAI + "." + PROPERTY_KEY_BASEURL, this.baseUrl);
+ config.setProperty(SECTION_MARKER_AAI + "." + PROPERTY_KEY_USERCREDENTIALS,
+ nullorempty(this.username) && nullorempty(this.password)?"":this.username + ":" + this.password);
+ config.setProperty(SECTION_MARKER_AAI + "." + PROPERTY_KEY_HEADERS, _printHeadersMap(this.headers));
+ config.setProperty(SECTION_MARKER_AAI + "." + PROPERTY_KEY_DELETEONMOUNTPOINTREMOVED,
+ this.deleteOnMountPointRemoved);
+ config.setProperty(SECTION_MARKER_AAI + "." + PROPERTY_KEY_TRUSTALLCERTS, this.trustAllCerts);
+ config.setProperty(SECTION_MARKER_AAI+"."+PROPERTY_KEY_AAIPROP_FILE, this.aaiPropFile);
+ config.setProperty(SECTION_MARKER_AAI+"."+PROPERTY_KEY_APIVERSION,this.apiVersion);
+ config.setProperty(SECTION_MARKER_AAI+"."+PROPERTY_KEY_APPLICATIONID, this.applicationIdentifier);
+ config.setProperty(SECTION_MARKER_AAI+"."+PROPERTY_KEY_CONNECTIONTIMEOUT, this.connectionTimeout);
+ /*if(this.pcks12CertificateFilename !=null && !this.pcks12CertificateFilename.isEmpty() &&
+ this.pcks12CertificatePassphrase!=null && !this.pcks12CertificatePassphrase.isEmpty())*/
+ {
+ LOG.debug("no client credentials to save");
+ config.setProperty(SECTION_MARKER_AAI+"."+PROPERTY_KEY_PCKS12CERTFILENAME, this.pcks12CertificateFilename);
+ config.setProperty(SECTION_MARKER_AAI+"."+PROPERTY_KEY_PCKS12PASSPHRASE, this.pcks12CertificatePassphrase);
+ }
+ LOG.debug("save");
+ this.save();
+ }
+ }
+
+ private boolean nullorempty(String s) {
+ return s==null || s.isEmpty();
+ }
+
+ public boolean isOff() {
+ return this.baseUrl == null || this.baseUrl.toLowerCase().equals("off");
+ }
+
+ private static boolean propertyEquals(final Object p1,final Object p2)
+ {
+ return p1==null && p2==null || p1 != null && p1.equals(p2);
+ }
+ private static boolean propertyEquals(final int p1,final int p2)
+ {
+ return p1==p2;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + (aaiPropFile == null ? 0 : aaiPropFile.hashCode());
+ result = prime * result + (apiVersion == null ? 0 : apiVersion.hashCode());
+ result = prime * result + (applicationIdentifier == null ? 0 : applicationIdentifier.hashCode());
+ result = prime * result + (baseUrl == null ? 0 : baseUrl.hashCode());
+ result = prime * result + connectionTimeout;
+ result = prime * result + (deleteOnMountPointRemoved ? 1231 : 1237);
+ result = prime * result + (headers == null ? 0 : headers.hashCode());
+ result = prime * result + (password == null ? 0 : password.hashCode());
+ result = prime * result + (pcks12CertificateFilename == null ? 0 : pcks12CertificateFilename.hashCode());
+ result = prime * result + (pcks12CertificatePassphrase == null ? 0 : pcks12CertificatePassphrase.hashCode());
+ result = prime * result + (trustAllCerts ? 1231 : 1237);
+ result = prime * result + (username == null ? 0 : username.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ AaiConfig other = (AaiConfig) obj;
+ if (aaiPropFile == null) {
+ if (other.aaiPropFile != null) {
+ return false;
+ }
+ } else if (!aaiPropFile.equals(other.aaiPropFile)) {
+ return false;
+ }
+ if (apiVersion == null) {
+ if (other.apiVersion != null) {
+ return false;
+ }
+ } else if (!apiVersion.equals(other.apiVersion)) {
+ return false;
+ }
+ if (applicationIdentifier == null) {
+ if (other.applicationIdentifier != null) {
+ return false;
+ }
+ } else if (!applicationIdentifier.equals(other.applicationIdentifier)) {
+ return false;
+ }
+ if (baseUrl == null) {
+ if (other.baseUrl != null) {
+ return false;
+ }
+ } else if (!baseUrl.equals(other.baseUrl)) {
+ return false;
+ }
+ if (connectionTimeout != other.connectionTimeout) {
+ return false;
+ }
+ if (deleteOnMountPointRemoved != other.deleteOnMountPointRemoved) {
+ return false;
+ }
+ if (headers == null) {
+ if (other.headers != null) {
+ return false;
+ }
+ } else if (!headers.equals(other.headers)) {
+ return false;
+ }
+ if (password == null) {
+ if (other.password != null) {
+ return false;
+ }
+ } else if (!password.equals(other.password)) {
+ return false;
+ }
+ if (pcks12CertificateFilename == null) {
+ if (other.pcks12CertificateFilename != null) {
+ return false;
+ }
+ } else if (!pcks12CertificateFilename.equals(other.pcks12CertificateFilename)) {
+ return false;
+ }
+ if (pcks12CertificatePassphrase == null) {
+ if (other.pcks12CertificatePassphrase != null) {
+ return false;
+ }
+ } else if (!pcks12CertificatePassphrase.equals(other.pcks12CertificatePassphrase)) {
+ return false;
+ }
+ if (trustAllCerts != other.trustAllCerts) {
+ return false;
+ }
+ if (username == null) {
+ if (other.username != null) {
+ return false;
+ }
+ } else if (!username.equals(other.username)) {
+ return false;
+ }
+ return true;
+ }
+
+ public String getBaseUrl() {
+ String url=this.baseUrl;
+ if(!url.endsWith("/")) {
+ url+="/";
+ }
+ if(this.apiVersion.startsWith("/")) {
+ this.apiVersion=this.apiVersion.substring(1);
+ }
+ return url+this.apiVersion;
+ }
+
+ public Map<String, String> getHeaders() {
+ if (this.headers == null) {
+ this.headers = new HashMap<>();
+ }
+ this.headers.put(HEADER_KEY_APPLICATION, this.applicationIdentifier);
+ String s = this.headers.getOrDefault("Authorization", null);
+ if (nullorempty(s) && !nullorempty(this.username) && !nullorempty(this.password)) {
+ this.headers.put("Authorization", "Basic "
+ + new String(Base64.getEncoder().encode((this.username + ":" + this.password).getBytes())));
+ }
+ return this.headers;
+ }
+
+ @Override
+ public String toString() {
+ return "AaiConfig [aaiPropFile=" + aaiPropFile + ", baseUrl=" + baseUrl + ", apiVersion=" + apiVersion
+ + ", applicationIdentifier=" + applicationIdentifier + ", username=" + username + ", password="
+ + password + ", pcks12CertificateFilename=" + pcks12CertificateFilename
+ + ", pcks12CertificatePassphrase=" + pcks12CertificatePassphrase + ", connectionTimeout="
+ + connectionTimeout + ", deleteOnMountPointRemoved=" + deleteOnMountPointRemoved + ", trustAllCerts="
+ + trustAllCerts + ", headers=" + this.getHeaders() + "]";
+ }
+
+ private static String _printHeadersMap(Map<String, String> headers) {
+ String r = "[";
+ if (headers != null) {
+ int i = 0;
+ for (Entry<String, String> entry : headers.entrySet()) {
+ if (i > 0) {
+ r += ",";
+ }
+ r += "\"" + entry.getKey() + ":" + entry.getValue() + "\"";
+ i++;
+ }
+ }
+ r += "]";
+ return r;
+ }
+
+ private static Map<String, String> _parseHeadersMap(String s) throws JSONException {
+ Map<String, String> r = new HashMap<>();
+ JSONArray a = new JSONArray(s);
+ if (a != null && a.length() > 0) {
+ for (int i = 0; i < a.length(); i++) {
+ String item = a.getString(i);
+ String[] hlp = item.split(":");
+ if (hlp.length > 1) {
+ r.put(hlp[0], hlp[1]);
+ }
+ }
+ }
+ return r;
+ }
+
+ public static boolean isInstantiated() {
+ return aaiConfig != null;
+ }
+
+ public static AaiConfig getDefaultConfiguration() {
+ return new AaiConfig();
+ }
+
+ public static AaiConfig getAai(IniConfigurationFile config, ISubConfigHandler configHandler) {
+ if (aaiConfig == null) {
+ try {
+ aaiConfig = new AaiConfig(config, configHandler);
+ } catch (ConfigurationException e) {
+ aaiConfig = AaiConfig.getDefaultConfiguration();
+ }
+ }
+ return aaiConfig;
+ }
+
+ public static @Nullable AaiConfig reload() {
+ if (aaiConfig == null) {
+ return null;
+ }
+ AaiConfig tmpConfig;
+ try {
+ tmpConfig = new AaiConfig(aaiConfig.getConfig(), aaiConfig.getConfigHandler(), false);
+ } catch (ConfigurationException e) {
+ tmpConfig = AaiConfig.getDefaultConfiguration();
+ LOG.warn("problem loading config: "+e.getMessage());
+ }
+ aaiConfig = tmpConfig;
+ return aaiConfig;
+ }
+
+ public boolean getTrustAll() {
+ return this.trustAllCerts;
+ }
+
+ public String getPcks12CertificateFilename() {
+ return this.pcks12CertificateFilename;
+ }
+
+ public String getPcks12CertificatePassphrase() {
+ return this.pcks12CertificatePassphrase;
+ }
+
+ public int getConnectionTimeout() {
+ return this.connectionTimeout;
+ }
+
+ public static void clear() {
+ aaiConfig=null;
+ }
+
+}
diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/config/impl/AkkaConfig.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/config/impl/AkkaConfig.java
new file mode 100644
index 000000000..6c416a257
--- /dev/null
+++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/config/impl/AkkaConfig.java
@@ -0,0 +1,88 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 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.config.impl;
+
+import com.typesafe.config.Config;
+import com.typesafe.config.ConfigFactory;
+import java.io.File;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.config.util.ClusterConfig;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class AkkaConfig {
+
+ @SuppressWarnings("unused")
+ private static final Logger LOG = LoggerFactory.getLogger(AkkaConfig.class);
+
+ private static final String DEFAULT_FILENAME = "configuration/initial/akka.conf";
+ private final String filename;
+ private ClusterConfig cluserConfig;
+
+ public ClusterConfig getClusterConfig() {
+ return this.cluserConfig;
+ }
+
+ private AkkaConfig(String filename) {
+ this.filename = filename;
+ }
+
+ public AkkaConfig() {
+ this(null);
+ }
+
+ @Override
+ public String toString() {
+ return "AkkaConfig [filename=" + filename + ", cluserConfig=" + cluserConfig + "]";
+ }
+
+ private void loadFromFile() throws Exception {
+ Config cfg = ConfigFactory.parseFile(new File(this.filename));
+ this.cluserConfig = new ClusterConfig(cfg.getConfig("odl-cluster-data").getConfig("akka").getConfig("cluster"));
+ }
+
+ public boolean isCluster() {
+ return this.cluserConfig != null ? this.cluserConfig.isCluster() : false;
+ }
+
+ public static AkkaConfig load() throws Exception {
+ return load(DEFAULT_FILENAME);
+ }
+
+ public static AkkaConfig load(String filename) throws Exception {
+ AkkaConfig cfg = new AkkaConfig(filename);
+ cfg.loadFromFile();
+ return cfg;
+ }
+
+ public boolean isSingleNode() {
+ return !this.isCluster();
+ }
+ public static AkkaConfig defaultSingleNodeConfig()
+ {
+ AkkaConfig cfg=new AkkaConfig();
+ cfg.cluserConfig=new ClusterConfig();
+ return cfg;
+ }
+
+ public static AkkaConfig parse(String content) throws Exception {
+ Config cfg = ConfigFactory.parseString(content);
+ AkkaConfig c = new AkkaConfig();
+ c.cluserConfig=new ClusterConfig(cfg.getConfig("odl-cluster-data").getConfig("akka").getConfig("cluster"));
+ return c;
+ }
+}
diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/config/impl/DcaeConfig.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/config/impl/DcaeConfig.java
new file mode 100644
index 000000000..669b211e1
--- /dev/null
+++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/config/impl/DcaeConfig.java
@@ -0,0 +1,200 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 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.config.impl;
+
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.internalTypes.IniConfigurationFile;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.internalTypes.IniConfigurationFile.ConfigurationException;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.config.BaseSubConfig;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.config.ISubConfigHandler;
+
+public class DcaeConfig extends BaseSubConfig {
+ private static final String SECTION_MARKER_DCAE = "dcae";
+
+ private static final String PROPERTY_KEY_EVENTRECEIVERURL = "dcaeUrl";
+ //private static final String PROPERTY_KEY_TESTCOLLECTOR = "dcaeTestCollector";
+ private static final String PROPERTY_KEY_USERCREDENTIALS = "dcaeUserCredentials";
+ private static final String PROPERTY_KEY_TIMERPERIOD = "dcaeHeartbeatPeriodSeconds";
+
+ private static final String DEFAULT_VALUE_EVENTRECEIVERURL = "off";
+ @SuppressWarnings("unused")
+ private static final String DEFAULT_VALUE_TESTCOLLECTOR = "no";
+ private static final String DEFAULT_VALUE_USERCREDENTIALS = "admin:admin";
+ private static final int DEFAULT_VALUE_TIMERPERIOD = 120;
+
+ private static DcaeConfig dcaeConfig = null; // Singleton of configuration data
+
+ private String eventReceiverUrl;
+ private String userCredentials;
+ private Integer timerPeriodSeconds;
+
+ private DcaeConfig() {
+ super();
+ this.eventReceiverUrl = DEFAULT_VALUE_EVENTRECEIVERURL;
+ this.userCredentials = DEFAULT_VALUE_USERCREDENTIALS;
+ this.timerPeriodSeconds = DEFAULT_VALUE_TIMERPERIOD;
+ }
+
+ private DcaeConfig(IniConfigurationFile config, ISubConfigHandler configHandler) throws ConfigurationException {
+ this(config, configHandler, true);
+ }
+
+ private DcaeConfig(IniConfigurationFile config, ISubConfigHandler configHandler, boolean save)
+ throws ConfigurationException {
+
+ super(config, configHandler, SECTION_MARKER_DCAE);
+
+ this.eventReceiverUrl = this.getString(PROPERTY_KEY_EVENTRECEIVERURL, DEFAULT_VALUE_EVENTRECEIVERURL);
+ this.userCredentials = this.getString(PROPERTY_KEY_USERCREDENTIALS, DEFAULT_VALUE_USERCREDENTIALS);
+ this.timerPeriodSeconds = this.getInt(PROPERTY_KEY_TIMERPERIOD, DEFAULT_VALUE_TIMERPERIOD);
+ if (save) {
+ config.setProperty(SECTION_MARKER_DCAE + "." + PROPERTY_KEY_EVENTRECEIVERURL, this.eventReceiverUrl);
+ config.setProperty(SECTION_MARKER_DCAE + "." + PROPERTY_KEY_USERCREDENTIALS, this.userCredentials);
+ config.setProperty(SECTION_MARKER_DCAE + "." + PROPERTY_KEY_TIMERPERIOD, this.timerPeriodSeconds);
+
+ this.save();
+ }
+ }
+
+ /*
+ * Setter
+ */
+
+ public void setEventReceiverUrl(String eventReveicerUrl) {
+ this.eventReceiverUrl = eventReveicerUrl;
+ }
+
+ public void setUserCredentials(String userCredentials) {
+ this.userCredentials = userCredentials;
+ }
+
+
+
+ public void setTimerPeriodSeconds(Integer timerPeriodSeconds) {
+ this.timerPeriodSeconds = timerPeriodSeconds;
+ }
+
+ /*
+ * Getter
+ */
+
+ public String getEventReveicerUrl() {
+ return eventReceiverUrl;
+ }
+
+ public String getUserCredentials() {
+ return userCredentials;
+ }
+
+
+ public Integer getTimerPeriodSeconds() {
+ return timerPeriodSeconds;
+ }
+
+ @Override
+ public String toString() {
+ return "DcaeConfig [eventReceiverUrl=" + eventReceiverUrl + ", userCredentials=" + userCredentials
+ + ", timerPeriodSeconds=" + timerPeriodSeconds + "]";
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + (eventReceiverUrl == null ? 0 : eventReceiverUrl.hashCode());
+ result = prime * result + (timerPeriodSeconds == null ? 0 : timerPeriodSeconds.hashCode());
+ result = prime * result + (userCredentials == null ? 0 : userCredentials.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ DcaeConfig other = (DcaeConfig) obj;
+ if (eventReceiverUrl == null) {
+ if (other.eventReceiverUrl != null) {
+ return false;
+ }
+ } else if (!eventReceiverUrl.equals(other.eventReceiverUrl)) {
+ return false;
+ }
+ if (timerPeriodSeconds == null) {
+ if (other.timerPeriodSeconds != null) {
+ return false;
+ }
+ } else if (!timerPeriodSeconds.equals(other.timerPeriodSeconds)) {
+ return false;
+ }
+ if (userCredentials == null) {
+ if (other.userCredentials != null) {
+ return false;
+ }
+ } else if (!userCredentials.equals(other.userCredentials)) {
+ return false;
+ }
+ return true;
+ }
+
+ /*-------------------------------------
+ * static Functions
+ */
+
+ public static DcaeConfig getDefaultConfiguration() {
+ return new DcaeConfig();
+ }
+
+ public static DcaeConfig getDcae(IniConfigurationFile config, ISubConfigHandler configHandler) {
+ if (dcaeConfig == null) {
+ try {
+ dcaeConfig = new DcaeConfig(config, configHandler);
+ } catch (ConfigurationException e) {
+ dcaeConfig = DcaeConfig.getDefaultConfiguration();
+ }
+ }
+ return dcaeConfig;
+ }
+
+ public static boolean isInstantiated() {
+ return dcaeConfig != null;
+ }
+
+ public static DcaeConfig reload() {
+ if (dcaeConfig == null) {
+ return null;
+ }
+ DcaeConfig tmpConfig;
+ try {
+ tmpConfig = new DcaeConfig(dcaeConfig.getConfig(), dcaeConfig.getConfigHandler(), false);
+ } catch (ConfigurationException e) {
+ tmpConfig = DcaeConfig.getDefaultConfiguration();
+ }
+ dcaeConfig = tmpConfig;
+ return dcaeConfig;
+ }
+
+ public static void clear() {
+ dcaeConfig=null;
+ }
+}
diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/config/impl/EsConfig.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/config/impl/EsConfig.java
new file mode 100644
index 000000000..958a0dfd3
--- /dev/null
+++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/config/impl/EsConfig.java
@@ -0,0 +1,219 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 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.config.impl;
+
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.internalTypes.Environment;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.internalTypes.IniConfigurationFile;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.internalTypes.IniConfigurationFile.ConfigurationException;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.config.BaseSubConfig;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.config.ISubConfigHandler;
+
+public class EsConfig extends BaseSubConfig {
+
+ public static final String SECTION_MARKER_ES = "es";
+ public static final String ESDATATYPENAME = "database";
+ private static final String EMPTY = "empty";
+ private static final String PROPERTY_KEY_CLUSTER = "esCluster";
+ private static final String DEFAULT_VALUE_CLUSTER = "";
+ private static EsConfig esConfig;
+
+ private String cluster;
+ private String host;
+ private String node;
+ private String index;
+
+ private EsConfig() {
+ super();
+ this.host = EMPTY;
+ this.node = EMPTY;
+ this.index = EMPTY;
+ this.cluster = DEFAULT_VALUE_CLUSTER;
+ }
+
+ public EsConfig cloneWithIndex(String _index) {
+ EsConfig c = new EsConfig();
+ c.index = _index;
+ c.host = this.host;
+ c.node = this.node;
+ c.cluster = this.cluster;
+ return c;
+ }
+
+ public static String getESDATATYPENAME() {
+ return ESDATATYPENAME;
+ }
+
+ public String getCluster() {
+ return cluster;
+ }
+
+ public void setCluster(String cluster) {
+ this.cluster = cluster;
+ }
+
+ public String getHost() {
+ return host;
+ }
+
+ public void setHost(String host) {
+ this.host = host;
+ }
+
+ public String getNode() {
+ return node;
+ }
+
+ public void setNode(String node) {
+ this.node = node;
+ }
+
+ public String getIndex() {
+ return index;
+ }
+
+ public void setIndex(String index) {
+ this.index = index;
+ }
+
+ @Override
+ public String toString() {
+ return "EsConfig [cluster=" + cluster + ", host=" + host + ", node=" + node + ", index=" + index + "]";
+ }
+
+ public EsConfig(IniConfigurationFile config, ISubConfigHandler configHandler) throws ConfigurationException {
+ this(config, configHandler, true);
+ }
+
+ public EsConfig(IniConfigurationFile config, ISubConfigHandler configHandler, boolean save)
+ throws ConfigurationException {
+
+ super(config, configHandler, SECTION_MARKER_ES);
+ String clustername = Environment.getVar("$HOSTNAME");
+
+ String c = this.getString(PROPERTY_KEY_CLUSTER, clustername);
+ if (c != null && c.startsWith("$")) {
+ c = Environment.getVar(c);
+ }
+ this.cluster = c;
+ this.node = String.format("%s%s", this.cluster, "n1");
+ this.host = "localhost";
+
+ if (save) {
+ config.setProperty(SECTION_MARKER_ES + "." + PROPERTY_KEY_CLUSTER, this.cluster);
+ this.save();
+ }
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + (cluster == null ? 0 : cluster.hashCode());
+ result = prime * result + (host == null ? 0 : host.hashCode());
+ result = prime * result + (index == null ? 0 : index.hashCode());
+ result = prime * result + (node == null ? 0 : node.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ EsConfig other = (EsConfig) obj;
+ if (cluster == null) {
+ if (other.cluster != null) {
+ return false;
+ }
+ } else if (!cluster.equals(other.cluster)) {
+ return false;
+ }
+ if (host == null) {
+ if (other.host != null) {
+ return false;
+ }
+ } else if (!host.equals(other.host)) {
+ return false;
+ }
+ if (index == null) {
+ if (other.index != null) {
+ return false;
+ }
+ } else if (!index.equals(other.index)) {
+ return false;
+ }
+ if (node == null) {
+ if (other.node != null) {
+ return false;
+ }
+ } else if (!node.equals(other.node)) {
+ return false;
+ }
+ return true;
+ }
+
+ @Override
+ public void save()
+ {
+ this.getConfig().setProperty(SECTION_MARKER_ES + "." + PROPERTY_KEY_CLUSTER, this.cluster);
+ super.save();
+ }
+ public static boolean isInstantiated() {
+ return esConfig != null;
+ }
+
+ public static EsConfig getDefaultConfiguration() {
+ return new EsConfig();
+ }
+
+ public static EsConfig getEs(IniConfigurationFile config, ISubConfigHandler configHandler) {
+ if (esConfig == null) {
+ try {
+ esConfig = new EsConfig(config, configHandler);
+ } catch (ConfigurationException e) {
+ esConfig = EsConfig.getDefaultConfiguration();
+ }
+ }
+ return esConfig;
+ }
+
+ public static EsConfig reload() {
+ if (esConfig == null) {
+ return null;
+ }
+ EsConfig tmpConfig;
+ try {
+ tmpConfig = new EsConfig(esConfig.getConfig(), esConfig.getConfigHandler(), false);
+ } catch (ConfigurationException e) {
+ tmpConfig = EsConfig.getDefaultConfiguration();
+ }
+ esConfig = tmpConfig;
+ return esConfig;
+ }
+
+ public static void clear() {
+ esConfig=null;
+ }
+
+}
diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/config/impl/GeoConfig.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/config/impl/GeoConfig.java
new file mode 100644
index 000000000..ac9c3cb50
--- /dev/null
+++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/config/impl/GeoConfig.java
@@ -0,0 +1,163 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 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.config.impl;
+
+import com.typesafe.config.Config;
+import com.typesafe.config.ConfigFactory;
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.config.util.ClusterRoleInfo;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.config.util.ClusterRoleInfoCollection;
+
+public class GeoConfig {
+
+ private static final String DEFAULT_FILENAME = "configuration/initial/geo.conf";
+ private static final String LUMINA_ROOTNODENAME = "lumina-geo-cluster";
+ private final String filename;
+ private final String rootNodename;
+ private ClusterRoleInfoCollection primaryRoles;
+ private ClusterRoleInfoCollection secondayRoles;
+ private RolesTable rolesTable;
+
+ private GeoConfig() {
+ this(null);
+ }
+
+ private GeoConfig(String filename) {
+ this(filename, LUMINA_ROOTNODENAME);
+ }
+
+ private GeoConfig(String filename, String rootNodeName) {
+ this.filename = filename;
+ this.rootNodename = rootNodeName;
+ }
+
+ public static boolean fileExists() {
+ File f = new File(DEFAULT_FILENAME);
+ return f.exists();
+ }
+
+ public static GeoConfig load() throws Exception {
+ return load(DEFAULT_FILENAME);
+ }
+
+ public static GeoConfig load(String filename) throws Exception {
+ GeoConfig cfg = new GeoConfig(filename);
+ cfg._load();
+ return cfg;
+ }
+
+ private void _load() throws Exception {
+ this._load(ConfigFactory.parseFile(new File(this.filename)));
+ }
+
+ private void _load(Config cfg) throws Exception {
+ this.primaryRoles = new ClusterRoleInfoCollection();
+ List<String> a = cfg.getConfig(this.rootNodename).getStringList("primary_roles");
+
+ for (int i = 0; i < a.size(); i++) {
+ ClusterRoleInfo s = new ClusterRoleInfo(a.get(i));
+ this.primaryRoles.add(s);
+ }
+ this.secondayRoles = new ClusterRoleInfoCollection();
+ a = cfg.getConfig(this.rootNodename).getStringList("secondary_roles");
+ for (int i = 0; i < a.size(); i++) {
+ ClusterRoleInfo s = new ClusterRoleInfo(a.get(i));
+ this.secondayRoles.add(s);
+ }
+ this.checkDuplicateRoleEntries();
+ this.rolesTable = new RolesTable(cfg.getConfig(this.rootNodename).getConfigList("ip_roles_table"));
+ }
+
+ private void checkDuplicateRoleEntries() throws Exception {
+ ClusterRoleInfoCollection duplicateEntries = new ClusterRoleInfoCollection();
+ for (ClusterRoleInfo primaryRole : this.primaryRoles) {
+ if (this.secondayRoles.contains(primaryRole)) {
+ duplicateEntries.add(primaryRole);
+ }
+ }
+ if (duplicateEntries.size() > 0) {
+ throw new Exception("duplicate entries found: " + duplicateEntries.toString());
+ }
+
+ }
+
+ public static GeoConfig parse(String content) throws Exception {
+ GeoConfig cfg = new GeoConfig();
+ cfg._load(ConfigFactory.parseString(content));
+ return cfg;
+ }
+
+ public ClusterRoleInfoCollection getPrimaryRoles() {
+ return this.primaryRoles;
+ }
+
+ public ClusterRoleInfoCollection getSecondaryRoles() {
+ return this.secondayRoles;
+ }
+
+ public boolean isPrimary(ClusterRoleInfo roleMember) {
+ return !this.isSecondary(roleMember);
+ }
+
+ private boolean isSecondary(ClusterRoleInfo roleMember) {
+ if (roleMember == null) {
+ return false;
+ }
+ for (ClusterRoleInfo info : this.secondayRoles) {
+ if (info.equals(roleMember)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ @Override
+ public String toString() {
+ return "GeoConfig [filename=" + filename + ", rootNodename=" + rootNodename + ", primaryRoles=" + primaryRoles
+ + ", secondayRoles=" + secondayRoles + ", rolesTable=" + rolesTable + "]";
+ }
+
+ public static class RolesTableEntry {
+ private final ClusterRoleInfo role;
+ private final String ip;
+
+ public RolesTableEntry(Config c) throws Exception {
+ this.role = new ClusterRoleInfo(c.getString("role"));
+ this.ip = c.getString("ip");
+ }
+
+ @Override
+ public String toString() {
+ return "RolesTableEntry [role=" + role + ", ip=" + ip + "]";
+ }
+ }
+ public static class RolesTable extends ArrayList<RolesTableEntry> {
+ private static final long serialVersionUID = -9146218864237487506L;
+
+ public RolesTable(List<? extends Config> configList) throws Exception {
+ for (Config c : configList) {
+ this.add(new RolesTableEntry(c));
+ }
+ }
+
+ }
+
+
+}
diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/config/impl/PmConfig.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/config/impl/PmConfig.java
new file mode 100644
index 000000000..d710efed2
--- /dev/null
+++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/config/impl/PmConfig.java
@@ -0,0 +1,209 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 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.config.impl;
+
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.internalTypes.Environment;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.internalTypes.IniConfigurationFile;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.internalTypes.IniConfigurationFile.ConfigurationException;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.config.BaseSubConfig;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.config.ISubConfigHandler;
+
+public class PmConfig extends BaseSubConfig {
+
+ private static final String SECTION_MARKER_PM = "pm";
+ private static final String PROPERTY_KEY_ENABLED = "pmEnabled";
+ private static final String PROPERTY_KEY_CLUSTER = "pmCluster";
+
+ private static final boolean DEFAULT_VALUE_ENABLED = true;
+ private static final String DEFAULT_VALUE_CLUSTER = "";
+ private static PmConfig pmConfig;
+
+ private boolean enabled;
+
+ public static final String ESDATATYPENAME = "database";
+
+ private static final String EMPTY = "empty";
+
+ private String cluster;
+ private String host;
+ private String node;
+
+ public static String getESDATATYPENAME() {
+ return ESDATATYPENAME;
+ }
+
+ public String getCluster() {
+ return cluster;
+ }
+
+ public void setCluster(String cluster) {
+ this.cluster = cluster;
+ }
+
+ public String getHost() {
+ return host;
+ }
+
+ public void setHost(String host) {
+ this.host = host;
+ }
+
+ public String getNode() {
+ return node;
+ }
+
+ public void setNode(String node) {
+ this.node = node;
+ }
+
+ public boolean isPerformanceManagerEnabled() {
+ return this.enabled;
+ }
+
+ public PmConfig(IniConfigurationFile config, ISubConfigHandler configHandler) throws ConfigurationException {
+ this(config, configHandler, true);
+ }
+
+ public PmConfig(IniConfigurationFile config, ISubConfigHandler configHandler, boolean save)
+ throws ConfigurationException {
+
+ super(config, configHandler, SECTION_MARKER_PM);
+ String clustername = Environment.getVar("$HOSTNAME");
+
+ this.enabled = this.getBoolean(PROPERTY_KEY_ENABLED, DEFAULT_VALUE_ENABLED);
+ String c = this.getString(PROPERTY_KEY_CLUSTER, clustername);
+ if (c != null && c.startsWith("$")) {
+ c = Environment.getVar(c);
+ }
+ this.cluster = c;
+ this.node = String.format("%s%s", this.cluster, "n1");
+ this.host = "localhost";
+
+ if (save) {
+ config.setProperty(SECTION_MARKER_PM + "." + PROPERTY_KEY_ENABLED, this.enabled);
+ config.setProperty(SECTION_MARKER_PM + "." + PROPERTY_KEY_CLUSTER, this.cluster);
+
+ this.save();
+ }
+ }
+
+ private PmConfig() {
+ super();
+ this.cluster = EMPTY;
+ this.host = EMPTY;
+ this.node = EMPTY;
+ this.enabled = DEFAULT_VALUE_ENABLED;
+ }
+
+
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + (cluster == null ? 0 : cluster.hashCode());
+ result = prime * result + (enabled ? 1231 : 1237);
+ result = prime * result + (host == null ? 0 : host.hashCode());
+ result = prime * result + (node == null ? 0 : node.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ PmConfig other = (PmConfig) obj;
+ if (cluster == null) {
+ if (other.cluster != null) {
+ return false;
+ }
+ } else if (!cluster.equals(other.cluster)) {
+ return false;
+ }
+ if (enabled != other.enabled) {
+ return false;
+ }
+ if (host == null) {
+ if (other.host != null) {
+ return false;
+ }
+ } else if (!host.equals(other.host)) {
+ return false;
+ }
+ if (node == null) {
+ if (other.node != null) {
+ return false;
+ }
+ } else if (!node.equals(other.node)) {
+ return false;
+ }
+ return true;
+ }
+
+ public static PmConfig getDefaultConfiguration() {
+ PmConfig c = new PmConfig();
+ c.enabled = DEFAULT_VALUE_ENABLED;
+ c.cluster = DEFAULT_VALUE_CLUSTER;
+ return c;
+ }
+
+ @Override
+ public String toString() {
+ return "PmConfig [enabled=" + enabled + ", cluster=" + cluster + ", host=" + host + ", node=" + node + "]";
+ }
+
+ public static boolean isInstantiated() {
+ return pmConfig != null;
+ }
+
+ public static PmConfig getPm(IniConfigurationFile config, ISubConfigHandler configHandler) {
+ if (pmConfig == null) {
+ try {
+ pmConfig = new PmConfig(config, configHandler);
+ } catch (ConfigurationException e) {
+ pmConfig = PmConfig.getDefaultConfiguration();
+ }
+ }
+ return pmConfig;
+ }
+
+ public static PmConfig reload() {
+ if (pmConfig == null) {
+ return null;
+ }
+ PmConfig tmpConfig;
+ try {
+ tmpConfig = new PmConfig(pmConfig.getConfig(), pmConfig.getConfigHandler(), false);
+ } catch (ConfigurationException e) {
+ tmpConfig = PmConfig.getDefaultConfiguration();
+ }
+ pmConfig = tmpConfig;
+ return pmConfig;
+ }
+
+ public static void clear() {
+ pmConfig=null;
+ }
+}
diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/config/impl/ToggleAlarmConfig.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/config/impl/ToggleAlarmConfig.java
new file mode 100644
index 000000000..da2f10a75
--- /dev/null
+++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/config/impl/ToggleAlarmConfig.java
@@ -0,0 +1,139 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 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.config.impl;
+
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.internalTypes.IniConfigurationFile;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.internalTypes.IniConfigurationFile.ConfigurationException;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.config.BaseSubConfig;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.config.ISubConfigHandler;
+
+public class ToggleAlarmConfig extends BaseSubConfig{
+
+ private static final String SECTION_MARKER_TA = "toggleAlarmFilter";
+ private static final String PROPERTY_KEY_ENABLED = "taEnabled";
+ private static final String PROPERTY_KEY_DELAY = "taDelay";
+
+ private static final boolean DEFAULT_VALUE_ENABLED = true;
+ private static final long DEFAULT_VALUE_DELAY = 3000; //in ms
+ private static ToggleAlarmConfig taConfig;
+ private boolean enabled;
+ private long delay;
+
+ public boolean isEnabled() {
+ return this.enabled;
+ }
+ public long getDelay() {
+ return this.delay;
+ }
+ private ToggleAlarmConfig() {
+ super();
+ this.enabled = DEFAULT_VALUE_ENABLED;
+ this.delay=DEFAULT_VALUE_DELAY;
+ }
+ public ToggleAlarmConfig(IniConfigurationFile config, ISubConfigHandler configHandler) throws ConfigurationException {
+ this(config, configHandler, true);
+ }
+
+ public ToggleAlarmConfig(IniConfigurationFile config, ISubConfigHandler configHandler, boolean save)
+ throws ConfigurationException {
+
+ super(config, configHandler, SECTION_MARKER_TA);
+
+ this.enabled = this.getBoolean(PROPERTY_KEY_ENABLED, DEFAULT_VALUE_ENABLED);
+ this.delay = this.getLong(PROPERTY_KEY_DELAY,DEFAULT_VALUE_DELAY);
+ if (save) {
+ config.setProperty(SECTION_MARKER_TA + "." + PROPERTY_KEY_ENABLED, this.enabled);
+ config.setProperty(SECTION_MARKER_TA + "." + PROPERTY_KEY_DELAY, this.delay);
+
+ this.save();
+ }
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + (int) (delay ^ delay >>> 32);
+ result = prime * result + (enabled ? 1231 : 1237);
+ return result;
+ }
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ ToggleAlarmConfig other = (ToggleAlarmConfig) obj;
+ if (delay != other.delay) {
+ return false;
+ }
+ if (enabled != other.enabled) {
+ return false;
+ }
+ return true;
+ }
+
+ @Override
+ public String toString() {
+ return "ToggleAlarmConfig [enabled=" + enabled + ", delay=" + delay + "]";
+ }
+
+ public static ToggleAlarmConfig getDefaultConfiguration() {
+ ToggleAlarmConfig c = new ToggleAlarmConfig();
+ c.enabled = DEFAULT_VALUE_ENABLED;
+ c.delay = DEFAULT_VALUE_DELAY;
+ return c;
+ }
+ public static boolean isInstantiated() {
+ return taConfig != null;
+ }
+
+ public static ToggleAlarmConfig getTa(IniConfigurationFile config, ISubConfigHandler configHandler) {
+ if (taConfig == null) {
+ try {
+ taConfig = new ToggleAlarmConfig(config, configHandler);
+ } catch (ConfigurationException e) {
+ taConfig = ToggleAlarmConfig.getDefaultConfiguration();
+ }
+ }
+ return taConfig;
+ }
+
+ public static ToggleAlarmConfig reload() {
+ if (taConfig == null) {
+ return null;
+ }
+ ToggleAlarmConfig tmpConfig;
+ try {
+ tmpConfig = new ToggleAlarmConfig(taConfig.getConfig(), taConfig.getConfigHandler(), false);
+ } catch (ConfigurationException e) {
+ tmpConfig = ToggleAlarmConfig.getDefaultConfiguration();
+ }
+ taConfig = tmpConfig;
+ return taConfig;
+ }
+
+ public static void clear() {
+ taConfig=null;
+ }
+}
diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/config/util/ClusterConfig.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/config/util/ClusterConfig.java
new file mode 100644
index 000000000..7d3174bce
--- /dev/null
+++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/config/util/ClusterConfig.java
@@ -0,0 +1,133 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 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.config.util;
+
+import com.typesafe.config.Config;
+import java.util.ArrayList;
+import java.util.List;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class ClusterConfig {
+
+ private static final Logger LOG = LoggerFactory.getLogger(ClusterConfig.class);
+
+ private final List<ClusterNodeInfo> seedNodes;
+ private final ClusterRoleInfoCollection roles;
+ private ClusterNodeInfo ismeInfo;
+
+ public static ClusterConfig defaultSingleNodeConfig()
+ {
+ ClusterConfig cfg=new ClusterConfig();
+ cfg.ismeInfo=ClusterNodeInfo.defaultSingleNodeInfo();
+ cfg.seedNodes.add(cfg.ismeInfo);
+ cfg.roles.add(ClusterRoleInfo.defaultSingleNodeRole());
+ return cfg;
+ }
+ public ClusterConfig()
+ {
+ this.seedNodes = new ArrayList<>();
+ this.roles = new ClusterRoleInfoCollection();
+
+ }
+ public ClusterConfig(Config o) throws Exception {
+ {
+ this.seedNodes = new ArrayList<>();
+ this.roles = new ClusterRoleInfoCollection();
+ List<String> a = o.getStringList("seed-nodes");
+ for (int i = 0; i < a.size(); i++) {
+ ClusterNodeInfo info = new ClusterNodeInfo(a.get(i));
+ this.seedNodes.add(info);
+ }
+ a = o.getStringList("roles");
+ for (int i = 0; i < a.size(); i++) {
+ ClusterRoleInfo s = new ClusterRoleInfo(a.get(i));
+ this.roles.add(s);
+ }
+ int idx = this.roles.get(0).getIndex() - 1;
+ if (idx >= 0 && idx < this.seedNodes.size()) {
+ this.ismeInfo = this.seedNodes.get(idx);
+ } else {
+ this.ismeInfo = null;
+ }
+ }
+
+ }
+
+ public boolean isCluster() {
+ return this.seedNodes != null ? this.seedNodes.size() > 1 : false;
+ }
+
+ public boolean isMe(ClusterNodeInfo i) {
+ return this.ismeInfo != null ? this.ismeInfo.equals(i) : false;
+ }
+
+ public List<ClusterNodeInfo> getSeedNodes() {
+ return this.seedNodes;
+ }
+
+ public String getHostName(String defaultValue) {
+ if (getRoleMemberIndex() > 0 && getRoleMemberIndex() <= seedNodes.size()) {
+ return this.seedNodes.get(getRoleMemberIndex()-1).getRemoteAddress();
+ } else {
+ LOG.warn("Seednode not available for roleMemberIndex {}. Using default {}",getRoleMember(), defaultValue);
+ return defaultValue;
+ }
+ }
+
+ public String getDBClusterName(String defaultValue) {
+ String r = null;
+ if (this.seedNodes != null && this.seedNodes.size() > 0) {
+ r = String.format("cluster-%s.%d", this.seedNodes.get(0).getRemoteAddress(), this.seedNodes.get(0).getPort());
+ }
+ if (r == null || r.isEmpty()) {
+ r = defaultValue;
+ }
+ return r;
+ }
+ public String getClusterSeedNodeName() {
+ return this.getClusterSeedNodeName("");
+ }
+ public String getClusterSeedNodeName(String defaultValue) {
+ int idx=this.getRoleMemberIndex()-1;
+ String r=null;
+ if(this.seedNodes!=null && idx>=0 && this.seedNodes.size()>0 && this.seedNodes.size()>idx)
+ {
+ r=this.seedNodes.get(idx).getSeedNodeName();
+ }
+ if (r == null || r.isEmpty()) {
+ r = defaultValue;
+ }
+ return r;
+ }
+ public int getRoleMemberIndex() {
+
+ ClusterRoleInfo role=this.roles.get("member");
+ return role!=null?role.getIndex():0;
+ }
+ public ClusterRoleInfo getRoleMember() {
+ return this.roles.get("member");
+ }
+
+ @Override
+ public String toString() {
+ return "ClusterConfig [seedNodes=" + seedNodes + ", roles=" + roles + ", ismeInfo=" + ismeInfo + "]";
+ }
+
+
+}
diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/config/util/ClusterNodeInfo.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/config/util/ClusterNodeInfo.java
new file mode 100644
index 000000000..53dcfd102
--- /dev/null
+++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/config/util/ClusterNodeInfo.java
@@ -0,0 +1,81 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 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.config.util;
+
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+public class ClusterNodeInfo {
+ private final String protocol;
+ private final String clusterName;
+ private final String remoteAdr;
+ private final int port;
+ private final String seedNodeName;
+
+ public static ClusterNodeInfo defaultSingleNodeInfo() {
+ return new ClusterNodeInfo("akka.tcp","opendaylight-cluster-data","127.0.0.1",2550);
+ }
+
+ public ClusterNodeInfo(String s) throws Exception {
+ final String regex = "([a-z.]*):\\/\\/([a-zA-Z0-9-]*)@([a-zA-Z0-9.-]*):([0-9]*)";
+ final Pattern pattern = Pattern.compile(regex);
+ final Matcher matcher = pattern.matcher(s);
+ if (!matcher.find()) {
+ throw new Exception("invalid seedNode format");
+ }
+ this.seedNodeName = matcher.group();
+ this.protocol = matcher.group(1);
+ this.clusterName = matcher.group(2);
+ this.remoteAdr = matcher.group(3);
+ this.port = Integer.parseInt(matcher.group(4));
+ }
+
+ public ClusterNodeInfo(String protocol, String clustername, String remoteadr, int port) {
+ this.protocol=protocol;
+ this.clusterName=clustername;
+ this.remoteAdr=remoteadr;
+ this.port=port;
+ this.seedNodeName=this.protocol+"://"+this.clusterName+"@"+this.remoteAdr+":"+this.port;
+ }
+
+ public String getProtocol() {
+ return protocol;
+ }
+
+ public String getClusterName() {
+ return clusterName;
+ }
+
+ public String getRemoteAddress() {
+ return remoteAdr;
+ }
+ public String getSeedNodeName() {
+ return seedNodeName;
+ }
+
+ public int getPort() {
+ return port;
+ }
+
+ @Override
+ public String toString() {
+ return "ClusterNodeInfo [protocol=" + protocol + ", clusterName=" + clusterName + ", remoteAdr=" + remoteAdr
+ + ", port=" + port + ", seedNodeName=" + seedNodeName + "]";
+ }
+
+}
diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/config/util/ClusterRoleInfo.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/config/util/ClusterRoleInfo.java
new file mode 100644
index 000000000..fa2a21b6a
--- /dev/null
+++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/config/util/ClusterRoleInfo.java
@@ -0,0 +1,91 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 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.config.util;
+
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+public class ClusterRoleInfo {
+ private final String Role;
+ private final int Index;
+
+ public ClusterRoleInfo(String s) throws Exception {
+ final String regex = "([a-zA-Z]*)-([0-9]*)";
+ final Pattern pattern = Pattern.compile(regex);
+ final Matcher matcher = pattern.matcher(s);
+ if (!matcher.find()) {
+ throw new Exception("unexpected role format:"+s);
+ }
+ this.Role = matcher.group(1);
+ this.Index = Integer.parseInt(matcher.group(2));
+ }
+
+ private ClusterRoleInfo(String role, int idx) {
+ this.Role=role;
+ this.Index=idx;
+ }
+
+ public static ClusterRoleInfo defaultSingleNodeRole() {
+ return new ClusterRoleInfo("member",1);
+ }
+
+ public String getRole() {
+ return Role;
+ }
+ public int getIndex() {
+ return Index;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + Index;
+ result = prime * result + (Role == null ? 0 : Role.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ ClusterRoleInfo other = (ClusterRoleInfo) obj;
+ if (Index != other.Index) {
+ return false;
+ }
+ if (Role == null) {
+ if (other.Role != null) {
+ return false;
+ }
+ } else if (!Role.equals(other.Role)) {
+ return false;
+ }
+ return true;
+ }
+ @Override
+ public String toString() {
+ return "ClusterRoleInfo [Role=" + Role + ", Index=" + Index + "]";
+ }
+}
diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/config/util/ClusterRoleInfoCollection.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/config/util/ClusterRoleInfoCollection.java
new file mode 100644
index 000000000..6cb81c2af
--- /dev/null
+++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/config/util/ClusterRoleInfoCollection.java
@@ -0,0 +1,45 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 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.config.util;
+
+import java.util.ArrayList;
+
+public class ClusterRoleInfoCollection extends ArrayList<ClusterRoleInfo> {
+ private static final long serialVersionUID = 1L;
+
+ public ClusterRoleInfo get(String role) {
+ for (ClusterRoleInfo info : this) {
+ if (info.getRole().equals(role)) {
+ return info;
+ }
+ }
+ return null;
+ }
+
+ public boolean contains(ClusterRoleInfo info) {
+ if (info == null) {
+ return false;
+ }
+ for (ClusterRoleInfo i : this) {
+ if (i.equals(info)) {
+ return true;
+ }
+ }
+ return false;
+ }
+}
diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/config/util/ConfigFileObserver.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/config/util/ConfigFileObserver.java
new file mode 100644
index 000000000..daa572a63
--- /dev/null
+++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/config/util/ConfigFileObserver.java
@@ -0,0 +1,67 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 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.config.util;
+
+import java.util.ArrayList;
+import java.util.List;
+import javax.annotation.Nonnull;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.internalTypes.FileWatchdog;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.internalTypes.IniConfigurationFile;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.internalTypes.IniConfigurationFile.ConfigurationException;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.config.IConfigChangedListener;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class ConfigFileObserver extends FileWatchdog {
+
+ private static final Logger LOG = LoggerFactory.getLogger(ConfigFileObserver.class);
+
+ private final List<IConfigChangedListener> mConfigChangedHandlers = new ArrayList<>();
+ private final IniConfigurationFile mConfig;
+
+ public ConfigFileObserver(String filename, long pollIntervallMs, IniConfigurationFile mConfig) {
+ super(filename);
+ this.setDelay(pollIntervallMs);
+ this.mConfig = mConfig;
+ }
+
+ @Override
+ protected void doOnChange() {
+
+ LOG.debug("property file has changed");
+ try {
+ mConfig.reLoad();
+ // push event to all listeners
+ for (IConfigChangedListener listener : this.mConfigChangedHandlers) {
+ listener.onConfigChanged();
+ }
+ } catch (ConfigurationException e) {
+ LOG.warn("error reloading config: " + e.getMessage());
+ }
+ }
+
+ public void registerConfigChangedListener(@Nonnull IConfigChangedListener l) {
+ if (!this.mConfigChangedHandlers.contains(l)) {
+ this.mConfigChangedHandlers.add(l);
+ }
+ }
+
+ public void unregisterConfigChangedListener(IConfigChangedListener l) {
+ this.mConfigChangedHandlers.remove(l);
+ }
+}
diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/dcaeconnector/impl/DcaeMessages.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/dcaeconnector/impl/DcaeMessages.java
new file mode 100644
index 000000000..5f3c1aaca
--- /dev/null
+++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/dcaeconnector/impl/DcaeMessages.java
@@ -0,0 +1,341 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 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==========================================================================
+ ******************************************************************************/
+/**
+ ecompProvider.sendProblemNotification(ownKeyName, notificationXml);
+ * ECOMP Messages are generated an send to destination
+ *
+ * @author herbert
+ */
+package org.onap.ccsdk.features.sdnr.wt.devicemanager.dcaeconnector.impl;
+
+import java.io.IOException;
+import java.net.HttpURLConnection;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URLConnection;
+import java.text.ParseException;
+import javax.annotation.Nullable;
+import javax.net.ssl.HostnameVerifier;
+import javax.net.ssl.HttpsURLConnection;
+import javax.net.ssl.SSLContext;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.internalTypes.InternalSeverity;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.internalTypes.InventoryInformation;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.netconf.ONFCoreNetworkElementRepresentation;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.netconf.util.NetconfTimeStamp;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.DeviceManagerImpl;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.xml.ProblemNotificationXml;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class DcaeMessages {
+
+ private static final Logger LOG = LoggerFactory.getLogger(DcaeSenderImpl.class);
+
+ private static final String DCAE_NORMAL = "NORMAL";
+ private static final String DCAE_MINOR = "MINOR";
+ private static final String DCAE_WARNING = "WARNING";
+ private static final String DCAE_CRITICAL = "CRITICAL";
+ private static final String DCAE_MAJOR = "MAJOR";
+
+ private static final String eventNamePrefix = "fault_Microwave_Radio_Alarms";
+ private static final String eventType = "Microwave_Radio_Alarms";
+ private static final String eventSourceType = "Microwave_Radio";
+
+ private static final String charset = "UTF-8";
+
+ private static final HostnameVerifier allHostsValid = (hostname, session) -> true;
+
+ private static final String CONTENT_TYPE_APPJSON = "application/json";
+
+ private static final NetconfTimeStamp NETCONFTIME_CONVERTER = NetconfTimeStamp.getConverter();
+
+ //Configurable parameters
+ private final DcaeSender dcaeSender;
+ private final int heartbeatIntervallSeconds;
+ private final String entityName;
+ private final DeviceManagerImpl deviceManager;
+
+ //Variables
+ private int heartbeatsequence = 0;
+
+ public DcaeMessages(DcaeSender ecompSender, String entityName, Integer heartbeatIntervallSeconds, DeviceManagerImpl deviceManager) {
+ this.dcaeSender = ecompSender;
+ this.entityName = entityName;
+ this.deviceManager = deviceManager;
+ this.heartbeatIntervallSeconds = heartbeatIntervallSeconds;
+ }
+
+ /**
+ * Create a heartbeat message.
+ * @return Result string with answer from server
+ */
+ public String postHeartBeat() {
+ String epochTimeMicrosecondsString = getEpochTimeMicroseconds();
+ String body = assembleHeartbeatFromTemplate(null,
+ epochTimeMicrosecondsString,
+ heartbeatsequence++,
+ NETCONFTIME_CONVERTER.getTimeStampAsNetconfString()).toString();
+ return dcaeSender.sendDcaePost( body);
+ }
+
+ /**
+ * ONF 1.2 Problem Notification
+ * @param mountPointName self-explaining
+ * @param notification Notification input
+ * @return String with answer
+ */
+
+ public String postNotification(String mountPointName, ProblemNotificationXml notification) {
+
+ String problemName = notification.getProblem();
+ String sequence = notification.getCounter();
+ String objId = notification.getObjectId();
+ String severity = convert( notification.getSeverity());
+ String timeStamp = convert( notification.getTimeStamp() );
+
+ String body = assembleEventNotificationFromTemplate(null,
+ timeStamp, sequence,
+ mountPointName, objId, problemName, severity, notification.getTimeStamp() ).toString();
+
+ return dcaeSender.sendDcaePost( body);
+ }
+
+ /**
+ * Setup a connection to URL with authorisation header
+ * @param url e.g. "https://plan.fritz.box:9092/ux/#" or "
+ * @param basicAuth authorisation header like "Basic SGVyYmVydDpIZXJiZXJ0"
+ * @param insertContentHeader
+ * @return Null in case of error or the URLConnection
+ * @throws IOException
+ * @throws MalformedURLException
+ */
+ static @Nullable HttpURLConnection openConnection( URL url, String basicAuth, boolean insertContentHeader, @Nullable SSLContext sc) throws MalformedURLException, IOException {
+
+ //Prepare the connection
+ HttpURLConnection newHttpConnection = null;
+ {
+ URLConnection newConnection = url.openConnection();
+ if (newConnection instanceof HttpURLConnection) {
+ LOG.debug("Setup connection to {} ", url.toString());
+
+ newHttpConnection = (HttpURLConnection)newConnection;
+
+ newHttpConnection.setDoOutput(true); // Triggers POST.
+ newHttpConnection.setRequestProperty("Accept-Charset", charset);
+ if (basicAuth != null) {
+ newHttpConnection.setRequestProperty("Authorization", basicAuth);
+ }
+ if (insertContentHeader) {
+ newHttpConnection.setRequestProperty("Content-Type", CONTENT_TYPE_APPJSON);
+ }
+
+ if (newHttpConnection instanceof HttpsURLConnection) {
+ LOG.debug("SSL connection setup with trust all.");
+ HttpsURLConnection newHttpsConnection = (HttpsURLConnection)newHttpConnection;
+ if (sc != null) {
+ newHttpsConnection.setSSLSocketFactory(sc.getSocketFactory());
+ } else {
+ LOG.warn("No SSL Contect available");
+ }
+ newHttpsConnection.setHostnameVerifier(allHostsValid);
+ }
+ } else {
+ LOG.warn("URL not a HTTP protocol: {}", url);
+ }
+ }
+ return newHttpConnection;
+ }
+
+ /* -----------------
+ * Private function for message creation and with templates
+ */
+
+ /**
+ * Get actual microseconds
+ * @return String
+ */
+ private String getEpochTimeMicroseconds() {
+ long microseconds = System.nanoTime() / 1000;
+ return String.valueOf(microseconds);
+ }
+
+ /**
+ * Assemble heartbeat message
+ * @param sb StringBuffer to be used or null to allocate
+ * @param epochTimeMicrosecondsString Text with time stamp
+ * @param sequence integer sequence number
+ * @param eventTimeValueNetconfFormatString like this: 2018-05-14T05:32:17.292Z
+ * @return StringBuffer with result
+ */
+ private StringBuffer assembleHeartbeatFromTemplate(
+ StringBuffer sb,
+ String epochTimeMicrosecondsString,
+ int sequence,
+ String eventTimeValueNetconfFormatString) {
+
+ if (sb == null) {
+ sb = new StringBuffer();
+ }
+ sb.append("{\n" +
+ " \"event\": {\n" +
+ " \"commonEventHeader\": {\n" +
+ " \"domain\": \"heartbeat\",\n" +
+ " \"eventId\": \"testpattern-ab305d54-85b4-a31b-7db2-fb6b9e546015\",\n" +
+ " \"eventName\": \"heartbeat_Controller\",\n" +
+ " \"eventType\": \"Controller\",\n" +
+ " \"priority\": \"Low\",\n" +
+ " \"reportingEntityId\": \"\",\n" +
+ " \"reportingEntityName\": \""+entityName+"\",\n" +
+ " \"sequence\": "+String.valueOf(sequence)+",\n" +
+ " \"sourceId\": \"\",\n" +
+ " \"sourceName\": \""+entityName+"\",\n" +
+ " \"startEpochMicrosec\": "+epochTimeMicrosecondsString+",\n" +
+ " \"lastEpochMicrosec\": "+epochTimeMicrosecondsString+",\n" +
+ " \"version\": 3.0\n" +
+ " },\n" +
+ " \"heartbeatFields\": {\n" +
+ " \"additionalFields\": [\n" +
+ " {\n" +
+ " \"name\": \"eventTime\",\n" +
+ " \"value\": \""+eventTimeValueNetconfFormatString+"\"\n" +
+ " }\n" +
+ " ],\n" +
+ " \"heartbeatFieldsVersion\": 1.0,\n" +
+ " \"heartbeatInterval\": "+heartbeatIntervallSeconds+"\n" +
+ " }\n" +
+ " }\n" +
+ "}\n"
+ );
+
+ return sb;
+ }
+
+ /**
+ * Assemble notification message
+ * @param sb StringBuffer to be used or null to allocate
+ * @param epochTimeMicrosecondsString Text with time stamp
+ * @param sequence integer sequence number
+ * @param mountpointName
+ * @param objId
+ * @param problemName
+ * @param severity
+ * @return StringBuffer with result
+ */
+
+ private StringBuffer assembleEventNotificationFromTemplate(StringBuffer sb,
+ String epochTimeMicrosecondsString, String sequence,
+ String mountpointName, String objId, String problemName, String severity, String eventTimeValueNetconfFormatString
+ ) {
+
+ if (sb == null) {
+ sb = new StringBuffer();
+ }
+
+ ONFCoreNetworkElementRepresentation optionalNe = deviceManager != null ? deviceManager.getNeByMountpoint(mountpointName) : null;
+ InventoryInformation neInventory = optionalNe != null ? optionalNe.getInventoryInformation() : InventoryInformation.getDefault();
+
+ sb.append("{\n" +
+ " \"event\": {\n" +
+ " \"commonEventHeader\": {\n" +
+ " \"domain\": \"fault\",\n" +
+ " \"eventId\": \""+mountpointName+"_"+objId+"_"+problemName+"\",\n" +
+ " \"eventName\": \""+eventNamePrefix+"_"+problemName+"\",\n" +
+ " \"eventType\": \""+eventType+"\",\n" +
+ " \"sequence\": "+sequence+",\n" +
+ " \"priority\": \"High\",\n" +
+ " \"reportingEntityId\": \"\",\n" +
+ " \"reportingEntityName\": \""+entityName+"\",\n" +
+ " \"sourceId\": \"\",\n" +
+ " \"sourceName\": \""+mountpointName+"\",\n" +
+ " \"startEpochMicrosec\": "+epochTimeMicrosecondsString+",\n" +
+ " \"lastEpochMicrosec\": "+epochTimeMicrosecondsString+",\n" +
+ " \"version\": 3.0\n" +
+ " },\n" +
+ " \"faultFields\": {\n" +
+ " \"alarmAdditionalInformation\": [\n" +
+ " {\n" +
+ " \"name\": \"eventTime\",\n" +
+ " \"value\": \""+eventTimeValueNetconfFormatString+"\"\n" +
+ " },\n" +
+ " {\n" +
+ " \"name\": \"equipType\",\n" +
+ " \"value\": \""+neInventory.getType()+"\"\n" +
+ " },\n" +
+ " {\n" +
+ " \"name\": \"vendor\",\n" +
+ " \"value\": \""+neInventory.getVendor()+"\"\n" +
+ " },\n" +
+ " {\n" +
+ " \"name\": \"model\",\n" +
+ " \"value\": \""+neInventory.getModel()+"\"\n" +
+ " }\n" +
+ " ],\n" +
+ " \"faultFieldsVersion\":2.0,\n" +
+ " \"eventSourceType\": \""+eventSourceType+"\",\n" +
+ " \"alarmCondition\": \""+problemName+"\",\n" +
+ " \"alarmInterfaceA\": \""+objId+"\",\n" +
+ " \"specificProblem\": \""+problemName+"\",\n" +
+ " \"eventSeverity\": \""+severity+"\",\n" +
+ " \"vfStatus\": \"Active\"\n" +
+ " }\n" +
+ " }\n" +
+ "}\n"
+ );
+
+ return sb;
+ }
+
+ /* -----------------
+ * Convert internal type formats into the Ecomp format
+ */
+
+ private String convert(InternalSeverity severity ) {
+ switch( severity ) {
+ case NonAlarmed:
+ break;
+ case Warning:
+ return DCAE_WARNING;
+ case Minor:
+ return DCAE_MINOR;
+ case Major:
+ return DCAE_MAJOR;
+ case Critical:
+ return DCAE_CRITICAL;
+ }
+ return DCAE_NORMAL;
+ }
+
+
+ /**
+ * Time has to be converted into milliseconds
+ * @param timeAsString time as string
+ * @return as string
+ */
+ private String convert(String timeAsString) {
+
+ long microseconds = -1;
+ try {
+ microseconds = NETCONFTIME_CONVERTER.getTimeStampFromNetconfAsMilliseconds(timeAsString) * 1000;
+ } catch (IllegalArgumentException | ParseException e) {
+ LOG.info("Can not convert timeAsString", e);
+ }
+ return String.valueOf(microseconds);
+ }
+
+
+}
diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/dcaeconnector/impl/DcaeProviderClient.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/dcaeconnector/impl/DcaeProviderClient.java
new file mode 100644
index 000000000..0f817323f
--- /dev/null
+++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/dcaeconnector/impl/DcaeProviderClient.java
@@ -0,0 +1,82 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 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.dcaeconnector.impl;
+
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.config.HtDevicemanagerConfiguration;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.config.IConfigChangedListener;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.config.impl.DcaeConfig;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.DeviceManagerImpl;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.ProviderClient;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.xml.ProblemNotificationXml;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+public class DcaeProviderClient implements AutoCloseable, ProviderClient {
+
+ private static final Logger LOG = LoggerFactory.getLogger(DcaeProviderClient.class);
+
+ private final HtDevicemanagerConfiguration htConfig;
+ private final IConfigChangedListener configChangedListener;
+
+ private final Object lock = new Object();;
+ private DcaeProviderWorker worker;
+
+ public DcaeProviderClient(HtDevicemanagerConfiguration cfg, String entityName, DeviceManagerImpl deviceManager) {
+ LOG.info("Create");
+ this.htConfig=cfg;
+ worker = new DcaeProviderWorker(this.htConfig.getDcae(), entityName, deviceManager);
+ this.configChangedListener = () -> {
+ LOG.info("Configuration change. Worker exchanged");
+ synchronized(lock) {
+ worker.close();
+ worker = new DcaeProviderWorker(DcaeConfig.reload(), entityName, deviceManager);
+ }
+ };
+ this.htConfig.registerConfigChangedListener(configChangedListener );
+
+ }
+
+ @Override
+ public void sendProblemNotification(String mountPointName, ProblemNotificationXml notification) {
+ synchronized(lock) {
+ worker.sendProblemNotification(mountPointName, notification);
+ }
+ }
+
+ @Override
+ public void sendProblemNotification(String mountPointName, ProblemNotificationXml notification, boolean neDeviceAlarm) {
+ sendProblemNotification(mountPointName, notification);
+ }
+
+ @Override
+ public void close() {
+ this.htConfig.unregisterConfigChangedListener(configChangedListener);
+ synchronized(lock) {
+ worker.close();
+ }
+ }
+
+ /* ---------------------------------------------------------
+ * Private
+ */
+
+}
+
+
+
diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/dcaeconnector/impl/DcaeProviderTask.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/dcaeconnector/impl/DcaeProviderTask.java
new file mode 100644
index 000000000..2a169db01
--- /dev/null
+++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/dcaeconnector/impl/DcaeProviderTask.java
@@ -0,0 +1,50 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 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==========================================================================
+ ******************************************************************************/
+/**
+ * Event provider to ECOMP for heartbeat message
+ *
+ * @author herbert
+ *
+ */
+package org.onap.ccsdk.features.sdnr.wt.devicemanager.dcaeconnector.impl;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+class DcaeProviderTask implements Runnable {
+
+ private static final Logger LOG = LoggerFactory.getLogger(DcaeProviderTask.class);
+
+ private int t = 0;
+ private final DcaeMessages dcaeMessages;
+
+ DcaeProviderTask(DcaeMessages dcaeMessages) {
+ LOG.info("Create eventprovider task");
+ this.dcaeMessages = dcaeMessages;
+ }
+
+ private void sendHeartbeat() {
+ dcaeMessages.postHeartBeat();
+ }
+
+ @Override
+ public void run() {
+ LOG.debug("DCAE provider heartbeat tick start {}", t++);
+ sendHeartbeat();
+ }
+}
diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/dcaeconnector/impl/DcaeProviderWorker.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/dcaeconnector/impl/DcaeProviderWorker.java
new file mode 100644
index 000000000..17d09ecb2
--- /dev/null
+++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/dcaeconnector/impl/DcaeProviderWorker.java
@@ -0,0 +1,83 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 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.dcaeconnector.impl;
+
+import java.util.concurrent.Executors;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.ScheduledFuture;
+import java.util.concurrent.TimeUnit;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.config.impl.DcaeConfig;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.DeviceManagerImpl;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.xml.ProblemNotificationXml;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+class DcaeProviderWorker implements AutoCloseable {
+
+ private static final Logger LOG = LoggerFactory.getLogger(DcaeProviderWorker.class);
+
+ private static final int MIN_HEARTBEAT_TIME_SECONDS = 30;
+
+ private final ScheduledExecutorService scheduler;
+ private final DcaeSenderImpl dcaepClient;
+ private final DcaeMessages dcaeMessages;
+ private final ScheduledFuture<?> taskReference;
+
+ public DcaeProviderWorker(DcaeConfig configuration, String entityName, DeviceManagerImpl deviceManager) {
+
+ //Start services
+ LOG.info("Configuration: "+configuration);
+ int heartbeatSeconds = configuration.getTimerPeriodSeconds();
+ if ( heartbeatSeconds < MIN_HEARTBEAT_TIME_SECONDS ) {
+ heartbeatSeconds = MIN_HEARTBEAT_TIME_SECONDS;
+ LOG.info("Adjust heartbeat intervall to minimum of { } seconds.",heartbeatSeconds);
+ }
+
+ dcaepClient = new DcaeSenderImpl(configuration.getEventReveicerUrl(), configuration.getUserCredentials());
+ dcaeMessages = new DcaeMessages(dcaepClient, entityName, heartbeatSeconds, deviceManager);
+
+ //Activate task
+ LOG.info("Create Fault manager client Task");
+ this.scheduler = Executors.newSingleThreadScheduledExecutor();
+ Runnable task = new DcaeProviderTask(dcaeMessages);
+
+ LOG.info("Fault task created with "+heartbeatSeconds+" Seconds");
+ this.taskReference = this.scheduler.scheduleAtFixedRate(task, 0, heartbeatSeconds, TimeUnit.SECONDS);
+ LOG.info("Fault task scheduled");
+ }
+
+ public void sendProblemNotification(String mountPointName, ProblemNotificationXml notification) {
+ LOG.debug("Notification answer: {}", dcaeMessages.postNotification(mountPointName, notification));
+ }
+
+ @Override
+ public void close() {
+ this.taskReference.cancel(false);
+ try {
+ this.scheduler.shutdown();
+ this.scheduler.awaitTermination(5, TimeUnit.SECONDS);
+ } catch (InterruptedException | SecurityException e) {
+ LOG.debug("Schedler shutdown interrupted with exception: ",e);
+ if (e instanceof InterruptedException) {
+ Thread.currentThread().interrupt();
+ }
+ }
+ }
+
+
+}
diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/dcaeconnector/impl/DcaeSender.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/dcaeconnector/impl/DcaeSender.java
new file mode 100644
index 000000000..5ebc37d51
--- /dev/null
+++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/dcaeconnector/impl/DcaeSender.java
@@ -0,0 +1,31 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 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.dcaeconnector.impl;
+
+/**
+ * @author herbert
+ *
+ */
+public interface DcaeSender {
+
+ public String sendDcaePost(String body);
+
+}
diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/dcaeconnector/impl/DcaeSenderImpl.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/dcaeconnector/impl/DcaeSenderImpl.java
new file mode 100644
index 000000000..9b386add5
--- /dev/null
+++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/dcaeconnector/impl/DcaeSenderImpl.java
@@ -0,0 +1,236 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 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==========================================================================
+ ******************************************************************************/
+/**
+ * Client for ECOMP notification server
+ *
+ * Reference: @link
+ * http://stackoverflow.com/questions/13022717/java-and-https-url-connection-without-downloading-certificate
+ *
+ * @author herbert
+ */
+package org.onap.ccsdk.features.sdnr.wt.devicemanager.dcaeconnector.impl;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.OutputStream;
+import java.io.Reader;
+import java.net.HttpURLConnection;
+import java.net.URL;
+import java.net.URLConnection;
+import java.security.KeyManagementException;
+import java.security.KeyStoreException;
+import java.security.NoSuchAlgorithmException;
+import java.security.UnrecoverableKeyException;
+import java.security.cert.CertificateException;
+import java.security.spec.InvalidKeySpecException;
+import java.util.Base64;
+import javax.net.ssl.SSLContext;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.http.BaseHTTPClient;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class DcaeSenderImpl implements DcaeSender {
+
+ private static final Logger LOG = LoggerFactory.getLogger(DcaeSenderImpl.class);
+ private static final String EMPTY = "";
+ private static final String charset = "UTF-8";
+
+ private final String urlString;
+ private final String basicAuth;
+
+ private SSLContext sc = null;
+ private URL url = null;
+ private HttpURLConnection connection = null;
+
+ public DcaeSenderImpl(String url, String userCredentials) {
+
+ LOG.info("DcaeSenderImpl setup start with {} {}", url, userCredentials);
+
+ this.urlString = url;
+ this.basicAuth = "Basic " + new String(Base64.getEncoder().encode(userCredentials.getBytes()));
+
+ if (urlString != null && !urlString.equals("off")) {
+ try {
+ this.url = new URL(url);
+ sc = BaseHTTPClient.setupSsl(true);
+ } catch (KeyManagementException | NoSuchAlgorithmException | UnrecoverableKeyException
+ | CertificateException | KeyStoreException | InvalidKeySpecException | IOException e) {
+ LOG.warn("SSL setup failed: {}", e.getMessage());
+ }
+ }
+ LOG.info("DcaeSenderImpl setup ends");
+ }
+
+ /**
+ * Send message to ECOMP Server
+ *
+ * @param body for POST message
+ */
+ @Override
+ public String sendDcaePost(String body) {
+
+ if (url != null) {
+ try {
+ connection = DcaeMessages.openConnection(url, basicAuth, true, sc);
+ if (connection != null) {
+ return processPost(connection, body);
+ } else {
+ LOG.warn("No SSL context available");
+ }
+ } catch (IOException e) {
+ LOG.warn("Dcae post failed {}", e.getMessage());
+ }
+ }
+ return EMPTY;
+ }
+
+ /**
+ * Connect to Server and expect answer.
+ *
+ * @return with answer body
+ */
+ public String testConnectServer() {
+
+ if (url != null) {
+ try {
+ connection = DcaeMessages.openConnection(url, null, false, sc);
+ if (connection != null) {
+ return receiveInitialAnswer(connection);
+ }
+ } catch (IOException e) {
+ LOG.warn("Dcae post failed {}", e.getMessage());
+ }
+ }
+ return EMPTY;
+ }
+
+ /**
+ * Show status in readable form for testing
+ *
+ * @return String with result
+ */
+ public String getStatusAsString() {
+ StringBuffer sb = new StringBuffer();
+
+ sb.append("URL: " + url.getPath() + " " + url.getPort() + " Host: " + url.getHost());
+ sb.append("\n");
+ if (connection != null) {
+ sb.append("Connection setup: ");
+ sb.append(connection.getClass().getName());
+ sb.append(" ");
+ } else {
+ sb.append("Connection setup: No connection (server problem or switched off)");
+ }
+ return sb.toString();
+
+ }
+
+
+ /*------------------------------------------------------------------------------
+ * Private functions
+ */
+
+
+ /**
+ * Send Post and wait for answer
+ *
+ * @param connection
+ * @param body
+ * @return
+ * @throws IOException
+ */
+ private static String processPost(HttpURLConnection connection, String body) throws IOException {
+
+ LOG.debug("Post message: {}", connection.getURL().toString());
+ if (LOG.isTraceEnabled()) {
+ LOG.trace("Body: {} ", body);
+ }
+
+ // Send the message to destination
+ try (OutputStream output = connection.getOutputStream()) {
+ output.write(body.getBytes(charset));
+ }
+
+ // Receive answer
+ InputStream response = null;
+ BufferedReader rd = null;
+ StringBuilder result = new StringBuilder();
+
+ try {
+ int responseCode = connection.getResponseCode();
+ LOG.debug("Response code: {}", String.valueOf(responseCode));
+
+ if (responseCode >= 200 && responseCode < 300) {
+ response = connection.getInputStream();
+ } else {
+ response = connection.getErrorStream();
+ if (response == null) {
+ response = connection.getInputStream();
+ }
+ }
+ if (response != null) {
+ rd = new BufferedReader(new InputStreamReader(response));
+ String line;
+ while ((line = rd.readLine()) != null) {
+ result.append(line);
+ }
+ }
+ } catch (IOException e) {
+ LOG.debug("No response received: {}", e.getMessage());
+ } finally {
+ if (response != null) {
+ response.close();
+ }
+ if (rd != null) {
+ rd.close();
+ }
+ }
+
+ LOG.trace("Result: {} ", result);
+ return result.toString();
+ }
+
+ /**
+ * Read initial answer from Server after connect
+ *
+ * @param connection that was opened
+ * @return String with answer message
+ * @throws IOException
+ */
+ private static String receiveInitialAnswer(URLConnection iConnection) throws IOException {
+
+
+ final StringBuffer response = new StringBuffer();
+
+ if (iConnection != null) {
+
+ final Reader reader = new InputStreamReader(iConnection.getInputStream());
+ final BufferedReader br = new BufferedReader(reader);
+ String line = "";
+ while ((line = br.readLine()) != null) {
+ response.append(line);
+ response.append("\n");
+ }
+ br.close();
+ }
+
+ return response.toString();
+ }
+}
diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/devicemonitor/impl/Checker.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/devicemonitor/impl/Checker.java
new file mode 100644
index 000000000..1091c41eb
--- /dev/null
+++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/devicemonitor/impl/Checker.java
@@ -0,0 +1,48 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 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==========================================================================
+ ******************************************************************************/
+/**
+ * (c) highstreet technologies GmbH
+ */
+package org.onap.ccsdk.features.sdnr.wt.devicemanager.devicemonitor.impl;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Steps to Monitor the connection to a network element during state connected
+ */
+abstract class Checker {
+
+ @SuppressWarnings("unused")
+ private static final Logger LOG = LoggerFactory.getLogger(Checker.class);
+
+ /**
+ * Check action.
+ * @return true if reachable, false if not
+ */
+ abstract boolean isReachableOnce();
+
+ /**
+ * Procedure to check the connection of one mountpoint
+ * @return true if reachable, false if not
+ */
+ boolean isConnected() {
+ return isReachableOnce();
+ }
+}
+
diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/devicemonitor/impl/DeviceMonitorImpl.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/devicemonitor/impl/DeviceMonitorImpl.java
new file mode 100644
index 000000000..0141b2663
--- /dev/null
+++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/devicemonitor/impl/DeviceMonitorImpl.java
@@ -0,0 +1,208 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 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==========================================================================
+ ******************************************************************************/
+/**
+ * (c) 2017 highstreet technologies GmbH
+ */
+
+package org.onap.ccsdk.features.sdnr.wt.devicemanager.devicemonitor.impl;
+
+import java.util.Enumeration;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ScheduledExecutorService;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.listener.ODLEventListener;
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Implementation of concept "Active monitoring" of a device.<br>
+ * <br>
+ * For each existing mountpoint a task runs with 120s cycle time. Every 120 seconds the check actions are performed.
+ * The request is handled by the NETCONF layer with a (default)configured time-out of 60 seconds.<br>
+ * Generated alarms, by the object/node "SDN-Controller" are (enum DeviceMonitorProblems):<br>
+ * - notConnected(InternalSeverity.Warning)<br>
+ * - noConnectionMediator(InternalSeverity.Minor)<br>
+ * - noConnectionNe(InternalSeverity.Critical)<br>
+ * <br>
+ * 1. Mountpoint does not exist<br>
+ * If the mountpoint does not exists there are no related current alarms in the database.<br>
+ * <br>
+ * 2. Created mountpoint with state "Connecting" or "UnableToConnect"<br>
+ * If the Mountpoint is created and connection status is "Connecting" or "UnableToConnect".<br>
+ * - After about 2..4 Minutes ... raise alarm "notConnected" with severity warning<br>
+ * <br>
+ * 3. Created mountpoint with state "Connection"<br>
+ * There are two monitor activities.<br>
+ * 3a. Check of Mediator connection by requesting (typical) cached data.<br>
+ * - After about 60 seconds raise alarm: connection-loss-mediator with severity minor<br>
+ * - Request from Mediator: network-element<br>
+ * <br>
+ * 3b. Check connection to NEby requesting (typical) non-cached data.<br>
+ * - Only if AirInterface available. The first one is used.<br>
+ * - Requested are the currentAlarms<br>
+ * - After about 60 seconds raise alarm: connection-loss-network-element with severity critical<br>
+ * <br>
+ * @author herbert
+ */
+
+public class DeviceMonitorImpl implements AutoCloseable {
+
+ private static final Logger LOG = LoggerFactory.getLogger(DeviceMonitorImpl.class);
+
+ private final ConcurrentHashMap<String, DeviceMonitorTask> queue;
+ private final ScheduledExecutorService scheduler;
+ private final ODLEventListener odlEventListener;
+ @SuppressWarnings("unused")
+ private final DataBroker dataBroker; //Future usage
+
+ /*-------------------------------------------------------------
+ * Construction/ destruction of service
+ */
+
+ /**
+ * Basic implementation of devicemonitoring
+ * @param odlEventListener as destination for problems
+ */
+ public DeviceMonitorImpl(DataBroker dataBroker, ODLEventListener odlEventListener) {
+ LOG.info("Construct {}", this.getClass().getSimpleName());
+
+ this.odlEventListener = odlEventListener;
+ this.dataBroker = dataBroker;
+ this.queue = new ConcurrentHashMap<>();
+ this.scheduler = Executors.newScheduledThreadPool(10);
+ }
+
+ /**
+ * Stop the service. Stop all running monitoring tasks.
+ */
+ @Override
+ synchronized public void close() {
+ LOG.info("Close {}", this.getClass().getSimpleName());
+
+ Enumeration<String> e = queue.keys();
+ while (e.hasMoreElements()) {
+ deviceDisconnectIndication(e.nextElement());
+ }
+
+ scheduler.shutdown();
+ }
+
+ /*-------------------------------------------------------------
+ * Start/ stop/ update service for Mountpoint
+ */
+
+ /**
+ * Notify of device state changes to "connected" for slave nodes
+ * @param mountPointNodeName name of mount point
+ */
+ synchronized public void deviceConnectSlaveIndication(String mountPointNodeName) {
+ deviceConnectMasterIndication(mountPointNodeName, null);
+ }
+
+ /**
+ * Notify of device state changes to "connected"
+ * @param mountPointNodeName name of mount point
+ * @param ne to monitor
+ */
+ synchronized public void deviceConnectMasterIndication(String mountPointNodeName, DeviceMonitoredNe ne) {
+
+ LOG.debug("ne changes to connected state {}",mountPointNodeName);
+ createMonitoringTask(mountPointNodeName);
+ if (queue.containsKey(mountPointNodeName)) {
+ DeviceMonitorTask task = queue.get(mountPointNodeName);
+ task.deviceConnectIndication(ne);
+ } else {
+ LOG.warn("Monitoring task not in queue: {} {} {}", mountPointNodeName, mountPointNodeName.hashCode(), queue.size());
+ }
+ }
+
+ /**
+ * Notify of device state change to "disconnected"
+ * Mount point supervision
+ * @param mountPointNodeName to deregister
+ */
+ synchronized public void deviceDisconnectIndication(String mountPointNodeName) {
+
+ LOG.debug("State changes to not connected state {}",mountPointNodeName);
+ createMonitoringTask(mountPointNodeName);
+ if (queue.containsKey(mountPointNodeName)) {
+ DeviceMonitorTask task = queue.get(mountPointNodeName);
+ task.deviceDisconnectIndication();
+ } else {
+ LOG.warn("Monitoring task not in queue: {} {} {}", mountPointNodeName, mountPointNodeName.hashCode(), queue.size());
+ }
+ }
+
+ /**
+ * removeMountpointIndication deregisters a mountpoint for registration services
+ * @param mountPointNodeName to deregister
+ */
+ synchronized public void removeMountpointIndication(String mountPointNodeName) {
+
+ if (queue.containsKey(mountPointNodeName)) {
+ DeviceMonitorTask task = queue.get(mountPointNodeName);
+ //Remove from here
+ queue.remove(mountPointNodeName);
+
+ //Clear all problems
+ task.removeMountpointIndication();
+ LOG.debug("Task stopped: {}", mountPointNodeName);
+ } else {
+ LOG.warn("Task not in queue: {}", mountPointNodeName);
+ }
+ }
+
+ /**
+ * Referesh database by raising all alarms again.
+ */
+ public void refreshAlarmsInDb() {
+ synchronized(queue) {
+ for (DeviceMonitorTask task : queue.values()) {
+ task.refreshAlarms();
+ }
+ }
+ }
+
+ /*-------------------------------------------------------------
+ * Private functions
+ */
+
+ /**
+ * createMountpoint registers a new mountpoint monitoring service
+ * @param mountPointNodeName name of mountpoint
+ */
+ synchronized private DeviceMonitorTask createMonitoringTask(String mountPointNodeName) {
+
+ DeviceMonitorTask task;
+ LOG.debug("Register for monitoring {} {}",mountPointNodeName, mountPointNodeName.hashCode());
+
+ if (queue.containsKey(mountPointNodeName)) {
+ LOG.info("Monitoring task exists");
+ task = queue.get(mountPointNodeName);
+ } else {
+ LOG.info("Do start of DeviceMonitor task");
+ //Runnable task = new PerformanceManagerTask(queue, databaseService);
+ task = new DeviceMonitorTask(mountPointNodeName, this.odlEventListener);
+ queue.put(mountPointNodeName, task);
+ task.start(scheduler);
+ }
+ return task;
+ }
+
+}
diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/devicemonitor/impl/DeviceMonitorProblems.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/devicemonitor/impl/DeviceMonitorProblems.java
new file mode 100644
index 000000000..003c2002c
--- /dev/null
+++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/devicemonitor/impl/DeviceMonitorProblems.java
@@ -0,0 +1,57 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 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==========================================================================
+ ******************************************************************************/
+/**
+ * Problems generated by DeviceMonitor
+ *
+ * @author herbert
+ *
+ */
+package org.onap.ccsdk.features.sdnr.wt.devicemanager.devicemonitor.impl;
+
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.internalTypes.InternalSeverity;
+
+public enum DeviceMonitorProblems {
+
+ /**
+ * Mountpoint is not connected via NETCONF with NE/Mediator = ssh connection
+ */
+ connectionLossOAM(InternalSeverity.Major),
+
+ /**
+ * Mountpoint is connected via Netconf to Mediator, but mediator is not responding.
+ * Connection state to NE is unknown.
+ */
+ connectionLossMediator(InternalSeverity.Major),
+
+ /** Mountpoint is connected via Netconf to Mediator.
+ * This connection is OK, but mediator <-> NE Connection is not OK
+ */
+ connectionLossNeOAM(InternalSeverity.Major);
+
+ InternalSeverity severity;
+
+ DeviceMonitorProblems(InternalSeverity severity) {
+ this.severity = severity;
+ }
+
+ InternalSeverity getSeverity() {
+ return severity;
+ }
+
+}
+
diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/devicemonitor/impl/DeviceMonitorTask.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/devicemonitor/impl/DeviceMonitorTask.java
new file mode 100644
index 000000000..04d15cc19
--- /dev/null
+++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/devicemonitor/impl/DeviceMonitorTask.java
@@ -0,0 +1,320 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 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==========================================================================
+ ******************************************************************************/
+/**
+ * @author herbert
+ *
+ */
+package org.onap.ccsdk.features.sdnr.wt.devicemanager.devicemonitor.impl;
+
+import java.util.Collections;
+import java.util.EnumSet;
+import java.util.Set;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.ScheduledFuture;
+import java.util.concurrent.TimeUnit;
+
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.internalTypes.InternalSeverity;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.netconf.util.NetconfTimeStamp;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.listener.ODLEventListener;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class DeviceMonitorTask implements Runnable {
+
+ private static final Logger LOG = LoggerFactory.getLogger(DeviceMonitorTask.class);
+ private static final String LOGMARKER = "DMTick";
+ private static final NetconfTimeStamp NETCONFTIME_CONVERTER = NetconfTimeStamp.getConverter();
+
+ private final String mountPointName;
+ private final ODLEventListener odlEventListener;
+ private final Checker checkConnectionToMediator;
+ private final Checker checkConnectionToNe;
+
+ private int tickCounter; //Added for each tick. Not relevant for internal status
+
+ private ScheduledFuture<?> taskHandle;
+ private final Object lockNe = new Object(); //USe top lock access to member ne
+ private @Nullable DeviceMonitoredNe ne; //Indication if in status connect or disconnect
+ private @Nonnull Boolean mountpointConnectingStateSupervision; //Indication of mountpoint supervision
+
+ private final Object lockDisconnectSupervisionTickout = new Object();
+ private Integer disconnectSupervisionTickout; //Tickcounter of task ticks for "not connected indication"
+ private Set<DeviceMonitorProblems> currentProblems; //List with actual problems. Synchronized by itself
+
+ /*------------------------------------------------------------
+ * Construction
+ */
+
+ /**
+ * Setup monitoring task
+ * @param mountPointName to monitor
+ * @param odlEventListener to forward problems to
+ */
+ public DeviceMonitorTask(String mountPointName, ODLEventListener odlEventListener) {
+ LOG.debug("Init task {}", DeviceMonitorTask.class.getSimpleName());
+
+ //Setup finals
+ this.mountPointName = mountPointName;
+ this.odlEventListener = odlEventListener;
+ this.checkConnectionToMediator = new Checker() {
+ @Override
+ boolean isReachableOnce() {
+ synchronized(lockNe) {
+ //mountpoint state "Connected"
+ //If for any reason the mountpoint is Connected, but Notconf messages are not received
+ return ne == null ? true : ne.checkIfConnectionToMediatorIsOk();
+ }
+ }
+ };
+ this.checkConnectionToNe = new Checker() {
+ @Override
+ boolean isReachableOnce() {
+ synchronized(lockNe) {
+ //mountpoint state "Connected"
+ //If netconf mediator (netconf application software for NE) has connection loss to managed device.
+ //The networkelement object is available, but there is no interfacepack available.
+ return ne == null ? true : ne.checkIfConnectionToNeIsOk();
+ }
+ }
+ };
+
+ //Setup parameters
+ this.taskHandle = null;
+ this.tickCounter = 0;
+ this.ne = null;
+ this.mountpointConnectingStateSupervision = false;
+ this.currentProblems = Collections.synchronizedSet(EnumSet.noneOf(DeviceMonitorProblems.class));
+ this.disconnectSupervisionTickout = 0;
+
+ int removed = odlEventListener.removeAllCurrentProblemsOfNode(mountPointName);
+ LOG.debug("{} Init task removed fault entries {}", LOGMARKER, removed);
+
+ }
+
+ /**
+ * Start for each object an own instance of the thread.
+ * @param scheduler for all the threads.
+ */
+ public void start(ScheduledExecutorService scheduler) {
+ LOG.info("{} {} DeviceMonitor task to create", LOGMARKER, tickCounter);
+ if (taskHandle == null) {
+ startDisconnectSupervision();
+ taskHandle = scheduler.scheduleAtFixedRate(this, 0, 120, TimeUnit.SECONDS);
+ LOG.info("DeviceMonitor task scheduled");
+ } else {
+ LOG.error("{} {} Task already running.", LOGMARKER, tickCounter);
+ }
+ }
+
+ /**
+ * Call after NE change state to connected.
+ * Mountpoint exists. Status is Connecting.
+ * @param neParam that connected
+ */
+
+ public void deviceConnectIndication(DeviceMonitoredNe neParam) {
+ LOG.info("{} {} Connect {} and stop.", LOGMARKER, tickCounter, mountPointName);
+ clear(DeviceMonitorProblems.connectionLossOAM);
+ synchronized(lockNe) {
+ this.ne = neParam;
+ this.mountpointConnectingStateSupervision = false;
+ }
+ stopDisconnectSupervision();
+ }
+
+ /**
+ * If ne is disconnected do the related actions.
+ * - Mountpoint exists. Status is Connecting or UnableToConnect
+ */
+
+ public void deviceDisconnectIndication() {
+ LOG.info("{} {} Disconnect {} and start.", LOGMARKER, tickCounter, mountPointName);
+ clear(DeviceMonitorProblems.connectionLossOAM);
+ synchronized(lockNe) {
+ this.ne = null;
+ this.mountpointConnectingStateSupervision = true;
+ }
+ startDisconnectSupervision();
+ }
+
+ /**
+ * Do all actions to clean up the log if mountpoint has been deleted.
+ * - Mountpoint removed
+ * Prepare cancellation of the task and cancel task
+ */
+
+ public void removeMountpointIndication() {
+ for (DeviceMonitorProblems problem : DeviceMonitorProblems.values()) {
+ clear(problem);
+ }
+ //Cancel the task
+ if (this.taskHandle != null) {
+ this.taskHandle.cancel(false);
+ LOG.info("{} {} DeviceMonitor task canceled for {}", LOGMARKER, tickCounter, mountPointName);
+ } else {
+ LOG.error("{} {} Task already stopped", LOGMARKER, tickCounter);
+ }
+ }
+
+ /**
+ * Referesh Alarms
+ */
+ public void refreshAlarms() {
+ LOG.debug("{} Start refresh of all problems",LOGMARKER);
+ synchronized(currentProblems) {
+ for (DeviceMonitorProblems problem : currentProblems) {
+ LOG.debug("{} Refresh problem {} Raised-status {}",LOGMARKER, problem.name(), currentProblems.contains(problem));
+ odlEventListener.onProblemNotification(mountPointName, problem.name(), problem.getSeverity());
+ }
+ }
+ LOG.debug("{} Finish refresh of all problems",LOGMARKER);
+ }
+
+ /*------------------------------------------------------------
+ * Functions to clear/raise alarm
+ */
+
+ /**
+ * Raise a problem, but only once
+ * @param problem
+ */
+ private void raise(DeviceMonitorProblems problem) {
+ LOG.debug("{} Raise problem {} Raised-status {}",LOGMARKER, problem.name(), currentProblems.contains(problem));
+ synchronized(currentProblems) {
+ if (! currentProblems.contains(problem)) {
+ currentProblems.add(problem);
+ odlEventListener.onProblemNotification(mountPointName, problem.name(), problem.getSeverity());
+ }
+ }
+ }
+
+ /**
+ * Raise a problem, but only once
+ * @param problem
+ */
+ private void clear(DeviceMonitorProblems problem) {
+ LOG.debug("{} Clear problem {} Raised-status {}",LOGMARKER, problem.name(), currentProblems.contains(problem));
+ synchronized(currentProblems) {
+ if (currentProblems.contains(problem)) {
+ currentProblems.remove(problem);
+ odlEventListener.onProblemNotification(mountPointName, problem.name(), InternalSeverity.NonAlarmed);
+ }
+ }
+ }
+
+ /**
+ * Process problem notification cascade
+ * @param isReachable
+ * @param problem
+ */
+ private void clearRaiseIfConnected(Checker checker, DeviceMonitorProblems problem) {
+ LOG.debug("{} check start {} problem {} Raised-status {}",LOGMARKER, tickCounter, problem.name(), currentProblems.contains(problem));
+ if (checker.isConnected()) {
+ clear(problem);
+ } else {
+ raise(problem);
+ }
+ LOG.debug("{} check end {} problem {} Raised-status {}",LOGMARKER, tickCounter, problem.name(), currentProblems.contains(problem));
+ }
+
+ /*------------------------------------------------------------
+ * Functions to start/stop
+ */
+
+ private void startDisconnectSupervision() {
+ synchronized(lockDisconnectSupervisionTickout) {
+ this.disconnectSupervisionTickout = 2;
+ }
+ }
+
+ private void stopDisconnectSupervision() {
+ synchronized(lockDisconnectSupervisionTickout) {
+ this.disconnectSupervisionTickout = 0;
+ }
+ }
+
+ private boolean processDisconnectSupervisionAndCheckExceeded() {
+ synchronized(lockDisconnectSupervisionTickout) {
+ if (disconnectSupervisionTickout == 0) {
+ return true;
+ } else if (disconnectSupervisionTickout > 0) {
+ disconnectSupervisionTickout--;
+ }
+ return false;
+ }
+ }
+
+ /*------------------------------------------------------------
+ * TASK
+ */
+
+ /**
+ * Task to monitor connectivity to Network Elements.
+ * Connectivity problems lead to alarm indication.
+ */
+ @Override
+ public void run() {
+
+ try {
+ LOG.debug("{} UTCTime {} START mountpoint {} tick {} connecting supervision {} tickout {}",
+ LOGMARKER,
+ NETCONFTIME_CONVERTER.getTimeStamp(),
+ mountPointName,
+ tickCounter,
+ mountpointConnectingStateSupervision,
+ disconnectSupervisionTickout);
+
+ if (mountpointConnectingStateSupervision) {
+ LOG.debug("{} {} Mountpoint supervision {}", LOGMARKER, tickCounter, mountPointName);
+ if (processDisconnectSupervisionAndCheckExceeded()) {
+ raise(DeviceMonitorProblems.connectionLossOAM);
+ }
+
+ } else {
+ synchronized (lockNe) {
+ if (ne != null) {
+ //checks during "Connected"
+ clear(DeviceMonitorProblems.connectionLossOAM); //Always cleared never raised
+ LOG.debug("{} {} Prepare check", LOGMARKER, tickCounter);
+ ne.prepareCheck(); // Prepare ne check
+ // Mediator check
+ LOG.debug("{} {} Mediator check", LOGMARKER, tickCounter);
+ clearRaiseIfConnected(checkConnectionToMediator, DeviceMonitorProblems.connectionLossMediator);
+
+ // NE check
+ LOG.debug("{} {} Ne check", LOGMARKER, tickCounter);
+ clearRaiseIfConnected(checkConnectionToNe, DeviceMonitorProblems.connectionLossNeOAM);
+ } else {
+ //Monitor switch off.
+ LOG.debug("{} {} Monitor switch off state", LOGMARKER, tickCounter);
+ clear(DeviceMonitorProblems.connectionLossOAM); //Always cleared never raised
+ clear(DeviceMonitorProblems.connectionLossMediator); //Always cleared never raised
+ clear(DeviceMonitorProblems.connectionLossNeOAM); //Always cleared never raised
+ }
+ }
+ }
+ } catch (Exception e) {
+ //Prevent stopping the task
+ LOG.warn("{} {} During DeviceMontoring task",LOGMARKER, tickCounter, e);
+ }
+ LOG.debug("{} {} END", LOGMARKER, tickCounter++);
+
+ }
+}
diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/devicemonitor/impl/DeviceMonitoredNe.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/devicemonitor/impl/DeviceMonitoredNe.java
new file mode 100644
index 000000000..ec19f17b9
--- /dev/null
+++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/devicemonitor/impl/DeviceMonitoredNe.java
@@ -0,0 +1,47 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 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.devicemonitor.impl;
+
+/**
+ * @author herbert
+ *
+ */
+public interface DeviceMonitoredNe {
+
+ /**
+ * Prepare subsequent check calls
+ */
+ public void prepareCheck();
+
+ /**
+ * Test connection to mediator, by getting data that have to be called from NE
+ * @return true if connection working, false if not
+ */
+ public boolean checkIfConnectionToMediatorIsOk();
+
+ /**
+ * Test connection to NE via mediator, by getting data that have to be called from NE
+ * @return true if connection working, false if not
+ */
+ public boolean checkIfConnectionToNeIsOk();
+
+
+}
diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/DeviceManagerApiServiceImpl.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/DeviceManagerApiServiceImpl.java
new file mode 100644
index 000000000..6e8d85bda
--- /dev/null
+++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/DeviceManagerApiServiceImpl.java
@@ -0,0 +1,200 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 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.impl;
+
+import com.google.common.util.concurrent.ListenableFuture;
+import java.util.List;
+import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.RpcRegistration;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.maintenance.MaintenanceRPCServiceAPI;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.maintenance.impl.MaintenanceServiceImpl;
+import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.devicemanager.rev190109.ClearCurrentFaultByNodenameInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.devicemanager.rev190109.ClearCurrentFaultByNodenameOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.devicemanager.rev190109.ClearCurrentFaultByNodenameOutputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.devicemanager.rev190109.DevicemanagerService;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.devicemanager.rev190109.GetMaintenanceModeInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.devicemanager.rev190109.GetMaintenanceModeOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.devicemanager.rev190109.GetMaintenanceModeOutputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.devicemanager.rev190109.GetRequiredNetworkElementKeysInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.devicemanager.rev190109.GetRequiredNetworkElementKeysOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.devicemanager.rev190109.GetRequiredNetworkElementKeysOutputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.devicemanager.rev190109.SetMaintenanceModeInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.devicemanager.rev190109.SetMaintenanceModeOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.devicemanager.rev190109.SetMaintenanceModeOutputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.devicemanager.rev190109.ShowRequiredNetworkElementInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.devicemanager.rev190109.ShowRequiredNetworkElementOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.devicemanager.rev190109.ShowRequiredNetworkElementOutputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.devicemanager.rev190109.TestMaintenanceModeInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.devicemanager.rev190109.TestMaintenanceModeOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.devicemanager.rev190109.TestMaintenanceModeOutputBuilder;
+import org.opendaylight.yangtools.yang.common.RpcError.ErrorType;
+import org.opendaylight.yangtools.yang.common.RpcResult;
+import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class DeviceManagerApiServiceImpl implements DevicemanagerService, AutoCloseable {
+
+ private static final Logger LOG = LoggerFactory.getLogger(DevicemanagerService.class);
+
+ private final RpcRegistration<DevicemanagerService> rpcReg;
+
+ private MaintenanceRPCServiceAPI maintenanceService;
+ private ResyncNetworkElementsListener resyncCallbackListener;
+
+ DeviceManagerApiServiceImpl(final RpcProviderRegistry rpcProviderRegistry) {
+ // Register ourselves as the REST API RPC implementation
+ LOG.info("Register RPC Service "+DevicemanagerService.class.getSimpleName());
+ this.maintenanceService = null;
+ this.rpcReg = rpcProviderRegistry.addRpcImplementation(DevicemanagerService.class, this);
+ }
+
+ public void setMaintenanceService(MaintenanceServiceImpl maintenanceService2) {
+ this.maintenanceService = maintenanceService2;
+ }
+
+ @Override
+ public void close() throws Exception {
+ LOG.info("Close RPC Service");
+ if (rpcReg != null) {
+ rpcReg.close();
+ }
+ }
+
+ /*-------------------------------
+ * Interfaces for MaintenanceService
+ */
+
+ @Override
+ public ListenableFuture<RpcResult<GetRequiredNetworkElementKeysOutput>> getRequiredNetworkElementKeys(
+ GetRequiredNetworkElementKeysInput input) {
+ return getRequiredNetworkElementKeys();
+ }
+
+ // For casablanca version no input was generated.
+ public ListenableFuture<RpcResult<GetRequiredNetworkElementKeysOutput>> getRequiredNetworkElementKeys() {
+
+ LOG.info("RPC Request: getRequiredNetworkElementKeys");
+ RpcResultBuilder<GetRequiredNetworkElementKeysOutput> result;
+ try {
+ GetRequiredNetworkElementKeysOutputBuilder outputBuilder = maintenanceService.getRequiredNetworkElementKeys();
+ result = RpcResultBuilder.success(outputBuilder);
+ } catch (Exception e) {
+ result = RpcResultBuilder.failed();
+ result.withError(ErrorType.APPLICATION, "Exception", e);
+ }
+ return result.buildFuture();
+ }
+
+ @Override
+ public ListenableFuture<RpcResult<ShowRequiredNetworkElementOutput>> showRequiredNetworkElement(
+ ShowRequiredNetworkElementInput input) {
+
+ LOG.info("RPC Request: showRequiredNetworkElement input: {}", input.getMountpointName());
+ RpcResultBuilder<ShowRequiredNetworkElementOutput> result;
+
+ try {
+ ShowRequiredNetworkElementOutputBuilder outputBuilder = maintenanceService.showRequiredNetworkElement(input);
+ result = RpcResultBuilder.success(outputBuilder);
+ } catch (Exception e) {
+ result = RpcResultBuilder.failed();
+ result.withError(ErrorType.APPLICATION, "Exception", e);
+ }
+ return result.buildFuture();
+ }
+
+ @Override
+ public ListenableFuture<RpcResult<SetMaintenanceModeOutput>> setMaintenanceMode(SetMaintenanceModeInput input) {
+
+ LOG.info("RPC Request: setMaintenanceMode input: {}", input.getMountpointName());
+ RpcResultBuilder<SetMaintenanceModeOutput> result;
+
+ try {
+ SetMaintenanceModeOutputBuilder outputBuilder = maintenanceService.setMaintenanceMode(input);
+ result = RpcResultBuilder.success(outputBuilder);
+ } catch (Exception e) {
+ result = RpcResultBuilder.failed();
+ result.withError(ErrorType.APPLICATION, "Exception", e);
+ }
+ return result.buildFuture();
+
+ }
+
+
+
+ @Override
+ public ListenableFuture<RpcResult<GetMaintenanceModeOutput>> getMaintenanceMode(GetMaintenanceModeInput input) {
+
+ LOG.info("RPC Request: getMaintenanceMode input: {}", input.getMountpointName());
+ RpcResultBuilder<GetMaintenanceModeOutput> result;
+
+ try {
+ GetMaintenanceModeOutputBuilder outputBuilder = maintenanceService.getMaintenanceMode(input);
+ result = RpcResultBuilder.success(outputBuilder);
+ } catch (Exception e) {
+ result = RpcResultBuilder.failed();
+ result.withError(ErrorType.APPLICATION, "Exception", e);
+ }
+ return result.buildFuture();
+
+ }
+
+ @Override
+ public ListenableFuture<RpcResult<TestMaintenanceModeOutput>> testMaintenanceMode(TestMaintenanceModeInput input) {
+ LOG.info("RPC Request: getMaintenanceMode input: {}", input.getMountpointName());
+ RpcResultBuilder<TestMaintenanceModeOutput> result;
+
+ try {
+ TestMaintenanceModeOutputBuilder outputBuilder = maintenanceService.testMaintenanceMode(input);
+ result = RpcResultBuilder.success(outputBuilder);
+ } catch (Exception e) {
+ result = RpcResultBuilder.failed();
+ result.withError(ErrorType.APPLICATION, "Exception", e);
+ }
+ return result.buildFuture();
+
+ }
+
+
+ @Override
+ public ListenableFuture<RpcResult<ClearCurrentFaultByNodenameOutput>> clearCurrentFaultByNodename(
+ ClearCurrentFaultByNodenameInput input) {
+ LOG.info("RPC Request: clearNetworkElementAlarms input: {}", input.getNodenames());
+ RpcResultBuilder<ClearCurrentFaultByNodenameOutput> result;
+ try {
+ if(this.resyncCallbackListener!=null) {
+ List<String> nodeNames= this.resyncCallbackListener.doClearCurrentFaultByNodename(input.getNodenames());
+ ClearCurrentFaultByNodenameOutputBuilder outputBuilder = new ClearCurrentFaultByNodenameOutputBuilder();
+ outputBuilder.setNodenames(nodeNames);
+ result = RpcResultBuilder.success(outputBuilder);
+ } else {
+ result = RpcResultBuilder.failed();
+ result.withError(ErrorType.APPLICATION, "Startup running" );
+ }
+ } catch(Exception e) {
+ result = RpcResultBuilder.failed();
+ result.withError(ErrorType.APPLICATION, "Exception", e);
+ }
+ return result.buildFuture();
+ }
+
+ public void setResyncListener(ResyncNetworkElementsListener listener) {
+ this.resyncCallbackListener = listener;
+ }
+
+}
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
new file mode 100644
index 000000000..fcd7c1bc9
--- /dev/null
+++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/DeviceManagerImpl.java
@@ -0,0 +1,633 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 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.impl;
+
+import com.google.common.base.Optional;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.ConcurrentHashMap;
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.aaiconnector.impl.AaiProviderClient;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.database.HtDatabaseNode;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.netconf.ONFCoreNetworkElementFactory;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.netconf.ONFCoreNetworkElementRepresentation;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.toggleAlarmFilter.NotificationDelayService;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.config.HtDevicemanagerConfiguration;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.config.impl.AkkaConfig;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.config.impl.EsConfig;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.config.impl.GeoConfig;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.config.impl.PmConfig;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.dcaeconnector.impl.DcaeProviderClient;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.devicemonitor.impl.DeviceMonitorImpl;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.database.service.HtDatabaseEventsService;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.listener.NetconfChangeListener;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.listener.ODLEventListener;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.xml.ProblemNotificationXml;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.xml.WebSocketServiceClient;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.xml.WebSocketServiceClientImpl;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.xml.WebSocketServiceClientImpl2;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.index.impl.IndexConfigService;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.index.impl.IndexMwtnService;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.index.impl.IndexUpdateService;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.maintenance.impl.MaintenanceServiceImpl;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.performancemanager.impl.PerformanceManagerImpl;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.performancemanager.impl.database.service.MicrowaveHistoricalPerformanceWriterService;
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.controller.md.sal.binding.api.MountPoint;
+import org.opendaylight.controller.md.sal.binding.api.MountPointService;
+import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService;
+import org.opendaylight.controller.sal.binding.api.RpcConsumerRegistry;
+import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netconf.notification._1._0.rev080714.CreateSubscriptionInput;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netconf.notification._1._0.rev080714.CreateSubscriptionInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netconf.notification._1._0.rev080714.NotificationsService;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netconf.notification._1._0.rev080714.StreamNameType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.NetconfNode;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.network.topology.topology.topology.types.TopologyNetconf;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NetworkTopology;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.TopologyId;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.TopologyKey;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeKey;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class DeviceManagerImpl implements DeviceManagerService, AutoCloseable, ResyncNetworkElementsListener {
+
+ private static final Logger LOG = LoggerFactory.getLogger(DeviceManagerImpl.class);
+ private static final String APPLICATION_NAME = "DeviceManager";
+ private static final String MYDBKEYNAMEBASE = "SDN-Controller";
+
+ // http://sendateodl:8181/restconf/operational/network-topology:network-topology/topology/topology-netconf
+ private static final InstanceIdentifier<Topology> NETCONF_TOPO_IID =
+ InstanceIdentifier.create(NetworkTopology.class).child(Topology.class,
+ new TopologyKey(new TopologyId(TopologyNetconf.QNAME.getLocalName())));
+ @SuppressWarnings("unused")
+ private static final String STARTUPLOG_FILENAME = "etc/devicemanager.startup.log";
+ // private static final String STARTUPLOG_FILENAME2 = "data/cache/devicemanager.startup.log";
+
+ private DataBroker dataBroker = null;
+ private MountPointService mountPointService = null;
+ private RpcProviderRegistry rpcProviderRegistry = null;
+ @SuppressWarnings("unused")
+ private NotificationPublishService notificationPublishService = null;
+
+ private final ConcurrentHashMap<String, ONFCoreNetworkElementRepresentation> networkElementRepresentations =
+ new ConcurrentHashMap<>();
+
+ private WebSocketServiceClient webSocketService;
+ private HtDatabaseEventsService databaseClientEvents;
+ private ODLEventListener odlEventListener;
+ private NetconfChangeListener netconfChangeListener;
+ private DeviceManagerApiServiceImpl rpcApiService;
+ private @Nullable PerformanceManagerImpl performanceManager = null;
+ private ProviderClient dcaeProviderClient;
+ private ProviderClient aotsMProvider;
+ private @Nullable AaiProviderClient aaiProviderClient;
+ private DeviceMonitorImpl deviceMonitor;
+ private IndexUpdateService updateService;
+ private IndexConfigService configService;
+ private IndexMwtnService mwtnService;
+ private HtDatabaseNode htDatabase;
+ private Boolean devicemanagerInitializationOk = false;
+ private MaintenanceServiceImpl maintenanceService;
+ private NotificationDelayService<ProblemNotificationXml> notificationDelayService;
+ private Thread threadDoClearCurrentFaultByNodename = null;
+ private int refreshCounter = 0;
+ private AkkaConfig akkaConfig;
+
+ // Blueprint 1
+ public DeviceManagerImpl() {
+ LOG.info("Creating provider for {}", APPLICATION_NAME);
+ }
+
+ public void setDataBroker(DataBroker dataBroker) {
+ this.dataBroker = dataBroker;
+ }
+
+ public void setRpcProviderRegistry(RpcProviderRegistry rpcProviderRegistry) {
+ this.rpcProviderRegistry = rpcProviderRegistry;
+
+ }
+
+ public void setNotificationPublishService(NotificationPublishService notificationPublishService) {
+ this.notificationPublishService = notificationPublishService;
+ }
+
+ public void setMountPointService(MountPointService mountPointService) {
+ this.mountPointService = mountPointService;
+ }
+
+ public void init() {
+
+ LOG.info("Session Initiated start {}", APPLICATION_NAME);
+
+ // Start RPC Service
+ this.rpcApiService = new DeviceManagerApiServiceImpl(rpcProviderRegistry);
+ // Get configuration
+ HtDevicemanagerConfiguration config = HtDevicemanagerConfiguration.getConfiguration();
+ this.akkaConfig = null;
+ try {
+ this.akkaConfig = AkkaConfig.load();
+ LOG.debug("akka.conf loaded: " + akkaConfig.toString());
+ } catch (Exception e1) {
+ LOG.warn("problem loading akka.conf: " + e1.getMessage());
+ }
+ GeoConfig geoConfig = null;
+ if (akkaConfig != null && akkaConfig.isCluster()) {
+ LOG.info("cluster mode detected");
+ if (GeoConfig.fileExists()) {
+ try {
+ LOG.debug("try to load geoconfig");
+ geoConfig = GeoConfig.load();
+ } catch (Exception err) {
+ LOG.warn("problem loading geoconfig: " + err.getMessage());
+ }
+ } else {
+ LOG.debug("no geoconfig file found");
+ }
+ } else {
+ LOG.info("single node mode detected");
+ }
+
+ this.notificationDelayService = new NotificationDelayService<>(config);
+
+ EsConfig dbConfig = config.getEs();
+ LOG.debug("esConfig=" + dbConfig.toString());
+ // Start database
+ htDatabase = HtDatabaseNode.start(dbConfig, akkaConfig, geoConfig);
+ if (htDatabase == null) {
+ LOG.error("Can only run with local database. Stop initialization of devicemanager.");
+ } else {
+ // init Database Values only if singleNode or clusterMember=1
+ if (akkaConfig == null || akkaConfig.isSingleNode() || akkaConfig != null && akkaConfig.isCluster()
+ && akkaConfig.getClusterConfig().getRoleMemberIndex() == 1) {
+ // Create DB index if not existing and if database is running
+ try {
+ this.configService = new IndexConfigService(htDatabase);
+ this.mwtnService = new IndexMwtnService(htDatabase);
+ } catch (Exception e) {
+ LOG.warn("Can not start ES access clients to provide database index config, mwtn. ",e);
+ }
+ }
+ // start service for device maintenance service
+ this.maintenanceService = new MaintenanceServiceImpl(htDatabase);
+ // Websockets
+ try {
+ this.webSocketService = new WebSocketServiceClientImpl2(rpcProviderRegistry);
+ } catch (Exception e) {
+ LOG.error("Can not start websocket service. Loading mock class.", e);
+ this.webSocketService = new WebSocketServiceClientImpl();
+ }
+ // DCAE
+ this.dcaeProviderClient = new DcaeProviderClient(config, dbConfig.getCluster(), this);
+
+ this.aaiProviderClient = new AaiProviderClient(config, this);
+ // EM
+ EsConfig emConfig = dbConfig.cloneWithIndex("sdnevents");
+
+ if (emConfig == null) {
+ LOG.warn("No configuration available. Don't start event manager");
+ } else {
+ this.databaseClientEvents = new HtDatabaseEventsService(htDatabase);
+
+ String myDbKeyNameExtended = MYDBKEYNAMEBASE + "-" + dbConfig.getCluster();
+
+
+ this.odlEventListener = new ODLEventListener(myDbKeyNameExtended, webSocketService,
+ databaseClientEvents, dcaeProviderClient, aotsMProvider, maintenanceService);
+ }
+
+ // PM
+ PmConfig configurationPM = config.getPm();
+ LOG.info("Performance manager configuration: {}", configurationPM);
+ if (!configurationPM.isPerformanceManagerEnabled()) {
+
+ LOG.info("No configuration available. Don't start performance manager");
+ } else {
+ @Nullable
+ MicrowaveHistoricalPerformanceWriterService databaseClientHistoricalPerformance;
+ databaseClientHistoricalPerformance = new MicrowaveHistoricalPerformanceWriterService(htDatabase);
+ this.performanceManager = new PerformanceManagerImpl(60, databaseClientHistoricalPerformance);
+ }
+
+ // DUS (Database update service)
+ LOG.debug("start db update service");
+ this.updateService =
+ new IndexUpdateService(htDatabase, dbConfig.getHost(), dbConfig.getCluster(), dbConfig.getNode());
+ this.updateService.start();
+
+ // RPC Service for specific services
+ this.rpcApiService.setMaintenanceService(this.maintenanceService);
+ this.rpcApiService.setResyncListener(this);
+ // DM
+ // DeviceMonitor has to be available before netconfSubscriptionManager is
+ // configured
+ LOG.debug("start DeviceMonitor Service");
+ this.deviceMonitor = new DeviceMonitorImpl(dataBroker, odlEventListener);
+
+ // netconfSubscriptionManager should be the last one because this is a callback
+ // service
+ LOG.debug("start NetconfSubscriptionManager Service");
+ // this.netconfSubscriptionManager = new
+ // NetconfSubscriptionManagerOfDeviceManager(this, dataBroker);
+ // this.netconfSubscriptionManager.register();
+ this.netconfChangeListener = new NetconfChangeListener(this, dataBroker);
+ this.netconfChangeListener.register();
+
+ this.devicemanagerInitializationOk = true;
+ }
+ LOG.info("Session Initiated end. Initialization done {}", devicemanagerInitializationOk);
+ }
+
+ @Override
+ public void close() throws Exception {
+ LOG.info("DeviceManagerImpl closing ...");
+
+ close(performanceManager);
+ close(dcaeProviderClient);
+ close(aaiProviderClient);
+ close(aotsMProvider);
+ close(deviceMonitor);
+ close(updateService, configService, mwtnService);
+ close(htDatabase);
+ close(netconfChangeListener);
+ close(maintenanceService);
+ close(rpcApiService);
+ close(notificationDelayService);
+
+ LOG.info("DeviceManagerImpl closing done");
+ }
+
+
+ /**
+ * Used to close all Services, that should support AutoCloseable Pattern
+ *
+ * @param toClose
+ * @throws Exception
+ */
+ private void close(AutoCloseable... toCloseList) throws Exception {
+ for (AutoCloseable element : toCloseList) {
+ if (element != null) {
+ element.close();
+ }
+ }
+ }
+
+ /**
+ * For each mounted device a mountpoint is created and this listener is called.
+ *
+ */
+ @Override
+ public void startListenerOnNodeForConnectedState(Action action, NodeId nNodeId, NetconfNode nNode) {
+
+ String mountPointNodeName = nNodeId.getValue();
+ LOG.info("Starting Event listener on Netconf for mountpoint {} Action {}", mountPointNodeName, action);
+
+ boolean preConditionMissing = false;
+ if (mountPointService == null) {
+ preConditionMissing = true;
+ LOG.warn("No mountservice available.");
+ }
+ if (!devicemanagerInitializationOk) {
+ preConditionMissing = true;
+ LOG.warn("Devicemanager initialization still pending.");
+ }
+ if (preConditionMissing) {
+ return;
+ }
+
+ if (networkElementRepresentations.containsKey(mountPointNodeName)) {
+ LOG.warn("Mountpoint {} already registered. Leave startup procedure.", mountPointNodeName);
+ return;
+ }
+
+ if (!isMaster(nNode)) {
+ // Change Devicemonitor-status to connected ... for non master mountpoints.
+ deviceMonitor.deviceConnectSlaveIndication(mountPointNodeName);
+ return;
+ }
+
+ InstanceIdentifier<Node> instanceIdentifier =
+ NETCONF_TOPO_IID.child(Node.class, new NodeKey(new NodeId(mountPointNodeName)));
+
+ Optional<MountPoint> optionalMountPoint = null;
+ int timeout = 10000;
+ while (!(optionalMountPoint = mountPointService.getMountPoint(instanceIdentifier)).isPresent() && timeout > 0) {
+
+ LOG.info("Event listener waiting for mount point for Netconf device :: Name : {}", mountPointNodeName);
+ try {
+ Thread.sleep(1000);
+ timeout -= 1000;
+ } catch (InterruptedException e) {
+ LOG.info("Event listener waiting for mount point for Netconf device :: Name : {} Time: {}",
+ mountPointNodeName, timeout);
+ // Restore interrupted state...
+ Thread.currentThread().interrupt();
+ }
+ }
+
+ if (!optionalMountPoint.isPresent()) {
+ LOG.warn("Event listener timeout while waiting for mount point for Netconf device :: Name : {} ",
+ mountPointNodeName);
+ return;
+ }
+ // Mountpoint is present for sure
+ MountPoint mountPoint = optionalMountPoint.get();
+
+ DataBroker netconfNodeDataBroker = mountPoint.getService(DataBroker.class).orNull();
+ if (netconfNodeDataBroker == null) {
+ LOG.info("Mountpoint is slave mountpoint {}", mountPointNodeName);
+ return;
+ }
+
+ LOG.info("Databroker service 1:{} 2:{}", dataBroker.hashCode(), netconfNodeDataBroker.hashCode());
+ // getNodeInfoTest(dataBroker);
+
+ // create automatic empty maintenance entry into db before reading and listening for problems
+ this.maintenanceService.createIfNotExists(mountPointNodeName);
+
+ // Setup microwaveEventListener for Notificationservice
+
+ // MicrowaveEventListener microwaveEventListener = new
+ // MicrowaveEventListener(mountPointNodeName, websocketmanagerService,
+ // xmlMapper, databaseClientEvents);
+ ONFCoreNetworkElementRepresentation ne = ONFCoreNetworkElementFactory.create(mountPointNodeName, dataBroker,
+ webSocketService, databaseClientEvents, instanceIdentifier, netconfNodeDataBroker, dcaeProviderClient,
+ aotsMProvider, maintenanceService, notificationDelayService);
+ networkElementRepresentations.put(mountPointNodeName, ne);
+ ne.doRegisterMicrowaveEventListener(mountPoint);
+
+ // Register netconf stream
+ registerNotificationStream(mountPointNodeName, mountPoint, "NETCONF");
+
+ // -- Read data from NE
+ ne.initialReadFromNetworkElement();
+ ne.initSynchronizationExtension();
+
+ // Setup Service that monitors registration/ deregistration of session
+ odlEventListener.registration(mountPointNodeName);
+
+ if (aaiProviderClient != null) {
+ aaiProviderClient.onDeviceRegistered(mountPointNodeName);
+ }
+ // -- Register NE to performance manager
+ if (performanceManager != null) {
+ performanceManager.registration(mountPointNodeName, ne);
+ }
+
+ deviceMonitor.deviceConnectMasterIndication(mountPointNodeName, ne);
+
+ LOG.info("Starting Event listener on Netconf device :: Name : {} finished", mountPointNodeName);
+ }
+
+ // removeListenerOnNode
+ @Override
+ public void leaveConnectedState(NodeId nNodeId, NetconfNode nNode) {
+ String mountPointNodeName = nNodeId.getValue();
+ LOG.info("leaveConnectedState for device :: Name : {}", mountPointNodeName);
+
+ this.maintenanceService.deleteIfNotRequired(mountPointNodeName);
+ ONFCoreNetworkElementRepresentation ne = networkElementRepresentations.remove(mountPointNodeName);
+ if (ne != null) {
+ int problems = ne.removeAllCurrentProblemsOfNode();
+ LOG.debug("Removed all {} problems from database at deregistration for {}", problems, mountPointNodeName);
+ if (odlEventListener != null) {
+ odlEventListener.deRegistration(mountPointNodeName);
+ }
+ if (performanceManager != null) {
+ performanceManager.deRegistration(mountPointNodeName);
+ }
+ if (aaiProviderClient != null) {
+ aaiProviderClient.onDeviceUnregistered(mountPointNodeName);
+ }
+ } else {
+ LOG.info("No related ne object for mountpoint {} to deregister .", mountPointNodeName);
+ }
+ if (deviceMonitor != null) {
+ deviceMonitor.deviceDisconnectIndication(mountPointNodeName);
+ }
+
+ }
+
+ /*
+ * @Override public void mountpointNodeCreation(NodeId nNodeId, NetconfNode nNode) { String
+ * mountPointNodeName = nNodeId.getValue(); LOG.info("mountpointNodeCreation {} {}",
+ * nNodeId.getValue(), nNode.getConnectionStatus());
+ * deviceMonitor.createMountpointIndication(mountPointNodeName); }
+ */
+ @Override
+ public void mountpointNodeRemoved(NodeId nNodeId) {
+ String mountPointNodeName = nNodeId.getValue();
+ LOG.info("mountpointNodeRemoved {}", nNodeId.getValue());
+ deviceMonitor.removeMountpointIndication(mountPointNodeName);
+ }
+
+ /**
+ * Async RPC Interface implementation
+ */
+ @Override
+ public @Nonnull List<String> doClearCurrentFaultByNodename(@Nullable List<String> nodeNamesInput)
+ throws IllegalStateException {
+
+ if (this.databaseClientEvents == null) {
+ throw new IllegalStateException("dbEvents service not instantiated");
+ }
+
+ if (threadDoClearCurrentFaultByNodename != null && threadDoClearCurrentFaultByNodename.isAlive()) {
+ throw new IllegalStateException("A clear task is already active");
+ } else {
+
+ // Create list of mountpoints if input is empty, using the content in ES
+ if (nodeNamesInput == null || nodeNamesInput.size() <= 0) {
+ nodeNamesInput = this.databaseClientEvents.getAllNodesWithCurrentAlarms();
+ }
+
+ // Filter all mountpoints from input that were found and are known to this Cluster-node instance of
+ // DeviceManager
+ final List<String> nodeNamesHandled = new ArrayList<>();
+ for (String mountpointName : nodeNamesInput) {
+ LOG.info("Work with mountpoint {}", mountpointName);
+
+ if (odlEventListener != null && mountpointName.equals(odlEventListener.getOwnKeyName())) {
+
+ // SDN Controller related alarms
+ // -- can not be recreated on all nodes in connected state
+ // -- would result in a DCAE/AAI Notification
+ // Conclusion for 1810 Delivery ... not covered by RPC function (See issue #43)
+ LOG.info("Ignore SDN Controller related alarms for {}", mountpointName);
+ // this.databaseClientEvents.clearFaultsCurrentOfNode(mountpointName);
+ // nodeNamesHandled.add(mountpointName);
+
+ } else {
+
+ if (mountPointService != null) {
+ InstanceIdentifier<Node> instanceIdentifier =
+ NETCONF_TOPO_IID.child(Node.class, new NodeKey(new NodeId(mountpointName)));
+ Optional<MountPoint> optionalMountPoint = mountPointService.getMountPoint(instanceIdentifier);
+
+ if (!optionalMountPoint.isPresent()) {
+ LOG.info("Remove Alarms for unknown mountpoint {}", mountpointName);
+ this.databaseClientEvents.clearFaultsCurrentOfNode(mountpointName);
+ nodeNamesHandled.add(mountpointName);
+ } else {
+ if (networkElementRepresentations.containsKey(mountpointName)) {
+ LOG.info("At node known mountpoint {}", mountpointName);
+ nodeNamesHandled.add(mountpointName);
+ } else {
+ LOG.info("At node unknown mountpoint {}", mountpointName);
+ }
+ }
+ }
+ }
+ }
+
+ // Force a sync
+ if (this.deviceMonitor != null) {
+ this.deviceMonitor.refreshAlarmsInDb();
+ }
+
+ threadDoClearCurrentFaultByNodename = new Thread(() -> {
+ refreshCounter++;
+ LOG.info("Start refresh mountpoint task {}", refreshCounter);
+ // for(String nodeName:nodeNamesOutput) {
+ for (String nodeName : nodeNamesHandled) {
+ ONFCoreNetworkElementRepresentation ne = networkElementRepresentations.get(nodeName);
+ if (ne != null) {
+ LOG.info("Refresh mountpoint {}", nodeName);
+ ne.initialReadFromNetworkElement();
+ } else {
+ LOG.info("Unhandled mountpoint {}", nodeName);
+ }
+ }
+ LOG.info("End refresh mountpoint task {}", refreshCounter);
+ });
+ threadDoClearCurrentFaultByNodename.start();
+ return nodeNamesHandled;
+ }
+ };
+
+ /**
+ * Indication if init() of devicemanager successfully done.
+ *
+ * @return true if init() was sucessfull. False if not done or not successfull.
+ */
+ public boolean isDevicemanagerInitializationOk() {
+ return this.devicemanagerInitializationOk;
+ }
+
+ /**
+ * Get initialization status of database.
+ *
+ * @return true if fully initialized false if not
+ */
+ public boolean isDatabaseInitializationFinished() {
+ return htDatabase == null ? false : htDatabase.getInitialized();
+ }
+
+ /*---------------------------------------------------------------------
+ * Private funtions
+ */
+
+ /**
+ * Do the stream creation for the device.
+ *
+ * @param mountPointNodeName
+ * @param mountPoint
+ */
+ private void registerNotificationStream(String mountPointNodeName, MountPoint mountPoint, String streamName) {
+
+ final Optional<RpcConsumerRegistry> optionalRpcConsumerService =
+ mountPoint.getService(RpcConsumerRegistry.class);
+ if (optionalRpcConsumerService.isPresent()) {
+ final RpcConsumerRegistry rpcConsumerRegitry = optionalRpcConsumerService.get();
+ final NotificationsService rpcService = rpcConsumerRegitry.getRpcService(NotificationsService.class);
+ if (rpcService == null) {
+ LOG.warn("rpcService is null for mountpoint {}", mountPointNodeName);
+ } else {
+ final CreateSubscriptionInputBuilder createSubscriptionInputBuilder =
+ new CreateSubscriptionInputBuilder();
+ createSubscriptionInputBuilder.setStream(new StreamNameType(streamName));
+ LOG.info("Event listener triggering notification stream {} for node {}", streamName,
+ mountPointNodeName);
+ try {
+ CreateSubscriptionInput createSubscriptionInput = createSubscriptionInputBuilder.build();
+ if (createSubscriptionInput == null) {
+ LOG.warn("createSubscriptionInput is null for mountpoint {}", mountPointNodeName);
+ } else {
+ rpcService.createSubscription(createSubscriptionInput);
+ }
+ } catch (NullPointerException e) {
+ LOG.warn("createSubscription failed");
+ }
+ }
+ } else {
+ LOG.warn("No RpcConsumerRegistry avaialble.");
+ }
+
+ }
+
+ /**
+ * Get NE object
+ *
+ * @param mountpoint mount point name
+ * @return null or NE specific data
+ */
+ public @Nullable ONFCoreNetworkElementRepresentation getNeByMountpoint(String mountpoint) {
+
+ return networkElementRepresentations.get(mountpoint);
+
+ }
+
+ /* -- LOG related functions -- */
+
+
+ private boolean isInClusterMode() {
+ return this.akkaConfig == null ? false : this.akkaConfig.isCluster();
+ }
+
+ private String getClusterNetconfNodeName() {
+ return this.akkaConfig == null ? "" : this.akkaConfig.getClusterConfig().getClusterSeedNodeName("abc");
+ }
+
+ private boolean isMaster(NetconfNode nnode) {
+ if (isInClusterMode()) {
+ LOG.debug("check if me is responsible for node");
+ String masterNodeName = nnode.getClusteredConnectionStatus() == null ? "null"
+ : nnode.getClusteredConnectionStatus().getNetconfMasterNode();
+ /*
+ * List<NodeStatus> clusterNodeStatusList=nnode.getClusteredConnectionStatus()==null?null:nnode.
+ * getClusteredConnectionStatus().getNodeStatus(); if(clusterNodeStatusList!=null) { for(NodeStatus
+ * s: clusterNodeStatusList) LOG.debug("node "+s.getNode()+
+ * " with status "+(s.getStatus()==null?"null":s.getStatus().getName())); }
+ */
+ String myNodeName = getClusterNetconfNodeName();
+ LOG.debug("sdnMasterNode=" + masterNodeName + " and sdnMyNode=" + myNodeName);
+ if (!masterNodeName.equals(myNodeName)) {
+ LOG.debug("netconf change but me is not master for this node");
+ return false;
+ }
+ }
+ return true;
+ }
+
+}
diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/DeviceManagerService.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/DeviceManagerService.java
new file mode 100644
index 000000000..817d78d42
--- /dev/null
+++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/DeviceManagerService.java
@@ -0,0 +1,50 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 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.impl;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.NetconfNode;
+
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId;
+
+public interface DeviceManagerService {
+
+ public enum Action {
+ ADD,
+ REMOVE,
+ UPDATE
+ }
+ /**
+ * Managed device is connected to node/mountpoint.
+ * @param action provide action
+ * @param nNodeId id of the mountpoint
+ * @param nNode mountpoint contents
+ */
+ void startListenerOnNodeForConnectedState(Action action, NodeId nNodeId, NetconfNode nNode);
+
+ /**
+ * Managed device is disconnected from node/mountpoint.
+ * @param nNodeId id of the mountpoint
+ * @param nNode mountpoint contents
+ */
+ void leaveConnectedState(NodeId nNodeId, NetconfNode nNode);
+
+ /**
+ * Removal indication of node/mountpoint.
+ * @param nNodeId id of the mountpoint
+ */
+ void mountpointNodeRemoved(NodeId nNodeId);
+}
diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/ProviderClient.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/ProviderClient.java
new file mode 100644
index 000000000..922b8a0e0
--- /dev/null
+++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/ProviderClient.java
@@ -0,0 +1,39 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 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.impl;
+
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.xml.ProblemNotificationXml;
+
+public interface ProviderClient extends AutoCloseable {
+
+ /**
+ * Send out problem notification, that was created by a device/ or NE
+ * @param mountPointName related
+ * @param notification xml description
+ */
+ public void sendProblemNotification(String mountPointName, ProblemNotificationXml notification);
+
+ /**
+ * Send out problem notification
+ * @param mountPointName related
+ * @param notification xml description
+ * @param neDeviceAlarm true indicates an NE originated alarm, false an sdncontroller generated alarm
+ */
+ public void sendProblemNotification(String mountPointName, ProblemNotificationXml notification, boolean neDeviceAlarm);
+
+}
diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/ResyncNetworkElementsListener.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/ResyncNetworkElementsListener.java
new file mode 100644
index 000000000..d202cde40
--- /dev/null
+++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/ResyncNetworkElementsListener.java
@@ -0,0 +1,35 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 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.impl;
+
+import java.util.List;
+
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
+
+public interface ResyncNetworkElementsListener
+{
+ /**
+ * Handle API Request and clean up current alarms according to the list of mountpoint id's/devices
+ * Implement RPC function "clear-current-fault-by-nodename"
+ * @return List with
+ * @throws IllegalStateException Illegal state exception
+ */
+ public @Nonnull List<String> doClearCurrentFaultByNodename(@Nullable List<String> nodeNamesInput) throws IllegalStateException;
+
+}
diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/database/service/HtDatabaseEventsService.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/database/service/HtDatabaseEventsService.java
new file mode 100644
index 000000000..90b07999c
--- /dev/null
+++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/database/service/HtDatabaseEventsService.java
@@ -0,0 +1,228 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 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.impl.database.service;
+
+import java.util.ArrayList;
+import java.util.List;
+import javax.annotation.Nonnull;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.database.HtDataBaseReaderAndWriter;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.database.HtDatabaseClientAbstract;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.database.HtDatabaseNode;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.database.IndexClientBuilder;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.netconf.ONFCoreNetworkElement12Equipment;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.database.types.EsEventBase;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.database.types.EsFaultCurrent;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.database.types.EsFaultLog;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.database.types.equipment.EsEquipment;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.database.types.equipment.EsToplevelEquipment;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.database.types.equipment.ExtendedEquipment;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.xml.AttributeValueChangedNotificationXml;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.xml.MwtNotificationBase;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.xml.ObjectCreationNotificationXml;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.xml.ObjectDeletionNotificationXml;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.xml.ProblemNotificationXml;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Event service, writing all events into the database into the appropriate index.
+ *
+ * @author herbert
+ */
+public class HtDatabaseEventsService {
+ private static final Logger LOG = LoggerFactory.getLogger(HtDatabaseEventsService.class);
+
+ ///** Filename in the resources with maven initialized version information */
+ //private static final String RESOURCENAME = "version.properties"; // could also be a constant
+ ///** Index name to be used */
+ private static final String INDEX = "sdnevents";
+ private static final String MAPPING = "/elasticsearch/index/sdnevents/sdneventsMapping.json";
+
+ private HtDatabaseClientAbstract client;
+ private HtDataBaseReaderAndWriter<EsEventBase> eventRWEventLog;
+ private HtDataBaseReaderAndWriter<EsFaultCurrent> eventRWFaultCurrent;
+ private HtDataBaseReaderAndWriter<EsFaultLog> eventRWFaultLog;
+ private HtDataBaseReaderAndWriter<EsEquipment> eventRWEquipment;
+ private HtDataBaseReaderAndWriter<EsToplevelEquipment> eventRWToplevelEquipment;
+
+
+ // --- Construct and initialize
+
+ public HtDatabaseEventsService(HtDatabaseNode database) {
+
+ LOG.info("Create {} start", HtDatabaseEventsService.class);
+
+ try {
+ // Create control structure
+ IndexClientBuilder clientBuilder = IndexClientBuilder.getBuilder(INDEX).setMappingSettingJsonFileName(MAPPING);
+ client = clientBuilder.create(database);
+ clientBuilder.close();
+
+ eventRWEventLog = new HtDataBaseReaderAndWriter<>(client, EsEventBase.ESDATATYPENAME, EsEventBase.class);
+ eventRWFaultLog = new HtDataBaseReaderAndWriter<>(client, EsFaultLog.ESDATATYPENAME, EsFaultLog.class);
+ eventRWFaultCurrent = new HtDataBaseReaderAndWriter<>(client, EsFaultCurrent.ESDATATYPENAME, EsFaultCurrent.class);
+ eventRWToplevelEquipment = new HtDataBaseReaderAndWriter<>(client, EsToplevelEquipment.ESDATATYPENAME, EsToplevelEquipment.class);
+ eventRWEquipment = new HtDataBaseReaderAndWriter<>(client, EsEquipment.ESDATATYPENAME, EsEquipment.class);
+
+
+ } catch (Exception e) {
+ LOG.error("Can not start database client. Exception: {}", e.getMessage());
+ }
+ LOG.info("Create {} finished. DB Service {} started.", HtDatabaseEventsService.class, client != null ? "sucessfully" : "not" );
+ }
+
+ // --- Function
+
+ public void writeEventLog(ObjectCreationNotificationXml event) {
+ writeEventGeneric(event);
+ }
+
+ public void writeEventLog(ObjectDeletionNotificationXml event) {
+ writeEventGeneric(event);
+ }
+
+ public void writeEventLog(AttributeValueChangedNotificationXml event) {
+ writeEventGeneric(event);
+ }
+
+ private void writeEventGeneric(MwtNotificationBase event) {
+ if (client == null) {
+ LOG.debug("No DB, can not write: {}",event.toString());
+ return;
+ }
+
+ LOG.debug("Write event: {}",event.toString());
+ EsEventBase eventBase = new EsEventBase();
+ eventBase.setProblem(event);
+ eventRWEventLog.doWrite(eventBase);
+ }
+
+ public void writeFaultLog(ProblemNotificationXml fault) {
+ if (client == null) {
+ LOG.debug("No DB, can not write: {}",fault.toString());
+ return;
+ }
+
+ LOG.debug("Write fault to faultlog: {}",fault.toString());
+ EsFaultLog eventProblem = new EsFaultLog();
+ eventProblem.setProblem(fault);
+ eventRWFaultLog.doWrite(eventProblem);
+ }
+
+ public void updateFaultCurrent(ProblemNotificationXml fault) {
+ if (client == null) {
+ LOG.debug("No DB, can not write: {}",fault.toString());
+ return;
+ }
+
+ if (!fault.isNotManagedAsCurrentProblem()) {
+ EsFaultCurrent eventProblem = new EsFaultCurrent();
+ eventProblem.setProblem(fault);
+
+ if (eventProblem.isNoAlarmIndication()) {
+ LOG.debug("Remove from currentFaults: {}",fault.toString());
+ eventRWFaultCurrent.doRemove(eventProblem);
+ } else {
+ LOG.debug("Write to currentFaults: {}",fault.toString());
+ eventRWFaultCurrent.doWrite(eventProblem);
+ }
+ } else {
+ LOG.debug("Ingnore for currentFaults: {}",fault.toString());
+ }
+ }
+
+ /**
+ * Remove all entries for one node
+ * @param nodeName contains the mountpointname
+ * @return number of deleted entries
+ */
+ public int clearFaultsCurrentOfNode(String nodeName) {
+ if (client == null) {
+ LOG.debug("No DB, can not delete for node: {}", nodeName);
+ return -1;
+ }
+ LOG.debug("Remove from currentFaults all faults for node: {}", nodeName);
+ return eventRWFaultCurrent.doRemoveByQuery(EsFaultCurrent.getQueryForOneNode(nodeName));
+ }
+
+ /**
+ * Remove all entries for one node
+ * @param nodeName contains the mountpointname
+ * @param objectId of element to be deleted
+ * @return number of deleted entries
+ */
+ public int clearFaultsCurrentOfNodeWithObjectId(String nodeName, String objectId) {
+ if (client == null) {
+ LOG.debug("No DB, can not delete for node: {}", nodeName);
+ return -1;
+ }
+ LOG.debug("Remove from currentFaults all faults for node/objectId: {}/{}", nodeName, objectId);
+ return eventRWFaultCurrent.doRemoveByQuery(EsFaultCurrent.getQueryForOneNodeAndObjectId(nodeName, objectId));
+
+ }
+
+ /**
+ * Deliver list with all mountpoint/node-names in the database.
+ * @return List of all mountpoint/node-names the had active alarms.
+ */
+ public @Nonnull List<String> getAllNodesWithCurrentAlarms() {
+ if (client == null) {
+ LOG.debug("No DB, can not delete for all nodes");
+ return new ArrayList<>();
+ }
+ LOG.debug("Remove from currentFaults faults for all node");
+ List<String> nodeNames = new ArrayList<>();
+
+ for (EsFaultCurrent fault : eventRWFaultCurrent.doReadAll()) {
+ String nodeName = fault.getProblem().getNodeName();
+ if (!nodeNames.contains(nodeName)) {
+ //this.clearFaultsCurrentOfNode(nodeName); -> Function shifted
+ nodeNames.add(nodeName);
+ }
+ }
+ return nodeNames;
+ }
+
+
+ /**
+ * Write inventory to DB
+ * @param equipment all equipment of network element
+ */
+ public void writeInventory(ONFCoreNetworkElement12Equipment equipment) {
+ if (client == null) {
+ LOG.debug("No DB, can not write for mountpoint: {}",equipment.getMountpoint());
+ return;
+ }
+
+ LOG.debug("Write inventory to database for mountpoint: {}",equipment.getMountpoint());
+
+ EsToplevelEquipment esToplevelEquipment = new EsToplevelEquipment();
+ esToplevelEquipment.set(equipment);
+ eventRWToplevelEquipment.doWrite(esToplevelEquipment);
+
+ List<ExtendedEquipment> equipmentList = equipment.getEquipmentList();
+ EsEquipment esEquipment;
+ for (ExtendedEquipment equipment1 : equipmentList) {
+ esEquipment = new EsEquipment();
+ esEquipment.set(equipment.getMountpoint(), equipment1);
+ eventRWEquipment.doWrite(esEquipment);
+ }
+ }
+
+
+}
diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/database/types/EsEventBase.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/database/types/EsEventBase.java
new file mode 100644
index 000000000..d1731459e
--- /dev/null
+++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/database/types/EsEventBase.java
@@ -0,0 +1,47 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 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.impl.database.types;
+
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.database.EsObject;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.xml.MwtNotificationBase;
+
+/**
+ *
+ * Event from Network to be recorded in the database
+ *
+ */
+
+public class EsEventBase extends EsObject {
+
+ public static final String ESDATATYPENAME = "eventlog";
+
+ private MwtNotificationBase event;
+
+ public MwtNotificationBase getProblem() {
+ return event;
+ }
+
+ public void setProblem(MwtNotificationBase event) {
+ this.event = event;
+ }
+
+ public static String getEsdatatypename() {
+ return ESDATATYPENAME;
+ }
+
+ }
diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/database/types/EsFaultCurrent.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/database/types/EsFaultCurrent.java
new file mode 100644
index 000000000..b39b2e296
--- /dev/null
+++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/database/types/EsFaultCurrent.java
@@ -0,0 +1,75 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 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.impl.database.types;
+
+import org.elasticsearch.index.query.BoolQueryBuilder;
+import org.elasticsearch.index.query.QueryBuilder;
+import org.elasticsearch.index.query.QueryBuilders;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.database.EsObject;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.xml.ProblemNotificationXml;
+
+/**
+ * Event from Network to be recorded in the database
+ *
+ */
+
+public class EsFaultCurrent extends EsObject {
+
+ public static final String ESDATATYPENAME = "faultcurrent";
+ //private static final String NOALARM = "NonAlarmed";
+
+ private ProblemNotificationXml faultCurrent;
+
+ public ProblemNotificationXml getProblem() {
+ return faultCurrent;
+ }
+
+ public void setProblem(ProblemNotificationXml fault) {
+ this.faultCurrent = fault;
+ setEsId(fault.genSpecificEsId());
+ }
+
+ public boolean isNoAlarmIndication() {
+ return faultCurrent.getSeverity().isNoAlarmIndication();
+ }
+
+ /**
+ * TODO: termquery to matchquery, termquery with scoring, not exact matching
+ * @param nodeName name of the node
+ * @return query builder
+ */
+ public static QueryBuilder getQueryForOneNode( String nodeName) {
+ return QueryBuilders.termQuery("faultCurrent.nodeName", nodeName);
+ }
+ public static QueryBuilder getQueryForAll() {
+ return QueryBuilders.matchAllQuery();
+ }
+
+ public static QueryBuilder getQueryForOneNodeAndObjectId( String nodeName, String objectId) {
+ BoolQueryBuilder bq = QueryBuilders.boolQuery();
+ bq.must(QueryBuilders.termQuery("faultCurrent.nodeName", nodeName));
+ bq.must(QueryBuilders.termQuery("faultCurrent.objectId", objectId));
+ return bq;
+ //return QueryBuilders.termQuery("faultCurrent.objectId", objectId);
+
+ }
+
+ public static String getEsdatatypename() {
+ return ESDATATYPENAME;
+ }
+ }
diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/database/types/EsFaultLog.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/database/types/EsFaultLog.java
new file mode 100644
index 000000000..87c77ea99
--- /dev/null
+++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/database/types/EsFaultLog.java
@@ -0,0 +1,47 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 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.impl.database.types;
+
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.database.EsObject;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.xml.ProblemNotificationXml;
+
+/**
+ *
+ * Event from Network to be recorded in the database
+ *
+ */
+
+public class EsFaultLog extends EsObject {
+
+ public static final String ESDATATYPENAME = "faultlog";
+
+ private ProblemNotificationXml fault;
+
+ public ProblemNotificationXml getProblem() {
+ return fault;
+ }
+
+ public void setProblem(ProblemNotificationXml fault) {
+ this.fault = fault;
+ }
+
+ public static String getEsdatatypename() {
+ return ESDATATYPENAME;
+ }
+
+ }
diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/database/types/EsVersionInfo.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/database/types/EsVersionInfo.java
new file mode 100644
index 000000000..ca5b36717
--- /dev/null
+++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/database/types/EsVersionInfo.java
@@ -0,0 +1,75 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 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.impl.database.types;
+
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.database.EsObject;
+import org.osgi.framework.Version;
+
+/**
+ *
+ * Create a VersionInfo Object Network to be recorded in the database
+ *
+ */
+
+public class EsVersionInfo extends EsObject {
+
+ public static final String ESDATATYPENAME = "versioninfo";
+ private static final String EMPTY = "";
+
+ private Version bundleVersion;
+ private String build = EMPTY;
+ private String version = EMPTY;
+
+ public EsVersionInfo() {
+ }
+
+ public Version getBundleVersion() {
+ return bundleVersion;
+ }
+
+ public void setBundleVersion(Version bundleVersion) {
+ this.bundleVersion = bundleVersion;
+ }
+
+ public String getBuild() {
+ return build;
+ }
+
+ public void setBuild(String build) {
+ this.build = build;
+ }
+
+ public String getVersion() {
+ return version;
+ }
+
+ public void setVersion(String version) {
+ this.version = version;
+ }
+
+ public static String getEsdatatypename() {
+ return ESDATATYPENAME;
+ }
+
+ @Override
+ public String toString() {
+ return "EsVersionInfo [bundleVersion=" + bundleVersion + ", build=" + build + ", version=" + version + "]";
+ }
+
+
+ }
diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/database/types/equipment/EsEquipment.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/database/types/equipment/EsEquipment.java
new file mode 100644
index 000000000..5c70ad972
--- /dev/null
+++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/database/types/equipment/EsEquipment.java
@@ -0,0 +1,92 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 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.impl.database.types.equipment;
+
+import java.util.ArrayList;
+import java.util.List;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.database.EsObject;
+import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.Equipment;
+import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.equipment.g.ContainedHolder;
+import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.equipment.g.ManufacturedThing;
+import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.manufactured.thing.g.EquipmentInstance;
+import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.manufactured.thing.g.EquipmentType;
+import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.manufactured.thing.g.ManufacturerProperties;
+
+public class EsEquipment extends EsObject {
+
+ public static final String ESDATATYPENAME = "inventoryequipment";
+
+ int treeLevel;
+ String parentUuid;
+ String mountpoint;
+ String uuid;
+ List<String> containedHolder;
+ String manufacturerName;
+ String manufacturerIdentifier;
+ String serial;
+ String date;
+ String version;
+ String description;
+ String partTypeId;
+ String modelIdentifier;
+ String typeName;
+
+
+ public EsEquipment set( String mountpoint, ExtendedEquipment extendedEquipment ) {
+
+ Equipment equipment = extendedEquipment.getEquipment();
+
+ this.parentUuid = extendedEquipment.getParentUuid();
+ this.treeLevel = extendedEquipment.getTreeLevel();
+ this.mountpoint = mountpoint;
+ this.uuid = equipment.getUuid().getValue();
+ this.setEsId(this.mountpoint+"/"+this.uuid);
+
+ this.containedHolder = new ArrayList<>();
+ List<ContainedHolder> containedHolderList = equipment.getContainedHolder();
+ if (containedHolderList != null && !containedHolderList.isEmpty()) {
+ for (ContainedHolder containedHolderElement: containedHolderList) {
+ this.containedHolder.add(containedHolderElement.key().getUuid().getValue());
+ }
+ }
+ ManufacturedThing manufacturedThing = equipment.getManufacturedThing();
+ if (manufacturedThing != null) {
+ ManufacturerProperties manufacturedProperties = manufacturedThing.getManufacturerProperties();
+ if (manufacturedProperties != null) {
+ this.manufacturerName = manufacturedProperties.getManufacturerName();
+ this.manufacturerIdentifier = manufacturedProperties.getManufacturerIdentifier();
+ }
+ EquipmentInstance equipmentInstance = manufacturedThing.getEquipmentInstance();
+ if (equipmentInstance != null) {
+ this.serial = equipmentInstance.getSerialNumber();
+ this.date = equipmentInstance.getManufactureDate();
+ }
+ EquipmentType equipmentType = manufacturedThing.getEquipmentType();
+ if (equipmentType != null) {
+ this.version = equipmentType.getVersion();
+ this.description = equipmentType.getDescription();
+ this.partTypeId = equipmentType.getPartTypeIdentifier();
+ this.modelIdentifier = equipmentType.getModelIdentifier();
+ this.typeName = equipmentType.getTypeName();
+ }
+ }
+
+ return this;
+ }
+
+}
diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/database/types/equipment/EsToplevelEquipment.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/database/types/equipment/EsToplevelEquipment.java
new file mode 100644
index 000000000..a2e7af787
--- /dev/null
+++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/database/types/equipment/EsToplevelEquipment.java
@@ -0,0 +1,46 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 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.impl.database.types.equipment;
+
+import java.util.ArrayList;
+import java.util.List;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.database.EsObject;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.netconf.ONFCoreNetworkElement12Equipment;
+import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.UniversalId;
+
+public class EsToplevelEquipment extends EsObject {
+
+ public static final String ESDATATYPENAME = "inventorytoplevel";
+
+ String mountpoint;
+ List<String> uuidList;
+
+ public EsToplevelEquipment set(ONFCoreNetworkElement12Equipment coreEquipment) {
+
+ mountpoint = coreEquipment.getMountpoint();
+ this.setEsId(mountpoint);
+
+ uuidList = new ArrayList<>();
+ for (UniversalId uuid : coreEquipment.getTopLevelEqUuidList()) {
+ uuidList.add(uuid.getValue());
+ }
+
+ return(this);
+ }
+
+}
diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/database/types/equipment/ExtendedEquipment.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/database/types/equipment/ExtendedEquipment.java
new file mode 100644
index 000000000..cdccd97ed
--- /dev/null
+++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/database/types/equipment/ExtendedEquipment.java
@@ -0,0 +1,56 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 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.impl.database.types.equipment;
+
+import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.Equipment;
+
+public class ExtendedEquipment {
+
+ private final String parentUuid;
+ private final int treeLevel;
+ private final Equipment equipment;
+
+ /**
+ * Equipment with additional information beside NETCONF equipment
+ *
+ * @param parentUuid of parent equipment
+ * @param equipment NETCONF Equipment
+ * @param treeLevel level of tree starting with root at 0
+ */
+ public ExtendedEquipment(String parentUuid, Equipment equipment, int treeLevel) {
+ super();
+ this.parentUuid = parentUuid;
+ this.equipment = equipment;
+ this.treeLevel = treeLevel;
+ }
+
+ public String getParentUuid() {
+ return parentUuid;
+ }
+
+ public Equipment getEquipment() {
+ return equipment;
+ }
+
+ public int getTreeLevel() {
+ return treeLevel;
+ }
+
+
+
+}
diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/listener/MicrowaveEventListener12.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/listener/MicrowaveEventListener12.java
new file mode 100644
index 000000000..6612f626b
--- /dev/null
+++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/listener/MicrowaveEventListener12.java
@@ -0,0 +1,205 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 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.impl.listener;
+
+import java.util.List;
+
+import javax.annotation.Nullable;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.internalTypes.InternalSeverity;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.netconf.ONFCoreNetworkElement12Equipment;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.netconf.ONFCoreNetworkElementCallback;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.netconf.wrapperc.OnfMicrowaveModelNotification;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.toggleAlarmFilter.NotificationDelayFilter;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.toggleAlarmFilter.NotificationDelayService;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.toggleAlarmFilter.NotificationDelayedListener;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.ProviderClient;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.database.service.HtDatabaseEventsService;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.xml.AttributeValueChangedNotificationXml;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.xml.ObjectCreationNotificationXml;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.xml.ObjectDeletionNotificationXml;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.xml.ProblemNotificationXml;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.xml.WebSocketServiceClient;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.maintenance.MaintenanceService;
+import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.ProblemNotification;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Important: Websocket notification must be the last action.
+ * @author herbert
+ *
+ */ //OnfMicrowaveModelNotification //
+public class MicrowaveEventListener12 implements OnfMicrowaveModelNotification, NotificationDelayedListener<ProblemNotificationXml> {
+
+ private static final Logger LOG = LoggerFactory.getLogger(MicrowaveEventListener12.class);
+
+ private final String nodeName;
+ private final WebSocketServiceClient webSocketService;
+ //private final WebsocketmanagerService websocketmanagerService;
+ //private final XmlMapper xmlMapper;
+ private final HtDatabaseEventsService databaseService;
+ private final ProviderClient dcaeProvider;
+ private final @Nullable ProviderClient aotsmClient;
+
+ private final MaintenanceService maintenanceService;
+
+ private final NotificationDelayFilter<ProblemNotificationXml> delayFilter;
+ private final ONFCoreNetworkElementCallback ne;
+
+ public MicrowaveEventListener12(String nodeName, WebSocketServiceClient webSocketService,
+ HtDatabaseEventsService databaseService, ProviderClient dcaeProvider,@Nullable ProviderClient aotsmClient,
+ MaintenanceService maintenanceService2,NotificationDelayService<ProblemNotificationXml> notificationDelayService,
+ ONFCoreNetworkElementCallback ne) {
+ super();
+ this.nodeName = nodeName;
+ //this.websocketmanagerService = websocketmanagerService;
+ //this.xmlMapper = xmlMapper;
+ this.webSocketService = webSocketService;
+ this.databaseService = databaseService;
+ this.dcaeProvider = dcaeProvider;
+ this.aotsmClient = aotsmClient;
+ this.maintenanceService=maintenanceService2;
+ this.delayFilter=notificationDelayService.getInstance(nodeName, this);//12(nodeName,this);
+ this.ne = ne;
+ }
+
+
+ @Override
+ public void onAttributeValueChangedNotification(AttributeValueChangedNotificationXml notificationXml) {
+
+ ne.notificationFromNeListener(notificationXml);
+
+ databaseService.writeEventLog(notificationXml);
+
+ webSocketService.sendViaWebsockets(nodeName, notificationXml);
+ }
+
+
+ @Override
+ public void onObjectCreationNotification(ObjectCreationNotificationXml notificationXml) {
+
+ databaseService.writeEventLog(notificationXml);
+
+ webSocketService.sendViaWebsockets(nodeName, notificationXml);
+
+ }
+
+ @Override
+ public void onObjectDeletionNotification(ObjectDeletionNotificationXml notificationXml) {
+
+ databaseService.writeEventLog(notificationXml);
+
+ webSocketService.sendViaWebsockets(nodeName, notificationXml);
+ }
+
+ @Override
+ public void onProblemNotification(ProblemNotificationXml notificationXml) {
+
+ databaseService.writeFaultLog(notificationXml);
+ databaseService.updateFaultCurrent(notificationXml);
+
+ //ToggleAlarmFilter functionality
+ if(NotificationDelayFilter.isEnabled())
+ {
+ if(notificationXml.getSeverity() == InternalSeverity.NonAlarmed) {
+ delayFilter.clearAlarmNotification(notificationXml.getProblem(), notificationXml);
+ } else {
+ delayFilter.pushAlarmNotification(notificationXml.getProblem(), notificationXml);
+ }
+ }
+ else
+ {
+ this.pushAlarmIfNotInMaintenance(notificationXml);
+ }
+ //end of ToggleAlarmFilter
+
+ this.webSocketService.sendViaWebsockets(nodeName, notificationXml);
+
+ }
+
+ @Override
+ public void onNotificationDelay(ProblemNotificationXml notificationXml) {
+
+ LOG.debug("Got delayed event of type :: {}", ProblemNotification.class.getSimpleName());
+ this.pushAlarmIfNotInMaintenance(notificationXml);
+
+ }
+ private void pushAlarmIfNotInMaintenance(ProblemNotificationXml notificationXml)
+ {
+ if(!this.maintenanceService.isONFObjectInMaintenance(nodeName, notificationXml.getObjectId(), notificationXml.getProblem()))
+ {
+ this.dcaeProvider.sendProblemNotification(nodeName, notificationXml);
+ if(this.aotsmClient!=null) {
+ this.aotsmClient.sendProblemNotification(nodeName, notificationXml);
+ }
+ }
+ else
+ {
+ LOG.debug("Notification will not be sent to external services. Device "+this.nodeName+" is in maintenance mode");
+ }
+ }
+ private void initCurrentProblem(ProblemNotificationXml notificationXml) {
+ databaseService.updateFaultCurrent(notificationXml);
+ //to prevent push alarms on reconnect
+ //=> only pushed alarms are forwared to dcae
+ //dcaeProvider.sendProblemNotification(nodeName, notificationXml);
+ if(aotsmClient!=null) {
+ aotsmClient.sendProblemNotification(this.nodeName, notificationXml);
+ }
+ }
+
+ /**
+ * Called to initialize with the current status and notify the clients
+ * @param notificationXmlList List with problems
+ */
+ public void initCurrentProblemStatus(List<ProblemNotificationXml> notificationXmlList) {
+
+ for (ProblemNotificationXml notificationXml : notificationXmlList) {
+ initCurrentProblem(notificationXml);
+ }
+
+ }
+
+ /**
+ * Called on exit to remove everything from the current list.
+ * @return Number of deleted objects
+ */
+ public int removeAllCurrentProblemsOfNode() {
+ int deleted = databaseService.clearFaultsCurrentOfNode(nodeName);
+ return deleted;
+ }
+
+ /**
+ * Called on exit to remove for one Object-Pac from the current list.
+ * @param objectId uuid of the interface-pac or equipment-pac
+ * @return Number of deleted objects
+ */
+ public int removeObjectsCurrentProblemsOfNode(String objectId) {
+ int deleted = databaseService.clearFaultsCurrentOfNodeWithObjectId(nodeName, objectId);
+ return deleted;
+ }
+
+ /**
+ * Write equipment data to database
+ * @param equipment to write
+ */
+ public void writeEquipment(ONFCoreNetworkElement12Equipment equipment) {
+ databaseService.writeInventory(equipment);
+ }
+
+ }
diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/listener/NetconfChangeListener.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/listener/NetconfChangeListener.java
new file mode 100644
index 000000000..1a92f37b7
--- /dev/null
+++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/listener/NetconfChangeListener.java
@@ -0,0 +1,180 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 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.impl.listener;
+
+import java.util.Collection;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.DeviceManagerService;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.DeviceManagerService.Action;
+import org.opendaylight.controller.md.sal.binding.api.ClusteredDataTreeChangeListener;
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.controller.md.sal.binding.api.DataObjectModification;
+import org.opendaylight.controller.md.sal.binding.api.DataObjectModification.ModificationType;
+import org.opendaylight.controller.md.sal.binding.api.DataTreeIdentifier;
+import org.opendaylight.controller.md.sal.binding.api.DataTreeModification;
+import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.NetconfNode;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.NetconfNodeConnectionStatus.ConnectionStatus;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.network.topology.topology.topology.types.TopologyNetconf;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NetworkTopology;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.TopologyId;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.TopologyKey;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeKey;
+import org.opendaylight.yangtools.concepts.ListenerRegistration;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+// 07.09.18 Switched to DataTreeChangeListener from ClusteredDataTreeChangeListener -> DM Service is running at all nodes
+// This is not correct
+public class NetconfChangeListener implements ClusteredDataTreeChangeListener<Node>, AutoCloseable {
+
+ private static final Logger LOG = LoggerFactory.getLogger(NetconfChangeListener.class);
+
+ private static final InstanceIdentifier<Node> NETCONF_NODE_TOPO_IID = InstanceIdentifier
+ .create(NetworkTopology.class)
+ .child(Topology.class, new TopologyKey(new TopologyId(TopologyNetconf.QNAME.getLocalName())))
+ .child(Node.class);
+ // Name of ODL controller NETCONF instance
+ private static final String CONTROLLER = "controller-config";
+
+ private final DeviceManagerService deviceManagerService;
+ private final DataBroker dataBroker;
+ private ListenerRegistration<NetconfChangeListener> dlcReg;
+
+ public NetconfChangeListener(DeviceManagerService deviceManagerService, DataBroker dataBroker) {
+ this.deviceManagerService = deviceManagerService;
+ this.dataBroker = dataBroker;
+ }
+
+ public void register() {
+ DataTreeIdentifier<Node> treeId = new DataTreeIdentifier<>(LogicalDatastoreType.OPERATIONAL,
+ NETCONF_NODE_TOPO_IID);
+ dlcReg = dataBroker.registerDataTreeChangeListener(treeId, this);
+ }
+
+ @Override
+ public void close() {
+ if (dlcReg != null) {
+ dlcReg.close();
+ }
+ }
+ /*---------------------------------------------------------------------------
+ * Listener
+ */
+
+ @Override
+ public void onDataTreeChanged(Collection<DataTreeModification<Node>> changes) {
+ if (LOG.isTraceEnabled()) {
+ LOG.trace("OnDataChange, TreeChange {}", changes);
+ } else if (LOG.isDebugEnabled()) {
+ LOG.debug("OnDataChange, TreeChange");
+ }
+
+ for (final DataTreeModification<Node> change : changes) {
+ final DataObjectModification<Node> root = change.getRootNode();
+ final ModificationType modificationType = root.getModificationType();
+ if (LOG.isTraceEnabled()) {
+ LOG.trace("Handle this modificationType:{} path:{} root:{}", modificationType, change.getRootPath(), root);
+ }
+ switch (modificationType) {
+ case SUBTREE_MODIFIED:
+ // Change of subtree information
+ // update(change); OLD
+ doProcessing(Action.UPDATE, root.getDataAfter());
+ break;
+ case WRITE:
+ // Create or modify top level node
+ // Treat an overwrite as an update
+ boolean update = root.getDataBefore() != null;
+ if (update) {
+ //update(change);
+ doProcessing(Action.UPDATE, root.getDataAfter());
+ } else {
+ //add(change);
+ doProcessing(Action.ADD, root.getDataAfter());
+ }
+ break;
+ case DELETE:
+ // Node removed
+ //remove(change);
+ doProcessing(Action.REMOVE, root.getDataBefore());
+ break;
+ }
+ }
+ }
+
+ /* ----------------------------------------------------------------
+ * Functions to select the right node from DataObjectModification
+ */
+
+ /**
+ * Process event and forward to clients
+ * @param action
+ * @param node Basis node
+ */
+ private void doProcessing(Action action, Node node) {
+
+ NodeId nodeId;
+ NetconfNode nnode;
+ try {
+ NodeKey nodeKey = node.key();
+ nodeId = nodeKey.getNodeId();
+ nnode = node.augmentation(NetconfNode.class);
+ } catch (NullPointerException e) {
+ LOG.warn("Unexpected null .. stop processing.", e);
+ return;
+ }
+
+ LOG.debug("doProcessing action {} {}",action, nodeId);
+ String nodeIdString = nodeId.getValue();
+ // Do not forward any controller related events to devicemanager
+ if (nodeIdString.equals(CONTROLLER)) {
+ LOG.debug("Stop processing for [{}]", nodeIdString);
+ return;
+ }
+
+ // Related to action
+ if (action == Action.REMOVE) {
+ deviceManagerService.mountpointNodeRemoved(nodeId); //Stop Monitor
+ deviceManagerService.leaveConnectedState(nodeId, nnode); //Remove Mountpoint handler
+ return;
+ }
+
+ // Related to Mountpoint status
+ ConnectionStatus csts = nnode.getConnectionStatus();
+ LOG.debug("NETCONF Node handled with status: {} {}", csts, nnode.getClusteredConnectionStatus());
+ if (csts != null) {
+ switch (csts) {
+ case Connected: {
+ deviceManagerService.startListenerOnNodeForConnectedState(action, nodeId, nnode);
+ break;
+ }
+ case UnableToConnect:
+ case Connecting: {
+ deviceManagerService.leaveConnectedState(nodeId, nnode);
+ break;
+ }
+ }
+ } else {
+ LOG.debug("NETCONF Node handled with null status");
+ }
+ }
+}
diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/listener/ODLEventListener.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/listener/ODLEventListener.java
new file mode 100644
index 000000000..ace5f123d
--- /dev/null
+++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/listener/ODLEventListener.java
@@ -0,0 +1,208 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 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.impl.listener;
+
+import javax.annotation.Nullable;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.internalTypes.InternalDateAndTime;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.internalTypes.InternalSeverity;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.netconf.util.NetconfTimeStamp;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.ProviderClient;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.database.service.HtDatabaseEventsService;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.xml.ObjectCreationNotificationXml;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.xml.ObjectDeletionNotificationXml;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.xml.ProblemNotificationXml;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.xml.WebSocketServiceClient;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.maintenance.MaintenanceService;
+import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.ProblemNotification;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Responsible class for documenting changes in the ODL itself. The occurence of
+ * such an event is documented in the database and to clients. Specific example
+ * here is the registration or deregistration of a netconf device. This service
+ * has an own eventcounter to apply to the ONF Coremodel netconf behaviour.
+ *
+ * Important: Websocket notification must be the last action.
+ *
+ * @author herbert
+ */
+
+public class ODLEventListener {
+
+ private static final Logger LOG = LoggerFactory.getLogger(ODLEventListener.class);
+ private static final NetconfTimeStamp NETCONFTIME_CONVERTER = NetconfTimeStamp.getConverter();
+
+
+ private final String ownKeyName;
+
+ private final WebSocketServiceClient webSocketService;
+ private final HtDatabaseEventsService databaseService;
+ private final ProviderClient dcaeProvider;
+ private final ProviderClient aotsMProvider;
+ private int eventNumber;
+ private final MaintenanceService maintenanceService;
+ /*---------------------------------------------------------------
+ * Construct
+ */
+
+ /**
+ * Create a Service to document events to clients and within a database
+ *
+ * @param ownKeyName The name of this service, that is used in the
+ * database as identification key.
+ * @param webSocketService service to direct messages to clients
+ * @param databaseService service to write to the database
+ * @param dcaeProvider to deliver problems to
+ * @param maintenanceService2
+ */
+ @SuppressWarnings("javadoc")
+ public ODLEventListener(String ownKeyName, WebSocketServiceClient webSocketService,
+ HtDatabaseEventsService databaseService, ProviderClient dcaeProvider,
+ @Nullable ProviderClient aotsMProvider, MaintenanceService maintenanceService) {
+ super();
+
+ this.ownKeyName = ownKeyName;
+ this.webSocketService = webSocketService;
+
+ this.databaseService = databaseService;
+ this.dcaeProvider = dcaeProvider;
+ this.aotsMProvider = aotsMProvider;
+
+ this.eventNumber = 0;
+ this.maintenanceService = maintenanceService;
+
+ }
+
+ /*---------------------------------------------------------------
+ * Functions
+ */
+
+ /**
+ * A registration of a mountpoint occured.
+ *
+ * @param registrationName Name of the event that is used as key in the
+ * database.
+ */
+
+ public void registration(String registrationName) {
+
+ ObjectCreationNotificationXml cNotificationXml = new ObjectCreationNotificationXml(ownKeyName,
+ popEvntNumberAsString(), InternalDateAndTime.valueOf(NETCONFTIME_CONVERTER.getTimeStamp()),
+ registrationName);
+
+ // Write first to prevent missing entries
+ databaseService.writeEventLog(cNotificationXml);
+
+ webSocketService.sendViaWebsockets(registrationName, cNotificationXml);
+
+ }
+
+ /**
+ * A deregistration of a mountpoint occured.
+ *
+ * @param registrationName Name of the event that is used as key in the
+ * database.
+ */
+
+ public void deRegistration(String registrationName) {
+
+ ObjectDeletionNotificationXml dNotificationXml = new ObjectDeletionNotificationXml(ownKeyName,
+ popEvntNumberAsString(), InternalDateAndTime.valueOf(NETCONFTIME_CONVERTER.getTimeStamp()),
+ registrationName);
+
+ // Write first to prevent missing entries
+ databaseService.writeEventLog(dNotificationXml);
+
+ webSocketService.sendViaWebsockets(registrationName, dNotificationXml);
+
+ }
+
+ /**
+ * At a mountpoint a problem situation is indicated
+ *
+ * @param registrationName indicating object within SDN controller, normally the
+ * mountpointName
+ * @param problemName that changed
+ * @param problemSeverity of the problem according to NETCONF/YANG
+ */
+
+ public void onProblemNotification(String registrationName, String problemName, InternalSeverity problemSeverity) {
+ LOG.debug("Got event of type :: {} or {} or {}", ProblemNotification.class.getSimpleName(),
+ org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.ProblemNotification.class
+ .getSimpleName(),
+ org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.ProblemNotification.class
+ .getSimpleName());
+ // notification
+
+ ProblemNotificationXml notificationXml = new ProblemNotificationXml(ownKeyName, registrationName, problemName,
+ problemSeverity,
+ // popEvntNumberAsString(), InternalDateAndTime.TESTPATTERN );
+ popEvntNumberAsString(), InternalDateAndTime.valueOf(NETCONFTIME_CONVERTER.getTimeStamp()));
+
+ databaseService.writeFaultLog(notificationXml);
+ databaseService.updateFaultCurrent(notificationXml);
+
+ if (!maintenanceService.isONFObjectInMaintenance(registrationName, notificationXml.getObjectId(),
+ notificationXml.getProblem())) {
+ dcaeProvider.sendProblemNotification(ownKeyName, notificationXml);
+ if (aotsMProvider != null) {
+ aotsMProvider.sendProblemNotification(ownKeyName, notificationXml, false);// not a nealarm, its a
+ }
+ } // sdncontroller alarm
+ else {
+ LOG.debug("Notification will not be sent to external services. Device " + registrationName
+ + " is in maintenance mode");
+ }
+
+ webSocketService.sendViaWebsockets(registrationName, notificationXml);
+ }
+
+ /**
+ * Called on exit to remove everything for a node from the current list.
+ *
+ * @param nodeName to remove all problems for
+ * @return Number of deleted objects
+ */
+ public int removeAllCurrentProblemsOfNode(String nodeName) {
+ return databaseService.clearFaultsCurrentOfNodeWithObjectId(ownKeyName, nodeName);
+ }
+
+ /*---------------------------------------------------------------
+ * Get/Set
+ */
+
+ /**
+ * @return the ownKeyName
+ */
+ public String getOwnKeyName() {
+ return ownKeyName;
+ }
+
+ /*---------------------------------------------------------------
+ * Private
+ */
+
+ private String popEvntNumberAsString() {
+ return String.valueOf(popEvntNumber());
+ }
+
+ private int popEvntNumber() {
+ return eventNumber++;
+ }
+}
diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/xml/AttributeValueChangedNotificationXml.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/xml/AttributeValueChangedNotificationXml.java
new file mode 100644
index 000000000..8ec5903d1
--- /dev/null
+++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/xml/AttributeValueChangedNotificationXml.java
@@ -0,0 +1,68 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 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.impl.xml;
+
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.internalTypes.InternalDateAndTime;
+
+@XmlRootElement(name = "AttributeValueChangedNotification")
+public class AttributeValueChangedNotificationXml extends MwtNotificationBase implements GetEventType {
+
+ private static String EVENTTYPE = "AttributeValueChangedNotification";
+
+ @XmlElement(name = "attributeName")
+ private String attributeName;
+
+ @XmlElement(name = "newValue")
+ private String newValue;
+
+ public AttributeValueChangedNotificationXml() {
+
+ }
+
+ /**
+ * Normalized notification
+ * @param nodeName name of mountpoint
+ * @param counter of notification
+ * @param timeStamp from ne
+ * @param objectIdRef from ne
+ * @param attributeName from ne
+ * @param newValue from ne
+ */
+ public AttributeValueChangedNotificationXml(String nodeName, String counter, InternalDateAndTime timeStamp, String objectIdRef,
+ String attributeName, String newValue) {
+ super(nodeName, counter, timeStamp, objectIdRef);
+ this.attributeName = attributeName;
+ this.newValue = newValue;
+ }
+
+ public String getAttributeName() {
+ return attributeName;
+ }
+
+ public String getNewValue() {
+ return newValue;
+ }
+
+ @Override
+ public String getEventType() {
+ return EVENTTYPE;
+ }
+
+}
diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/xml/GetEventType.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/xml/GetEventType.java
new file mode 100644
index 000000000..ba3e23c77
--- /dev/null
+++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/xml/GetEventType.java
@@ -0,0 +1,29 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 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.impl.xml;
+
+/**
+ * @author herbert
+ *
+ */
+public interface GetEventType {
+ public String getEventType();
+}
diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/xml/MwtNotificationBase.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/xml/MwtNotificationBase.java
new file mode 100644
index 000000000..149640641
--- /dev/null
+++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/xml/MwtNotificationBase.java
@@ -0,0 +1,83 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 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.impl.xml;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import javax.xml.bind.annotation.XmlElement;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.internalTypes.InternalDateAndTime;
+
+public class MwtNotificationBase {
+
+ private static String EMPTY = "empty";
+
+ private String nodeName;
+ private String counter;
+ private String timeStamp;
+ private String objectId;
+
+ public MwtNotificationBase() {
+ // For Jaxb
+ }
+
+ public MwtNotificationBase(String nodeName, String counter, InternalDateAndTime timeStamp, String objectId) {
+ this.nodeName = nodeName;
+ this.counter = counter;
+ this.timeStamp = timeStamp.getValue();
+ this.objectId = objectId;
+ if (this.objectId == null) {
+ this.objectId = EMPTY;
+ }
+ }
+
+ @XmlElement(name = "nodeName")
+ public String getNodeName() {
+ return nodeName;
+ }
+
+ @XmlElement(name = "counter")
+ public String getCounter() {
+ return counter;
+ }
+
+ @XmlElement(name = "timeStamp")
+ public String getTimeStamp() {
+ return timeStamp;
+ }
+
+ @XmlElement(name = "objectId")
+ public String getObjectId() {
+ return objectId;
+ }
+
+ /**
+ * Type for the Database to document the the same name that is used in the websockets.
+ * @return String with type name of child class
+ */
+ @JsonProperty("type")
+ public String getType() {
+ return this.getClass().getSimpleName();
+ }
+
+ @Override
+ public String toString() {
+ return "MwtNotificationBase [getType()="+ getType() + ", nodeName=" + nodeName + ", counter=" + counter + ", timeStamp=" + timeStamp
+ + ", objectId=" + objectId + "]";
+ }
+
+
+}
diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/xml/ObjectCreationNotificationXml.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/xml/ObjectCreationNotificationXml.java
new file mode 100644
index 000000000..b404073b7
--- /dev/null
+++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/xml/ObjectCreationNotificationXml.java
@@ -0,0 +1,58 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 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.impl.xml;
+
+import javax.xml.bind.annotation.XmlRootElement;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.internalTypes.InternalDateAndTime;
+
+@XmlRootElement(name = "ObjectCreationNotification")
+public class ObjectCreationNotificationXml extends MwtNotificationBase implements GetEventType {
+
+ private static String EVENTTYPE = "ObjectCreationNotification";
+
+ public ObjectCreationNotificationXml() {
+
+ }
+
+ /**
+ * Normalized notification
+ * @param nodeName name of mountpoint or instance that owns the problem
+ * @param counter of notification
+ * @param timeStamp from ne
+ * @param objectIdRef from ne
+ */
+ public ObjectCreationNotificationXml(String nodeName, String counter, InternalDateAndTime timeStamp, String objectIdRef) {
+ super(nodeName, counter, timeStamp, objectIdRef);
+ }
+
+ /*public ObjectCreationNotificationXml(String nodeName, org.opendaylight.yang.gen.v1.uri.onf.microwavemodel.notifications.rev160809.ObjectCreationNotification notification) {
+ super(nodeName, notification.getCounter().toString(), InternalDateAndTime.valueOf(notification.getTimeStamp()),
+ notification.getObjectIdRef().getValue());
+ }
+
+ public ObjectCreationNotificationXml(String nodeName, org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.ObjectCreationNotification notification) {
+ super(nodeName, notification.getCounter().toString(), InternalDateAndTime.valueOf(notification.getTimeStamp()),
+ notification.getObjectIdRef().getValue());
+ }*/
+
+ @Override
+ public String getEventType() {
+ return EVENTTYPE;
+ }
+
+}
diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/xml/ObjectDeletionNotificationXml.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/xml/ObjectDeletionNotificationXml.java
new file mode 100644
index 000000000..c61a94ac4
--- /dev/null
+++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/xml/ObjectDeletionNotificationXml.java
@@ -0,0 +1,61 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 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.impl.xml;
+
+import javax.xml.bind.annotation.XmlRootElement;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.internalTypes.InternalDateAndTime;
+
+@XmlRootElement(name = "ObjectDeletionNotification")
+public class ObjectDeletionNotificationXml extends MwtNotificationBase implements GetEventType {
+
+ private static String EVENTTYPE = "ObjectDeletionNotification";
+
+ public ObjectDeletionNotificationXml() {
+
+ }
+
+ /**
+ * Normalized notification
+ * @param nodeName name of mountpoint or instance that owns the problem
+ * @param counter of notification
+ * @param timeStamp from ne
+ * @param objectIdRef from ne
+ */
+ public ObjectDeletionNotificationXml(String nodeName, String counter, InternalDateAndTime timeStamp, String objectIdRef) {
+ super(nodeName, counter, timeStamp, objectIdRef);
+ }
+
+ /*
+ public ObjectDeletionNotificationXml(String nodeName, ObjectDeletionNotification notification) {
+ super(nodeName, notification.getCounter().toString(), InternalDateAndTime.valueOf(notification.getTimeStamp()),
+// notification.getObjectId().getValue());
+ notification.getObjectIdRef().getValue());
+ }*/
+/*
+ public ObjectDeletionNotificationXml(String nodeName, org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.ObjectDeletionNotification notification) {
+ super(nodeName, notification.getCounter().toString(), InternalDateAndTime.valueOf(notification.getTimeStamp()),
+// notification.getObjectId().getValue());
+ notification.getObjectIdRef().getValue());
+ }
+*/
+ @Override
+ public String getEventType() {
+ return EVENTTYPE;
+ }
+
+}
diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/xml/ProblemNotificationXml.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/xml/ProblemNotificationXml.java
new file mode 100644
index 000000000..282c1bad9
--- /dev/null
+++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/xml/ProblemNotificationXml.java
@@ -0,0 +1,115 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 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.impl.xml;
+
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.internalTypes.InternalDateAndTime;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.internalTypes.InternalSeverity;
+
+@XmlRootElement(name = "ProblemNotification")
+public class ProblemNotificationXml extends MwtNotificationBase implements GetEventType {
+
+ private static String EVENTTYPE = "ProblemNotification";
+ private static final Pattern pattern = Pattern.compile(".*\\[layerProtocol=(.*)\\]");
+ /**
+ * The leading indication for notification or events that are not in the
+ * currentProblem data of the ONF Coremodel
+ */
+ private static final String NOCURRENTPROBLEMINDICATION = "#";
+
+ @XmlElement(name = "problem")
+ private String problem;
+
+ @XmlElement(name = "severity")
+ private InternalSeverity severity;
+
+ public ProblemNotificationXml() {
+
+ }
+
+ /**
+ * Generic Problem. All the parameters are of type Strings according to YANG
+ * specification.
+ *
+ * @param nodeName Name of mountpoint
+ * @param uuId Name of Interface Pac
+ * @param problemNameString Name of the problem
+ * @param problemSeverityString Severitycode of the problem
+ * @param counterString Counter from device
+ * @param internaltimeStampString Timestamp according to internal format.
+ */
+ public ProblemNotificationXml(String nodeName, String uuId, String problemNameString,
+ InternalSeverity problemSeverityString, String counterString, InternalDateAndTime internaltimeStampString) {
+ super(nodeName, counterString, internaltimeStampString, uuId);
+ this.problem = problemNameString;
+ this.severity = problemSeverityString;
+ }
+
+ public String getProblem() {
+ return problem;
+ }
+
+ public InternalSeverity getSeverity() {
+ return severity;
+ }
+
+ public boolean isNotManagedAsCurrentProblem() {
+ return problem.startsWith(NOCURRENTPROBLEMINDICATION);
+ }
+
+ /**
+ * Create a specific ES id for the current log.
+ *
+ * @return a string with the generated ES Id
+ */
+ @JsonIgnore
+ public String genSpecificEsId() {
+
+ String uuId;
+
+ Matcher matcher = pattern.matcher(getObjectId());
+ if (matcher.matches() && matcher.groupCount() == 1) {
+ uuId = matcher.group(1);
+ } else {
+ uuId = getObjectId();
+ }
+
+ StringBuffer strBuf = new StringBuffer();
+ strBuf.append(getNodeName());
+ strBuf.append("/");
+ strBuf.append(uuId);
+ strBuf.append("/");
+ strBuf.append(getProblem());
+ return strBuf.toString();
+ }
+
+ @Override
+ public String toString() {
+ return "ProblemNotificationXml [problem=" + problem + ", severity=" + severity + ", toString()="
+ + super.toString() + "]";
+ }
+
+ @Override
+ public String getEventType() {
+ return EVENTTYPE;
+ }
+}
diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/xml/WebSocketServiceClient.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/xml/WebSocketServiceClient.java
new file mode 100644
index 000000000..8cfd63d39
--- /dev/null
+++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/xml/WebSocketServiceClient.java
@@ -0,0 +1,31 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 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.impl.xml;
+
+/**
+ * Wrapper for forwarding websocket notifications to the websocket service, that is running as container.
+ * @author herbert
+ */
+public interface WebSocketServiceClient {
+
+ public <T extends MwtNotificationBase & GetEventType> void sendViaWebsockets(String nodeName, T notificationXml);
+
+}
diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/xml/WebSocketServiceClientImpl.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/xml/WebSocketServiceClientImpl.java
new file mode 100644
index 000000000..af1a32de3
--- /dev/null
+++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/xml/WebSocketServiceClientImpl.java
@@ -0,0 +1,38 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 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.impl.xml;
+
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.listener.ODLEventListener;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * WrapperMock class for web-socket notifications to the web-socket service.
+ */
+public class WebSocketServiceClientImpl implements WebSocketServiceClient {
+
+ private static final Logger LOG = LoggerFactory.getLogger(ODLEventListener.class);
+
+ public WebSocketServiceClientImpl() {
+ }
+
+ @Override
+ public <T extends MwtNotificationBase & GetEventType> void sendViaWebsockets(String nodeName, T notificationXml) {
+ LOG.info("Dummy to send websocket event {} for mountpoint {}", notificationXml.getClass().getSimpleName(), nodeName);
+ }
+}
diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/xml/WebSocketServiceClientImpl2.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/xml/WebSocketServiceClientImpl2.java
new file mode 100644
index 000000000..0cc83cf50
--- /dev/null
+++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/xml/WebSocketServiceClientImpl2.java
@@ -0,0 +1,68 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 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.impl.xml;
+
+import java.util.concurrent.Future;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.listener.ODLEventListener;
+import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.websocketmanager.rev150105.WebsocketEventInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.websocketmanager.rev150105.WebsocketEventOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.websocketmanager.rev150105.WebsocketmanagerService;
+import org.opendaylight.yangtools.yang.common.RpcResult;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Wrapper for forwarding web-socket notifications to the web-socket service, that is running as
+ * bundle.
+ */
+public class WebSocketServiceClientImpl2 implements WebSocketServiceClient {
+
+ private static final Logger LOG = LoggerFactory.getLogger(ODLEventListener.class);
+
+ private final WebsocketmanagerService websocketmanagerService;
+ private final XmlMapper xmlMapper;
+
+ /**
+ * Implementation of Websocket notification processor.
+ *
+ * @param rpcProviderRegistry to get MDSAL services.
+ */
+ public WebSocketServiceClientImpl2(RpcProviderRegistry rpcProviderRegistry) {
+ super();
+ this.websocketmanagerService = rpcProviderRegistry.getRpcService(WebsocketmanagerService.class);
+ this.xmlMapper = new XmlMapper();
+ }
+
+ @Override
+ public <T extends MwtNotificationBase & GetEventType> void sendViaWebsockets(String nodeName, T notificationXml) {
+ LOG.info("Send websocket event {} for mountpoint {}", notificationXml.getClass().getSimpleName(), nodeName);
+
+ try {
+ WebsocketEventInputBuilder wsBuilder = new WebsocketEventInputBuilder();
+ wsBuilder.setNodeName(nodeName);
+ wsBuilder.setEventType(notificationXml.getEventType());
+ wsBuilder.setXmlEvent(xmlMapper.getXmlString(notificationXml));
+ Future<RpcResult<WebsocketEventOutput>> result = websocketmanagerService.websocketEvent(wsBuilder.build());
+ LOG.info("Send websocket result: {}", result.get().getResult().getResponse());
+ } catch (Exception e) {
+ LOG.warn("Can not send websocket event {} for mountpoint {} {}", notificationXml.getClass().getSimpleName(),
+ nodeName, e.toString());
+ }
+ }
+}
diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/xml/XmlMapper.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/xml/XmlMapper.java
new file mode 100644
index 000000000..897795a0e
--- /dev/null
+++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/xml/XmlMapper.java
@@ -0,0 +1,49 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 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.impl.xml;
+
+import java.io.StringWriter;
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBException;
+import javax.xml.bind.Marshaller;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class XmlMapper {
+ private static final Logger LOG = LoggerFactory.getLogger(XmlMapper.class);
+
+ public String getXmlString(MwtNotificationBase base) {
+ String xml;
+ JAXBContext jaxbContext;
+ try {
+ jaxbContext = JAXBContext.newInstance(AttributeValueChangedNotificationXml.class,
+ ObjectCreationNotificationXml.class, ObjectDeletionNotificationXml.class,
+ ProblemNotificationXml.class);
+ Marshaller jaxbMarshaller = jaxbContext.createMarshaller();
+ jaxbMarshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
+
+ StringWriter stringWriter = new StringWriter();
+ jaxbMarshaller.marshal(base, stringWriter);
+ xml = stringWriter.toString();
+ } catch (JAXBException e) {
+ LOG.warn("Problem in marshalling xml file {}", e);
+ xml = null;
+ }
+ return xml;
+ }
+}
diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/index/impl/IndexConfigService.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/index/impl/IndexConfigService.java
new file mode 100644
index 000000000..25e18eb23
--- /dev/null
+++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/index/impl/IndexConfigService.java
@@ -0,0 +1,58 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 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.index.impl;
+
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.database.HtDatabaseClientAbstract;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.database.HtDatabaseNode;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.database.IndexClientBuilder;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Setup index mwtn in the database
+ * @author herbert
+ *
+ */
+public class IndexConfigService implements AutoCloseable {
+
+ private static final Logger LOG = LoggerFactory.getLogger(IndexConfigService.class);
+
+ /** Index name to be used */
+ private static final String INDEX = "config";
+ /** Location of configuration data **/
+ private static final String MODELDATA = "/elasticsearch/index/config";
+
+ private final HtDatabaseClientAbstract client;
+
+ // --- Construct and initialize
+
+ public IndexConfigService(HtDatabaseNode database) throws Exception {
+ LOG.info("Create {} start", this.getClass().getSimpleName());
+
+ IndexClientBuilder clientBuilder = IndexClientBuilder.getBuilder(INDEX).setModelDataDirectory(MODELDATA);
+ client = clientBuilder.create(database);
+ clientBuilder.close();
+ LOG.info("Create {} finished. DB Service sucessfully started.", this.getClass().getSimpleName());
+ }
+
+ @Override
+ public void close() throws Exception {
+ client.close();
+ }
+
+}
diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/index/impl/IndexMwtnService.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/index/impl/IndexMwtnService.java
new file mode 100644
index 000000000..4a9ac9881
--- /dev/null
+++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/index/impl/IndexMwtnService.java
@@ -0,0 +1,71 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 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.index.impl;
+
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.database.HtDatabaseClientAbstract;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.database.HtDatabaseNode;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.database.IndexClientBuilder;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Setup index mwtn in the database
+ * @author herbert
+ *
+ */
+public class IndexMwtnService implements AutoCloseable {
+
+ private static final Logger LOG = LoggerFactory.getLogger(IndexMwtnService.class);
+
+ /** Index name to be used */
+ public static final String INDEX = "mwtn";
+ /** Location of mapping data **/
+ private static final String MAPPING = "/elasticsearch/index/mwtn/mwtnMapping.json";
+ /** Location of configuration data **/
+ private static final String MODELDATA = "/elasticsearch/index/mwtn/modelDescription";
+
+ private final HtDatabaseClientAbstract client;
+
+ // --- Construct and initialize
+
+ public IndexMwtnService(HtDatabaseNode database) throws Exception {
+ LOG.info("Create {} start", this.getClass().getSimpleName());
+
+ IndexClientBuilder clientBuilder = IndexClientBuilder.getBuilder(INDEX)
+ .setMappingSettingJsonFileName(MAPPING)
+ .setModelDataDirectory(MODELDATA);
+ client = clientBuilder.create(database);
+ clientBuilder.close();
+ LOG.info("Create {} finished. DB Service sucessfully started.", this.getClass().getSimpleName());
+ }
+
+ /**
+ * Get client to be used in other services
+ * @return client
+ */
+ public HtDatabaseClientAbstract getClient() {
+ return client;
+ }
+
+
+
+ @Override
+ public void close() throws Exception {
+ client.close();
+ }
+}
diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/index/impl/IndexUpdateService.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/index/impl/IndexUpdateService.java
new file mode 100644
index 000000000..db567f28c
--- /dev/null
+++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/index/impl/IndexUpdateService.java
@@ -0,0 +1,111 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 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.index.impl;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.ScheduledFuture;
+import java.util.concurrent.TimeUnit;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.database.HtDatabaseNode;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.database.HtDatabaseUpdateFile;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.database.HtDatabaseWebAPIClient;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.database.HtDatabaseUpdateFile.EsUpdateObject;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.database.HtDatabaseUpdateFile.FileReadCallback;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class IndexUpdateService implements AutoCloseable {
+
+ private static final Logger LOG = LoggerFactory.getLogger(IndexUpdateService.class);
+
+ private static final String FILENAME = "etc/elasticsearch_update.zip";
+
+ private final HtDatabaseWebAPIClient webClient;
+
+ private final boolean autoremove=true;
+
+ @SuppressWarnings("unused")
+ private ScheduledFuture<?> taskHandle;
+ private final ScheduledExecutorService scheduler;
+ @SuppressWarnings("unused")
+ private final HtDatabaseNode database;
+
+ private final FileReadCallback onReadUpdateFile = new FileReadCallback()
+ {
+ @Override
+ public void read(EsUpdateObject obj,String filename) {
+ try {
+ IndexUpdateService.this.webClient.sendRequest(obj.Uri, obj.Method, obj.Body);
+ LOG.info("run database update file {}", filename);
+ } catch (IOException e) {
+ LOG.warn("problem for request {}", obj.Uri);
+ }
+ }
+
+ @Override
+ public void onerror(String filename,IOException e) {
+ LOG.warn("problem reading content file {} : {}", filename, e.getMessage());
+ }
+
+ };
+ private final Runnable checkForUpdateTask = () -> {
+ File f=new File(FILENAME);
+ if(f.exists())
+ {
+ LOG.debug("found update file {}", f.getAbsolutePath());
+ try {
+ HtDatabaseUpdateFile updateFile=new HtDatabaseUpdateFile(FILENAME);
+ if(updateFile.readFiles(onReadUpdateFile))
+ {
+ LOG.info("update successful");
+ }
+ updateFile.close();
+ if(IndexUpdateService.this.autoremove)
+ {
+ boolean res = f.delete();
+ LOG.debug("autodelete updatefile done {}", res);
+ }
+
+ } catch (IOException e) {
+ LOG.warn("problem with update file: {}", e.getMessage());
+ }
+ }
+ };
+
+
+
+ public IndexUpdateService(HtDatabaseNode database, String esNodeserverName, String esClusterName, String esNodeName) {
+ this.database = database;
+ this.webClient = new HtDatabaseWebAPIClient();
+ this.scheduler = Executors.newSingleThreadScheduledExecutor();
+ }
+ public void start()
+ {
+ this.taskHandle = this.scheduler.scheduleAtFixedRate(checkForUpdateTask, 0, 120, TimeUnit.SECONDS);
+ }
+ public void stop()
+ {
+ this.scheduler.shutdown();
+ }
+ @Override
+ public void close() throws Exception {
+ stop();
+ }
+}
diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/maintenance/MaintenanceRPCServiceAPI.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/maintenance/MaintenanceRPCServiceAPI.java
new file mode 100644
index 000000000..3687625a0
--- /dev/null
+++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/maintenance/MaintenanceRPCServiceAPI.java
@@ -0,0 +1,42 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 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.maintenance;
+
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.devicemanager.rev190109.GetMaintenanceModeInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.devicemanager.rev190109.GetMaintenanceModeOutputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.devicemanager.rev190109.GetRequiredNetworkElementKeysOutputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.devicemanager.rev190109.SetMaintenanceModeInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.devicemanager.rev190109.SetMaintenanceModeOutputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.devicemanager.rev190109.ShowRequiredNetworkElementInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.devicemanager.rev190109.ShowRequiredNetworkElementOutputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.devicemanager.rev190109.TestMaintenanceModeInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.devicemanager.rev190109.TestMaintenanceModeOutputBuilder;
+
+public interface MaintenanceRPCServiceAPI {
+
+ public GetRequiredNetworkElementKeysOutputBuilder getRequiredNetworkElementKeys();
+
+ public ShowRequiredNetworkElementOutputBuilder showRequiredNetworkElement(ShowRequiredNetworkElementInput input);
+
+ public GetMaintenanceModeOutputBuilder getMaintenanceMode(GetMaintenanceModeInput input);
+
+ public SetMaintenanceModeOutputBuilder setMaintenanceMode(SetMaintenanceModeInput input);
+
+ public TestMaintenanceModeOutputBuilder testMaintenanceMode(TestMaintenanceModeInput input);
+
+}
diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/maintenance/MaintenanceService.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/maintenance/MaintenanceService.java
new file mode 100644
index 000000000..e9aec4146
--- /dev/null
+++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/maintenance/MaintenanceService.java
@@ -0,0 +1,33 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 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.maintenance;
+
+public interface MaintenanceService {
+
+ /**
+ * Verify maintenance state of given object according to the filter settings.
+ * The object is specified by the criteria provided in the parameters.
+ * The data _id (uuid) is equal to the mountpointReference.
+ * @param mountpointReference used as reference, to query the data from database.
+ * @param objectIdRef first level id in onf core model, delivered by notification objectid
+ * @param problem problem name of device, delivered in problem notification
+ * @return boolean indication
+ */
+ boolean isONFObjectInMaintenance(String mountpointReference, String objectIdRef, String problem);
+
+}
diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/maintenance/database/types/EsMaintenanceFilter.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/maintenance/database/types/EsMaintenanceFilter.java
new file mode 100644
index 000000000..46b434217
--- /dev/null
+++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/maintenance/database/types/EsMaintenanceFilter.java
@@ -0,0 +1,227 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 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.maintenance.database.types;
+
+import com.fasterxml.jackson.annotation.JsonGetter;
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.fasterxml.jackson.annotation.JsonSetter;
+import java.time.Instant;
+import java.time.ZoneId;
+import java.time.ZonedDateTime;
+import java.time.format.DateTimeFormatter;
+import java.time.format.DateTimeParseException;
+import java.util.Collections;
+import java.util.Map;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.devicemanager.rev190109.maintenance.mode.g.Filter;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.devicemanager.rev190109.maintenance.mode.g.filter.Definition;
+import org.opendaylight.yangtools.yang.binding.Augmentation;
+import org.opendaylight.yangtools.yang.binding.DataContainer;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * One filter element to describe a maintenance status for an object referenced by definition.
+ * TODO: Merge Filter and ES driven implementation
+ */
+public class EsMaintenanceFilter implements Filter {
+
+ private static final Logger LOG = LoggerFactory.getLogger(EsMaintenanceFilter.class);
+
+ private static ZoneId EsMaintenanceFilterTimeZone = ZoneId.of("UTC");
+ //private static DateTimeFormatter FORMAT = DateTimeFormatter.ISO_DATE_TIME; // "1986-04-08T12:30:00"
+ private static DateTimeFormatter FORMAT = DateTimeFormatter.ISO_OFFSET_DATE_TIME; // 2011-12-03T10:15:30+01:00
+ private static ZonedDateTime EMPTYDATETIME = ZonedDateTime.ofInstant(Instant.EPOCH, EsMaintenanceFilterTimeZone);
+ private static String EMPTY = "";
+
+ //yang tools
+ @JsonIgnore
+ private final Map<java.lang.Class<? extends Augmentation<Filter>>, Augmentation<Filter>> augmentation = Collections.emptyMap();
+
+ @JsonIgnore
+ private ZonedDateTime start = EMPTYDATETIME;
+ @JsonIgnore
+ private ZonedDateTime end = EMPTYDATETIME;
+
+ private EsMaintenanceFilterDefinition definition = new EsMaintenanceFilterDefinition();
+ private String description = EMPTY;
+
+ // For jackson
+ public EsMaintenanceFilter() {
+ }
+
+ public EsMaintenanceFilter(Filter filter) {
+ setStartAsString(filter.getStartDate());
+ setEndAsString(filter.getEndDate());
+ description = filter.getDescription();
+ definition = new EsMaintenanceFilterDefinition(filter.getDefinition());
+ }
+
+ /*------
+ * start
+ */
+ public ZonedDateTime getStart() {
+ return start;
+ }
+ @JsonGetter("start")
+ public String getStartAsString() {
+ return toString(start);
+ }
+ public void setStart(ZonedDateTime start) {
+ this.start = start;
+ }
+ @JsonSetter("start")
+ public void setStartAsString(String startAsString) {
+ this.start = valueOf(startAsString);
+ }
+
+ /*------
+ * end
+ */
+ public ZonedDateTime getEnd() {
+ return end;
+ }
+ @JsonGetter("end")
+ public String getEndAsString() {
+ return toString(end);
+ }
+ public void setEnd(ZonedDateTime end) {
+ this.end = end;
+ }
+ @JsonSetter("end")
+ public void setEndAsString(String endAsString) {
+ this.end = valueOf(endAsString);
+ }
+
+ /*-----------------
+ * other parameters
+ */
+
+ public EsMaintenanceFilterDefinition getDefinition2() {
+ return definition;
+ }
+ public void setDefinition(EsMaintenanceFilterDefinition definition) {
+ this.definition = definition;
+ }
+ @Override
+ public String getDescription() {
+ return description;
+ }
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ /**
+ * Get the actual time in the Filter time zone.
+ * @return actual Time
+ */
+ public static ZonedDateTime getNow() {
+ return ZonedDateTime.now(EsMaintenanceFilterTimeZone);
+ }
+
+
+ /**
+ * Verify if the filter is active for an object
+ * @param now point of time to verify
+ * @return if the object is covered by filter and now within point of time
+ */
+ public boolean isInMaintenance(String objectIdRef, String problem, ZonedDateTime now) {
+ return definition.appliesToObjectReference(objectIdRef, problem) && isInPeriod(start, end, now);
+ }
+
+ @Override
+ public String toString() {
+ return "EsMaintenanceFilter [start=" + start + ", end=" + end + ", definition=" + definition + ", description="
+ + description + "]";
+ }
+
+ /*---------------------------------------------
+ * YANG tools related functions for interface
+ */
+
+ @Override
+ public Class<? extends DataContainer> getImplementedInterface() {
+ return Filter.class;
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public <E extends Augmentation<Filter>> E augmentation(Class<E> augmentationType) {
+ return (E) augmentation.get(augmentationType);
+ }
+
+ @Override
+ public Definition getDefinition() {
+ return definition;
+ }
+
+ @Override
+ public String getStartDate() {
+ return getStartAsString();
+ }
+
+ @Override
+ public String getEndDate() {
+ return getEndAsString();
+ }
+
+ /*---------------------------------------------
+ * private static helper functions to verify
+ */
+
+ /**
+ * Compare the if probe is within the range of start and end.
+ * @param start of range
+ * @param end of range
+ * @param probe time to verify
+ * @return boolean result true if (start <= probe <= end)
+ */
+ public static boolean isInPeriod(ZonedDateTime start, ZonedDateTime end, ZonedDateTime probe) {
+ return start.compareTo(end) < 0 && start.compareTo(probe) <= 0 && end.compareTo(probe) >= 0;
+ }
+
+ /**
+ * Convert to time value to String
+ * @param ldt ZonedDateTime format
+ * @return String output
+ */
+ public static String toString(ZonedDateTime ldt) {
+ if(ldt==null) {
+ return "";
+ }
+ return ldt.format(FORMAT);
+ }
+
+ /**
+ * Convert String to time value
+ * @param zoneTimeString with time
+ * @return ZonedDateTime string
+ */
+ public static ZonedDateTime valueOf(String zoneTimeString) {
+ if (zoneTimeString == null || zoneTimeString.isEmpty()) {
+ LOG.warn("Null or empty zoneTimeString");
+ return EMPTYDATETIME;
+ }
+ try {
+ return ZonedDateTime.parse(zoneTimeString, FORMAT);
+ } catch (DateTimeParseException e) {
+ LOG.warn("Can not parse zoneTimeString '{}'",zoneTimeString);
+ return EMPTYDATETIME;
+ }
+ }
+
+}
diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/maintenance/database/types/EsMaintenanceFilterDefinition.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/maintenance/database/types/EsMaintenanceFilterDefinition.java
new file mode 100644
index 000000000..c548a98e2
--- /dev/null
+++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/maintenance/database/types/EsMaintenanceFilterDefinition.java
@@ -0,0 +1,97 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 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.maintenance.database.types;
+
+import java.util.Collections;
+import java.util.Map;
+import org.eclipse.jdt.annotation.Nullable;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.devicemanager.rev190109.maintenance.mode.g.filter.Definition;
+import org.opendaylight.yangtools.yang.binding.Augmentation;
+import org.opendaylight.yangtools.yang.binding.DataContainer;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+public class EsMaintenanceFilterDefinition implements Definition {
+
+ private static final Logger LOG = LoggerFactory.getLogger(EsMaintenanceFilterDefinition.class);
+ private static final String ALL = "";
+
+ //yang tools
+ @JsonIgnore
+ private final Map<java.lang.Class<? extends Augmentation<Definition>>, Augmentation<Definition>> augmentation = Collections.emptyMap();
+
+ private String objectIdRef = ALL;
+ private String problem = ALL;
+
+ public EsMaintenanceFilterDefinition() {
+ }
+
+ public EsMaintenanceFilterDefinition(Definition definition) {
+ objectIdRef = definition.getObjectIdRef();
+ problem = definition.getProblem();
+ }
+
+ @Override
+ @JsonProperty("object-id-ref")
+ public String getObjectIdRef() {
+ return objectIdRef;
+ }
+
+ @JsonProperty("object-id-ref")
+ public void setObjectIdRef(String objectIdRef) {
+ this.objectIdRef = objectIdRef == null ? ALL : objectIdRef;
+ }
+
+ @Override
+ @JsonProperty("problem")
+ public String getProblem() {
+ return problem;
+ }
+
+ @JsonProperty("problem")
+ public void setProblem(String pProblem) {
+ this.problem = pProblem == null ? ALL : pProblem;
+ }
+
+ public boolean appliesToObjectReference(String pObjectIdRef, String pProblem) {
+ boolean res = (pObjectIdRef.isEmpty() || pObjectIdRef.contains(pObjectIdRef)) && (pProblem.isEmpty() || pProblem.contains(pProblem));
+ LOG.debug("Check result applies {}: {} {} against: {}",res, pObjectIdRef, pProblem, this);
+ return res;
+ }
+
+ @Override
+ public String toString() {
+ return "EsMaintenanceFilterDefinition [objectIdRef=" + objectIdRef + ", problem=" + problem + "]";
+ }
+
+ @Override
+ public Class<? extends DataContainer> getImplementedInterface() {
+ return Definition.class;
+ }
+
+ @Override
+ public <E extends Augmentation<Definition>> @Nullable E augmentation(Class<E> augmentationType) {
+ return null;
+ }
+
+
+
+}
diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/maintenance/database/types/EsMaintenanceMode.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/maintenance/database/types/EsMaintenanceMode.java
new file mode 100644
index 000000000..456c146b1
--- /dev/null
+++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/maintenance/database/types/EsMaintenanceMode.java
@@ -0,0 +1,181 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 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.maintenance.database.types;
+
+import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
+import java.time.ZonedDateTime;
+import java.util.ArrayList;
+import java.util.List;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.database.EsObject;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.devicemanager.rev190109.MaintenanceModeG;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.devicemanager.rev190109.maintenance.mode.g.Filter;
+import org.opendaylight.yangtools.yang.binding.DataContainer;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Database record entry for maintenance mode, as specified. Used for read operations Structure: _id
+ * : Contains the mountpoint name, must be specified before read. startTime: String representing
+ * Java LocalDateTime with absolute UTC Time endTime: String representing Java LocalDateTime with
+ * absolute UTC Time JSON Structure example { "_index": "mwtn_v1", "_type": "maintenancemode",
+ * "_id": "LumpiWave-Z3", "_score": 1, "_source": { "node": "LumpiWave-Z3", "filter": [ {
+ * "definition": { "object-id-ref": "", "problem": "" }, "description": "", "start":
+ * "2018-01-01T10:00+00:00", "end": "2018-10-10T10:00+00:00" }, { "definition": { "object-id-ref":
+ * "network-element", "problem": "power-alarm" }, "description": "", "start":
+ * "2018-01-01T10:00+00:00", "end": "2018-10-10T10:00+00:00" } ] } },
+ *
+ * Two filters for all element and one for network-element power-alarm
+ */
+
+public class EsMaintenanceMode extends EsObject implements MaintenanceModeG {
+
+ @SuppressWarnings("unused")
+ private static final Logger LOG = LoggerFactory.getLogger(EsMaintenanceMode.class);
+
+ public static final String ESDATATYPENAME = "maintenancemode";
+
+ private static final EsMaintenanceMode NOT_IN_MAINTENANCE = new EsMaintenanceMode("notinmaintenance");
+
+ private String node;
+
+ @JsonDeserialize(as = ArrayList.class)
+ private List<EsMaintenanceFilter> filter;
+
+ private boolean active;
+
+ // for jackson
+ public EsMaintenanceMode() {
+ this.active = false;
+ this.filter = new ArrayList<>();
+ }
+
+ public EsMaintenanceMode(String mountpoint) {
+ this();
+ this.setEsId(mountpoint);
+ this.node = mountpoint;
+ }
+
+ public EsMaintenanceMode(MaintenanceModeG maintenanceModeG) {
+ this.setEsId(maintenanceModeG.getMountpointName());
+ this.node = maintenanceModeG.getNodeName();
+ List<Filter> filters = maintenanceModeG.getFilter();
+ if (filter != null) {
+ for (Filter filterElement : filters) {
+ this.filter.add(new EsMaintenanceFilter(filterElement));
+ }
+ }
+ }
+
+
+ public String getNode() {
+ return node;
+ }
+
+ public void setNode(String node) {
+ this.node = node;
+ }
+
+ public List<EsMaintenanceFilter> getFilter2() {
+ return filter;
+ }
+
+ public void setActive(boolean a) {
+ this.active = a;
+ }
+
+ /**
+ * Replace list with new one.
+ *
+ * @param filterList new filter list
+ */
+ public void setFilter(List<EsMaintenanceFilter> filterList) {
+ this.filter = filterList;
+ }
+
+ /**
+ * Add one filter to internal list
+ *
+ * @param pFilter the Filter
+ */
+ public void addFilter(EsMaintenanceFilter pFilter) {
+ this.filter.add(pFilter);
+ }
+
+ /**
+ * Verify maintenance status
+ *
+ * @param objectIdRef NETCONF object id
+ * @param problem name that was provided
+ * @param now time to verify with
+ * @return true if in maintenance status
+ */
+ public boolean isONFObjectInMaintenance(String objectIdRef, String problem, ZonedDateTime now) {
+ if (!active) {
+ return false;
+ }
+ boolean res = false;
+ if (this != NOT_IN_MAINTENANCE) {
+ for (EsMaintenanceFilter oneFilter : filter) {
+ if (oneFilter.isInMaintenance(objectIdRef, problem, now)) {
+ res = true;
+ break;
+ }
+ }
+ }
+ return res;
+ }
+
+ /** Shortcut **/
+ public boolean isONFObjectInMaintenance(String objectIdRef, String problem) {
+ return isONFObjectInMaintenance(objectIdRef, problem, EsMaintenanceFilter.getNow());
+ }
+
+ @Override
+ public String toString() {
+ return "EsMaintenanceMode [node=" + node + ", filter=" + filter + ", active=" + active + "]";
+ }
+
+ public static EsMaintenanceMode getNotInMaintenance() {
+ return NOT_IN_MAINTENANCE;
+ }
+
+ /*---------------------------------------------
+ * yang tools related functions
+ */
+
+ @Override
+ public Class<? extends DataContainer> getImplementedInterface() {
+ return MaintenanceModeG.class;
+ }
+
+ @Override
+ public String getMountpointName() {
+ return this.getEsId();
+ }
+
+ @Override
+ public String getNodeName() {
+ return node;
+ }
+
+ @Override
+ public List<Filter> getFilter() {
+ return filter.isEmpty() ? null : new ArrayList<>(filter);
+ }
+
+}
diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/maintenance/impl/MaintenanceServiceImpl.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/maintenance/impl/MaintenanceServiceImpl.java
new file mode 100644
index 000000000..1db3433e2
--- /dev/null
+++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/maintenance/impl/MaintenanceServiceImpl.java
@@ -0,0 +1,269 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 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.maintenance.impl;
+
+import java.time.ZonedDateTime;
+import java.util.ArrayList;
+import java.util.List;
+import javax.annotation.Nonnull;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.database.EsBaseRequireNetworkElement;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.database.HtDataBaseReaderAndWriter;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.database.HtDatabaseClientAbstract;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.database.HtDatabaseNode;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.index.impl.IndexMwtnService;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.maintenance.MaintenanceRPCServiceAPI;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.maintenance.MaintenanceService;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.maintenance.database.types.EsMaintenanceFilter;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.maintenance.database.types.EsMaintenanceFilterDefinition;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.maintenance.database.types.EsMaintenanceMode;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.devicemanager.rev190109.GetMaintenanceModeInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.devicemanager.rev190109.GetMaintenanceModeOutputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.devicemanager.rev190109.GetRequiredNetworkElementKeysOutputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.devicemanager.rev190109.SetMaintenanceModeInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.devicemanager.rev190109.SetMaintenanceModeOutputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.devicemanager.rev190109.ShowRequiredNetworkElementInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.devicemanager.rev190109.ShowRequiredNetworkElementOutputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.devicemanager.rev190109.TestMaintenanceModeInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.devicemanager.rev190109.TestMaintenanceModeOutputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.devicemanager.rev190109.show.required.network.element.output.RequiredNetworkElementBuilder;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class MaintenanceServiceImpl implements MaintenanceService, MaintenanceRPCServiceAPI, AutoCloseable {
+
+ private static final Logger LOG = LoggerFactory.getLogger(MaintenanceServiceImpl.class);
+
+ /**
+ * Use the Client Index
+ */
+ private HtDataBaseReaderAndWriter<EsMaintenanceMode> maintenanceRW;
+ private HtDataBaseReaderAndWriter<EsBaseRequireNetworkElement> requiredNeRW;
+
+ public MaintenanceServiceImpl(HtDatabaseClientAbstract client) {
+
+ LOG.info("Create {} start", MaintenanceServiceImpl.class);
+
+ try {
+ // Create control structure
+ maintenanceRW = new HtDataBaseReaderAndWriter<>(client, EsMaintenanceMode.ESDATATYPENAME, EsMaintenanceMode.class);
+ requiredNeRW = new HtDataBaseReaderAndWriter<>(client, EsBaseRequireNetworkElement.ESDATATYPENAME, EsBaseRequireNetworkElement.class);
+
+ } catch (Exception e) {
+ LOG.error("Can not start database client. Exception: {}", e.getMessage());
+ }
+ LOG.info("Create {} finished. DB Service {} started.", MaintenanceServiceImpl.class, client != null ? "sucessfully" : "not" );
+
+ }
+
+ public MaintenanceServiceImpl(HtDatabaseNode database) {
+ this(getDatabaseClient(database));
+ }
+
+ private static HtDatabaseClientAbstract getDatabaseClient(HtDatabaseNode database) {
+ return new HtDatabaseClientAbstract(IndexMwtnService.INDEX,database);
+ }
+
+ /**
+ * Get existing object for mountpoint to manage maintenance mode
+ * @return Object with configuration
+ */
+ private @Nonnull EsMaintenanceMode getMaintenance(String mountpointId)
+ {
+ EsMaintenanceMode deviceMaintenanceMode = null;
+ if (maintenanceRW != null) {
+ deviceMaintenanceMode = maintenanceRW.doRead(mountpointId);
+ }
+
+ return deviceMaintenanceMode == null ? EsMaintenanceMode.getNotInMaintenance() : deviceMaintenanceMode;
+ }
+ /**
+ * Check in required ne if entry exists for mountpointNodeName
+ * @param mountPointNodeName
+ * @return
+ */
+ private boolean isRequireNe(String mountPointNodeName) {
+ EsBaseRequireNetworkElement ne=null;
+ if( requiredNeRW!=null)
+ {
+ LOG.debug("searching for entry in required-networkelement for "+mountPointNodeName);
+ ne = requiredNeRW.doRead(mountPointNodeName);
+ } else {
+ LOG.warn("cannot read db. no db reader writer initialized");
+ }
+ return ne!=null;
+ }
+ public EsMaintenanceMode createIfNotExists(String mountpointId)
+ {
+ EsMaintenanceMode deviceMaintenanceMode = null;
+ if (maintenanceRW != null)
+ {
+ deviceMaintenanceMode = maintenanceRW.doRead(mountpointId);
+ if(deviceMaintenanceMode==null)
+ {
+ LOG.debug("creating empty maintenance object in database");
+ deviceMaintenanceMode=new EsMaintenanceMode(mountpointId);
+ EsMaintenanceFilter filter = new EsMaintenanceFilter();
+ filter.setDescription("");
+ filter.setStart(null);
+ filter.setEnd(null);
+ EsMaintenanceFilterDefinition definition=new EsMaintenanceFilterDefinition();
+ definition.setObjectIdRef("");
+ definition.setProblem("");
+ filter.setDefinition(definition);
+ deviceMaintenanceMode.addFilter(filter );
+ maintenanceRW.doWrite(deviceMaintenanceMode);
+ } else {
+ LOG.debug("maintenance object already exists in database");
+ }
+ } else {
+ LOG.warn("cannot create maintenance obj. db reader/writer is null");
+ }
+
+ return deviceMaintenanceMode;
+ }
+ public void deleteIfNotRequired(String mountPointNodeName) {
+
+ if(!this.isRequireNe(mountPointNodeName))
+ {
+ EsMaintenanceMode deviceMaintenanceMode = new EsMaintenanceMode(mountPointNodeName);
+ if (maintenanceRW != null)
+ {
+ LOG.debug("removing maintenance object in database for "+mountPointNodeName);
+ maintenanceRW.doRemove(deviceMaintenanceMode);
+ } else {
+ LOG.warn("cannot create maintenance obj. db reader/writer is null");
+ }
+ }
+
+ }
+
+
+
+ /*-------------------------------------------------
+ * Interface AutoClosable
+ */
+
+ @Override
+ public void close() throws Exception {
+ }
+
+ /*-------------------------------------------------
+ * Interface MaintenanceRPCServiceAPI
+ */
+
+ @Override
+ public GetRequiredNetworkElementKeysOutputBuilder getRequiredNetworkElementKeys() {
+ GetRequiredNetworkElementKeysOutputBuilder outputBuilder = new GetRequiredNetworkElementKeysOutputBuilder();
+ List<EsMaintenanceMode> all = maintenanceRW != null ? maintenanceRW.doReadAll() : new ArrayList<>();
+ List<String> mountpointList = new ArrayList<>();
+ for (EsMaintenanceMode oneOfAll : all) {
+ mountpointList.add(oneOfAll.getEsId());
+
+ }
+ outputBuilder.setMountpointNames(mountpointList);
+ return outputBuilder;
+ }
+
+ @Override
+ public ShowRequiredNetworkElementOutputBuilder showRequiredNetworkElement(ShowRequiredNetworkElementInput input) {
+ ShowRequiredNetworkElementOutputBuilder outputBuilder = new ShowRequiredNetworkElementOutputBuilder();
+ EsMaintenanceMode maintenanceMode = new EsMaintenanceMode(input.getMountpointName());
+ if (maintenanceRW != null) {
+ maintenanceMode = maintenanceRW.doRead(maintenanceMode);
+ }
+ if (maintenanceMode != null) {
+ RequiredNetworkElementBuilder valueBuilder = new RequiredNetworkElementBuilder();
+
+ valueBuilder.setMountpointName(maintenanceMode.getNode());
+ valueBuilder.setStatus(String.valueOf(maintenanceMode.isONFObjectInMaintenance("","")));
+ valueBuilder.setDescription("Pretty description here");
+ outputBuilder.setRequiredNetworkElement(valueBuilder.build());
+ } else {
+ LOG.warn("No info in database for {}",input.getMountpointName());
+ }
+ return outputBuilder;
+ }
+
+ @Override
+ public GetMaintenanceModeOutputBuilder getMaintenanceMode(GetMaintenanceModeInput input) {
+ EsMaintenanceMode maintenanceMode = null;
+ GetMaintenanceModeOutputBuilder outputBuilder;
+ if (maintenanceRW != null) {
+ maintenanceMode = maintenanceRW.doRead(input.getMountpointName());
+ }
+ if (maintenanceMode != null) {
+ outputBuilder = new GetMaintenanceModeOutputBuilder(maintenanceMode);
+ } else {
+ throw new IllegalArgumentException("No info in database for "+input.getMountpointName());
+ }
+ return outputBuilder;
+ }
+
+ @Override
+ public SetMaintenanceModeOutputBuilder setMaintenanceMode(SetMaintenanceModeInput input) {
+
+ SetMaintenanceModeOutputBuilder outputBuilder = new SetMaintenanceModeOutputBuilder();
+ if (maintenanceRW != null) {
+ EsMaintenanceMode m = new EsMaintenanceMode(input);
+ if (maintenanceRW.doWrite(m) == null) {
+ throw new IllegalArgumentException("Problem writing to database: "+input.getMountpointName());
+ }
+ outputBuilder = new SetMaintenanceModeOutputBuilder(m);
+ LOG.info("Wrote maintenance object {}", m.toString());
+ }
+ return outputBuilder;
+ }
+
+ @Override
+ public TestMaintenanceModeOutputBuilder testMaintenanceMode(TestMaintenanceModeInput input) {
+
+ StringBuffer resultString = new StringBuffer();
+
+ EsMaintenanceMode maintenanceMode = getMaintenance(input.getMountpointName());
+
+ TestMaintenanceModeOutputBuilder outputBuilder = new TestMaintenanceModeOutputBuilder(maintenanceMode);
+
+ ZonedDateTime now = EsMaintenanceFilter.valueOf(input.getTestDate());
+
+ resultString.append("In database table: ");
+ resultString.append(!(EsMaintenanceMode.getNotInMaintenance() == maintenanceMode));
+ resultString.append(" Maintenance active: ");
+ resultString.append(maintenanceMode.isONFObjectInMaintenance(input.getObjectIdRef(), input.getProblemName(), now));
+ resultString.append(" at Timestamp: ");
+ resultString.append(now);
+
+ outputBuilder.setResultString(resultString.toString());
+
+ return outputBuilder;
+ }
+
+ /*-------------------------------------------------
+ * Interface MaintenaceService
+ */
+
+ @Override
+ public boolean isONFObjectInMaintenance(String mountpointReference, String objectIdRef, String problem) {
+ EsMaintenanceMode maintenanceMode = getMaintenance(mountpointReference);
+ boolean res = maintenanceMode.isONFObjectInMaintenance(objectIdRef, problem);
+ LOG.debug("inMaintenance={} for mountpoint/id/problem:{} {} {} Definition: {}",res, mountpointReference, objectIdRef, problem, this );
+ return res;
+ }
+
+
+
+}
diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/performancemanager/impl/PerformanceManagerImpl.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/performancemanager/impl/PerformanceManagerImpl.java
new file mode 100644
index 000000000..b4c5abd7d
--- /dev/null
+++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/performancemanager/impl/PerformanceManagerImpl.java
@@ -0,0 +1,72 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 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.performancemanager.impl;
+
+import javax.annotation.Nullable;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.netconf.ONFCoreNetworkElementRepresentation;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.performancemanager.impl.database.service.MicrowaveHistoricalPerformanceWriterService;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class PerformanceManagerImpl implements AutoCloseable {
+
+ private static final Logger LOG = LoggerFactory.getLogger(PerformanceManagerImpl.class);
+
+ private @Nullable PerformanceManagerTask task;
+
+ public PerformanceManagerImpl(long seconds, MicrowaveHistoricalPerformanceWriterService databaseService) {
+
+ LOG.info("Construct begin {} with {} Seconds",PerformanceManagerImpl.class.getSimpleName(), seconds);
+
+ if (MicrowaveHistoricalPerformanceWriterService.isAvailable(databaseService)) {
+
+ LOG.info("Do start of PM task");
+ task = new PerformanceManagerTask(seconds, databaseService);
+ task.start();
+ LOG.info("PM task scheduled");
+
+ } else {
+ LOG.info("Database not available. Do not start PM task");
+ }
+
+ LOG.info("Construct end {}",PerformanceManagerImpl.class.getSimpleName());
+ }
+
+ @Override
+ public void close() {
+ LOG.info("Close {}", PerformanceManagerImpl.class.getSimpleName());
+ if (task != null) {
+ task.stop();
+ }
+ }
+
+ public void registration(String mountPointNodeName, ONFCoreNetworkElementRepresentation ne) {
+ LOG.debug("Register {}",mountPointNodeName);
+ if (task != null) {
+ task.registration(mountPointNodeName, ne);
+ }
+ }
+
+ public void deRegistration(String mountPointNodeName) {
+ LOG.debug("Deregister {}",mountPointNodeName);
+ if (task != null) {
+ task.deRegistration(mountPointNodeName);
+ }
+ }
+
+}
diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/performancemanager/impl/PerformanceManagerTask.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/performancemanager/impl/PerformanceManagerTask.java
new file mode 100644
index 000000000..ef2a0b8db
--- /dev/null
+++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/performancemanager/impl/PerformanceManagerTask.java
@@ -0,0 +1,238 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 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.performancemanager.impl;
+
+import java.util.Iterator;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.ScheduledFuture;
+import java.util.concurrent.TimeUnit;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.netconf.ONFCoreNetworkElementRepresentation;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.netconf.container.AllPm;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.performancemanager.impl.database.service.MicrowaveHistoricalPerformanceWriterService;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class PerformanceManagerTask implements Runnable {
+
+ private static final Logger LOG = LoggerFactory.getLogger(PerformanceManagerTask.class);
+ private static final String LOGMARKER = "PMTick";
+
+ private int tickCounter = 0;
+
+ private final ConcurrentHashMap<String, ONFCoreNetworkElementRepresentation> queue = new ConcurrentHashMap<>();
+ private final MicrowaveHistoricalPerformanceWriterService databaseService;
+ private final ScheduledExecutorService scheduler;
+ private final long seconds;
+
+ private ScheduledFuture<?> taskHandle = null;
+ private Iterator<ONFCoreNetworkElementRepresentation> neIterator = null;
+ private ONFCoreNetworkElementRepresentation actualNE = null;
+
+ /**
+ * Constructor of PM Task
+ * @param seconds seconds to call PM Task
+ * @param databaseService DB Service to load PM data to
+ */
+
+ public PerformanceManagerTask(long seconds, MicrowaveHistoricalPerformanceWriterService databaseService) {
+
+ LOG.debug("Init task {}", PerformanceManagerTask.class.getSimpleName());
+ this.seconds = seconds;
+ this.databaseService = databaseService;
+ this.scheduler = Executors.newSingleThreadScheduledExecutor();
+
+ }
+
+ /**
+ * Start PM Task
+ */
+ public void start() {
+ LOG.info("PM task created");
+ taskHandle = this.scheduler.scheduleAtFixedRate(this, 0, seconds, TimeUnit.SECONDS);
+ LOG.info("PM task scheduled");
+ }
+
+ /**
+ * Stop everything
+ */
+ public void stop() {
+ LOG.info("Stop {}", PerformanceManagerImpl.class.getSimpleName());
+ if (taskHandle != null) {
+ taskHandle.cancel(true);
+ try {
+ scheduler.awaitTermination(10, TimeUnit.SECONDS);
+ } catch (InterruptedException e) {
+ LOG.debug("Schdule stopped.",e);
+ // Restore interrupted state...
+ Thread.currentThread().interrupt();
+ }
+ }
+ }
+
+ /**
+ * Add NE/Mountpoint to PM Processig
+ * @param mountPointNodeName to be added
+ * @param ne that is connected to the mountpoint
+ */
+ public void registration(String mountPointNodeName, ONFCoreNetworkElementRepresentation ne) {
+ queue.put(mountPointNodeName, ne);
+ }
+
+ /**
+ * Remove mountpoint/NE from PM process
+ * @param mountPointNodeName that has to be removed
+ */
+ public void deRegistration(String mountPointNodeName) {
+ LOG.debug("Deregister {}",mountPointNodeName);
+ ONFCoreNetworkElementRepresentation removedNE = queue.remove(mountPointNodeName);
+
+ if ( removedNE == null) {
+ LOG.warn("Couldn't delete {}",mountPointNodeName);
+ }
+ }
+
+
+ /*--------------------------------------------------------------
+ * Task to read PM data from NE
+ */
+
+ /**
+ * Task runner to read all performance data from Network Elements.
+ * Catch exceptions to make sure, that the Task is not stopped.
+ */
+ @Override
+ public void run() {
+
+ LOG.debug("{} start {} Start with mountpoint {}",LOGMARKER, tickCounter, actualNE == null ? "No NE" : actualNE.getMountPointNodeName());
+
+ //Proceed to next NE/Interface
+ getNextInterface();
+
+ LOG.debug("{} {} Next interface to handle {}", LOGMARKER, tickCounter,
+ actualNE == null ? "No NE/IF" : actualNE.getMountPointNodeName() + " " + actualNE.pmStatusToString());
+
+ if (actualNE != null) {
+ try {
+ LOG.debug("{} Start to read PM from NE ({})", LOGMARKER, tickCounter);
+ AllPm allPm = actualNE.getHistoricalPM();
+ LOG.debug("{} {} Got PM list. Start write to DB", LOGMARKER, tickCounter);
+ databaseService.writePM(allPm);
+ LOG.debug("{} {} PM List end.", LOGMARKER, tickCounter);
+ } catch (Exception e) {
+ LOG.warn("{} {} PM read/write failed. Write log entry {}", LOGMARKER, tickCounter, e);
+ String msg = e.getMessage();
+ if (msg == null || msg.isEmpty()) {
+ if (e.getCause() != null) {
+ msg = e.getCause().toString();
+ }
+ if (msg == null || msg.isEmpty()){
+ msg = "No message or cause";
+ }
+ }
+ databaseService.writePMLog(actualNE.getMountPointNodeName(), actualNE.pmStatusToString(), msg);
+ }
+ }
+
+ LOG.debug("{} end {}",LOGMARKER, tickCounter);
+ tickCounter++;
+ }
+
+ /**
+ * Reset queue to start from beginning
+ */
+ private void resetQueue() {
+ actualNE = null;
+ neIterator = null;
+ }
+
+ /**
+ * Get then next interface in the list.
+ * First try to find a next on the actual NE.
+ * If not available search next interface at a NE
+ * Special Situations to handle: Empty queue, NEs, but no interfaces
+ */
+ private void getNextInterface() {
+ boolean started = false;
+ int loopCounter = 0;
+
+ LOG.debug("{} {} getNextInterface enter. Queue size {} ", LOGMARKER, tickCounter, queue.size());
+
+ if (actualNE != null && !queue.containsValue(actualNE)) {
+ LOG.debug("{} {} NE Removed duringprocessing A",LOGMARKER, tickCounter);
+ resetQueue();
+ }
+
+ while (true) {
+
+ if (loopCounter++ >= 1000) {
+ LOG.error("{} {} Problem in PM iteration. endless condition reached", LOGMARKER, tickCounter);
+ resetQueue();
+ break;
+ }
+
+ LOG.debug("{} {} Loop ne {}:neiterator {}:Interfaceiterator:{} Loop:{}",
+ LOGMARKER,
+ tickCounter,
+ actualNE == null? "null" : actualNE.getMountPointNodeName(),
+ neIterator == null ? "null" : neIterator.hasNext(),
+ actualNE == null ? "null" : actualNE.hasNext(),
+ loopCounter);
+
+ if (actualNE != null && actualNE.hasNext()) {
+ // Yes, there is an interface, deliver back
+ LOG.debug("{} {} getNextInterface yes A",LOGMARKER, tickCounter);
+ actualNE.next();
+ break;
+
+ } else {
+ // No element in neInterfaceInterator .. get next NE and try
+ if (neIterator != null && neIterator.hasNext()) {
+ // Set a new NE
+ LOG.debug("{} {} Next NE A",LOGMARKER, tickCounter);
+ actualNE = neIterator.next();
+ actualNE.resetPMIterator();
+
+ } else {
+ // Goto start condition 1) first entry 2) end of queue reached
+ LOG.debug("{} {} Reset",LOGMARKER, tickCounter);
+ resetQueue();
+
+ if (queue.isEmpty()) {
+ LOG.debug("{} {} no nextInterfac. queue empty",LOGMARKER, tickCounter);
+ break;
+ } else if (!started){
+ LOG.debug("{} {} getNextInterface start condition. Get interator.",LOGMARKER, tickCounter);
+ neIterator = queue.values().iterator();
+ started = true;
+ } else {
+ LOG.debug("{} {} no nextInterface",LOGMARKER, tickCounter);
+ break;
+ }
+ }
+ }
+ } //while
+
+ if (actualNE != null && !queue.containsValue(actualNE)) {
+ LOG.debug("{} {} NE Removed duringprocessing B",LOGMARKER, tickCounter);
+ resetQueue();
+ }
+
+ }
+}
diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/performancemanager/impl/database/service/MicrowaveHistoricalPerformanceWriterService.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/performancemanager/impl/database/service/MicrowaveHistoricalPerformanceWriterService.java
new file mode 100644
index 000000000..4782f3305
--- /dev/null
+++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/performancemanager/impl/database/service/MicrowaveHistoricalPerformanceWriterService.java
@@ -0,0 +1,104 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 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.performancemanager.impl.database.service;
+
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.database.HtDataBaseReaderAndWriter;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.database.HtDatabaseClientAbstract;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.database.HtDatabaseNode;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.database.IndexClientBuilder;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.netconf.container.AllPm;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.netconf.util.NetconfTimeStamp;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.performancemanager.impl.database.types.EsHistoricalPerformance15Minutes;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.performancemanager.impl.database.types.EsHistoricalPerformance24Hours;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.performancemanager.impl.database.types.EsHistoricalPerformanceLogEntry;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class MicrowaveHistoricalPerformanceWriterService {
+
+ private static final Logger LOG = LoggerFactory.getLogger(MicrowaveHistoricalPerformanceWriterService.class);
+ private static final String INDEX = "sdnperformance";
+ private static final String MAPPING = "/elasticsearch/index/sdnperformance/sdnperformanceMapping.json";
+ private static final NetconfTimeStamp NETCONFTIME_CONVERTER = NetconfTimeStamp.getConverter();
+
+
+ private HtDatabaseClientAbstract client;
+ private HtDataBaseReaderAndWriter<EsHistoricalPerformance15Minutes> historicalPerformance15mRW;
+ private HtDataBaseReaderAndWriter<EsHistoricalPerformance24Hours> historicalPerformance24hRW;
+ private HtDataBaseReaderAndWriter<EsHistoricalPerformanceLogEntry> historicalPerformanceLogRW;
+
+ public MicrowaveHistoricalPerformanceWriterService(HtDatabaseNode database) {
+
+ LOG.info("Create {} start", MicrowaveHistoricalPerformanceWriterService.class);
+
+ try {
+
+ IndexClientBuilder clientBuilder =
+ IndexClientBuilder.getBuilder(INDEX).setMappingSettingJsonFileName(MAPPING);
+ client = clientBuilder.create(database);
+ clientBuilder.close();
+
+ historicalPerformance15mRW = new HtDataBaseReaderAndWriter<>(client,
+ EsHistoricalPerformance15Minutes.ESDATATYPENAME, EsHistoricalPerformance15Minutes.class);
+ historicalPerformance24hRW = new HtDataBaseReaderAndWriter<>(client,
+ EsHistoricalPerformance24Hours.ESDATATYPENAME, EsHistoricalPerformance24Hours.class);
+ historicalPerformanceLogRW = new HtDataBaseReaderAndWriter<>(client,
+ EsHistoricalPerformanceLogEntry.ESDATATYPENAME, EsHistoricalPerformanceLogEntry.class);
+
+ } catch (Exception e) {
+ client = null;
+ LOG.error("Can not start database client. Exception: {}", e.getMessage());
+ }
+
+ LOG.info("Create {} finished. DB Service {} started.", MicrowaveHistoricalPerformanceWriterService.class,
+ client != null ? "sucessfully" : "not");
+ }
+
+
+ public void writePM(AllPm pm) {
+
+ LOG.debug("Write {} pm records", pm.size());
+
+ LOG.debug("Write 15m write to DB");
+ historicalPerformance15mRW.doWrite(pm.getPm15());
+ LOG.debug("Write 15m done, Write 24h write to DB");
+ historicalPerformance24hRW.doWrite(pm.getPm24());
+ LOG.debug("Write 24h done");
+
+ }
+
+ public void writePMLog(String mountpointName, String layerProtocolName, String msg) {
+
+ LOG.debug("Write PM Log: {}", msg);
+ EsHistoricalPerformanceLogEntry logEntry = new EsHistoricalPerformanceLogEntry(mountpointName,
+ layerProtocolName, NETCONFTIME_CONVERTER.getTimeStamp().getValue(), msg);
+ historicalPerformanceLogRW.doWrite(logEntry);
+ LOG.debug("Write PM Log done");
+
+ }
+
+
+ static public boolean isAvailable(MicrowaveHistoricalPerformanceWriterService s) {
+
+ if (s == null || s.client == null) {
+ return false;
+ }
+ return true;
+ }
+
+}
diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/performancemanager/impl/database/types/EsHistoricalPerformance15Minutes.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/performancemanager/impl/database/types/EsHistoricalPerformance15Minutes.java
new file mode 100644
index 000000000..6754fced9
--- /dev/null
+++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/performancemanager/impl/database/types/EsHistoricalPerformance15Minutes.java
@@ -0,0 +1,43 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 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.performancemanager.impl.database.types;
+
+import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.logical.termination.point.g.Lp;
+import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.g._874._1.model.rev170320.OtnHistoryDataG;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class EsHistoricalPerformance15Minutes extends EsHistoricalPerformanceBase {
+
+ public static final String ESDATATYPENAME = "historicalperformance15min";
+
+ private static final Logger LOG = LoggerFactory.getLogger(EsHistoricalPerformance15Minutes.class);
+
+ public EsHistoricalPerformance15Minutes(String nodeName, Lp lp) {
+ super(nodeName, lp);
+ }
+
+ public <T extends OtnHistoryDataG> EsHistoricalPerformance15Minutes setHistoricalRecord15Minutes(OtnHistoryDataG record) {
+ if (record.getGranularityPeriod() != org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.g._874._1.model.rev170320.GranularityPeriodType.Period15Min) {
+ LOG.warn("Granularity mismatch for {} expected {} found {}", getNodeName(),getUuidInterface(), org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.g._874._1.model.rev170320.GranularityPeriodType.Period15Min, record.getGranularityPeriod());
+ }
+ set(record);
+ return this;
+ }
+
+}
diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/performancemanager/impl/database/types/EsHistoricalPerformance24Hours.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/performancemanager/impl/database/types/EsHistoricalPerformance24Hours.java
new file mode 100644
index 000000000..03c68451d
--- /dev/null
+++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/performancemanager/impl/database/types/EsHistoricalPerformance24Hours.java
@@ -0,0 +1,36 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 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.performancemanager.impl.database.types;
+
+import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.logical.termination.point.g.Lp;
+import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.g._874._1.model.rev170320.OtnHistoryDataG;
+
+public class EsHistoricalPerformance24Hours extends EsHistoricalPerformanceBase {
+
+ public static final String ESDATATYPENAME = "historicalperformance24h";
+
+ public EsHistoricalPerformance24Hours(String nodeName, Lp lp) {
+ super(nodeName, lp);
+ }
+
+ public <T extends OtnHistoryDataG> EsHistoricalPerformance24Hours setHistoricalRecord24Hours(T record) {
+ set(record);
+ return this;
+ }
+
+}
diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/performancemanager/impl/database/types/EsHistoricalPerformanceBase.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/performancemanager/impl/database/types/EsHistoricalPerformanceBase.java
new file mode 100644
index 000000000..5f8370f60
--- /dev/null
+++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/performancemanager/impl/database/types/EsHistoricalPerformanceBase.java
@@ -0,0 +1,165 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 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.performancemanager.impl.database.types;
+
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.database.EsObject;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.netconf.util.LinkIdentifyingObject;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.netconf.util.NetconfTimeStamp;
+import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.logical.termination.point.g.Lp;
+import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.g._874._1.model.rev170320.OtnHistoryDataG;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.fasterxml.jackson.annotation.JsonGetter;
+import com.fasterxml.jackson.annotation.JsonIgnore;
+
+public class EsHistoricalPerformanceBase extends EsObject {
+
+ private static final Logger LOG = LoggerFactory.getLogger(EsHistoricalPerformanceBase.class);
+ private static final NetconfTimeStamp NETCONFTIME_CONVERTER = NetconfTimeStamp.getConverter();
+
+ @JsonIgnore private final String nodeName;
+ @JsonIgnore private final String uuidInterface;
+ @JsonIgnore private final String layerProtocolName;
+
+ @JsonIgnore private String radioSignalId = null; //Meaning of connection Id
+ @JsonIgnore private String timeStamp = null;
+ @JsonIgnore private Boolean suspectIntervalFlag = null;
+ @JsonIgnore private String granularityPeriod = null; //Representation of GranularityPeriodType
+ @JsonIgnore private String scannerId = null;
+ @JsonIgnore private Object performanceData = null;
+
+
+ public EsHistoricalPerformanceBase(String nodeName, Lp actualInterface) {
+ this.nodeName = nodeName;
+ this.uuidInterface = actualInterface.getUuid().getValue();
+ this.layerProtocolName = actualInterface.getLayerProtocolName().getValue();
+
+ }
+
+ protected <T extends OtnHistoryDataG> void set(T record) {
+ if (record == null) {
+ LOG.warn("PM Record: null record. Can not handle");
+ return;
+ }
+
+ if (LOG.isTraceEnabled()) {
+ LOG.trace("PM Record: class {} '{}' ", record.getClass().getSimpleName(), record);
+ }
+
+ timeStamp = NETCONFTIME_CONVERTER.getTimeStampFromNetconf(record.getPeriodEndTime().getValue());
+ suspectIntervalFlag = record.isSuspectIntervalFlag();
+ granularityPeriod = getYangGranularityPeriodString( record.getGranularityPeriod() );
+ scannerId = record.getHistoryDataId();
+
+ if (record instanceof LinkIdentifyingObject) {
+ radioSignalId = ((LinkIdentifyingObject) record).getSignalId();
+ }
+
+ performanceData = new EsPerformanceData(record);
+ setEsId(genSpecificEsId(record.getPeriodEndTime().getValue()));
+ }
+
+
+ @JsonGetter("node-name")
+ public String getNodeName() {
+ return nodeName;
+ }
+
+ @JsonGetter("uuid-interface")
+ public String getUuidInterface() {
+ return uuidInterface;
+ }
+
+ @JsonGetter("layer-protocol-name")
+ public String getLayerProtocolName() {
+ return layerProtocolName;
+ }
+
+ @JsonGetter("radio-signal-id")
+ public String getRadioSignalId() {
+ return radioSignalId;
+ }
+
+ @JsonGetter("time-stamp")
+ public String getTimeStamp() {
+ return timeStamp;
+ }
+
+ @JsonGetter("suspect-interval-flag")
+ public Boolean getSuspect() {
+ return suspectIntervalFlag;
+ }
+
+ @JsonGetter("granularity-period")
+ public String getGranularityPeriod() {
+ return granularityPeriod;
+ }
+
+ @JsonGetter("scanner-id")
+ public String getScannerId() {
+ return scannerId;
+ }
+
+ @JsonGetter("performance-data")
+ public Object getData() {
+ return performanceData;
+ }
+
+
+
+ //Adapt JSON Text
+ //@JsonGetter("granularityPeriod")
+
+ private static String getYangGranularityPeriodString(org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.g._874._1.model.rev170320.GranularityPeriodType yangGanularityPeriod) {
+ switch(yangGanularityPeriod == null ? org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.g._874._1.model.rev170320.GranularityPeriodType.Unknown : yangGanularityPeriod) {
+ case Period15Min:
+ return "PERIOD_15MIN";
+ case Period24Hours:
+ return "PERIOD_24HOURS";
+ default:
+ return "PERIOD_UNKOWN";
+ }
+ }
+
+ /**
+ * Create a specific ES id for the current log.
+ * @param time is the input.
+ * @return a string with the generated ES Id
+ */
+ protected String genSpecificEsId(String time) {
+
+ StringBuffer strBuf = new StringBuffer();
+ strBuf.append(nodeName);
+ strBuf.append("/");
+ strBuf.append(uuidInterface);
+ strBuf.append("/");
+ strBuf.append(time == null || time.isEmpty() ? "Empty" : time);
+
+ return strBuf.toString();
+ }
+
+ @Override
+ public String toString() {
+ return "EsHistoricalPerformanceBase [nodeName=" + nodeName + ", uuidInterface=" + uuidInterface
+ + ", layerProtocolName=" + layerProtocolName + ", radioSignalId=" + radioSignalId + ", timeStamp="
+ + timeStamp + ", suspectIntervalFlag=" + suspectIntervalFlag + ", granularityPeriod="
+ + granularityPeriod + ", scannerId=" + scannerId + ", performanceData=" + performanceData + "]";
+ }
+
+}
diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/performancemanager/impl/database/types/EsHistoricalPerformanceLogEntry.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/performancemanager/impl/database/types/EsHistoricalPerformanceLogEntry.java
new file mode 100644
index 000000000..ebbf8b435
--- /dev/null
+++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/performancemanager/impl/database/types/EsHistoricalPerformanceLogEntry.java
@@ -0,0 +1,92 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 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.performancemanager.impl.database.types;
+
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.database.EsObject;
+
+/**
+ *
+ * Event from Network to be recorded in the database
+ *
+ */
+
+public class EsHistoricalPerformanceLogEntry extends EsObject {
+
+ public static final String ESDATATYPENAME = "performancelog";
+
+ private String mountpoint;
+ private String interfaceIdx;
+ private String timeStamp;
+ private String logText;
+
+ /**
+ * Create Log entry for NE/Interfaceproblems during PM execution
+ * @param mountpoint Name of
+ * @param interfaceIdx Name of
+ * @param timeStamp Time and date of occurence
+ * @param logText to write
+ */
+ public EsHistoricalPerformanceLogEntry(String mountpoint, String interfaceIdx, String timeStamp, String logText) {
+ super();
+ this.mountpoint = mountpoint;
+ this.interfaceIdx = interfaceIdx;
+ this.timeStamp = timeStamp;
+ this.logText = logText;
+ }
+
+ /**
+ * For jackson purpose
+ */
+ EsHistoricalPerformanceLogEntry() {
+ }
+
+ /**
+ * @return the mountpoint
+ */
+ public String getMountpoint() {
+ return mountpoint;
+ }
+
+ /**
+ * @return the interfaceIdx
+ */
+ public String getInterfaceIdx() {
+ return interfaceIdx;
+ }
+
+ /**
+ * @return the timeStamp
+ */
+ public String getTimeStamp() {
+ return timeStamp;
+ }
+
+ /**
+ * @return the logText
+ */
+ public String getLogText() {
+ return logText;
+ }
+
+
+
+ public static String getEsdatatypename() {
+ return ESDATATYPENAME;
+ }
+
+ }
diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/performancemanager/impl/database/types/EsPerformanceData.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/performancemanager/impl/database/types/EsPerformanceData.java
new file mode 100644
index 000000000..ef25f0282
--- /dev/null
+++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/performancemanager/impl/database/types/EsPerformanceData.java
@@ -0,0 +1,444 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 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.performancemanager.impl.database.types;
+
+import com.fasterxml.jackson.annotation.JsonGetter;
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.netconf.container.ExtendedAirInterfaceHistoricalPerformanceType12;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.netconf.container.ExtendedAirInterfaceHistoricalPerformanceType1211;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.netconf.container.ExtendedAirInterfaceHistoricalPerformanceType1211p;
+import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.g._874._1.model.rev170320.OtnHistoryDataG;
+import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.AirInterfaceHistoricalPerformanceTypeG;
+import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.AirInterfacePerformanceTypeG;
+import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.ContainerHistoricalPerformanceTypeG;
+import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.ContainerPerformanceTypeG;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+@JsonInclude(JsonInclude.Include.NON_NULL)
+public class EsPerformanceData {
+
+ @JsonIgnore
+ private static final Logger LOG = LoggerFactory.getLogger(EsPerformanceData.class);
+
+ @JsonIgnore
+ private AirInterfacePerformanceTypeG dataAirInterface12 = null;
+ @JsonIgnore
+ private ContainerPerformanceTypeG dataEthContainer12 = null;
+
+ @JsonIgnore
+ private org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.AirInterfacePerformanceTypeG dataAirInterface1211 = null;
+ @JsonIgnore
+ private org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.ContainerPerformanceTypeG dataEthContainer1211 = null;
+
+ @JsonIgnore
+ private org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.AirInterfacePerformanceTypeG dataAirInterface1211p = null;
+ @JsonIgnore
+ private org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.ContainerPerformanceTypeG dataEthContainer1211p = null;
+
+ public <T extends OtnHistoryDataG> EsPerformanceData(T otnHistoryData) {
+
+ if (otnHistoryData instanceof AirInterfaceHistoricalPerformanceTypeG) {
+ this.dataAirInterface12 = ((AirInterfaceHistoricalPerformanceTypeG) otnHistoryData).getPerformanceData();
+ } else if (otnHistoryData instanceof ContainerHistoricalPerformanceTypeG) {
+ this.dataEthContainer12 = ((ContainerHistoricalPerformanceTypeG) otnHistoryData).getPerformanceData();
+ } else if (otnHistoryData instanceof ExtendedAirInterfaceHistoricalPerformanceType12) {
+ this.dataAirInterface12 = ((ExtendedAirInterfaceHistoricalPerformanceType12) otnHistoryData)
+ .getAirInterfaceHistoricalPerformanceType().getPerformanceData();
+ } else if (otnHistoryData instanceof org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.AirInterfaceHistoricalPerformanceTypeG) {
+ this.dataAirInterface1211 = ((org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.AirInterfaceHistoricalPerformanceTypeG) otnHistoryData)
+ .getPerformanceData();
+ } else if (otnHistoryData instanceof org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.ContainerHistoricalPerformanceTypeG) {
+ this.dataEthContainer1211 = ((org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.ContainerHistoricalPerformanceTypeG) otnHistoryData)
+ .getPerformanceData();
+ } else if (otnHistoryData instanceof ExtendedAirInterfaceHistoricalPerformanceType1211) {
+ this.dataAirInterface1211 = ((ExtendedAirInterfaceHistoricalPerformanceType1211) otnHistoryData)
+ .getAirInterfaceHistoricalPerformanceType().getPerformanceData();
+ } else if (otnHistoryData instanceof org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.AirInterfaceHistoricalPerformanceTypeG) {
+ this.dataAirInterface1211p = ((org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.AirInterfaceHistoricalPerformanceTypeG) otnHistoryData)
+ .getPerformanceData();
+ } else if (otnHistoryData instanceof org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.ContainerHistoricalPerformanceTypeG) {
+ this.dataEthContainer1211p = ((org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.ContainerHistoricalPerformanceTypeG) otnHistoryData)
+ .getPerformanceData();
+ } else if (otnHistoryData instanceof ExtendedAirInterfaceHistoricalPerformanceType1211p) {
+ this.dataAirInterface1211p = ((ExtendedAirInterfaceHistoricalPerformanceType1211p) otnHistoryData)
+ .getAirInterfaceHistoricalPerformanceType().getPerformanceData();
+ } else {
+ LOG.warn("Can not assign historical performance type {}", otnHistoryData.getClass().getName());
+ }
+ }
+
+ @JsonGetter("es")
+ public java.lang.Integer getEs() {
+ return dataAirInterface12 != null ? dataAirInterface12.getEs()
+ : dataAirInterface1211 != null ? dataAirInterface1211.getEs()
+ : dataAirInterface1211p != null ? dataAirInterface1211p.getEs() : null;
+ }
+
+ @JsonGetter("ses")
+ java.lang.Integer getSes() {
+ return dataAirInterface12 != null ? dataAirInterface12.getSes()
+ : dataAirInterface1211 != null ? dataAirInterface1211.getSes()
+ : dataAirInterface1211p != null ? dataAirInterface1211p.getSes() : null;
+ }
+
+ @JsonGetter("cses")
+ java.lang.Integer getCses() {
+ return dataAirInterface12 != null ? dataAirInterface12.getCses()
+ : dataAirInterface1211 != null ? dataAirInterface1211.getCses()
+ : dataAirInterface1211p != null ? dataAirInterface1211p.getCses() : null;
+ }
+
+ @JsonGetter("unavailability")
+ java.lang.Integer getUnavailability() {
+ return dataAirInterface12 != null ? dataAirInterface12.getUnavailability()
+ : dataAirInterface1211 != null ? dataAirInterface1211.getUnavailability()
+ : dataAirInterface1211p != null ? dataAirInterface1211p.getUnavailability() : null;
+ }
+
+ @JsonGetter("tx-level-min")
+ java.lang.Byte getTxLevelMin() {
+ return dataAirInterface12 != null ? dataAirInterface12.getTxLevelMin()
+ : dataAirInterface1211 != null ? dataAirInterface1211.getTxLevelMin()
+ : dataAirInterface1211p != null ? dataAirInterface1211p.getTxLevelMin() : null;
+ }
+
+ @JsonGetter("tx-level-max")
+ java.lang.Byte getTxLevelMax() {
+ return dataAirInterface12 != null ? dataAirInterface12.getTxLevelMax()
+ : dataAirInterface1211 != null ? dataAirInterface1211.getTxLevelMax()
+ : dataAirInterface1211p != null ? dataAirInterface1211p.getTxLevelMax() : null;
+ }
+
+ @JsonGetter("tx-level-avg")
+ java.lang.Byte getTxLevelAvg() {
+ return dataAirInterface12 != null ? dataAirInterface12.getTxLevelAvg()
+ : dataAirInterface1211 != null ? dataAirInterface1211.getTxLevelAvg()
+ : dataAirInterface1211p != null ? dataAirInterface1211p.getTxLevelAvg() : null;
+ }
+
+ @JsonGetter("rx-level-min")
+ java.lang.Byte getRxLevelMin() {
+ return dataAirInterface12 != null ? dataAirInterface12.getRxLevelMin()
+ : dataAirInterface1211 != null ? dataAirInterface1211.getRxLevelMin()
+ : dataAirInterface1211p != null ? dataAirInterface1211p.getRxLevelMin() : null;
+ }
+
+ @JsonGetter("rx-level-max")
+ java.lang.Byte getRxLevelMax() {
+ return dataAirInterface12 != null ? dataAirInterface12.getRxLevelMax()
+ : dataAirInterface1211 != null ? dataAirInterface1211.getRxLevelMax()
+ : dataAirInterface1211p != null ? dataAirInterface1211p.getRxLevelMax() : null;
+ }
+
+ @JsonGetter("rx-level-avg")
+ java.lang.Byte getRxLevelAvg() {
+ return dataAirInterface12 != null ? dataAirInterface12.getRxLevelAvg()
+ : dataAirInterface1211 != null ? dataAirInterface1211.getRxLevelAvg()
+ : dataAirInterface1211p != null ? dataAirInterface1211p.getRxLevelAvg() : null;
+ }
+
+ @SuppressWarnings("deprecation")
+ @JsonGetter("time2-states")
+ java.lang.Integer getTime2States() {
+ return dataAirInterface12 != null ? dataAirInterface12.getTime2States()
+ : dataAirInterface1211 != null ? dataAirInterface1211.getTime2States()
+ : dataAirInterface1211p != null ? dataAirInterface1211p.getTime2States() : null;
+ }
+
+ @SuppressWarnings("deprecation")
+ @JsonGetter("time4-states-s")
+ java.lang.Integer getTime4StatesS() {
+ return dataAirInterface12 != null ? dataAirInterface12.getTime4StatesS()
+ : dataAirInterface1211 != null ? dataAirInterface1211.getTime4StatesS()
+ : dataAirInterface1211p != null ? dataAirInterface1211p.getTime4StatesS() : null;
+ }
+
+ @SuppressWarnings("deprecation")
+ @JsonGetter("time4-states")
+ java.lang.Integer getTime4States() {
+ return dataAirInterface12 != null ? dataAirInterface12.getTime4States()
+ : dataAirInterface1211 != null ? dataAirInterface1211.getTime4States()
+ : dataAirInterface1211p != null ? dataAirInterface1211p.getTime4States() : null;
+ }
+
+ @SuppressWarnings("deprecation")
+ @JsonGetter("time8-states")
+ java.lang.Integer getTime8States() {
+ return dataAirInterface12 != null ? dataAirInterface12.getTime8States()
+ : dataAirInterface1211 != null ? dataAirInterface1211.getTime8States()
+ : dataAirInterface1211p != null ? dataAirInterface1211p.getTime8States() : null;
+ }
+
+ @SuppressWarnings("deprecation")
+ @JsonGetter("time16-states-s")
+ java.lang.Integer getTime16StatesS() {
+ return dataAirInterface12 != null ? dataAirInterface12.getTime16StatesS()
+ : dataAirInterface1211 != null ? dataAirInterface1211.getTime16StatesS()
+ : dataAirInterface1211p != null ? dataAirInterface1211p.getTime16StatesS() : null;
+ }
+
+ @SuppressWarnings("deprecation")
+ @JsonGetter("time16-states")
+ java.lang.Integer getTime16States() {
+ return dataAirInterface12 != null ? dataAirInterface12.getTime16States()
+ : dataAirInterface1211 != null ? dataAirInterface1211.getTime16States()
+ : dataAirInterface1211p != null ? dataAirInterface1211p.getTime16States() : null;
+ }
+
+ @SuppressWarnings("deprecation")
+ @JsonGetter("time32-states")
+ java.lang.Integer getTime32States() {
+ return dataAirInterface12 != null ? dataAirInterface12.getTime32States()
+ : dataAirInterface1211 != null ? dataAirInterface1211.getTime32States()
+ : dataAirInterface1211p != null ? dataAirInterface1211p.getTime32States() : null;
+ }
+
+ @SuppressWarnings("deprecation")
+ @JsonGetter("time64-states")
+ java.lang.Integer getTime64States() {
+ return dataAirInterface12 != null ? dataAirInterface12.getTime64States()
+ : dataAirInterface1211 != null ? dataAirInterface1211.getTime64States()
+ : dataAirInterface1211p != null ? dataAirInterface1211p.getTime64States() : null;
+ }
+
+ @SuppressWarnings("deprecation")
+ @JsonGetter("time128-states")
+ java.lang.Integer getTime128States() {
+ return dataAirInterface12 != null ? dataAirInterface12.getTime128States()
+ : dataAirInterface1211 != null ? dataAirInterface1211.getTime128States()
+ : dataAirInterface1211p != null ? dataAirInterface1211p.getTime128States() : null;
+ }
+
+ @SuppressWarnings("deprecation")
+ @JsonGetter("time256-states")
+ java.lang.Integer getTime256States() {
+ return dataAirInterface12 != null ? dataAirInterface12.getTime256States()
+ : dataAirInterface1211 != null ? dataAirInterface1211.getTime256States()
+ : dataAirInterface1211p != null ? dataAirInterface1211p.getTime256States() : null;
+ }
+
+ @SuppressWarnings("deprecation")
+ @JsonGetter("time512-states")
+ java.lang.Integer getTime512States() {
+ return dataAirInterface12 != null ? dataAirInterface12.getTime512States()
+ : dataAirInterface1211 != null ? dataAirInterface1211.getTime512States()
+ : dataAirInterface1211p != null ? dataAirInterface1211p.getTime512States() : null;
+ }
+
+ @SuppressWarnings("deprecation")
+ @JsonGetter("time512-states-l")
+ java.lang.Integer getTime512StatesL() {
+ return dataAirInterface12 != null ? dataAirInterface12.getTime512StatesL()
+ : dataAirInterface1211 != null ? dataAirInterface1211.getTime512StatesL()
+ : dataAirInterface1211p != null ? dataAirInterface1211p.getTime512StatesL() : null;
+ }
+
+ @SuppressWarnings("deprecation")
+ @JsonGetter("time1024-states")
+ java.lang.Integer getTime1024States() {
+ return dataAirInterface12 != null ? dataAirInterface12.getTime1024States()
+ : dataAirInterface1211 != null ? dataAirInterface1211.getTime1024States()
+ : dataAirInterface1211p != null ? dataAirInterface1211p.getTime1024States() : null;
+ }
+
+ @SuppressWarnings("deprecation")
+ @JsonGetter("time1024-states-l")
+ java.lang.Integer getTime1024StatesL() {
+ return dataAirInterface12 != null ? dataAirInterface12.getTime1024StatesL()
+ : dataAirInterface1211 != null ? dataAirInterface1211.getTime1024StatesL()
+ : dataAirInterface1211p != null ? dataAirInterface1211p.getTime1024StatesL() : null;
+ }
+
+ @SuppressWarnings("deprecation")
+ @JsonGetter("time2048-states")
+ java.lang.Integer getTime2048States() {
+ return dataAirInterface12 != null ? dataAirInterface12.getTime2048States()
+ : dataAirInterface1211 != null ? dataAirInterface1211.getTime2048States()
+ : dataAirInterface1211p != null ? dataAirInterface1211p.getTime2048States() : null;
+ }
+
+ @SuppressWarnings("deprecation")
+ @JsonGetter("time2048-states-l")
+ java.lang.Integer getTime2048StatesL() {
+ return dataAirInterface12 != null ? dataAirInterface12.getTime2048StatesL()
+ : dataAirInterface1211 != null ? dataAirInterface1211.getTime2048StatesL()
+ : dataAirInterface1211p != null ? dataAirInterface1211p.getTime2048StatesL() : null;
+ }
+
+ @SuppressWarnings("deprecation")
+ @JsonGetter("time4096-states")
+ java.lang.Integer getTime4096States() {
+ return dataAirInterface12 != null ? dataAirInterface12.getTime4096States()
+ : dataAirInterface1211 != null ? dataAirInterface1211.getTime4096States()
+ : dataAirInterface1211p != null ? dataAirInterface1211p.getTime4096States() : null;
+ }
+
+ @SuppressWarnings("deprecation")
+ @JsonGetter("time4096-states-l")
+ java.lang.Integer getTime4096StatesL() {
+ return dataAirInterface12 != null ? dataAirInterface12.getTime4096StatesL()
+ : dataAirInterface1211 != null ? dataAirInterface1211.getTime4096StatesL()
+ : dataAirInterface1211p != null ? dataAirInterface1211p.getTime4096StatesL() : null;
+ }
+
+ @SuppressWarnings("deprecation")
+ @JsonGetter("time8192-states")
+ java.lang.Integer getTime8192States() {
+ return dataAirInterface12 != null ? dataAirInterface12.getTime8192States()
+ : dataAirInterface1211 != null ? dataAirInterface1211.getTime8192States()
+ : dataAirInterface1211p != null ? dataAirInterface1211p.getTime8192States() : null;
+ }
+
+ @SuppressWarnings("deprecation")
+ @JsonGetter("time8192-states-l")
+ java.lang.Integer getTime8192StatesL() {
+ return dataAirInterface12 != null ? dataAirInterface12.getTime8192StatesL()
+ : dataAirInterface1211 != null ? dataAirInterface1211.getTime8192StatesL()
+ : dataAirInterface1211p != null ? dataAirInterface1211p.getEs() : null;
+ }
+
+ @JsonGetter("snir-min")
+ java.lang.Byte getSnirMin() {
+ return dataAirInterface12 != null ? dataAirInterface12.getSnirMin()
+ : dataAirInterface1211 != null ? dataAirInterface1211.getSnirMin()
+ : dataAirInterface1211p != null ? dataAirInterface1211p.getSnirMin() : null;
+ }
+
+ @JsonGetter("snir-max")
+ java.lang.Byte getSnirMax() {
+ return dataAirInterface12 != null ? dataAirInterface12.getSnirMax()
+ : dataAirInterface1211 != null ? dataAirInterface1211.getSnirMax()
+ : dataAirInterface1211p != null ? dataAirInterface1211p.getSnirMax() : null;
+ }
+
+ @JsonGetter("snir-avg")
+ java.lang.Byte getSnirAvg() {
+ return dataAirInterface12 != null ? dataAirInterface12.getSnirAvg()
+ : dataAirInterface1211 != null ? dataAirInterface1211.getSnirAvg()
+ : dataAirInterface1211p != null ? dataAirInterface1211p.getSnirAvg() : null;
+ }
+
+ @JsonGetter("xpd-min")
+ java.lang.Byte getXpdMin() {
+ return dataAirInterface12 != null ? dataAirInterface12.getXpdMin()
+ : dataAirInterface1211 != null ? dataAirInterface1211.getXpdMin()
+ : dataAirInterface1211p != null ? dataAirInterface1211p.getXpdMin() : null;
+ }
+
+ @JsonGetter("xpd-max")
+ java.lang.Byte getXpdMax() {
+ return dataAirInterface12 != null ? dataAirInterface12.getXpdMax()
+ : dataAirInterface1211 != null ? dataAirInterface1211.getXpdMax()
+ : dataAirInterface1211p != null ? dataAirInterface1211p.getXpdMax() : null;
+ }
+
+ @JsonGetter("xpd-avg")
+ java.lang.Byte getXpdAvg() {
+ return dataAirInterface12 != null ? dataAirInterface12.getXpdAvg()
+ : dataAirInterface1211 != null ? dataAirInterface1211.getXpdAvg()
+ : dataAirInterface1211p != null ? dataAirInterface1211p.getXpdAvg() : null;
+ }
+
+ @JsonGetter("rf-temp-min")
+ java.lang.Byte getRfTempMin() {
+ return dataAirInterface12 != null ? dataAirInterface12.getRfTempMin()
+ : dataAirInterface1211 != null ? dataAirInterface1211.getRfTempMin()
+ : dataAirInterface1211p != null ? dataAirInterface1211p.getRfTempMin() : null;
+ }
+
+ @JsonGetter("rf-temp-max")
+ java.lang.Byte getRfTempMax() {
+ return dataAirInterface12 != null ? dataAirInterface12.getRfTempMax()
+ : dataAirInterface1211 != null ? dataAirInterface1211.getRfTempMax()
+ : dataAirInterface1211p != null ? dataAirInterface1211p.getRfTempMax() : null;
+ }
+
+ @JsonGetter("rf-temp-avg")
+ java.lang.Byte getRfTempAvg() {
+ return dataAirInterface12 != null ? dataAirInterface12.getRfTempAvg()
+ : dataAirInterface1211 != null ? dataAirInterface1211.getRfTempAvg()
+ : dataAirInterface1211p != null ? dataAirInterface1211p.getRfTempAvg() : null;
+ }
+
+ @JsonGetter("defect-blocks-sum")
+ java.lang.Short getDefectBlocksSum() {
+ return dataAirInterface12 != null ? dataAirInterface12.getDefectBlocksSum()
+ : dataAirInterface1211 != null ? dataAirInterface1211.getDefectBlocksSum()
+ : dataAirInterface1211p != null ? dataAirInterface1211p.getDefectBlocksSum() : null;
+ }
+
+ @JsonGetter("time-period")
+ java.lang.Integer getTimePeriod() {
+ return dataAirInterface12 != null ? dataAirInterface12.getTimePeriod()
+ : dataEthContainer12 != null ? dataEthContainer12.getTimePeriod()
+ : dataAirInterface1211 != null ? dataAirInterface1211.getTimePeriod()
+ : dataEthContainer1211 != null ? dataEthContainer1211.getTimePeriod()
+ : dataAirInterface1211p != null ? dataAirInterface1211p.getTimePeriod()
+ : dataEthContainer1211p != null ? dataEthContainer1211p.getTimePeriod()
+ : null;
+ }
+
+ @JsonGetter("tx-ethernet-bytes-max-s")
+ java.lang.Integer getTxEthernetBytesMaxS() {
+ return dataEthContainer12 != null ? dataEthContainer12.getTxEthernetBytesMaxS()
+ : dataEthContainer1211 != null ? dataEthContainer1211.getTxEthernetBytesMaxS()
+ : dataEthContainer1211p != null ? dataEthContainer1211p.getTxEthernetBytesMaxS() : null;
+ }
+
+ @JsonGetter("tx-ethernet-bytes-max-m")
+ java.lang.Long getTxEthernetBytesMaxM() {
+ return dataEthContainer12 != null ? dataEthContainer12.getTxEthernetBytesMaxM()
+ : dataEthContainer1211 != null ? dataEthContainer1211.getTxEthernetBytesMaxM()
+ : dataEthContainer1211p != null ? dataEthContainer1211p.getTxEthernetBytesMaxM() : null;
+ }
+
+ @JsonGetter("tx-ethernet-bytes-sum")
+ java.lang.Long getTxEthernetBytesSum() {
+ return dataEthContainer12 != null ? dataEthContainer12.getTxEthernetBytesSum()
+ : dataEthContainer1211 != null ? dataEthContainer1211.getTxEthernetBytesSum()
+ : dataEthContainer1211p != null ? dataEthContainer1211p.getTxEthernetBytesSum() : null;
+ }
+
+ @Override
+ public String toString() {
+ return "EsPerformanceData [getEs()=" + getEs() + ", getSes()=" + getSes() + ", getCses()=" + getCses()
+ + ", getUnavailability()=" + getUnavailability() + ", getTxLevelMin()=" + getTxLevelMin()
+ + ", getTxLevelMax()=" + getTxLevelMax() + ", getTxLevelAvg()=" + getTxLevelAvg() + ", getRxLevelMin()="
+ + getRxLevelMin() + ", getRxLevelMax()=" + getRxLevelMax() + ", getRxLevelAvg()=" + getRxLevelAvg()
+ + ", getTime2States()=" + getTime2States() + ", getTime4StatesS()=" + getTime4StatesS()
+ + ", getTime4States()=" + getTime4States() + ", getTime8States()=" + getTime8States()
+ + ", getTime16StatesS()=" + getTime16StatesS() + ", getTime16States()=" + getTime16States()
+ + ", getTime32States()=" + getTime32States() + ", getTime64States()=" + getTime64States()
+ + ", getTime128States()=" + getTime128States() + ", getTime256States()=" + getTime256States()
+ + ", getTime512States()=" + getTime512States() + ", getTime512StatesL()=" + getTime512StatesL()
+ + ", getTime1024States()=" + getTime1024States() + ", getTime1024StatesL()=" + getTime1024StatesL()
+ + ", getTime2048States()=" + getTime2048States() + ", getTime2048StatesL()=" + getTime2048StatesL()
+ + ", getTime4096States()=" + getTime4096States() + ", getTime4096StatesL()=" + getTime4096StatesL()
+ + ", getTime8192States()=" + getTime8192States() + ", getTime8192StatesL()=" + getTime8192StatesL()
+ + ", getSnirMin()=" + getSnirMin() + ", getSnirMax()=" + getSnirMax() + ", getSnirAvg()=" + getSnirAvg()
+ + ", getXpdMin()=" + getXpdMin() + ", getXpdMax()=" + getXpdMax() + ", getXpdAvg()=" + getXpdAvg()
+ + ", getRfTempMin()=" + getRfTempMin() + ", getRfTempMax()=" + getRfTempMax() + ", getRfTempAvg()="
+ + getRfTempAvg() + ", getDefectBlocksSum()=" + getDefectBlocksSum() + ", getTimePeriod()="
+ + getTimePeriod() + ", getTxEthernetBytesMaxS()=" + getTxEthernetBytesMaxS()
+ + ", getTxEthernetBytesMaxM()=" + getTxEthernetBytesMaxM() + ", getTxEthernetBytesSum()="
+ + getTxEthernetBytesSum() + "]";
+ }
+
+}
diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/ptp/impl/GeoLocation.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/ptp/impl/GeoLocation.java
new file mode 100644
index 000000000..1838c33c7
--- /dev/null
+++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/ptp/impl/GeoLocation.java
@@ -0,0 +1,48 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 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.ptp.impl;
+
+/**
+ * Path list with logical-termination-point list
+ "path" : [{
+ "path-id": "4d778388-41c8-11e7-a919-92ebcb67fe33",
+ "path-name": "NE-10-ClockIdentity",
+ "layer-protocol-name": "PTP",
+ "directionality": "unidirectional",
+ "logical-termination-point": [{
+ "ltp-reference":"yep",
+ "physical-port-reference": "shelf:1-slot:1-Card-port:5",
+ "node-reference":"NE-10",
+ "site-reference": "site-a",
+ "site-name": "GUI-Label",
+ "geo-location": {
+ "longitude": "54.123456",
+ "latitude": "13.123456"
+ }]
+ }]
+
+ * @author herbert
+ */
+
+public class GeoLocation {
+ String longitude;
+ String latitude;
+}
diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/ptp/impl/LogicalTerminationPoint.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/ptp/impl/LogicalTerminationPoint.java
new file mode 100644
index 000000000..6efd3f90c
--- /dev/null
+++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/ptp/impl/LogicalTerminationPoint.java
@@ -0,0 +1,55 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 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.ptp.impl;
+
+/**
+ * Path list with logical-termination-point list
+ "path" : [{
+ "path-id": "4d778388-41c8-11e7-a919-92ebcb67fe33",
+ "path-name": "NE-10-ClockIdentity",
+ "layer-protocol-name": "PTP",
+ "directionality": "unidirectional",
+ "logical-termination-point": [{
+ "ltp-reference":"yep",
+ "physical-port-reference": "shelf:1-slot:1-Card-port:5",
+ "node-reference":"NE-10",
+ "site-reference": "site-a",
+ "site-name": "GUI-Label",
+ "geo-location": {
+ "longitude": "54.123456",
+ "latitude": "13.123456"
+ }]
+ }]
+
+
+ * @author herbert
+ *
+ */
+public class LogicalTerminationPoint {
+
+ String ltpReference;
+ String physicalPortReference;
+ String nodeReference;
+ String siteReference;
+ String siteName;
+ GeoLocation geoLocation;
+
+}
diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/ptp/impl/Path.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/ptp/impl/Path.java
new file mode 100644
index 000000000..60a236d14
--- /dev/null
+++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/ptp/impl/Path.java
@@ -0,0 +1,54 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 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.ptp.impl;
+
+import java.util.List;
+
+/**
+ * Path list with logical-termination-point list
+ "path" : [{
+ "path-id": "4d778388-41c8-11e7-a919-92ebcb67fe33",
+ "path-name": "NE-10-ClockIdentity",
+ "layer-protocol-name": "PTP",
+ "directionality": "unidirectional",
+ "logical-termination-point": [{
+ "ltp-reference":"yep",
+ "physical-port-reference": "shelf:1-slot:1-Card-port:5",
+ "node-reference":"NE-10",
+ "site-reference": "site-a",
+ "site-name": "GUI-Label",
+ "geo-location": {
+ "longitude": "54.123456",
+ "latitude": "13.123456"
+ }]
+ }]
+ * @author herbert
+ *
+ */
+public class Path {
+
+ String pathId;
+ String pathName;
+ String layperProtocolName;
+ String directionality;
+ List<LogicalTerminationPoint> logicalTerminationPoints;
+
+}
diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/ptp/impl/PtpManagerImpl.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/ptp/impl/PtpManagerImpl.java
new file mode 100644
index 000000000..3bb16938e
--- /dev/null
+++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/ptp/impl/PtpManagerImpl.java
@@ -0,0 +1,29 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 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.ptp.impl;
+
+/**
+ * @author herbert
+ *
+ */
+public class PtpManagerImpl {
+
+}