From ea5ba02bdfd1ed6e16683b01f1f499cb2473e37e Mon Sep 17 00:00:00 2001 From: Ravi Pendurty Date: Fri, 20 Oct 2023 14:30:41 +0530 Subject: Support multiple YANG revisions Provide o-ran-supervision messages to VES collector Issue-ID: CCSDK-3948 Change-Id: I16cb880414dde00a48fa59d8b90251beedae2c0e Signed-off-by: Ravi Pendurty --- sdnr/wt/data-provider/dblib/test2.properties | 7 - .../devicemanager/service/VESCollectorService.java | 11 + .../types/VESStndDefinedFieldsPOJO.java | 54 ++++ .../impl/VESCollectorServiceImpl.java | 20 ++ .../wt/devicemanager/oran/config/ORanDMConfig.java | 83 ++++++ .../dataprovider/ORanDOMToInternalDataModel.java | 332 +++++++++++++++++++++ .../oran/impl/dom/DOMNotificationToXPath.java | 234 --------------- .../oran/impl/dom/DeviceManagerORanImpl.java | 9 +- .../oran/impl/dom/ORanDMDOMUtility.java | 93 ------ .../dom/ORanDOMChangeNotificationListener.java | 148 --------- .../impl/dom/ORanDOMFaultNotificationListener.java | 171 ----------- .../impl/dom/ORanDOMFaultToVESFaultMapper.java | 154 ---------- .../oran/impl/dom/ORanDOMNetworkElement.java | 121 +++++--- .../impl/dom/ORanDOMNotifToVESEventAssembly.java | 102 ------- .../oran/impl/dom/ORanDOMToInternalDataModel.java | 293 ------------------ .../oran/impl/dom/ORanDeviceManagerQNames.java | 118 -------- .../oran/impl/dom/ORanNetworkElementFactory.java | 14 +- ...ORanRegistrationToVESpnfRegistrationMapper.java | 113 ------- .../ORanDOMChangeNotificationListener.java | 149 +++++++++ .../ORanDOMFaultNotificationListener.java | 178 +++++++++++ .../ORanDOMNotifToVESEventAssembly.java | 102 +++++++ .../notification/ORanDOMNotificationToXPath.java | 234 +++++++++++++++ .../ORanDOMSupervisionNotificationListener.java | 105 +++++++ .../notification/ORanNotificationObserver.java | 31 ++ .../notification/ORanNotificationObserverImpl.java | 43 +++ .../ORanNotificationReceivedService.java | 33 ++ .../oran/rpc/ORanSupervisionRPCImpl.java | 82 +++++ .../devicemanager/oran/util/ORanDMDOMUtility.java | 89 ++++++ .../oran/util/ORanDeviceManagerQNames.java | 101 +++++++ .../vesmapper/ORanDOMFaultToVESFaultMapper.java | 153 ++++++++++ .../ORanDOMSupervisionNotifToVESMapper.java | 206 +++++++++++++ ...ORanRegistrationToVESpnfRegistrationMapper.java | 115 +++++++ .../wt/devicemanager/oran/yangspecs/ORANFM.java | 113 +++++++ .../devicemanager/oran/yangspecs/OnapSystem.java | 127 ++++++++ .../devicemanager/oran/yangspecs/YangModule.java | 51 ++++ .../dom/TestORanDOMFaultNotificationListener.java | 36 ++- .../oran/impl/dom/TestORanDOMNetworkElement.java | 38 ++- .../oran/impl/dom/TestORanDOMNotification.java | 3 +- .../impl/dom/TestORanDOMToInternalDataModel.java | 91 ++++-- .../impl/dom/TestORanNetworkElementFactory.java | 61 ++-- .../TestORanRegistrationToVESpnfRegistration.java | 5 +- .../src/test/resources/o-ran-fm@2022-08-15.yang | 153 ++++++++++ .../src/test/resources/oran-fm-active-alarm.xml | 25 ++ .../wt/netconfnodestateservice/Capabilities.java | 15 + .../wt/netconfnodestateservice/DomContext.java | 38 +++ .../NetconfDomAccessor.java | 13 +- .../impl/NetconfNodeStateServiceImpl.java | 6 +- .../impl/access/NetconfAccessorImpl.java | 2 +- .../impl/access/NetconfAccessorManager.java | 2 +- .../impl/access/NetconfCommunicatorManager.java | 2 +- .../impl/access/dom/DomContext.java | 50 ---- .../impl/access/dom/DomContextImpl.java | 53 ++++ .../impl/access/dom/NetconfDomAccessorImpl.java | 11 + .../test/TestNetconfAccessorImpl.java | 6 +- .../test/example/ExampleConfig.java | 3 +- .../test/example/TestNetconfHelper.java | 4 +- 56 files changed, 3006 insertions(+), 1600 deletions(-) delete mode 100644 sdnr/wt/data-provider/dblib/test2.properties create mode 100644 sdnr/wt/devicemanager-core/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/types/VESStndDefinedFieldsPOJO.java create mode 100644 sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/config/ORanDMConfig.java create mode 100644 sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/dataprovider/ORanDOMToInternalDataModel.java delete mode 100644 sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/dom/DOMNotificationToXPath.java delete mode 100644 sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/dom/ORanDMDOMUtility.java delete mode 100644 sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/dom/ORanDOMChangeNotificationListener.java delete mode 100644 sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/dom/ORanDOMFaultNotificationListener.java delete mode 100644 sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/dom/ORanDOMFaultToVESFaultMapper.java delete mode 100644 sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/dom/ORanDOMNotifToVESEventAssembly.java delete mode 100644 sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/dom/ORanDOMToInternalDataModel.java delete mode 100644 sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/dom/ORanDeviceManagerQNames.java delete mode 100644 sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/dom/ORanRegistrationToVESpnfRegistrationMapper.java create mode 100644 sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/notification/ORanDOMChangeNotificationListener.java create mode 100644 sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/notification/ORanDOMFaultNotificationListener.java create mode 100644 sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/notification/ORanDOMNotifToVESEventAssembly.java create mode 100644 sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/notification/ORanDOMNotificationToXPath.java create mode 100644 sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/notification/ORanDOMSupervisionNotificationListener.java create mode 100644 sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/notification/ORanNotificationObserver.java create mode 100644 sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/notification/ORanNotificationObserverImpl.java create mode 100644 sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/notification/ORanNotificationReceivedService.java create mode 100644 sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/rpc/ORanSupervisionRPCImpl.java create mode 100644 sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/util/ORanDMDOMUtility.java create mode 100644 sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/util/ORanDeviceManagerQNames.java create mode 100644 sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/vesmapper/ORanDOMFaultToVESFaultMapper.java create mode 100644 sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/vesmapper/ORanDOMSupervisionNotifToVESMapper.java create mode 100644 sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/vesmapper/ORanRegistrationToVESpnfRegistrationMapper.java create mode 100644 sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/yangspecs/ORANFM.java create mode 100644 sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/yangspecs/OnapSystem.java create mode 100644 sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/yangspecs/YangModule.java create mode 100644 sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/test/resources/o-ran-fm@2022-08-15.yang create mode 100644 sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/test/resources/oran-fm-active-alarm.xml create mode 100644 sdnr/wt/netconfnode-state-service/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/DomContext.java delete mode 100644 sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/access/dom/DomContext.java create mode 100644 sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/access/dom/DomContextImpl.java (limited to 'sdnr') diff --git a/sdnr/wt/data-provider/dblib/test2.properties b/sdnr/wt/data-provider/dblib/test2.properties deleted file mode 100644 index e3485ea95..000000000 --- a/sdnr/wt/data-provider/dblib/test2.properties +++ /dev/null @@ -1,7 +0,0 @@ -[mariadb] -url=${SDNRDBURL} -username=${SDNRDBUSERNAME} -password=${SDNRDBPASSWORD} -controllerId=null -suffix= - diff --git a/sdnr/wt/devicemanager-core/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/service/VESCollectorService.java b/sdnr/wt/devicemanager-core/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/service/VESCollectorService.java index f93b599bf..ab016f74f 100644 --- a/sdnr/wt/devicemanager-core/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/service/VESCollectorService.java +++ b/sdnr/wt/devicemanager-core/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/service/VESCollectorService.java @@ -28,6 +28,7 @@ import org.onap.ccsdk.features.sdnr.wt.devicemanager.types.VESFaultFieldsPOJO; import org.onap.ccsdk.features.sdnr.wt.devicemanager.types.VESMessage; import org.onap.ccsdk.features.sdnr.wt.devicemanager.types.VESNotificationFieldsPOJO; import org.onap.ccsdk.features.sdnr.wt.devicemanager.types.VESPNFRegistrationFieldsPOJO; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.types.VESStndDefinedFieldsPOJO; /** * Interface used for publishing VES messages to the VES Collector @@ -97,4 +98,14 @@ public interface VESCollectorService extends DeviceManagerService { */ VESMessage generateVESEvent(VESCommonEventHeaderPOJO commonEventHeader, VESPNFRegistrationFieldsPOJO faultFields) throws JsonProcessingException; + /** + * Generates VES Event JSON containing commonEventHeader and stndDefined fields + * + * @param commonEventHeader + * @param stndDefinedFields + * @return VESMessage - representing the VES Event JSON + * @throws JsonProcessingException + */ + VESMessage generateVESEvent(VESCommonEventHeaderPOJO commonEventHeader, VESStndDefinedFieldsPOJO stndDefinedFields) throws JsonProcessingException; + } diff --git a/sdnr/wt/devicemanager-core/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/types/VESStndDefinedFieldsPOJO.java b/sdnr/wt/devicemanager-core/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/types/VESStndDefinedFieldsPOJO.java new file mode 100644 index 000000000..65bb48302 --- /dev/null +++ b/sdnr/wt/devicemanager-core/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/types/VESStndDefinedFieldsPOJO.java @@ -0,0 +1,54 @@ +/* + * ============LICENSE_START======================================================= + * ONAP : ccsdk features + * ================================================================================ + * Copyright (C) 2023 highstreet technologies GmbH Intellectual Property. + * All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + * + */ +package org.onap.ccsdk.features.sdnr.wt.devicemanager.types; + +public class VESStndDefinedFieldsPOJO { + + private String schemaReference; + private String stndDefinedFieldsVersion = "1.0"; + private Object data; + + public String getSchemaReference() { + return schemaReference; + } + + public void setSchemaReference(String schemaReference) { + this.schemaReference = schemaReference; + } + + public String getStndDefinedFieldsVersion() { + return stndDefinedFieldsVersion; + } + + public void setStndDefinedFieldsVersion(String stndDefinedFieldsVersion) { + this.stndDefinedFieldsVersion = stndDefinedFieldsVersion; + } + + public Object getData() { + return data; + } + + public void setData(Object data) { + this.data = data; + } + +} diff --git a/sdnr/wt/devicemanager-core/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/vescollectorconnector/impl/VESCollectorServiceImpl.java b/sdnr/wt/devicemanager-core/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/vescollectorconnector/impl/VESCollectorServiceImpl.java index 945d42550..a2e6c9a13 100644 --- a/sdnr/wt/devicemanager-core/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/vescollectorconnector/impl/VESCollectorServiceImpl.java +++ b/sdnr/wt/devicemanager-core/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/vescollectorconnector/impl/VESCollectorServiceImpl.java @@ -44,6 +44,7 @@ import org.onap.ccsdk.features.sdnr.wt.devicemanager.types.VESFaultFieldsPOJO; import org.onap.ccsdk.features.sdnr.wt.devicemanager.types.VESMessage; import org.onap.ccsdk.features.sdnr.wt.devicemanager.types.VESNotificationFieldsPOJO; import org.onap.ccsdk.features.sdnr.wt.devicemanager.types.VESPNFRegistrationFieldsPOJO; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.types.VESStndDefinedFieldsPOJO; import org.onap.ccsdk.features.sdnr.wt.devicemanager.vescollectorconnector.impl.config.VESCollectorCfgImpl; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -204,4 +205,23 @@ public class VESCollectorServiceImpl implements VESCollectorService, IConfigChan return new VESMessage(objMapper.writeValueAsString(outerEvent)); } + /** + * Generates VES Event JSON containing commonEventHeader and stndDefined fields + * + * @param commonEventHeader + * @param stndDefinedFields + * @return VESMessage - representing the VES Event JSON + * @throws JsonProcessingException + */ + @Override + public VESMessage generateVESEvent(VESCommonEventHeaderPOJO commonEventHeader, + VESStndDefinedFieldsPOJO stndDefinedFields) throws JsonProcessingException { + Map innerEvent = new HashMap(); + innerEvent.put("commonEventHeader", commonEventHeader); + innerEvent.put("stndDefinedFields", stndDefinedFields); + + Map outerEvent = new HashMap(); + outerEvent.put("event", innerEvent); + return new VESMessage(objMapper.writeValueAsString(outerEvent)); + } } diff --git a/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/config/ORanDMConfig.java b/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/config/ORanDMConfig.java new file mode 100644 index 000000000..11a68e5fa --- /dev/null +++ b/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/config/ORanDMConfig.java @@ -0,0 +1,83 @@ +/* + * ============LICENSE_START======================================================= + * ONAP : ccsdk features + * ================================================================================ + * Copyright (C) 2023 highstreet technologies GmbH Intellectual Property. + * All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + * + */ +package org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.config; + +import org.onap.ccsdk.features.sdnr.wt.common.configuration.Configuration; +import org.onap.ccsdk.features.sdnr.wt.common.configuration.ConfigurationFileRepresentation; + +public class ORanDMConfig implements Configuration { + + private static final String SECTION_MARKER_ORAN_SUPERVISION = "ORAN-SUPERVISION"; + private static final String PROPERTY_KEY_SUPERVISION_NOTIFICATION_INTERVAL = "supervision-notification-interval"; + private static final String PROPERTY_KEY_GUARD_TIMER_OVERHEAD = "guard-timer-overhead"; + + private static final String DEFAULT_SUPERVISION_NOTIFICATION_INTERVAL = "${O_RU_SUPERVISION_NOTIFICATION_INTERVAL}"; + private static final String DEFAULT_GUARD_TIMER_OVERHEAD = "${O_RU_GUARD_TIMER_OVERHEAD}"; + + private static final int DEFAULT_SUPERVISION_NOTIFICATION_INTERVAL_VAL = 60; + private static final int DEFAULT_GUARD_TIMER_OVERHEAD_VAL = 10; + + private ConfigurationFileRepresentation configuration; + + public ORanDMConfig(ConfigurationFileRepresentation configuration) { + this.configuration = configuration; + this.configuration.addSection(SECTION_MARKER_ORAN_SUPERVISION); + defaults(); + } + + @Override + public String getSectionName() { + return SECTION_MARKER_ORAN_SUPERVISION; + } + + @Override + public void defaults() { + configuration.setPropertyIfNotAvailable(this.getSectionName(), PROPERTY_KEY_SUPERVISION_NOTIFICATION_INTERVAL, + DEFAULT_SUPERVISION_NOTIFICATION_INTERVAL); + configuration.setPropertyIfNotAvailable(this.getSectionName(), PROPERTY_KEY_GUARD_TIMER_OVERHEAD, + DEFAULT_GUARD_TIMER_OVERHEAD); + } + + public int getNotificationInterval() { + String v = this.configuration.getProperty(SECTION_MARKER_ORAN_SUPERVISION, + PROPERTY_KEY_SUPERVISION_NOTIFICATION_INTERVAL); + return (v == null || v.equals("null") || v.isEmpty() || !isNumeric(v)) + ? DEFAULT_SUPERVISION_NOTIFICATION_INTERVAL_VAL + : Integer.parseInt(v); + } + + public int getWatchdogTimer() { + String v = this.configuration.getProperty(SECTION_MARKER_ORAN_SUPERVISION, PROPERTY_KEY_GUARD_TIMER_OVERHEAD); + return (v == null || v.equals("null") || v.isEmpty() || !isNumeric(v)) ? DEFAULT_GUARD_TIMER_OVERHEAD_VAL + : Integer.parseInt(v); + } + + private boolean isNumeric(String v) { + try { + int i = Integer.parseInt(v); + } catch (NumberFormatException nfe) { + return false; + } + return true; + } + +} diff --git a/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/dataprovider/ORanDOMToInternalDataModel.java b/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/dataprovider/ORanDOMToInternalDataModel.java new file mode 100644 index 000000000..4b55f1681 --- /dev/null +++ b/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/dataprovider/ORanDOMToInternalDataModel.java @@ -0,0 +1,332 @@ +/* + * ============LICENSE_START======================================================= + * ONAP : ccsdk features + * ================================================================================ + * Copyright (C) 2021 highstreet technologies GmbH Intellectual Property. + * All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + * + */ +package org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.dataprovider; + +import java.time.Instant; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Date; +import java.util.List; +import java.util.Objects; +import java.util.Optional; +import java.util.regex.Matcher; +import java.util.regex.Pattern; +import org.eclipse.jdt.annotation.NonNull; +import org.eclipse.jdt.annotation.Nullable; +import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.NetconfTimeStamp; +import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.types.NetconfTimeStampImpl; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.util.ORanDMDOMUtility; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.util.ORanDeviceManagerQNames; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.yangspecs.ORANFM; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.yangspecs.OnapSystem; +import org.opendaylight.mdsal.dom.api.DOMEvent; +import org.opendaylight.mdsal.dom.api.DOMNotification; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Uri; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DateAndTime; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.FaultlogBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.FaultlogEntity; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.Guicutthrough; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.GuicutthroughBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.Inventory; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.InventoryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.SeverityType; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.SourceType; +import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId; +import org.opendaylight.yangtools.yang.binding.CodeHelpers; +import org.opendaylight.yangtools.yang.common.Uint32; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier; +import org.opendaylight.yangtools.yang.data.api.schema.AugmentationNode; +import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode; +import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode; +import org.opendaylight.yangtools.yang.data.api.schema.MapNode; +import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; +import org.opendaylight.yangtools.yang.data.api.schema.UnkeyedListEntryNode; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class ORanDOMToInternalDataModel { + + private static final Logger LOG = LoggerFactory.getLogger(ORanDOMToInternalDataModel.class); + private static final NetconfTimeStamp NETCONFTIME_CONVERTER = NetconfTimeStampImpl.getConverter(); + + public static List getInventoryList(NodeId nodeId, NormalizedNode hwData) { + + List inventoryResultList = new ArrayList(); + ContainerNode hwContainer = (ContainerNode) hwData; + MapNode componentMap = (MapNode) hwContainer + .getChildByArg(new NodeIdentifier(ORanDeviceManagerQNames.IETF_HW_COMPONENT_LIST)); + Collection componentMapEntries = componentMap.body(); + + for (MapEntryNode componentMapEntryNode : getRootComponents(componentMapEntries)) { + inventoryResultList = + recurseGetInventory(nodeId, componentMapEntryNode, componentMapEntries, 0, inventoryResultList); + } + // Verify if result is complete + if (componentMapEntries.size() != inventoryResultList.size()) { + LOG.warn( + "Not all data were written to the Inventory. Potential entries with missing " + + "contained-child. Node Id = {}, Components Found = {}, Entries written to Database = {}", + nodeId.getValue(), componentMapEntries.size(), inventoryResultList.size()); + } + return inventoryResultList; + } + + private static List recurseGetInventory(NodeId nodeId, MapEntryNode component, + Collection componentList, int treeLevel, List inventoryResultList) { + //Add element to list, if conversion successfull + Optional oInventory = getInternalEquipment(nodeId, component, treeLevel); + if (oInventory.isPresent()) { + inventoryResultList.add(oInventory.get()); + } + //Walk through list of child keys and add to list + for (String childUuid : CodeHelpers.nonnull(new ArrayList<>(ORanDMDOMUtility.getLeafListValue(component, + ORanDeviceManagerQNames.IETF_HW_COMPONENT_LIST_CONTAINS_CHILD)))) { + for (MapEntryNode c : getComponentsByName(childUuid, componentList)) { + inventoryResultList = recurseGetInventory(nodeId, c, componentList, treeLevel + 1, inventoryResultList); + } + } + return inventoryResultList; + } + + public static List getRootComponents(Collection componentMapEntries) { + List resultList = new ArrayList<>(); + for (MapEntryNode componentMapEntryNode : componentMapEntries) { + if (ORanDMDOMUtility.getLeafValue(componentMapEntryNode, + ORanDeviceManagerQNames.IETF_HW_COMPONENT_LIST_PARENT) == null) { // Root elements do not have a parent + resultList.add(componentMapEntryNode); + } + } + return resultList; + } + + private static List getComponentsByName(String name, Collection componentList) { + List resultList = new ArrayList<>(); + for (MapEntryNode c : componentList) { + if (name.equals(ORanDMDOMUtility.getKeyValue(c))) { // <-- Component list is flat search for child's of name + resultList.add(c); + } + } + return resultList; + } + + public static Optional getInternalEquipment(NodeId nodeId, MapEntryNode component, int treeLevel) { + + // Make sure that expected data are not null + Objects.requireNonNull(nodeId); + Objects.requireNonNull(component); + + // Read mandatory data + + @Nullable + String nodeIdString = nodeId.getValue(); + @Nullable + String uuid = ORanDMDOMUtility.getKeyValue(component); + @Nullable + String idParent = + ORanDMDOMUtility.getLeafValue(component, ORanDeviceManagerQNames.IETF_HW_COMPONENT_LIST_PARENT); + @Nullable + String uuidParent = idParent != null ? idParent : uuid; //<- Passt nicht + + // do consistency check if all mandatory parameters are there + if (treeLevel >= 0 && nodeIdString != null && uuid != null && uuidParent != null) { + // Build output data + + InventoryBuilder inventoryBuilder = new InventoryBuilder(); + + // General assumed as mandatory + inventoryBuilder.setNodeId(nodeIdString); + inventoryBuilder.setUuid(uuid); + inventoryBuilder.setParentUuid(uuidParent); + inventoryBuilder.setTreeLevel(Uint32.valueOf(treeLevel)); + + // -- String list with ids of holders (optional) + inventoryBuilder.setContainedHolder(ORanDMDOMUtility.getLeafListValue(component, + ORanDeviceManagerQNames.IETF_HW_COMPONENT_LIST_CONTAINS_CHILD)); + + // -- Manufacturer related things (optional) + @Nullable + String mfgName = + ORanDMDOMUtility.getLeafValue(component, ORanDeviceManagerQNames.IETF_HW_COMPONENT_LIST_MFG_NAME); + inventoryBuilder.setManufacturerName(mfgName); + inventoryBuilder.setManufacturerIdentifier(mfgName); + + // Equipment type (optional) + inventoryBuilder.setDescription( + ORanDMDOMUtility.getLeafValue(component, ORanDeviceManagerQNames.IETF_HW_COMPONENT_LIST_DESC)); + inventoryBuilder.setModelIdentifier(ORanDMDOMUtility.getLeafValue(component, + ORanDeviceManagerQNames.IETF_HW_COMPONENT_LIST_MODEL_NAME)); + + inventoryBuilder.setPartTypeId( + ORanDMDOMUtility.getLeafValue(component, ORanDeviceManagerQNames.IETF_HW_COMPONENT_LIST_CLASS)); + + inventoryBuilder.setTypeName(ORanDMDOMUtility.getKeyValue(component)); + inventoryBuilder.setVersion( + ORanDMDOMUtility.getLeafValue(component, ORanDeviceManagerQNames.IETF_HW_COMPONENT_LIST_HW_REV)); + + // Equipment instance (optional) + @Nullable + String mfgDate = + ORanDMDOMUtility.getLeafValue(component, ORanDeviceManagerQNames.IETF_HW_COMPONENT_LIST_MFG_DATE); + if (mfgDate != null) { + inventoryBuilder.setDate(mfgDate); + } + inventoryBuilder.setSerial( + ORanDMDOMUtility.getLeafValue(component, ORanDeviceManagerQNames.IETF_HW_COMPONENT_LIST_SER_NUM)); + + return Optional.of(inventoryBuilder.build()); + } + return Optional.empty(); + } + + /** + * If system data is available convert + * + * @param sys + * @return + */ + public static Optional getGuicutthrough(@Nullable AugmentationNode onapSysAugData, @NonNull OnapSystem onapSys) { + + if (onapSysAugData != null) { + String name = ORanDMDOMUtility.getLeafValue(onapSysAugData, onapSys.getName()); + @Nullable + Uri uri = new Uri(ORanDMDOMUtility.getLeafValue(onapSysAugData, onapSys.getWebUi())); + if (uri.getValue() != null) { + GuicutthroughBuilder gcBuilder = new GuicutthroughBuilder(); + if (name != null) { + gcBuilder.setName(name); + } + gcBuilder.setWeburi(uri.getValue()); + return Optional.of(gcBuilder.build()); + } + LOG.warn("Uri not set to invoke a Gui cut through session to the device. Please set the Uri in the device"); + } + LOG.warn("Retrieving augmented System details failed. Gui cut through information not available"); + return Optional.empty(); + } + + /** + * Convert fault notification into data-provider FaultLogEntity + * + * @param notification with O-RAN notification + * @param oranfm + * @param nodeId of node to handle + * @param counter to be integrated into data + * @return FaultlogEntity with data + */ + public static FaultlogEntity getFaultLog(DOMNotification notification, @NonNull ORANFM oranfm, NodeId nodeId, Integer counter) { + ContainerNode cn = notification.getBody(); + FaultlogBuilder faultAlarm = new FaultlogBuilder(); + faultAlarm.setNodeId(nodeId.getValue()); + faultAlarm.setObjectId(ORanDMDOMUtility.getLeafValue(cn, oranfm.getFaultSourceQName())); + faultAlarm.setProblem(ORanDMDOMUtility.getLeafValue(cn, oranfm.getFaultTextQName())); + faultAlarm.setSeverity(getSeverityType( + ORanDMDOMUtility.getLeafValue(cn, oranfm.getFaultSeverityQName()), + ORanDMDOMUtility.getLeafValue(cn, oranfm.getFaultIsClearedQName()).equals("true"))); + faultAlarm.setCounter(counter); + faultAlarm.setId(ORanDMDOMUtility.getLeafValue(cn, oranfm.getFaultIdQName())); + faultAlarm.setSourceType(SourceType.Netconf); + faultAlarm.setTimestamp(getEventTime(notification)); + return faultAlarm.build(); + } + + public static FaultlogEntity getFaultLog(UnkeyedListEntryNode activeAlarmEntry, ORANFM oranfm, NodeId nodeId, Integer counter) { + FaultlogBuilder faultAlarm = new FaultlogBuilder(); + faultAlarm.setNodeId(nodeId.getValue()); + faultAlarm.setObjectId(getObjectId( + ORanDMDOMUtility.getLeafValue(activeAlarmEntry, oranfm.getFaultSourceQName()))); + faultAlarm.setProblem( + ORanDMDOMUtility.getLeafValue(activeAlarmEntry, oranfm.getFaultTextQName())); + faultAlarm.setSeverity(getSeverityType( + ORanDMDOMUtility.getLeafValue(activeAlarmEntry, oranfm.getFaultSeverityQName()), + ORanDMDOMUtility.getLeafValue(activeAlarmEntry, oranfm.getFaultIsClearedQName()) + .equals("true"))); + faultAlarm.setCounter(counter); + faultAlarm.setId(ORanDMDOMUtility.getLeafValue(activeAlarmEntry, oranfm.getFaultIdQName())); + faultAlarm.setSourceType(SourceType.Netconf); + faultAlarm.setTimestamp(NetconfTimeStampImpl.getConverter().getTimeStamp( + ORanDMDOMUtility.getLeafValue(activeAlarmEntry, oranfm.getFaultEventTimeQName()))); + return faultAlarm.build(); + + } + + /** + * Convert Instant to NETCONF DateAndTime + * @param eventTimeInstant + * @return DateAndTime + */ + public static DateAndTime getDateAndTimeOfInstant(Instant eventTimeInstant) { + Date eventDate = Date.from(eventTimeInstant); + return new DateAndTime(NETCONFTIME_CONVERTER.getTimeStamp(eventDate)); + } + + private static DateAndTime getEventTime(DOMNotification notification) { + DateAndTime eventTime; + Instant notificationEventTime = null; + if (notification instanceof DOMEvent) { + notificationEventTime = ((DOMEvent) notification).getEventInstant(); + eventTime = NetconfTimeStampImpl.getConverter().getTimeStamp(notificationEventTime.toString()); + } else { + eventTime = NetconfTimeStampImpl.getConverter().getTimeStamp(); + } + return eventTime; + } + + /** + * Convert O-RAN specific severity into data-provider severity + * + * @param faultSeverity O-RAN severity + * @param isCleared clear indicator + * @return data-provider severity type + * @throws IllegalArgumentException if conversion not possible. + */ + private static SeverityType getSeverityType(@Nullable String faultSeverity, @Nullable Boolean isCleared) + throws IllegalArgumentException { + if (isCleared != null && isCleared) { + return SeverityType.NonAlarmed; + } + if (faultSeverity != null) { + switch (faultSeverity) { + case "CRITICAL": + return SeverityType.Critical; + case "MAJOR": + return SeverityType.Major; + case "MINOR": + return SeverityType.Minor; + case "WARNING": + return SeverityType.Warning; + } + } + throw new IllegalArgumentException("Unknown Alarm state represent as Critical. isCleared=" + isCleared + + " faultSeverity=" + faultSeverity); + } + + private static String getObjectId(String leafValue) { + // fault-source = /ietf-hardware:hardware/component[name='slot0-logical0'] + Pattern p = Pattern.compile("\\/ietf-hardware:hardware\\/component\\[name=\\'(.*)\\']"); + Matcher m = p.matcher(leafValue); + if (m.find()) { + return m.group(1); + } + return leafValue; + } + +} diff --git a/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/dom/DOMNotificationToXPath.java b/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/dom/DOMNotificationToXPath.java deleted file mode 100644 index 3d7353328..000000000 --- a/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/dom/DOMNotificationToXPath.java +++ /dev/null @@ -1,234 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * ONAP : ccsdk features - * ================================================================================ - * Copyright (C) 2020 highstreet technologies GmbH Intellectual Property. - * All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - * - */ -package org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.impl.dom; - -import com.google.common.base.VerifyException; -import java.time.Instant; -import java.util.Collection; -import java.util.HashMap; -import org.eclipse.jdt.annotation.NonNull; -import org.opendaylight.mdsal.dom.api.DOMEvent; -import org.opendaylight.mdsal.dom.api.DOMNotification; -import org.opendaylight.yangtools.yang.common.QName; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument; -import org.opendaylight.yangtools.yang.data.api.schema.ChoiceNode; -import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode; -import org.opendaylight.yangtools.yang.data.api.schema.DataContainerChild; -import org.opendaylight.yangtools.yang.data.api.schema.DataContainerNode; -import org.opendaylight.yangtools.yang.data.api.schema.LeafSetEntryNode; -import org.opendaylight.yangtools.yang.data.api.schema.LeafSetNode; -import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode; -import org.opendaylight.yangtools.yang.data.api.schema.MapNode; -import org.opendaylight.yangtools.yang.data.api.schema.UnkeyedListEntryNode; -import org.opendaylight.yangtools.yang.data.api.schema.UnkeyedListNode; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class DOMNotificationToXPath { - private static final Logger LOG = LoggerFactory.getLogger(DOMNotificationToXPath.class); - - public HashMap convertDomNotifToXPath(@NonNull DOMNotification domNotification) { - @NonNull - ContainerNode notifContainer = domNotification.getBody(); - HashMap xPathData = new HashMap(); - - Collection data = notifContainer.body(); - for (DataContainerChild data1 : data) { - String namePath = ""; - recurseDOMData(notifContainer, data1, notifContainer, xPathData, namePath); - } - LOG.debug("XPath Data = {}", xPathData); - return xPathData; - - } - - private void recurseDOMData(@NonNull ContainerNode notifContainer, DataContainerChild domData, DataContainerNode cn, - HashMap result, String namePath) { - PathArgument pa1 = domData.getIdentifier(); - namePath += "/" + pa1.getNodeType().getLocalName(); - if (domData.getClass().getSimpleName().equals("ImmutableContainerNode")) { - try { - ContainerNode cn1 = (ContainerNode) cn.getChildByArg(pa1); - for (DataContainerChild data1 : cn1.body()) { - recurseDOMData(notifContainer, data1, cn1, result, namePath); - } - } catch (VerifyException ve) { - LOG.debug("{} does not exist", pa1); - } - } - - if (domData.getClass().getSimpleName().equals("ImmutableChoiceNode")) { - try { - ChoiceNode cn1 = (ChoiceNode) cn.getChildByArg(pa1); - for (DataContainerChild data1 : cn1.body()) { - // recurseChoiceData(data1, cn1, namePath); - recurseDOMData(notifContainer, data1, cn1, result, namePath); - } - } catch (VerifyException ve) { - LOG.debug("{} does not exist", pa1); - } - } - - if (domData.getClass().getSimpleName().equals("ImmutableUnkeyedListNode")) { - try { - UnkeyedListNode cn1 = (UnkeyedListNode) cn.getChildByArg(pa1); - for (UnkeyedListEntryNode data1 : cn1.body()) { - recurseUnkeyedListEntryNodeData(data1, cn1, result, namePath); - } - } catch (VerifyException ve) { - LOG.debug("{} does not exist", pa1); - } - } - - if (domData.getClass().getSimpleName().equals("ImmutableMapNode")) { - try { - MapNode cn1 = (MapNode) cn.getChildByArg(pa1); - for (MapEntryNode data1 : cn1.body()) { - recurseMapEntryNodeData(notifContainer, data1, cn1, result, namePath); - } - } catch (VerifyException ve) { - LOG.debug("{} does not exist", pa1); - } - } - - if (domData.getClass().getSimpleName().equals("ImmutableLeafSetNode")) { - try { - LeafSetNode cn1 = (LeafSetNode) cn.getChildByArg(pa1); - for (LeafSetEntryNode data1 : cn1.body()) { - recurseLeafSetEntryNodeData(data1, cn1, result, namePath); - } - } catch (VerifyException ve) { - LOG.debug("{} does not exist", pa1); - } - } - - if (domData.getClass().getSimpleName().equals("ImmutableLeafNode")) { - recurseLeafNode(domData, result, namePath); - } - } - - private void recurseLeafSetEntryNodeData(LeafSetEntryNode data, LeafSetNode cn1, - HashMap result, String namePath) { - PathArgument pa1 = data.getIdentifier(); - namePath += "/" + pa1.getNodeType().getLocalName(); - - if (data.getClass().getSimpleName().equals("ImmutableLeafSetEntryNode")) { - LOG.debug("{}={}", namePath, data.body()); - result.put(namePath, data.body().toString()); - } - } - - private void recurseMapEntryNodeData(@NonNull ContainerNode notifContainer, MapEntryNode data, MapNode cn1, - HashMap result, String namePath) { - PathArgument pa1 = data.getIdentifier(); - NodeIdentifierWithPredicates ni = data.getIdentifier(); - - for (QName qn : ni.keySet()) { - namePath += "/" + ni.getValue(qn); - } - - if (data.getClass().getSimpleName().equals("ImmutableMapEntryNode")) { - for (DataContainerChild data1 : data.body()) { - if (data1.getClass().getSimpleName().equals("ImmutableLeafSetNode")) { - try { - LeafSetNode cn2 = (LeafSetNode) data.getChildByArg(data1.getIdentifier()); - for (LeafSetEntryNode data2 : cn2.body()) { - recurseLeafSetEntryNodeData(data2, cn2, result, namePath); - } - } catch (VerifyException ve) { - LOG.debug("{} does not exist", data1.getIdentifier()); - } - } else { - recurseLeafNode(data1, result, namePath); - } - } - } - - if (data.getClass().getSimpleName().equals("ImmutableLeafSetNode")) { - try { - LeafSetNode cn2 = (LeafSetNode) notifContainer.getChildByArg(pa1); - for (LeafSetEntryNode data1 : cn2.body()) { - recurseLeafSetEntryNodeData(data1, cn2, result, namePath); - } - } catch (VerifyException ve) { - LOG.debug("{} does not exist", pa1); - } - } - - if (data.getClass().getSimpleName().equals("ImmutableLeafNode")) { - LOG.debug("{}={}", namePath, data.body()); - result.put(namePath, data.body().toString()); - } - } - - private void recurseUnkeyedListEntryNodeData(UnkeyedListEntryNode data, UnkeyedListNode cn1, - HashMap result, String namePath) { - PathArgument pa1 = data.getIdentifier(); - namePath += "/" + pa1.getNodeType().getLocalName(); - - if (data.getClass().getSimpleName().equals("ImmutableUnkeyedListEntryNode")) { - for (DataContainerChild data1 : data.body()) { - recurseLeafNode(data1, result, namePath); - } - } - - if (data.getClass().getSimpleName().equals("ImmutableLeafNode")) { - LOG.debug("{}={}", namePath, data.body()); - result.put(namePath, data.body().toString()); - } - } - - public void recurseLeafNode(DataContainerChild data, HashMap result, String namePath) { - PathArgument pa1 = data.getIdentifier(); - if (!(data.getClass().getSimpleName().equals("ImmutableAugmentationNode"))) - namePath += "/" + pa1.getNodeType().getLocalName(); - if (data.getClass().getSimpleName().equals("ImmutableLeafNode")) { - LOG.debug("{}={}", namePath, data.body()); - result.put(namePath, data.body().toString()); - } - } - - public void recurseChoiceData(HashMap result, DataContainerChild data, ChoiceNode cn, - String namePath) { - PathArgument pa1 = data.getIdentifier(); - namePath += "/" + pa1.getNodeType().getLocalName(); - // NodeIdentifier nodeId = new NodeIdentifier(pa1.getNodeType()); - if (data.getClass().getSimpleName().equals("ImmutableLeafNode")) { - LOG.debug("{}={}", namePath, data.body()); - result.put(namePath, data.body().toString()); - } - } - - public Instant getTime(@NonNull DOMNotification domNotification) { - @NonNull - Instant eventTime; - if (domNotification instanceof DOMEvent) { - eventTime = ((DOMEvent) domNotification).getEventInstant(); - LOG.debug("Event time {}", eventTime); - } else { - eventTime = Instant.now(); - LOG.debug("Defaulting to actual time of processing the notification - {}", eventTime); - } - return eventTime; - } -} diff --git a/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/dom/DeviceManagerORanImpl.java b/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/dom/DeviceManagerORanImpl.java index de018ba4e..fd9ed2afa 100644 --- a/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/dom/DeviceManagerORanImpl.java +++ b/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/dom/DeviceManagerORanImpl.java @@ -17,8 +17,10 @@ */ package org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.impl.dom; +import org.onap.ccsdk.features.sdnr.wt.common.configuration.ConfigurationFileRepresentation; import org.onap.ccsdk.features.sdnr.wt.common.database.HtDatabaseClient; import org.onap.ccsdk.features.sdnr.wt.devicemanager.ne.factory.FactoryRegistration; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.config.ORanDMConfig; import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.NetconfNetworkElementService; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -27,7 +29,6 @@ public class DeviceManagerORanImpl implements AutoCloseable { private static final Logger LOG = LoggerFactory.getLogger(DeviceManagerORanImpl.class); private static final String APPLICATION_NAME = "DeviceManagerORan"; - @SuppressWarnings("unused") private static final String CONFIGURATIONFILE = "etc/devicemanager-oran.properties"; @@ -36,6 +37,7 @@ public class DeviceManagerORanImpl implements AutoCloseable { private HtDatabaseClient htDatabaseClient; private Boolean devicemanagerInitializationOk = false; private FactoryRegistration resORan; + private ORanDMConfig oranSupervisionConfig; // Blueprint begin public DeviceManagerORanImpl() { @@ -51,8 +53,11 @@ public class DeviceManagerORanImpl implements AutoCloseable { LOG.info("Session Initiated start {}", APPLICATION_NAME); - resORan = netconfNetworkElementService.registerBindingNetworkElementFactory(new ORanNetworkElementFactory()); + ConfigurationFileRepresentation configFileRepresentation = + new ConfigurationFileRepresentation(CONFIGURATIONFILE); + oranSupervisionConfig = new ORanDMConfig(configFileRepresentation); + resORan = netconfNetworkElementService.registerBindingNetworkElementFactory(new ORanNetworkElementFactory(configFileRepresentation, oranSupervisionConfig)); netconfNetworkElementService.writeToEventLog(APPLICATION_NAME, "startup", "done"); this.devicemanagerInitializationOk = true; diff --git a/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/dom/ORanDMDOMUtility.java b/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/dom/ORanDMDOMUtility.java deleted file mode 100644 index a3bd14e3e..000000000 --- a/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/dom/ORanDMDOMUtility.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * ONAP : ccsdk features - * ================================================================================ - * Copyright (C) 2021 highstreet technologies GmbH Intellectual Property. - * All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - * - */ -package org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.impl.dom; - -import java.time.Instant; -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Set; - -import org.opendaylight.mdsal.dom.api.DOMEvent; -import org.opendaylight.mdsal.dom.api.DOMNotification; -import org.opendaylight.yangtools.yang.common.QName; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates; -import org.opendaylight.yangtools.yang.data.api.schema.DataContainerChild; -import org.opendaylight.yangtools.yang.data.api.schema.DataContainerNode; -import org.opendaylight.yangtools.yang.data.api.schema.LeafNode; -import org.opendaylight.yangtools.yang.data.api.schema.LeafSetEntryNode; -import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import com.google.common.base.VerifyException; - -public class ORanDMDOMUtility { - public static final Logger LOG = LoggerFactory.getLogger(ORanDMDOMUtility.class); - - public static String getKeyValue(MapEntryNode componentEntry) { - NodeIdentifierWithPredicates componentKey = componentEntry.getIdentifier(); // list key - return (String) componentKey.getValue(ORanDeviceManagerQNames.IETF_HW_COMPONENT_LIST_KEY); - } - - public static String getLeafValue(DataContainerNode componentEntry, QName leafQName) { - NodeIdentifier leafNodeIdentifier = new NodeIdentifier(leafQName); - try { - LeafNode optLeafNode = (LeafNode) componentEntry.getChildByArg(leafNodeIdentifier); - if (optLeafNode.body() instanceof QName) { - LOG.debug("Leaf is of type QName"); - } - return optLeafNode.body().toString(); - } catch (VerifyException ve) { - LOG.debug("Leaf with QName {} not found", leafQName.toString()); - return null; - } - } - - public static Set getLeafListValue(DataContainerNode componentEntry, QName leafListQName) { - Set containsChildList = new HashSet(); - try { - DataContainerChild childSet = componentEntry.getChildByArg(new NodeIdentifier(leafListQName)); - Collection childEntry = (Collection) childSet.body(); - Iterator childEntryItr = childEntry.iterator(); - while (childEntryItr.hasNext()) { - LeafSetEntryNode childEntryNode = (LeafSetEntryNode) childEntryItr.next(); - containsChildList.add(childEntryNode.body().toString()); - } - } catch (VerifyException ve) { - LOG.debug("Child for {} does not exist", leafListQName); - } - return containsChildList; - } - - public static Instant getNotificationInstant(DOMNotification notification) { - if (notification instanceof DOMEvent) { - return ((DOMEvent) notification).getEventInstant(); - } else { - return Instant.now(); - } - } - -} diff --git a/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/dom/ORanDOMChangeNotificationListener.java b/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/dom/ORanDOMChangeNotificationListener.java deleted file mode 100644 index f8e8b6da2..000000000 --- a/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/dom/ORanDOMChangeNotificationListener.java +++ /dev/null @@ -1,148 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * ONAP : ccsdk features - * ================================================================================ - * Copyright (C) 2021 highstreet technologies GmbH Intellectual Property. - * All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - * - */ -package org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.impl.dom; - -import com.fasterxml.jackson.core.JsonProcessingException; -import java.time.Instant; -import org.eclipse.jdt.annotation.NonNull; -import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.DataProvider; -import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.types.NetconfTimeStampImpl; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.VESCollectorService; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.types.VESCommonEventHeaderPOJO; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.types.VESNotificationFieldsPOJO; -import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfDomAccessor; -import org.opendaylight.mdsal.dom.api.DOMEvent; -import org.opendaylight.mdsal.dom.api.DOMNotification; -import org.opendaylight.mdsal.dom.api.DOMNotificationListener; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DateAndTime; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.EventlogBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.EventlogEntity; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.SourceType; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier; -import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode; -import org.opendaylight.yangtools.yang.data.api.schema.UnkeyedListNode; -import org.opendaylight.yangtools.yang.model.api.stmt.SchemaNodeIdentifier.Absolute; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class ORanDOMChangeNotificationListener implements DOMNotificationListener { - - private static final Logger log = LoggerFactory.getLogger(ORanDOMChangeNotificationListener.class); - - private final NetconfDomAccessor netconfDomAccessor; - private final DataProvider databaseService; - private @NonNull VESCollectorService vesCollectorService; - private final DOMNotificationToXPath domNotificationXPath; - private ORanDOMNotifToVESEventAssembly mapper = null; - private static int sequenceNo = 0; - - public ORanDOMChangeNotificationListener(NetconfDomAccessor netconfDomAccessor, - @NonNull VESCollectorService vesCollectorService, DataProvider databaseService) { - this.netconfDomAccessor = netconfDomAccessor; - this.databaseService = databaseService; - this.vesCollectorService = vesCollectorService; - domNotificationXPath = new DOMNotificationToXPath(); - } - - @Override - public void onNotification(@NonNull DOMNotification domNotification) { - if (domNotification.getType() - .equals(Absolute.of(ORanDeviceManagerQNames.IETF_NETCONF_NOTIFICATIONS_NETCONF_CONFIG_CHANGE))) { - handleNetconfConfigChange(domNotification); - } - } - - private void handleNetconfConfigChange(@NonNull DOMNotification domNotification) { - DateAndTime eventTime; - Instant notificationEventTime = null; - if (domNotification instanceof DOMEvent) { - notificationEventTime = ((DOMEvent) domNotification).getEventInstant(); - eventTime = NetconfTimeStampImpl.getConverter().getTimeStamp(notificationEventTime.toString()); - } else { - eventTime = NetconfTimeStampImpl.getConverter().getTimeStamp(); - } - - ContainerNode cn = domNotification.getBody(); - - // Process the changed-by child - // ContainerNode changedByContainerNode = (ContainerNode) cn - // .childByArg(new NodeIdentifier(ORanDeviceManagerQNames.IETF_NETCONF_NOTIFICATIONS_CHANGEDBY)); - // ChoiceNode serverOrUserIDVal = (ChoiceNode) changedByContainerNode - // .childByArg(new NodeIdentifier(ORanDeviceManagerQNames.IETF_NETCONF_NOTIFICATIONS_SERVERORUSER)); - // @SuppressWarnings("unused") - // String userIDValue = serverOrUserIDVal - // .childByArg(new NodeIdentifier(ORanDeviceManagerQNames.IETF_NETCONF_NOTIFICATIONS_USERNAME)).body() - // .toString(); - // @SuppressWarnings("unused") - // Integer sessionIDVal = Integer.valueOf(serverOrUserIDVal - // .childByArg(new NodeIdentifier(ORanDeviceManagerQNames.IETF_NETCONF_NOTIFICATIONS_SESSIONID)).body() - // .toString()); - // - // // Process the datastore child - // @SuppressWarnings("unused") - // String datastoreValue = cn - // .childByArg(new NodeIdentifier(ORanDeviceManagerQNames.IETF_NETCONF_NOTIFICATIONS_DATASTORE)).body() - // .toString(); - - // Process the edit child - UnkeyedListNode editList = (UnkeyedListNode) cn - .childByArg(new NodeIdentifier(ORanDeviceManagerQNames.IETF_NETCONF_NOTIFICATIONS_EDITNODE)); - if (editList != null) { - for (int listCnt = 0; listCnt < editList.size(); listCnt++) { - String operationValue = editList.childAt(listCnt) - .childByArg(new NodeIdentifier(ORanDeviceManagerQNames.IETF_NETCONF_NOTIFICATIONS_OPERATION)) - .body().toString(); - String targetValue = editList.childAt(listCnt) - .childByArg(new NodeIdentifier(ORanDeviceManagerQNames.IETF_NETCONF_NOTIFICATIONS_TARGET)) - .body().toString(); - - EventlogEntity eventLogEntity1 = new EventlogBuilder() - .setNodeId(netconfDomAccessor.getNodeId().getValue()).setCounter(sequenceNo++) - .setTimestamp(eventTime).setObjectId(targetValue).setAttributeName("N.A") - .setSourceType(SourceType.Netconf).setNewValue(String.valueOf(operationValue)).build(); - databaseService.writeEventLog(eventLogEntity1); - } - } - - if (vesCollectorService.getConfig().isVESCollectorEnabled()) { - if (mapper == null) { - this.mapper = new ORanDOMNotifToVESEventAssembly(netconfDomAccessor, vesCollectorService); - } - VESCommonEventHeaderPOJO header = - mapper.createVESCommonEventHeader(domNotificationXPath.getTime(domNotification), - ORanDeviceManagerQNames.IETF_NETCONF_NOTIFICATIONS_NETCONF_CONFIG_CHANGE.getLocalName(), - sequenceNo); - VESNotificationFieldsPOJO body = - mapper.createVESNotificationFields(domNotificationXPath.convertDomNotifToXPath(domNotification), - ORanDeviceManagerQNames.IETF_NETCONF_NOTIFICATIONS_NETCONF_CONFIG_CHANGE.getLocalName()); - log.debug("domNotification in XPath format = {}", - domNotificationXPath.convertDomNotifToXPath(domNotification)); - try { - vesCollectorService.publishVESMessage(vesCollectorService.generateVESEvent(header, body)); - } catch (JsonProcessingException e) { - log.warn("Exception while generating JSON object ", e); - - } - } - - } -} diff --git a/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/dom/ORanDOMFaultNotificationListener.java b/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/dom/ORanDOMFaultNotificationListener.java deleted file mode 100644 index 3e6921272..000000000 --- a/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/dom/ORanDOMFaultNotificationListener.java +++ /dev/null @@ -1,171 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * ONAP : ccsdk features - * ================================================================================ - * Copyright (C) 2021 highstreet technologies GmbH Intellectual Property. - * All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - * - */ -package org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.impl.dom; - -import com.fasterxml.jackson.core.JsonProcessingException; -import java.time.Instant; -import java.time.format.DateTimeParseException; -import java.util.Collection; -import java.util.Objects; -import org.eclipse.jdt.annotation.NonNull; -import org.json.JSONException; -import org.json.JSONObject; -import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.DataProvider; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.FaultService; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.VESCollectorService; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.types.VESCommonEventHeaderPOJO; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.types.VESFaultFieldsPOJO; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.types.VESMessage; -import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfDomAccessor; -import org.onap.ccsdk.features.sdnr.wt.websocketmanager.model.WebsocketManagerService; -import org.opendaylight.mdsal.dom.api.DOMNotification; -import org.opendaylight.mdsal.dom.api.DOMNotificationListener; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.EventlogBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.SourceType; -import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class ORanDOMFaultNotificationListener implements DOMNotificationListener { - - private static final Logger LOG = LoggerFactory.getLogger(ORanDOMFaultNotificationListener.class); - - private final @NonNull NetconfDomAccessor netconfDomAccessor; - private final @NonNull VESCollectorService vesCollectorService; - private final @NonNull ORanDOMFaultToVESFaultMapper mapper; - private final @NonNull FaultService faultService; - private final @NonNull WebsocketManagerService websocketManagerService; - private final @NonNull DataProvider databaseService; - - private Integer counter; //Local counter is assigned to Notifications - - public ORanDOMFaultNotificationListener(@NonNull NetconfDomAccessor netconfDomAccessor, - @NonNull VESCollectorService vesCollectorService, @NonNull FaultService faultService, - @NonNull WebsocketManagerService websocketManagerService, @NonNull DataProvider databaseService) { - this.netconfDomAccessor = Objects.requireNonNull(netconfDomAccessor); - this.vesCollectorService = Objects.requireNonNull(vesCollectorService); - this.faultService = Objects.requireNonNull(faultService); - this.websocketManagerService = Objects.requireNonNull(websocketManagerService); - this.databaseService = Objects.requireNonNull(databaseService); - - this.mapper = - new ORanDOMFaultToVESFaultMapper(netconfDomAccessor.getNodeId(), vesCollectorService, "AlarmNotif"); - this.counter = 0; - } - - @Override - public void onNotification(@NonNull DOMNotification notification) { - onAlarmNotif(notification); - } - - /** - * Gets the mfg name, mode-name and Uuid of the root component (Ex: Chassis.) In cases where there are multiple root - * components i.e., components with no parent, the Uuid of the last occurred component from the componentList will - * be considered. Till now we haven't seen Uuid set for root components, so not an issue for now. - * - * @param componentList - */ - public void setComponentList(Collection componentList) { - for (MapEntryNode component : ORanDOMToInternalDataModel.getRootComponents(componentList)) { - mapper.setMfgName( - ORanDMDOMUtility.getLeafValue(component, ORanDeviceManagerQNames.IETF_HW_COMPONENT_LIST_MFG_NAME)); - mapper.setUuid(ORanDMDOMUtility.getLeafValue(component, - ORanDeviceManagerQNames.IETF_HW_COMPONENT_LIST_UUID) != null - ? ORanDMDOMUtility.getLeafValue(component, - ORanDeviceManagerQNames.IETF_HW_COMPONENT_LIST_UUID) - : netconfDomAccessor.getNodeId().getValue()); - mapper.setModelName(ORanDMDOMUtility.getLeafValue(component, - ORanDeviceManagerQNames.IETF_HW_COMPONENT_LIST_MODEL_NAME)); - } - } - - public void onAlarmNotif(DOMNotification notification) { - - LOG.debug("onAlarmNotif {}", notification.getClass().getSimpleName()); - counter++; - // Send devicemanager specific notification for database and ODLUX - Instant eventTimeInstant = ORanDMDOMUtility.getNotificationInstant(notification); - faultService.faultNotification( - ORanDOMToInternalDataModel.getFaultLog(notification, netconfDomAccessor.getNodeId(), counter)); - // Send model specific notification to WebSocketManager - websocketManagerService.sendNotification(notification, netconfDomAccessor.getNodeId(), ORanDeviceManagerQNames.ORAN_FM_ALARM_NOTIF); - - try { - if (vesCollectorService.getConfig().isVESCollectorEnabled()) { - VESCommonEventHeaderPOJO header = mapper.mapCommonEventHeader(notification, eventTimeInstant, counter); - VESFaultFieldsPOJO body = mapper.mapFaultFields(notification); - VESMessage vesMsg = vesCollectorService.generateVESEvent(header, body); - vesCollectorService.publishVESMessage(vesMsg); - LOG.debug("VES Message is {}", vesMsg.getMessage()); - writeToEventLog(vesMsg.getMessage(), eventTimeInstant, ORanDeviceManagerQNames.ORAN_FM_ALARM_NOTIF.getLocalName(), counter); - } - } catch (JsonProcessingException | DateTimeParseException e) { - LOG.debug("Can not convert event into VES message {}", notification, e); - } - } - - private void writeToEventLog(String data, Instant eventTimeInstant, String notificationName, int sequenceNo) { - EventlogBuilder eventlogBuilder = new EventlogBuilder(); - - eventlogBuilder.setObjectId("Device"); - eventlogBuilder.setCounter(sequenceNo); - eventlogBuilder.setAttributeName(notificationName); - eventlogBuilder.setNodeId(netconfDomAccessor.getNodeId().getValue()); - String eventLogMsgLvl = vesCollectorService.getConfig().getEventLogMsgDetail(); - if (eventLogMsgLvl.equalsIgnoreCase("SHORT")) { - data = getShortEventLogMessage(data); - } else if (eventLogMsgLvl.equalsIgnoreCase("MEDIUM")) { - data = getMediumEventLogMessage(data); - } else if (eventLogMsgLvl.equalsIgnoreCase("LONG")) { - // do nothing, data already contains long message - } else { // Unknown value, default to "SHORT" - data = getShortEventLogMessage(data); - } - eventlogBuilder.setNewValue(data); - eventlogBuilder.setSourceType(SourceType.Netconf); - eventlogBuilder.setTimestamp(ORanDOMToInternalDataModel.getDateAndTimeOfInstant(eventTimeInstant)); - - databaseService.writeEventLog(eventlogBuilder.build()); - } - - private String getShortEventLogMessage(String data) { - try { - JSONObject jsonObj = new JSONObject(data); - String domain = jsonObj.getJSONObject("event").getJSONObject("commonEventHeader").getString("domain"); - String eventId = jsonObj.getJSONObject("event").getJSONObject("commonEventHeader").getString("eventId"); - return "domain:" + domain + " eventId:" + eventId; - } catch (JSONException e) { - LOG.debug("{}", e); - return "Invalid message received"; - } - } - - private String getMediumEventLogMessage(String data) { - try { - JSONObject jsonObj = new JSONObject(data); - return jsonObj.getJSONObject("event").getJSONObject("commonEventHeader").toString(); - } catch (JSONException e) { - LOG.debug("{}", e); - return "Invalid message received"; - } - } -} diff --git a/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/dom/ORanDOMFaultToVESFaultMapper.java b/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/dom/ORanDOMFaultToVESFaultMapper.java deleted file mode 100644 index 77bd82d12..000000000 --- a/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/dom/ORanDOMFaultToVESFaultMapper.java +++ /dev/null @@ -1,154 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * ONAP : ccsdk features - * ================================================================================ - * Copyright (C) 2021 highstreet technologies GmbH Intellectual Property. - * All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - * - */ -package org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.impl.dom; - -import java.time.Instant; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.VESCollectorService; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.types.VESCommonEventHeaderPOJO; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.types.VESFaultFieldsPOJO; -import org.opendaylight.mdsal.dom.api.DOMNotification; -import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId; -import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -//@formatter:off -/* -* Maps ORAN Fault fields to VES fault domain fields and VES commonEventHeader fields -* -* -* VES Fields Mapping -* ---------- ------- -* domain "fault" -* eventId "nt:network-topology/nt:topology/nt:node/nt:node-id" -* eventName "nt:network-topology/nt:topology/nt:node/nt:node-id" -* eventType "O-RAN-RU-Fault" -* lastEpochMicrosec TimeStamp represented by field in NetConf notification header in unix time format - as microseconds elapsed since 1 Jan 1970 not including leap seconds. -* nfcNamingCode always "" -* nfNamingCode always "" -* nfVendorName /ietf-hardware:hardware/component[not(parent)][1]/mfg-name -* priority "Normal" -* reportingEntityId The OAM-Controller identifier with in the SMO - e.g. the fully qualified domain name or IP-Address. -* reportingEntityName as configured by helm charts for the OpenDaylight cluster name ?????? -* sequence As per NetConf notification increasing sequence number as unsigned integer 32 bits. The value is reused in the eventId field. -* sourceId Value of ietf-hardware (RFC8348) /hardware/component[not(parent)][1]/uuid or 'nt:network-topology/nt:topology/nt:node/nt:node-id' if ietf component not found. -* sourceName "nt:network-topology/nt:topology/nt:node/nt:node-id" -* startEpochMicrosec Current OAM-Controller Node timestamp in unix time format - as microseconds elapsed since 1 Jan 1970 not including leap seconds. -* timeZoneOffset Static text: "+00:00" -* version "4.1" -* vesEventListenerVersion "7.2.1" -* -* -* alarmAdditionalInformation -* alarmCondition Value of "o-ran-fm:alarm-notif/fault-id" -* alarmInterfaceA Value of "o-ran-fm:alarm-notif/fault-source" -* eventCategory Static text "O-RU failure" -* eventSeverity Value of "o-ran-fm:alarm-notif/fault-severity". But if "o-ran-fm:alarm-notif/is-cleared" then "NORMAL" -* eventSourceType The value of ietf-hardware (RFC8348) /hardware/component[not(parent)][1]/model-name or "O-RU" if not found. -* faultFieldsVersion "4.0" -* specificProblem A mapping of the fault-id to its description according to O-RAN OpenFronthaul specification. -* vfStatus "Active" -* -*/ -//@formatter:on - -public class ORanDOMFaultToVESFaultMapper { - @SuppressWarnings("unused") - private static final Logger LOG = LoggerFactory.getLogger(ORanDOMFaultToVESFaultMapper.class); - private static final String VES_EVENT_DOMAIN = "fault"; - private static final String VES_EVENTTYPE = "ORAN_Fault"; - private static final String VES_EVENT_PRIORITY = "Normal"; - private static final String VES_EVENT_CATEGORY = "O-RU Failure"; - private static final String VES_FAULT_FIELDS_VERSION = "4.0"; - private static final String VES_FAULT_FIELDS_VFSTATUS = "Active"; //virtual function status - - private final VESCollectorService vesProvider; - private final String notifName; // Name - private final String nodeIdString; // Sourcename - //Initialized during registration - private String mfgName; - private String uuid; - private String modelName; - - public ORanDOMFaultToVESFaultMapper(NodeId nodeId, VESCollectorService vesCollectorService, String notifName) { - this.nodeIdString = nodeId.getValue(); - this.vesProvider = vesCollectorService; - this.notifName = notifName; - } - - public void setMfgName(String mfgName) { - this.mfgName = mfgName; - } - - public void setUuid(String uuid) { - this.uuid = uuid; - } - - public void setModelName(String modelName) { - this.modelName = modelName; - } - - public VESCommonEventHeaderPOJO mapCommonEventHeader(DOMNotification notification, Instant eventTime, - int sequenceNo) { - VESCommonEventHeaderPOJO vesCEH = new VESCommonEventHeaderPOJO(); - vesCEH.setDomain(VES_EVENT_DOMAIN); - vesCEH.setEventName(notifName); - vesCEH.setEventType(VES_EVENTTYPE); - vesCEH.setPriority(VES_EVENT_PRIORITY); - - String eventId = notifName + "-" + Long.toUnsignedString(sequenceNo); - - vesCEH.setEventId(eventId); - vesCEH.setStartEpochMicrosec(eventTime.toEpochMilli() * 1000); - vesCEH.setLastEpochMicrosec(eventTime.toEpochMilli() * 1000); - vesCEH.setNfVendorName(mfgName); - vesCEH.setReportingEntityName(vesProvider.getConfig().getReportingEntityName()); - vesCEH.setSequence(sequenceNo); - vesCEH.setSourceId(uuid); - vesCEH.setSourceName(nodeIdString); - - return vesCEH; - } - - public VESFaultFieldsPOJO mapFaultFields(DOMNotification alarmNotif) { - VESFaultFieldsPOJO vesFaultFields = new VESFaultFieldsPOJO(); - ContainerNode cn = alarmNotif.getBody(); - vesFaultFields.setAlarmCondition(ORanDMDOMUtility.getLeafValue(cn, ORanDeviceManagerQNames.ORAN_FM_FAULT_ID)); - vesFaultFields - .setAlarmInterfaceA(ORanDMDOMUtility.getLeafValue(cn, ORanDeviceManagerQNames.ORAN_FM_FAULT_SOURCE)); - vesFaultFields.setEventCategory(VES_EVENT_CATEGORY); - if (ORanDMDOMUtility.getLeafValue(cn, ORanDeviceManagerQNames.ORAN_FM_FAULT_IS_CLEARED).equals("true")) { - vesFaultFields.setEventSeverity("NORMAL"); - } else { - vesFaultFields.setEventSeverity( - ORanDMDOMUtility.getLeafValue(cn, ORanDeviceManagerQNames.ORAN_FM_FAULT_SEVERITY)); - } - vesFaultFields.setEventSourceType(modelName); - vesFaultFields.setFaultFieldsVersion(VES_FAULT_FIELDS_VERSION); - vesFaultFields - .setSpecificProblem(ORanDMDOMUtility.getLeafValue(cn, ORanDeviceManagerQNames.ORAN_FM_FAULT_TEXT)); - vesFaultFields.setVfStatus(VES_FAULT_FIELDS_VFSTATUS); - - return vesFaultFields; - } - -} diff --git a/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/dom/ORanDOMNetworkElement.java b/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/dom/ORanDOMNetworkElement.java index 5e25ce8b1..72cda1679 100644 --- a/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/dom/ORanDOMNetworkElement.java +++ b/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/dom/ORanDOMNetworkElement.java @@ -22,7 +22,6 @@ package org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.impl.dom; import com.fasterxml.jackson.core.JsonProcessingException; -import com.google.common.collect.Sets; import java.util.Collection; import java.util.Collections; import java.util.List; @@ -30,10 +29,23 @@ import java.util.Map; import java.util.Objects; import java.util.Optional; import org.eclipse.jdt.annotation.NonNull; -import org.eclipse.jdt.annotation.Nullable; +import org.onap.ccsdk.features.sdnr.wt.common.configuration.ConfigurationFileRepresentation; +import org.onap.ccsdk.features.sdnr.wt.common.configuration.filechange.IConfigChangedListener; import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.DataProvider; import org.onap.ccsdk.features.sdnr.wt.devicemanager.ne.service.NetworkElement; import org.onap.ccsdk.features.sdnr.wt.devicemanager.ne.service.NetworkElementService; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.config.ORanDMConfig; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.dataprovider.ORanDOMToInternalDataModel; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.notification.ORanDOMChangeNotificationListener; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.notification.ORanDOMFaultNotificationListener; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.notification.ORanDOMSupervisionNotificationListener; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.notification.ORanNotificationObserverImpl; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.rpc.ORanSupervisionRPCImpl; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.util.ORanDMDOMUtility; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.util.ORanDeviceManagerQNames; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.vesmapper.ORanRegistrationToVESpnfRegistrationMapper; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.yangspecs.ORANFM; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.yangspecs.OnapSystem; import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.DeviceManagerServiceProvider; import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.FaultService; import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.NotificationService; @@ -52,17 +64,19 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.pro import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId; import org.opendaylight.yangtools.yang.common.QName; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.AugmentationIdentifier; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.InstanceIdentifierBuilder; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier; +import org.opendaylight.yangtools.yang.data.api.schema.AugmentationNode; import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode; import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode; import org.opendaylight.yangtools.yang.data.api.schema.MapNode; import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; +import org.opendaylight.yangtools.yang.data.api.schema.UnkeyedListEntryNode; +import org.opendaylight.yangtools.yang.data.api.schema.UnkeyedListNode; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class ORanDOMNetworkElement implements NetworkElement { +public class ORanDOMNetworkElement implements NetworkElement, IConfigChangedListener { private static final Logger LOG = LoggerFactory.getLogger(ORanDOMNetworkElement.class); @@ -72,11 +86,16 @@ public class ORanDOMNetworkElement implements NetworkElement { private final @NonNull NotificationService notificationService; private final @NonNull ORanDOMChangeNotificationListener oranDomChangeNotificationListener; private final @NonNull ORanDOMFaultNotificationListener oranDomFaultNotificationListener; + private final @NonNull ORanDOMSupervisionNotificationListener oranDomSupervisionNotificationListener; private final @NonNull VESCollectorService vesCollectorService; private final @NonNull ORanRegistrationToVESpnfRegistrationMapper mapper; + private final Optional onapSystem; + private final Optional oranfm; + private ORanDMConfig oranSupervisionConfig; public ORanDOMNetworkElement(@NonNull NetconfDomAccessor netconfDomAccessor, - @NonNull DeviceManagerServiceProvider serviceProvider) { + @NonNull DeviceManagerServiceProvider serviceProvider, ORanDMConfig oranSupervisionConfig, + ConfigurationFileRepresentation configFileRepresentation) { LOG.debug("Create {}", ORanDOMNetworkElement.class.getSimpleName()); this.netconfDomAccessor = Objects.requireNonNull(netconfDomAccessor); Objects.requireNonNull(serviceProvider); @@ -84,14 +103,21 @@ public class ORanDOMNetworkElement implements NetworkElement { this.vesCollectorService = serviceProvider.getVESCollectorService(); this.faultService = serviceProvider.getFaultService(); this.notificationService = serviceProvider.getNotificationService(); + this.onapSystem = OnapSystem.getModule(netconfDomAccessor); + this.oranfm = ORANFM.getModule(netconfDomAccessor); + this.oranSupervisionConfig = oranSupervisionConfig; + configFileRepresentation.registerConfigChangedListener(this); this.oranDomChangeNotificationListener = new ORanDOMChangeNotificationListener(netconfDomAccessor, vesCollectorService, databaseService); this.oranDomFaultNotificationListener = - new ORanDOMFaultNotificationListener(netconfDomAccessor, vesCollectorService, + new ORanDOMFaultNotificationListener(netconfDomAccessor, this.oranfm, vesCollectorService, serviceProvider.getFaultService(), serviceProvider.getWebsocketService(), databaseService); + this.oranDomSupervisionNotificationListener = new ORanDOMSupervisionNotificationListener(netconfDomAccessor, + vesCollectorService, databaseService, oranSupervisionConfig); + this.mapper = new ORanRegistrationToVESpnfRegistrationMapper(netconfDomAccessor, vesCollectorService); } @@ -106,13 +132,28 @@ public class ORanDOMNetworkElement implements NetworkElement { ORanDeviceManagerQNames.IETF_NETCONF_NOTIFICATIONS_NETCONF_SESSION_END, ORanDeviceManagerQNames.IETF_NETCONF_NOTIFICATIONS_NETCONF_CAPABILITY_CHANGE}; netconfDomAccessor.doRegisterNotificationListener(oranDomChangeNotificationListener, notifications); - QName[] faultNotification = {ORanDeviceManagerQNames.ORAN_FM_ALARM_NOTIF}; + + QName[] faultNotification = {oranfm.get().getAlarmNotifQName()}; netconfDomAccessor.doRegisterNotificationListener(oranDomFaultNotificationListener, faultNotification); + + Capabilities x = netconfDomAccessor.getCapabilites(); + if (x.isSupportingNamespaceAndRevision(ORanDeviceManagerQNames.ORAN_SUPERVISION_MODULE)) { + LOG.debug("Device {} supports oran-supervision", netconfDomAccessor.getNodeId().getValue()); + oranDomSupervisionNotificationListener.setComponentList(componentList); + QName[] supervisionNotification = {ORanDeviceManagerQNames.ORAN_SUPERVISION_NOTIFICATION}; + netconfDomAccessor.doRegisterNotificationListener(oranDomSupervisionNotificationListener, + supervisionNotification); + } // Output notification streams to LOG @SuppressWarnings("unused") Map streams = netconfDomAccessor.getNotificationStreamsAsMap(); // Register to default stream netconfDomAccessor.invokeCreateSubscription(); + if (x.isSupportingNamespaceAndRevision(ORanDeviceManagerQNames.ORAN_SUPERVISION_MODULE)) { + ORanSupervisionRPCImpl.invokeWatchdogReset(netconfDomAccessor, oranSupervisionConfig); + oranDomSupervisionNotificationListener.registerForNotificationReceivedEvent( + new ORanNotificationObserverImpl(netconfDomAccessor, oranSupervisionConfig)); + } } public Collection initialReadFromNetworkElement() { @@ -133,9 +174,16 @@ public class ORanDOMNetworkElement implements NetworkElement { componentMapEntries = Collections.emptyList(); } - Optional oGuicutthrough = ORanDOMToInternalDataModel.getGuicutthrough(getOnapSystemData()); - if (oGuicutthrough.isPresent()) { - databaseService.writeGuiCutThroughData(oGuicutthrough.get(), netconfDomAccessor.getNodeId().getValue()); + if (oranfm.isPresent()) { + getActiveAlarms(); + } + if (onapSystem.isPresent()) { + AugmentationNode gcData = (AugmentationNode) onapSystem.get().getOnapSystemData(); + Optional oGuicutthrough = + ORanDOMToInternalDataModel.getGuicutthrough(gcData, onapSystem.get()); + if (oGuicutthrough.isPresent()) { + databaseService.writeGuiCutThroughData(oGuicutthrough.get(), netconfDomAccessor.getNodeId().getValue()); + } } return componentMapEntries; } @@ -192,36 +240,6 @@ public class ORanDOMNetworkElement implements NetworkElement { return null; } - // Read from device - /** - * Read system data with GUI cut through information from device if ONAP_SYSTEM YANG is supported. - * - * @return NormalizedNode data with GUI cut through information or null if not available. - */ - private @Nullable NormalizedNode getOnapSystemData() { - LOG.debug("Get System1 for mountpoint {}", netconfDomAccessor.getNodeId().getValue()); - @NonNull - InstanceIdentifierBuilder ietfSystemIID = - YangInstanceIdentifier.builder().node(ORanDeviceManagerQNames.IETF_SYSTEM_CONTAINER); - @NonNull - AugmentationIdentifier onapSystemIID = YangInstanceIdentifier.AugmentationIdentifier - .create(Sets.newHashSet(ORanDeviceManagerQNames.ONAP_SYSTEM_NAME, - ORanDeviceManagerQNames.ONAP_SYSTEM_WEB_UI, ORanDeviceManagerQNames.ONAP_SYSTEM_GEOLOCATION)); - InstanceIdentifierBuilder augmentedOnapSystem = - YangInstanceIdentifier.builder(ietfSystemIID.build()).node(onapSystemIID); - Capabilities x = netconfDomAccessor.getCapabilites(); - LOG.debug("Capabilites: {}", x); - if (x.isSupportingNamespace(ORanDeviceManagerQNames.ONAP_SYSTEM_QNAME)) { - Optional res = - netconfDomAccessor.readDataNode(LogicalDatastoreType.OPERATIONAL, augmentedOnapSystem.build()); - LOG.debug("Result of System1 = {}", res); - return res.isPresent() ? res.get() : null; - } else { - LOG.debug("No GUI cut through support"); - return null; - } - } - // VES related private void publishMountpointToVES(Collection componentList) { /* @@ -280,4 +298,27 @@ public class ORanDOMNetworkElement implements NetworkElement { return false; } + private void getActiveAlarms() { + InstanceIdentifierBuilder activeAlarmListBuilder = + YangInstanceIdentifier.builder().node(oranfm.get().getFaultActiveAlarmListQName()); + Optional oData = + netconfDomAccessor.readDataNode(LogicalDatastoreType.OPERATIONAL, activeAlarmListBuilder.build()); + if (oData.isPresent()) { + ContainerNode cn = (ContainerNode) oData.get(); + UnkeyedListNode activeAlarmsList = + (UnkeyedListNode) cn.childByArg(new NodeIdentifier(oranfm.get().getFaultActiveAlarmsQName())); + int counter = 0; + for (UnkeyedListEntryNode activeAlarmEntry : activeAlarmsList.body()) + faultService.faultNotification(ORanDOMToInternalDataModel.getFaultLog(activeAlarmEntry, oranfm.get(), + netconfDomAccessor.getNodeId(), Integer.valueOf(counter++))); + } + + } + + @Override + public void onConfigChanged() { + LOG.info("O-RU Supervision Watchdog timers changed, resetting in O-RU via RPC"); + ORanSupervisionRPCImpl.invokeWatchdogReset(netconfDomAccessor, oranSupervisionConfig); + } + } diff --git a/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/dom/ORanDOMNotifToVESEventAssembly.java b/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/dom/ORanDOMNotifToVESEventAssembly.java deleted file mode 100644 index 7a2cd43cf..000000000 --- a/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/dom/ORanDOMNotifToVESEventAssembly.java +++ /dev/null @@ -1,102 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * ONAP : ccsdk features - * ================================================================================ - * Copyright (C) 2021 highstreet technologies GmbH Intellectual Property. - * All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - * - */ -package org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.impl.dom; - -import java.time.Instant; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map.Entry; -import java.util.Objects; -import org.eclipse.jdt.annotation.NonNull; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.VESCollectorService; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.types.VESCommonEventHeaderPOJO; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.types.VESNotificationFieldsPOJO; -import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfDomAccessor; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class ORanDOMNotifToVESEventAssembly { - - private static final Logger log = LoggerFactory.getLogger(ORanDOMNotifToVESEventAssembly.class); - private static final String VES_EVENT_DOMAIN = "notification"; - private static final String VES_EVENTTYPE = "ORAN_notification"; - private static final String VES_EVENT_PRIORITY = "Normal"; - private NetconfDomAccessor netconfDomAccessor; - private VESCollectorService vesProvider; - - public ORanDOMNotifToVESEventAssembly(@NonNull NetconfDomAccessor netconfDomAccessor, - @NonNull VESCollectorService vesCollectorService) { - this.netconfDomAccessor = Objects.requireNonNull(netconfDomAccessor); - this.vesProvider = Objects.requireNonNull(vesCollectorService); - } - - // VES CommonEventHeader fields - public VESCommonEventHeaderPOJO createVESCommonEventHeader(Instant time, String notificationTypeName, - long sequenceNo) { - VESCommonEventHeaderPOJO vesCEH = new VESCommonEventHeaderPOJO(); - vesCEH.setDomain(VES_EVENT_DOMAIN); - vesCEH.setEventName(notificationTypeName); - vesCEH.setEventType(VES_EVENTTYPE); - vesCEH.setPriority(VES_EVENT_PRIORITY); - - String eventId; - - eventId = notificationTypeName + "-" + Long.toUnsignedString(sequenceNo); - - vesCEH.setEventId(eventId); - vesCEH.setStartEpochMicrosec(time.toEpochMilli() * 1000); - vesCEH.setLastEpochMicrosec(time.toEpochMilli() * 1000); - vesCEH.setNfVendorName("ORAN"); - vesCEH.setReportingEntityName(vesProvider.getConfig().getReportingEntityName()); - vesCEH.setSequence(sequenceNo); - vesCEH.setSourceId("ORAN"); - vesCEH.setSourceName(netconfDomAccessor.getNodeId().getValue()); - return vesCEH; - } - - // Notification fields - public VESNotificationFieldsPOJO createVESNotificationFields(HashMap xPathFields, - String notificationTypeName) { - VESNotificationFieldsPOJO vesNotifFields = new VESNotificationFieldsPOJO(); - - vesNotifFields.setChangeType(notificationTypeName); - vesNotifFields.setChangeIdentifier(netconfDomAccessor.getNodeId().getValue()); - - StringBuffer buf = new StringBuffer(); - Iterator> it = xPathFields.entrySet().iterator(); - while (it.hasNext()) { - Entry pair = it.next(); - buf.append("\n" + pair.getKey() + " = " + pair.getValue()); - } - log.debug("Resultlist({}):{}", xPathFields.size(), buf.toString()); - - ArrayList> arrayOfNamedHashMap = new ArrayList>(); - HashMap namedHashMap = new HashMap(); - namedHashMap.put("hashMap", xPathFields); - namedHashMap.put("name", notificationTypeName); - arrayOfNamedHashMap.add(namedHashMap); - vesNotifFields.setArrayOfNamedHashMap(arrayOfNamedHashMap); - return vesNotifFields; - - } -} diff --git a/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/dom/ORanDOMToInternalDataModel.java b/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/dom/ORanDOMToInternalDataModel.java deleted file mode 100644 index 25a54f013..000000000 --- a/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/dom/ORanDOMToInternalDataModel.java +++ /dev/null @@ -1,293 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * ONAP : ccsdk features - * ================================================================================ - * Copyright (C) 2021 highstreet technologies GmbH Intellectual Property. - * All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - * - */ -package org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.impl.dom; - -import java.time.Instant; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Date; -import java.util.List; -import java.util.Objects; -import java.util.Optional; -import org.eclipse.jdt.annotation.Nullable; -import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.NetconfTimeStamp; -import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.types.NetconfTimeStampImpl; -import org.opendaylight.mdsal.dom.api.DOMEvent; -import org.opendaylight.mdsal.dom.api.DOMNotification; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Uri; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DateAndTime; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.FaultlogBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.FaultlogEntity; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.Guicutthrough; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.GuicutthroughBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.Inventory; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.InventoryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.SeverityType; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.SourceType; -import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId; -import org.opendaylight.yangtools.yang.binding.CodeHelpers; -import org.opendaylight.yangtools.yang.common.Uint32; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier; -import org.opendaylight.yangtools.yang.data.api.schema.AugmentationNode; -import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode; -import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode; -import org.opendaylight.yangtools.yang.data.api.schema.MapNode; -import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class ORanDOMToInternalDataModel { - - private static final Logger LOG = LoggerFactory.getLogger(ORanDOMToInternalDataModel.class); - private static final NetconfTimeStamp NETCONFTIME_CONVERTER = NetconfTimeStampImpl.getConverter(); - - public static List getInventoryList(NodeId nodeId, NormalizedNode hwData) { - - List inventoryResultList = new ArrayList(); - ContainerNode hwContainer = (ContainerNode) hwData; - MapNode componentMap = (MapNode) hwContainer - .getChildByArg(new NodeIdentifier(ORanDeviceManagerQNames.IETF_HW_COMPONENT_LIST)); - Collection componentMapEntries = componentMap.body(); - - for (MapEntryNode componentMapEntryNode : getRootComponents(componentMapEntries)) { - inventoryResultList = - recurseGetInventory(nodeId, componentMapEntryNode, componentMapEntries, 0, inventoryResultList); - } - // Verify if result is complete - if (componentMapEntries.size() != inventoryResultList.size()) { - LOG.warn( - "Not all data were written to the Inventory. Potential entries with missing " - + "contained-child. Node Id = {}, Components Found = {}, Entries written to Database = {}", - nodeId.getValue(), componentMapEntries.size(), inventoryResultList.size()); - } - return inventoryResultList; - } - - private static List recurseGetInventory(NodeId nodeId, MapEntryNode component, - Collection componentList, int treeLevel, List inventoryResultList) { - //Add element to list, if conversion successfull - Optional oInventory = getInternalEquipment(nodeId, component, treeLevel); - if (oInventory.isPresent()) { - inventoryResultList.add(oInventory.get()); - } - //Walk through list of child keys and add to list - for (String childUuid : CodeHelpers.nonnull(new ArrayList<>(ORanDMDOMUtility.getLeafListValue(component, - ORanDeviceManagerQNames.IETF_HW_COMPONENT_LIST_CONTAINS_CHILD)))) { - for (MapEntryNode c : getComponentsByName(childUuid, componentList)) { - inventoryResultList = recurseGetInventory(nodeId, c, componentList, treeLevel + 1, inventoryResultList); - } - } - return inventoryResultList; - } - - public static List getRootComponents(Collection componentMapEntries) { - List resultList = new ArrayList<>(); - for (MapEntryNode componentMapEntryNode : componentMapEntries) { - if (ORanDMDOMUtility.getLeafValue(componentMapEntryNode, - ORanDeviceManagerQNames.IETF_HW_COMPONENT_LIST_PARENT) == null) { // Root elements do not have a parent - resultList.add(componentMapEntryNode); - } - } - return resultList; - } - - private static List getComponentsByName(String name, Collection componentList) { - List resultList = new ArrayList<>(); - for (MapEntryNode c : componentList) { - if (name.equals(ORanDMDOMUtility.getKeyValue(c))) { // <-- Component list is flat search for child's of name - resultList.add(c); - } - } - return resultList; - } - - public static Optional getInternalEquipment(NodeId nodeId, MapEntryNode component, int treeLevel) { - - // Make sure that expected data are not null - Objects.requireNonNull(nodeId); - Objects.requireNonNull(component); - - // Read mandatory data - - @Nullable - String nodeIdString = nodeId.getValue(); - @Nullable - String uuid = ORanDMDOMUtility.getKeyValue(component); - @Nullable - String idParent = - ORanDMDOMUtility.getLeafValue(component, ORanDeviceManagerQNames.IETF_HW_COMPONENT_LIST_PARENT); - @Nullable - String uuidParent = idParent != null ? idParent : uuid; //<- Passt nicht - - // do consistency check if all mandatory parameters are there - if (treeLevel >= 0 && nodeIdString != null && uuid != null && uuidParent != null) { - // Build output data - - InventoryBuilder inventoryBuilder = new InventoryBuilder(); - - // General assumed as mandatory - inventoryBuilder.setNodeId(nodeIdString); - inventoryBuilder.setUuid(uuid); - inventoryBuilder.setParentUuid(uuidParent); - inventoryBuilder.setTreeLevel(Uint32.valueOf(treeLevel)); - - // -- String list with ids of holders (optional) - inventoryBuilder.setContainedHolder(ORanDMDOMUtility.getLeafListValue(component, - ORanDeviceManagerQNames.IETF_HW_COMPONENT_LIST_CONTAINS_CHILD)); - - // -- Manufacturer related things (optional) - @Nullable - String mfgName = - ORanDMDOMUtility.getLeafValue(component, ORanDeviceManagerQNames.IETF_HW_COMPONENT_LIST_MFG_NAME); - inventoryBuilder.setManufacturerName(mfgName); - inventoryBuilder.setManufacturerIdentifier(mfgName); - - // Equipment type (optional) - inventoryBuilder.setDescription( - ORanDMDOMUtility.getLeafValue(component, ORanDeviceManagerQNames.IETF_HW_COMPONENT_LIST_DESC)); - inventoryBuilder.setModelIdentifier(ORanDMDOMUtility.getLeafValue(component, - ORanDeviceManagerQNames.IETF_HW_COMPONENT_LIST_MODEL_NAME)); - - inventoryBuilder.setPartTypeId( - ORanDMDOMUtility.getLeafValue(component, ORanDeviceManagerQNames.IETF_HW_COMPONENT_LIST_CLASS)); - - inventoryBuilder.setTypeName(ORanDMDOMUtility.getKeyValue(component)); - inventoryBuilder.setVersion( - ORanDMDOMUtility.getLeafValue(component, ORanDeviceManagerQNames.IETF_HW_COMPONENT_LIST_HW_REV)); - - // Equipment instance (optional) - @Nullable - String mfgDate = - ORanDMDOMUtility.getLeafValue(component, ORanDeviceManagerQNames.IETF_HW_COMPONENT_LIST_MFG_DATE); - if (mfgDate != null) { - inventoryBuilder.setDate(mfgDate); - } - inventoryBuilder.setSerial( - ORanDMDOMUtility.getLeafValue(component, ORanDeviceManagerQNames.IETF_HW_COMPONENT_LIST_SER_NUM)); - - return Optional.of(inventoryBuilder.build()); - } - return Optional.empty(); - } - - /** - * If system data is available convert - * - * @param sys - * @return - */ - public static Optional getGuicutthrough(@Nullable NormalizedNode sys) { - AugmentationNode onapSys = (AugmentationNode) sys; - if (onapSys != null) { - String name = ORanDMDOMUtility.getLeafValue(onapSys, ORanDeviceManagerQNames.ONAP_SYSTEM_NAME); - @Nullable - Uri uri = new Uri(ORanDMDOMUtility.getLeafValue(onapSys, ORanDeviceManagerQNames.ONAP_SYSTEM_WEB_UI)); - if (uri.getValue() != null) { - GuicutthroughBuilder gcBuilder = new GuicutthroughBuilder(); - if (name != null) { - gcBuilder.setName(name); - } - gcBuilder.setWeburi(uri.getValue()); - return Optional.of(gcBuilder.build()); - } - LOG.warn("Uri not set to invoke a Gui cut through session to the device. Please set the Uri in the device"); - } - LOG.warn("Retrieving augmented System details failed. Gui cut through information not available"); - return Optional.empty(); - } - - /** - * Convert fault notification into data-provider FaultLogEntity - * - * @param notification with O-RAN notification - * @param nodeId of node to handle - * @param counter to be integrated into data - * @return FaultlogEntity with data - */ - public static FaultlogEntity getFaultLog(DOMNotification notification, NodeId nodeId, Integer counter) { - ContainerNode cn = notification.getBody(); - FaultlogBuilder faultAlarm = new FaultlogBuilder(); - faultAlarm.setNodeId(nodeId.getValue()); - faultAlarm.setObjectId(ORanDMDOMUtility.getLeafValue(cn, ORanDeviceManagerQNames.ORAN_FM_FAULT_SOURCE)); - faultAlarm.setProblem(ORanDMDOMUtility.getLeafValue(cn, ORanDeviceManagerQNames.ORAN_FM_FAULT_TEXT)); - faultAlarm.setSeverity(getSeverityType( - ORanDMDOMUtility.getLeafValue(cn, ORanDeviceManagerQNames.ORAN_FM_FAULT_SEVERITY), - ORanDMDOMUtility.getLeafValue(cn, ORanDeviceManagerQNames.ORAN_FM_FAULT_IS_CLEARED).equals("true"))); - faultAlarm.setCounter(counter); - faultAlarm.setId(ORanDMDOMUtility.getLeafValue(cn, ORanDeviceManagerQNames.ORAN_FM_FAULT_ID)); - faultAlarm.setSourceType(SourceType.Netconf); - faultAlarm.setTimestamp(getEventTime(notification)); - return faultAlarm.build(); - } - - public static DateAndTime getEventTime(DOMNotification notification) { - DateAndTime eventTime; - Instant notificationEventTime = null; - if (notification instanceof DOMEvent) { - notificationEventTime = ((DOMEvent) notification).getEventInstant(); - eventTime = NetconfTimeStampImpl.getConverter().getTimeStamp(notificationEventTime.toString()); - } else { - eventTime = NetconfTimeStampImpl.getConverter().getTimeStamp(); - } - return eventTime; - } - - /** - * Convert O-RAN specific severity into data-provider severity - * - * @param faultSeverity O-RAN severity - * @param isCleared clear indicator - * @return data-provider severity type - * @throws IllegalArgumentException if conversion not possible. - */ - public static SeverityType getSeverityType(@Nullable String faultSeverity, @Nullable Boolean isCleared) - throws IllegalArgumentException { - if (isCleared != null && isCleared) { - return SeverityType.NonAlarmed; - } - if (faultSeverity != null) { - switch (faultSeverity) { - case "CRITICAL": - return SeverityType.Critical; - case "MAJOR": - return SeverityType.Major; - case "MINOR": - return SeverityType.Minor; - case "WARNING": - return SeverityType.Warning; - } - } - throw new IllegalArgumentException("Unknown Alarm state represent as Critical. isCleared=" + isCleared - + " faultSeverity=" + faultSeverity); - } - - /** - * Convert Instant to NETCONF DataAndTime - * @param eventTimeInstant - * @return DateAndTime - */ - public static DateAndTime getDateAndTimeOfInstant(Instant eventTimeInstant) { - Date eventDate = Date.from(eventTimeInstant); - return new DateAndTime(NETCONFTIME_CONVERTER.getTimeStamp(eventDate)); - } - -} diff --git a/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/dom/ORanDeviceManagerQNames.java b/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/dom/ORanDeviceManagerQNames.java deleted file mode 100644 index 9949a6ffc..000000000 --- a/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/dom/ORanDeviceManagerQNames.java +++ /dev/null @@ -1,118 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * ONAP : ccsdk features - * ================================================================================ - * Copyright (C) 2021 highstreet technologies GmbH Intellectual Property. - * All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - * - */ -package org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.impl.dom; - -import org.eclipse.jdt.annotation.NonNull; -import org.opendaylight.yangtools.yang.common.QName; - -public class ORanDeviceManagerQNames { - - //ietf-system - public static final String IETF_SYSTEM_NS = "urn:ietf:params:xml:ns:yang:ietf-system"; - public static final String IETF_SYSTEM_REVISION = "2014-08-06"; - public static final @NonNull QName IETF_SYSTEM_QNAME = - QName.create(IETF_SYSTEM_NS, IETF_SYSTEM_REVISION, "ietf-system"); - public static final @NonNull QName IETF_SYSTEM_CONTAINER = QName.create(IETF_SYSTEM_QNAME, "system"); - - // onap-system.yang - public static final String ONAP_SYSTEM_NS = "urn:onap:system"; - public static final String ONAP_SYSTEM_REVISION = "2022-11-04"; - public static final @NonNull QName ONAP_SYSTEM_QNAME = - QName.create(ONAP_SYSTEM_NS, ONAP_SYSTEM_REVISION, "onap-system"); -// public static final @NonNull QName ONAP_SYSTEM_QNAME = -// QName.create(ONAP_SYSTEM_NS, "onap-system"); - public static final @NonNull QName ONAP_SYSTEM_NAME = QName.create(ONAP_SYSTEM_QNAME, "name"); - public static final @NonNull QName ONAP_SYSTEM_WEB_UI = QName.create(ONAP_SYSTEM_QNAME, "web-ui"); - public static final @NonNull QName ONAP_SYSTEM_GEOLOCATION = QName.create(ONAP_SYSTEM_QNAME, "geographical-location"); - - //ietf-hardware.yang - public static final String IETF_HW_NS = "urn:ietf:params:xml:ns:yang:ietf-hardware"; - public static final String IETF_HW_REVISION = "2018-03-13"; - public static final @NonNull QName IETF_HW_MODULE_NAME = - QName.create(IETF_HW_NS, IETF_HW_REVISION, "ietf-hardware"); - public static final @NonNull QName IETF_HW_CONTAINER = QName.create(IETF_HW_MODULE_NAME, "hardware"); - public static final @NonNull QName IETF_HW_COMPONENT_LIST = QName.create(IETF_HW_MODULE_NAME, "component"); - public static final @NonNull QName IETF_HW_COMPONENT_LIST_KEY = QName.create(IETF_HW_MODULE_NAME, "name"); - public static final @NonNull QName IETF_HW_COMPONENT_LIST_MFG_NAME = QName.create(IETF_HW_MODULE_NAME, "mfg-name"); //leaf:String - public static final @NonNull QName IETF_HW_COMPONENT_LIST_UUID = QName.create(IETF_HW_MODULE_NAME, "uuid"); //leaf:yang:uuid - public static final @NonNull QName IETF_HW_COMPONENT_LIST_MODEL_NAME = QName.create(IETF_HW_MODULE_NAME, "model-name"); //leaf:String - public static final @NonNull QName IETF_HW_COMPONENT_LIST_SER_NUM = QName.create(IETF_HW_MODULE_NAME, "serial-num"); //leaf:String - public static final @NonNull QName IETF_HW_COMPONENT_LIST_SW_REV = QName.create(IETF_HW_MODULE_NAME, "software-rev"); //leaf:String - public static final @NonNull QName IETF_HW_COMPONENT_LIST_ALIAS = QName.create(IETF_HW_MODULE_NAME, "alias"); //leaf:String - public static final @NonNull QName IETF_HW_COMPONENT_LIST_CLASS = QName.create(IETF_HW_MODULE_NAME, "class"); - public static final @NonNull QName IETF_HW_COMPONENT_LIST_MFG_DATE = QName.create(IETF_HW_MODULE_NAME, "mfg-date"); //leaf:yang:date-and-time - public static final @NonNull QName IETF_HW_COMPONENT_LIST_CONTAINS_CHILD = QName.create(IETF_HW_MODULE_NAME, "contains-child"); //leaf-list:leafref - public static final @NonNull QName IETF_HW_COMPONENT_LIST_PARENT = QName.create(IETF_HW_MODULE_NAME, "parent"); //leaf:leafref - public static final @NonNull QName IETF_HW_COMPONENT_LIST_DESC = QName.create(IETF_HW_MODULE_NAME, "description"); //leaf:String - public static final @NonNull QName IETF_HW_COMPONENT_LIST_HW_REV = QName.create(IETF_HW_MODULE_NAME, "hardware-rev"); //leaf:String - - //odl-netconf-callhome-server.yang - public static final String CALLHOME_SERVER_NS = "urn:opendaylight:params:xml:ns:yang:netconf-callhome-server"; - public static final String CALLHOME_SERVER_REVISION = "2020-10-15"; - public static final @NonNull QName CALLHOME_SERVER_MODULE = - QName.create(CALLHOME_SERVER_NS, CALLHOME_SERVER_REVISION, "odl-netconf-callhome-server"); - public static final @NonNull QName CALLHOME_SERVER_CONTAINER = - QName.create(CALLHOME_SERVER_MODULE, "netconf-callhome-server"); - public static final @NonNull QName CALLHOME_SERVER_ALLOWED_DEVICE = - QName.create(CALLHOME_SERVER_MODULE, "allowed-devices"); - public static final @NonNull QName CALLHOME_SERVER_ALLOWED_DEVICE_DEVICE_LIST = - QName.create(CALLHOME_SERVER_MODULE, "device"); - public static final @NonNull QName CALLHOME_SERVER_ALLOWED_DEVICE_KEY = - QName.create(CALLHOME_SERVER_MODULE, "unique-id"); - - //o-ran-hardware.yang - public static final String ORAN_HW_NS = "urn:o-ran:hardware:1.0"; - public static final String ORAN_HW_REVISION = "2019-03-28"; - public static final @NonNull QName ORAN_HW_MODULE = QName.create(ORAN_HW_NS, ORAN_HW_REVISION, "o-ran-hardware").intern(); - public static final @NonNull QName ORAN_HW_COMPONENT = QName.create(ORAN_HW_MODULE, "O-RAN-HW-COMPONENT"); - - //o-ran-fm.yang - public static final String ORAN_FM_NS = "urn:o-ran:fm:1.0"; - //public static final String ORAN_FM_REVISION = "2019-02-04"; - public static final String ORAN_FM_REVISION = "2022-08-15"; - public static final @NonNull QName ORAN_FM_MODULE = QName.create(ORAN_FM_NS, ORAN_FM_REVISION, "o-ran-fm"); - public static final @NonNull QName ORAN_FM_ALARM_NOTIF = QName.create(ORAN_FM_MODULE, "alarm-notif"); - public static final @NonNull QName ORAN_FM_FAULT_ID = QName.create(ORAN_FM_MODULE, "fault-id"); - public static final @NonNull QName ORAN_FM_FAULT_SOURCE = QName.create(ORAN_FM_MODULE, "fault-source"); - public static final @NonNull QName ORAN_FM_FAULT_SEVERITY = QName.create(ORAN_FM_MODULE, "fault-severity"); - public static final @NonNull QName ORAN_FM_FAULT_TEXT = QName.create(ORAN_FM_MODULE, "fault-text"); - public static final @NonNull QName ORAN_FM_FAULT_IS_CLEARED = QName.create(ORAN_FM_MODULE, "is-cleared"); - - //ietf-netconf-notifications.yang - public static final String IETF_NETCONF_NOTIFICATIONS_NS = "urn:ietf:params:xml:ns:yang:ietf-netconf-notifications"; - public static final String IETF_NETCONF_NOTIFICATIONS_REVISION = "2012-02-06"; - public static final @NonNull QName IETF_NETCONF_NOTIFICATIONS_MODULE = QName.create(IETF_NETCONF_NOTIFICATIONS_NS, IETF_NETCONF_NOTIFICATIONS_REVISION, "ietf-netconf-notifications").intern(); - public static final @NonNull QName IETF_NETCONF_NOTIFICATIONS_NETCONF_CONFIG_CHANGE = QName.create(IETF_NETCONF_NOTIFICATIONS_MODULE, "netconf-config-change"); - public static final @NonNull QName IETF_NETCONF_NOTIFICATIONS_NETCONF_CONFIRMED_COMMIT = QName.create(IETF_NETCONF_NOTIFICATIONS_MODULE, "netconf-confirmed-commit"); - public static final @NonNull QName IETF_NETCONF_NOTIFICATIONS_NETCONF_SESSION_START = QName.create(IETF_NETCONF_NOTIFICATIONS_MODULE, "netconf-session-start"); - public static final @NonNull QName IETF_NETCONF_NOTIFICATIONS_NETCONF_SESSION_END = QName.create(IETF_NETCONF_NOTIFICATIONS_MODULE, "netconf-session-end"); - public static final @NonNull QName IETF_NETCONF_NOTIFICATIONS_NETCONF_CAPABILITY_CHANGE = QName.create(IETF_NETCONF_NOTIFICATIONS_MODULE, "netconf-capability-change"); - public static final @NonNull QName IETF_NETCONF_NOTIFICATIONS_CHANGEDBY = QName.create(IETF_NETCONF_NOTIFICATIONS_MODULE, "changed-by"); - public static final @NonNull QName IETF_NETCONF_NOTIFICATIONS_SERVERORUSER = QName.create(IETF_NETCONF_NOTIFICATIONS_MODULE, "server-or-user"); - public static final @NonNull QName IETF_NETCONF_NOTIFICATIONS_EDITNODE = QName.create(IETF_NETCONF_NOTIFICATIONS_MODULE, "edit"); - public static final @NonNull QName IETF_NETCONF_NOTIFICATIONS_USERNAME = QName.create(IETF_NETCONF_NOTIFICATIONS_MODULE, "username"); - public static final @NonNull QName IETF_NETCONF_NOTIFICATIONS_SESSIONID = QName.create(IETF_NETCONF_NOTIFICATIONS_MODULE, "session-id"); - public static final @NonNull QName IETF_NETCONF_NOTIFICATIONS_OPERATION = QName.create(IETF_NETCONF_NOTIFICATIONS_MODULE, "operation"); - public static final @NonNull QName IETF_NETCONF_NOTIFICATIONS_TARGET = QName.create(IETF_NETCONF_NOTIFICATIONS_MODULE, "target"); - public static final @NonNull QName IETF_NETCONF_NOTIFICATIONS_DATASTORE = QName.create(IETF_NETCONF_NOTIFICATIONS_MODULE, "datastore"); - -} diff --git a/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/dom/ORanNetworkElementFactory.java b/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/dom/ORanNetworkElementFactory.java index 05561d2ca..1f0fa06fb 100644 --- a/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/dom/ORanNetworkElementFactory.java +++ b/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/dom/ORanNetworkElementFactory.java @@ -21,8 +21,11 @@ package org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.impl.dom; import java.util.Optional; +import org.onap.ccsdk.features.sdnr.wt.common.configuration.ConfigurationFileRepresentation; import org.onap.ccsdk.features.sdnr.wt.devicemanager.ne.factory.NetworkElementFactory; import org.onap.ccsdk.features.sdnr.wt.devicemanager.ne.service.NetworkElement; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.config.ORanDMConfig; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.util.ORanDeviceManagerQNames; import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.DeviceManagerServiceProvider; import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.Capabilities; import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfAccessor; @@ -37,6 +40,13 @@ public class ORanNetworkElementFactory implements NetworkElementFactory { //Workaround private static final QName OneCell = QName.create("urn:onf:otcc:wireless:yang:radio-access:commscope-onecell", "2020-06-22", "onecell").intern(); + private ORanDMConfig oranSupervisionConfig; + private ConfigurationFileRepresentation configFileRepresentation; + + public ORanNetworkElementFactory(ConfigurationFileRepresentation configFileRepresentation, ORanDMConfig oranSupervisionConfig) { + this.configFileRepresentation = configFileRepresentation; + this.oranSupervisionConfig = oranSupervisionConfig; + } @Override public Optional create(NetconfAccessor accessor, DeviceManagerServiceProvider serviceProvider) { @@ -44,11 +54,9 @@ public class ORanNetworkElementFactory implements NetworkElementFactory { if (!capabilites.isSupportingNamespace(OneCell)) { if (capabilites.isSupportingNamespace(ORanDeviceManagerQNames.ORAN_HW_COMPONENT)) { log.info("Create device {} ", ORanDOMNetworkElement.class.getName()); - //Optional bindingAccessor = accessor.getNetconfBindingAccessor(); Optional domAccessor = accessor.getNetconfDomAccessor(); if (domAccessor.isPresent()) { - //return Optional.of(new ORanNetworkElement(bindingAccessor.get(), serviceProvider)); - return Optional.of(new ORanDOMNetworkElement(domAccessor.get(), serviceProvider)); + return Optional.of(new ORanDOMNetworkElement(domAccessor.get(), serviceProvider, oranSupervisionConfig, configFileRepresentation)); } } } diff --git a/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/dom/ORanRegistrationToVESpnfRegistrationMapper.java b/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/dom/ORanRegistrationToVESpnfRegistrationMapper.java deleted file mode 100644 index 5cad5881c..000000000 --- a/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/dom/ORanRegistrationToVESpnfRegistrationMapper.java +++ /dev/null @@ -1,113 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * ONAP : ccsdk features - * ================================================================================ - * Copyright (C) 2021 highstreet technologies GmbH Intellectual Property. - * All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - * - */ -package org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.impl.dom; - -import java.time.Instant; - -import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.VESCollectorService; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.types.VESCommonEventHeaderPOJO; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.types.VESPNFRegistrationFieldsPOJO; -import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfAccessor; -import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class ORanRegistrationToVESpnfRegistrationMapper { - - @SuppressWarnings("unused") - private static final Logger LOG = LoggerFactory.getLogger(ORanRegistrationToVESpnfRegistrationMapper.class); - //CommonEventHeader fields - private static final String VES_EVENT_DOMAIN = "pnfRegistration"; - private static final String VES_EVENTTYPE = "NetConf Callhome Registration"; - private static final String VES_EVENT_PRIORITY = "Normal"; - - private final VESCollectorService vesProvider; - private final NetconfAccessor netconfAccessor; - - private Integer sequenceNo; - - - public ORanRegistrationToVESpnfRegistrationMapper(NetconfAccessor netconfAccessor, - VESCollectorService vesCollectorService) { - this.netconfAccessor = netconfAccessor; - this.vesProvider = vesCollectorService; - - this.sequenceNo = 0; - } - - public VESCommonEventHeaderPOJO mapCommonEventHeader(MapEntryNode component) { - VESCommonEventHeaderPOJO vesCEH = new VESCommonEventHeaderPOJO(); - vesCEH.setDomain(VES_EVENT_DOMAIN); - vesCEH.setEventId(netconfAccessor.getNodeId().getValue()); - vesCEH.setEventName(netconfAccessor.getNodeId().getValue()); - vesCEH.setEventType(VES_EVENTTYPE); - vesCEH.setPriority(VES_EVENT_PRIORITY); - - vesCEH.setStartEpochMicrosec(Instant.now().toEpochMilli() * 1000); - vesCEH.setLastEpochMicrosec(Instant.now().toEpochMilli() * 1000); - vesCEH.setNfVendorName( - ORanDMDOMUtility.getLeafValue(component, ORanDeviceManagerQNames.IETF_HW_COMPONENT_LIST_MFG_NAME)); - vesCEH.setReportingEntityName(vesProvider.getConfig().getReportingEntityName()); - vesCEH.setSequence(sequenceNo++); - vesCEH.setSourceId( - ORanDMDOMUtility.getLeafValue(component, ORanDeviceManagerQNames.IETF_HW_COMPONENT_LIST_UUID) != null - ? ORanDMDOMUtility.getLeafValue(component, ORanDeviceManagerQNames.IETF_HW_COMPONENT_LIST_UUID) - : netconfAccessor.getNodeId().getValue()); - vesCEH.setSourceName(netconfAccessor.getNodeId().getValue()); - - return vesCEH; - } - - public VESPNFRegistrationFieldsPOJO mapPNFRegistrationFields(MapEntryNode component) { - VESPNFRegistrationFieldsPOJO vesPnfFields = new VESPNFRegistrationFieldsPOJO(); - vesPnfFields.setModelNumber( - ORanDMDOMUtility.getLeafValue(component, ORanDeviceManagerQNames.IETF_HW_COMPONENT_LIST_MFG_NAME)); - vesPnfFields - .setOamV4IpAddress(netconfAccessor.getNetconfNode().getHost().getIpAddress().getIpv4Address() != null - ? netconfAccessor.getNetconfNode().getHost().getIpAddress().getIpv4Address().getValue() - : null); - vesPnfFields - .setOamV6IpAddress(netconfAccessor.getNetconfNode().getHost().getIpAddress().getIpv6Address() != null - ? netconfAccessor.getNetconfNode().getHost().getIpAddress().getIpv6Address().getValue() - : null); - vesPnfFields.setSerialNumber( - ORanDMDOMUtility.getLeafValue(component, ORanDeviceManagerQNames.IETF_HW_COMPONENT_LIST_SER_NUM)); - vesPnfFields.setVendorName( - ORanDMDOMUtility.getLeafValue(component, ORanDeviceManagerQNames.IETF_HW_COMPONENT_LIST_MFG_NAME)); - vesPnfFields.setSoftwareVersion( - ORanDMDOMUtility.getLeafValue(component, ORanDeviceManagerQNames.IETF_HW_COMPONENT_LIST_SW_REV)); - vesPnfFields.setUnitType( - ORanDMDOMUtility.getLeafValue(component, ORanDeviceManagerQNames.IETF_HW_COMPONENT_LIST_ALIAS)); - vesPnfFields.setUnitFamily( - ORanDMDOMUtility.getLeafValue(component, ORanDeviceManagerQNames.IETF_HW_COMPONENT_LIST_CLASS)); - vesPnfFields - .setManufactureDate( - ORanDMDOMUtility.getLeafValue(component, - ORanDeviceManagerQNames.IETF_HW_COMPONENT_LIST_MFG_DATE) != null - ? ORanDMDOMUtility.getLeafValue(component, - ORanDeviceManagerQNames.IETF_HW_COMPONENT_LIST_MFG_DATE) - : "Unknown"); - //vesPnfFields.setLastServiceDate(component.getLastChange()); - - return vesPnfFields; - } -} diff --git a/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/notification/ORanDOMChangeNotificationListener.java b/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/notification/ORanDOMChangeNotificationListener.java new file mode 100644 index 000000000..b4f0fe010 --- /dev/null +++ b/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/notification/ORanDOMChangeNotificationListener.java @@ -0,0 +1,149 @@ +/* + * ============LICENSE_START======================================================= + * ONAP : ccsdk features + * ================================================================================ + * Copyright (C) 2021 highstreet technologies GmbH Intellectual Property. + * All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + * + */ +package org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.notification; + +import com.fasterxml.jackson.core.JsonProcessingException; +import java.time.Instant; +import org.eclipse.jdt.annotation.NonNull; +import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.DataProvider; +import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.types.NetconfTimeStampImpl; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.util.ORanDeviceManagerQNames; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.VESCollectorService; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.types.VESCommonEventHeaderPOJO; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.types.VESNotificationFieldsPOJO; +import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfDomAccessor; +import org.opendaylight.mdsal.dom.api.DOMEvent; +import org.opendaylight.mdsal.dom.api.DOMNotification; +import org.opendaylight.mdsal.dom.api.DOMNotificationListener; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DateAndTime; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.EventlogBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.EventlogEntity; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.SourceType; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier; +import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode; +import org.opendaylight.yangtools.yang.data.api.schema.UnkeyedListNode; +import org.opendaylight.yangtools.yang.model.api.stmt.SchemaNodeIdentifier.Absolute; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class ORanDOMChangeNotificationListener implements DOMNotificationListener { + + private static final Logger log = LoggerFactory.getLogger(ORanDOMChangeNotificationListener.class); + + private final NetconfDomAccessor netconfDomAccessor; + private final DataProvider databaseService; + private @NonNull VESCollectorService vesCollectorService; + private final ORanDOMNotificationToXPath domNotificationXPath; + private ORanDOMNotifToVESEventAssembly mapper = null; + private static int sequenceNo = 0; + + public ORanDOMChangeNotificationListener(NetconfDomAccessor netconfDomAccessor, + @NonNull VESCollectorService vesCollectorService, DataProvider databaseService) { + this.netconfDomAccessor = netconfDomAccessor; + this.databaseService = databaseService; + this.vesCollectorService = vesCollectorService; + domNotificationXPath = new ORanDOMNotificationToXPath(); + } + + @Override + public void onNotification(@NonNull DOMNotification domNotification) { + if (domNotification.getType() + .equals(Absolute.of(ORanDeviceManagerQNames.IETF_NETCONF_NOTIFICATIONS_NETCONF_CONFIG_CHANGE))) { + handleNetconfConfigChange(domNotification); + } + } + + private void handleNetconfConfigChange(@NonNull DOMNotification domNotification) { + DateAndTime eventTime; + Instant notificationEventTime = null; + if (domNotification instanceof DOMEvent) { + notificationEventTime = ((DOMEvent) domNotification).getEventInstant(); + eventTime = NetconfTimeStampImpl.getConverter().getTimeStamp(notificationEventTime.toString()); + } else { + eventTime = NetconfTimeStampImpl.getConverter().getTimeStamp(); + } + + ContainerNode cn = domNotification.getBody(); + + // Process the changed-by child + // ContainerNode changedByContainerNode = (ContainerNode) cn + // .childByArg(new NodeIdentifier(ORanDeviceManagerQNames.IETF_NETCONF_NOTIFICATIONS_CHANGEDBY)); + // ChoiceNode serverOrUserIDVal = (ChoiceNode) changedByContainerNode + // .childByArg(new NodeIdentifier(ORanDeviceManagerQNames.IETF_NETCONF_NOTIFICATIONS_SERVERORUSER)); + // @SuppressWarnings("unused") + // String userIDValue = serverOrUserIDVal + // .childByArg(new NodeIdentifier(ORanDeviceManagerQNames.IETF_NETCONF_NOTIFICATIONS_USERNAME)).body() + // .toString(); + // @SuppressWarnings("unused") + // Integer sessionIDVal = Integer.valueOf(serverOrUserIDVal + // .childByArg(new NodeIdentifier(ORanDeviceManagerQNames.IETF_NETCONF_NOTIFICATIONS_SESSIONID)).body() + // .toString()); + // + // // Process the datastore child + // @SuppressWarnings("unused") + // String datastoreValue = cn + // .childByArg(new NodeIdentifier(ORanDeviceManagerQNames.IETF_NETCONF_NOTIFICATIONS_DATASTORE)).body() + // .toString(); + + // Process the edit child + UnkeyedListNode editList = (UnkeyedListNode) cn + .childByArg(new NodeIdentifier(ORanDeviceManagerQNames.IETF_NETCONF_NOTIFICATIONS_EDITNODE)); + if (editList != null) { + for (int listCnt = 0; listCnt < editList.size(); listCnt++) { + String operationValue = editList.childAt(listCnt) + .childByArg(new NodeIdentifier(ORanDeviceManagerQNames.IETF_NETCONF_NOTIFICATIONS_OPERATION)) + .body().toString(); + String targetValue = editList.childAt(listCnt) + .childByArg(new NodeIdentifier(ORanDeviceManagerQNames.IETF_NETCONF_NOTIFICATIONS_TARGET)) + .body().toString(); + + EventlogEntity eventLogEntity1 = new EventlogBuilder() + .setNodeId(netconfDomAccessor.getNodeId().getValue()).setCounter(sequenceNo++) + .setTimestamp(eventTime).setObjectId(targetValue).setAttributeName("N.A") + .setSourceType(SourceType.Netconf).setNewValue(String.valueOf(operationValue)).build(); + databaseService.writeEventLog(eventLogEntity1); + } + } + + if (vesCollectorService.getConfig().isVESCollectorEnabled()) { + if (mapper == null) { + this.mapper = new ORanDOMNotifToVESEventAssembly(netconfDomAccessor, vesCollectorService); + } + VESCommonEventHeaderPOJO header = + mapper.createVESCommonEventHeader(domNotificationXPath.getTime(domNotification), + ORanDeviceManagerQNames.IETF_NETCONF_NOTIFICATIONS_NETCONF_CONFIG_CHANGE.getLocalName(), + sequenceNo); + VESNotificationFieldsPOJO body = + mapper.createVESNotificationFields(domNotificationXPath.convertDomNotifToXPath(domNotification), + ORanDeviceManagerQNames.IETF_NETCONF_NOTIFICATIONS_NETCONF_CONFIG_CHANGE.getLocalName()); + log.debug("domNotification in XPath format = {}", + domNotificationXPath.convertDomNotifToXPath(domNotification)); + try { + vesCollectorService.publishVESMessage(vesCollectorService.generateVESEvent(header, body)); + } catch (JsonProcessingException e) { + log.warn("Exception while generating JSON object ", e); + + } + } + + } +} diff --git a/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/notification/ORanDOMFaultNotificationListener.java b/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/notification/ORanDOMFaultNotificationListener.java new file mode 100644 index 000000000..3e99bcd6d --- /dev/null +++ b/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/notification/ORanDOMFaultNotificationListener.java @@ -0,0 +1,178 @@ +/* + * ============LICENSE_START======================================================= + * ONAP : ccsdk features + * ================================================================================ + * Copyright (C) 2021 highstreet technologies GmbH Intellectual Property. + * All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + * + */ +package org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.notification; + +import com.fasterxml.jackson.core.JsonProcessingException; +import java.time.Instant; +import java.time.format.DateTimeParseException; +import java.util.Collection; +import java.util.Objects; +import java.util.Optional; +import org.eclipse.jdt.annotation.NonNull; +import org.json.JSONException; +import org.json.JSONObject; +import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.DataProvider; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.dataprovider.ORanDOMToInternalDataModel; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.util.ORanDMDOMUtility; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.util.ORanDeviceManagerQNames; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.vesmapper.ORanDOMFaultToVESFaultMapper; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.yangspecs.ORANFM; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.FaultService; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.VESCollectorService; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.types.VESCommonEventHeaderPOJO; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.types.VESFaultFieldsPOJO; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.types.VESMessage; +import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfDomAccessor; +import org.onap.ccsdk.features.sdnr.wt.websocketmanager.model.WebsocketManagerService; +import org.opendaylight.mdsal.dom.api.DOMNotification; +import org.opendaylight.mdsal.dom.api.DOMNotificationListener; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.EventlogBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.SourceType; +import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class ORanDOMFaultNotificationListener implements DOMNotificationListener { + + private static final Logger LOG = LoggerFactory.getLogger(ORanDOMFaultNotificationListener.class); + + private final @NonNull NetconfDomAccessor netconfDomAccessor; + private final @NonNull VESCollectorService vesCollectorService; + private final @NonNull ORanDOMFaultToVESFaultMapper mapper; + private final @NonNull FaultService faultService; + private final @NonNull WebsocketManagerService websocketManagerService; + private final @NonNull DataProvider databaseService; + private final @NonNull ORANFM oranfm; + + private Integer counter; //Local counter is assigned to Notifications + + public ORanDOMFaultNotificationListener(@NonNull NetconfDomAccessor netconfDomAccessor, Optional oranfm, + @NonNull VESCollectorService vesCollectorService, @NonNull FaultService faultService, + @NonNull WebsocketManagerService websocketManagerService, @NonNull DataProvider databaseService) { + this.netconfDomAccessor = Objects.requireNonNull(netconfDomAccessor); + this.vesCollectorService = Objects.requireNonNull(vesCollectorService); + this.faultService = Objects.requireNonNull(faultService); + this.websocketManagerService = Objects.requireNonNull(websocketManagerService); + this.databaseService = Objects.requireNonNull(databaseService); + this.oranfm = oranfm.get(); + this.mapper = + new ORanDOMFaultToVESFaultMapper(netconfDomAccessor.getNodeId(), vesCollectorService, "AlarmNotif"); + this.counter = 0; + } + + @Override + public void onNotification(@NonNull DOMNotification notification) { + onAlarmNotif(notification); + } + + /** + * Gets the mfg name, mode-name and Uuid of the root component (Ex: Chassis.) In cases where there are multiple root + * components i.e., components with no parent, the Uuid of the last occurred component from the componentList will + * be considered. Till now we haven't seen Uuid set for root components, so not an issue for now. + * + * @param componentList + */ + public void setComponentList(Collection componentList) { + for (MapEntryNode component : ORanDOMToInternalDataModel.getRootComponents(componentList)) { + mapper.setMfgName( + ORanDMDOMUtility.getLeafValue(component, ORanDeviceManagerQNames.IETF_HW_COMPONENT_LIST_MFG_NAME)); + mapper.setUuid(ORanDMDOMUtility.getLeafValue(component, + ORanDeviceManagerQNames.IETF_HW_COMPONENT_LIST_UUID) != null + ? ORanDMDOMUtility.getLeafValue(component, + ORanDeviceManagerQNames.IETF_HW_COMPONENT_LIST_UUID) + : netconfDomAccessor.getNodeId().getValue()); + mapper.setModelName(ORanDMDOMUtility.getLeafValue(component, + ORanDeviceManagerQNames.IETF_HW_COMPONENT_LIST_MODEL_NAME)); + } + } + + public void onAlarmNotif(DOMNotification notification) { + + LOG.debug("onAlarmNotif {}", notification.getClass().getSimpleName()); + counter++; + // Send devicemanager specific notification for database and ODLUX + Instant eventTimeInstant = ORanDMDOMUtility.getNotificationInstant(notification); + faultService.faultNotification( + ORanDOMToInternalDataModel.getFaultLog(notification, oranfm, netconfDomAccessor.getNodeId(), counter)); + // Send model specific notification to WebSocketManager + websocketManagerService.sendNotification(notification, netconfDomAccessor.getNodeId(), oranfm.getAlarmNotifQName()); + + try { + if (vesCollectorService.getConfig().isVESCollectorEnabled()) { + VESCommonEventHeaderPOJO header = mapper.mapCommonEventHeader(notification, eventTimeInstant, counter); + VESFaultFieldsPOJO body = mapper.mapFaultFields(notification, oranfm); + VESMessage vesMsg = vesCollectorService.generateVESEvent(header, body); + vesCollectorService.publishVESMessage(vesMsg); + LOG.debug("VES Message is {}", vesMsg.getMessage()); + writeToEventLog(vesMsg.getMessage(), eventTimeInstant, oranfm.getAlarmNotifQName().getLocalName(), counter); + } + } catch (JsonProcessingException | DateTimeParseException e) { + LOG.debug("Can not convert event into VES message {}", notification, e); + } + } + + private void writeToEventLog(String data, Instant eventTimeInstant, String notificationName, int sequenceNo) { + EventlogBuilder eventlogBuilder = new EventlogBuilder(); + + eventlogBuilder.setObjectId("Device"); + eventlogBuilder.setCounter(sequenceNo); + eventlogBuilder.setAttributeName(notificationName); + eventlogBuilder.setNodeId(netconfDomAccessor.getNodeId().getValue()); + String eventLogMsgLvl = vesCollectorService.getConfig().getEventLogMsgDetail(); + if (eventLogMsgLvl.equalsIgnoreCase("SHORT")) { + data = getShortEventLogMessage(data); + } else if (eventLogMsgLvl.equalsIgnoreCase("MEDIUM")) { + data = getMediumEventLogMessage(data); + } else if (eventLogMsgLvl.equalsIgnoreCase("LONG")) { + // do nothing, data already contains long message + } else { // Unknown value, default to "SHORT" + data = getShortEventLogMessage(data); + } + eventlogBuilder.setNewValue(data); + eventlogBuilder.setSourceType(SourceType.Netconf); + eventlogBuilder.setTimestamp(ORanDOMToInternalDataModel.getDateAndTimeOfInstant(eventTimeInstant)); + + databaseService.writeEventLog(eventlogBuilder.build()); + } + + private String getShortEventLogMessage(String data) { + try { + JSONObject jsonObj = new JSONObject(data); + String domain = jsonObj.getJSONObject("event").getJSONObject("commonEventHeader").getString("domain"); + String eventId = jsonObj.getJSONObject("event").getJSONObject("commonEventHeader").getString("eventId"); + return "domain:" + domain + " eventId:" + eventId; + } catch (JSONException e) { + LOG.debug("{}", e); + return "Invalid message received"; + } + } + + private String getMediumEventLogMessage(String data) { + try { + JSONObject jsonObj = new JSONObject(data); + return jsonObj.getJSONObject("event").getJSONObject("commonEventHeader").toString(); + } catch (JSONException e) { + LOG.debug("{}", e); + return "Invalid message received"; + } + } +} diff --git a/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/notification/ORanDOMNotifToVESEventAssembly.java b/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/notification/ORanDOMNotifToVESEventAssembly.java new file mode 100644 index 000000000..6c572f35c --- /dev/null +++ b/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/notification/ORanDOMNotifToVESEventAssembly.java @@ -0,0 +1,102 @@ +/* + * ============LICENSE_START======================================================= + * ONAP : ccsdk features + * ================================================================================ + * Copyright (C) 2021 highstreet technologies GmbH Intellectual Property. + * All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + * + */ +package org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.notification; + +import java.time.Instant; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map.Entry; +import java.util.Objects; +import org.eclipse.jdt.annotation.NonNull; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.VESCollectorService; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.types.VESCommonEventHeaderPOJO; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.types.VESNotificationFieldsPOJO; +import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfDomAccessor; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class ORanDOMNotifToVESEventAssembly { + + private static final Logger log = LoggerFactory.getLogger(ORanDOMNotifToVESEventAssembly.class); + private static final String VES_EVENT_DOMAIN = "notification"; + private static final String VES_EVENTTYPE = "ORAN_notification"; + private static final String VES_EVENT_PRIORITY = "Normal"; + private NetconfDomAccessor netconfDomAccessor; + private VESCollectorService vesProvider; + + public ORanDOMNotifToVESEventAssembly(@NonNull NetconfDomAccessor netconfDomAccessor, + @NonNull VESCollectorService vesCollectorService) { + this.netconfDomAccessor = Objects.requireNonNull(netconfDomAccessor); + this.vesProvider = Objects.requireNonNull(vesCollectorService); + } + + // VES CommonEventHeader fields + public VESCommonEventHeaderPOJO createVESCommonEventHeader(Instant time, String notificationTypeName, + long sequenceNo) { + VESCommonEventHeaderPOJO vesCEH = new VESCommonEventHeaderPOJO(); + vesCEH.setDomain(VES_EVENT_DOMAIN); + vesCEH.setEventName(notificationTypeName); + vesCEH.setEventType(VES_EVENTTYPE); + vesCEH.setPriority(VES_EVENT_PRIORITY); + + String eventId; + + eventId = notificationTypeName + "-" + Long.toUnsignedString(sequenceNo); + + vesCEH.setEventId(eventId); + vesCEH.setStartEpochMicrosec(time.toEpochMilli() * 1000); + vesCEH.setLastEpochMicrosec(time.toEpochMilli() * 1000); + vesCEH.setNfVendorName("ORAN"); + vesCEH.setReportingEntityName(vesProvider.getConfig().getReportingEntityName()); + vesCEH.setSequence(sequenceNo); + vesCEH.setSourceId("ORAN"); + vesCEH.setSourceName(netconfDomAccessor.getNodeId().getValue()); + return vesCEH; + } + + // Notification fields + public VESNotificationFieldsPOJO createVESNotificationFields(HashMap xPathFields, + String notificationTypeName) { + VESNotificationFieldsPOJO vesNotifFields = new VESNotificationFieldsPOJO(); + + vesNotifFields.setChangeType(notificationTypeName); + vesNotifFields.setChangeIdentifier(netconfDomAccessor.getNodeId().getValue()); + + StringBuffer buf = new StringBuffer(); + Iterator> it = xPathFields.entrySet().iterator(); + while (it.hasNext()) { + Entry pair = it.next(); + buf.append("\n" + pair.getKey() + " = " + pair.getValue()); + } + log.debug("Resultlist({}):{}", xPathFields.size(), buf.toString()); + + ArrayList> arrayOfNamedHashMap = new ArrayList>(); + HashMap namedHashMap = new HashMap(); + namedHashMap.put("hashMap", xPathFields); + namedHashMap.put("name", notificationTypeName); + arrayOfNamedHashMap.add(namedHashMap); + vesNotifFields.setArrayOfNamedHashMap(arrayOfNamedHashMap); + return vesNotifFields; + + } +} diff --git a/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/notification/ORanDOMNotificationToXPath.java b/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/notification/ORanDOMNotificationToXPath.java new file mode 100644 index 000000000..697265f01 --- /dev/null +++ b/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/notification/ORanDOMNotificationToXPath.java @@ -0,0 +1,234 @@ +/* + * ============LICENSE_START======================================================= + * ONAP : ccsdk features + * ================================================================================ + * Copyright (C) 2020 highstreet technologies GmbH Intellectual Property. + * All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + * + */ +package org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.notification; + +import com.google.common.base.VerifyException; +import java.time.Instant; +import java.util.Collection; +import java.util.HashMap; +import org.eclipse.jdt.annotation.NonNull; +import org.opendaylight.mdsal.dom.api.DOMEvent; +import org.opendaylight.mdsal.dom.api.DOMNotification; +import org.opendaylight.yangtools.yang.common.QName; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument; +import org.opendaylight.yangtools.yang.data.api.schema.ChoiceNode; +import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode; +import org.opendaylight.yangtools.yang.data.api.schema.DataContainerChild; +import org.opendaylight.yangtools.yang.data.api.schema.DataContainerNode; +import org.opendaylight.yangtools.yang.data.api.schema.LeafSetEntryNode; +import org.opendaylight.yangtools.yang.data.api.schema.LeafSetNode; +import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode; +import org.opendaylight.yangtools.yang.data.api.schema.MapNode; +import org.opendaylight.yangtools.yang.data.api.schema.UnkeyedListEntryNode; +import org.opendaylight.yangtools.yang.data.api.schema.UnkeyedListNode; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class ORanDOMNotificationToXPath { + private static final Logger LOG = LoggerFactory.getLogger(ORanDOMNotificationToXPath.class); + + public HashMap convertDomNotifToXPath(@NonNull DOMNotification domNotification) { + @NonNull + ContainerNode notifContainer = domNotification.getBody(); + HashMap xPathData = new HashMap(); + + Collection data = notifContainer.body(); + for (DataContainerChild data1 : data) { + String namePath = ""; + recurseDOMData(notifContainer, data1, notifContainer, xPathData, namePath); + } + LOG.debug("XPath Data = {}", xPathData); + return xPathData; + + } + + private void recurseDOMData(@NonNull ContainerNode notifContainer, DataContainerChild domData, DataContainerNode cn, + HashMap result, String namePath) { + PathArgument pa1 = domData.getIdentifier(); + namePath += "/" + pa1.getNodeType().getLocalName(); + if (domData.getClass().getSimpleName().equals("ImmutableContainerNode")) { + try { + ContainerNode cn1 = (ContainerNode) cn.getChildByArg(pa1); + for (DataContainerChild data1 : cn1.body()) { + recurseDOMData(notifContainer, data1, cn1, result, namePath); + } + } catch (VerifyException ve) { + LOG.debug("{} does not exist", pa1); + } + } + + if (domData.getClass().getSimpleName().equals("ImmutableChoiceNode")) { + try { + ChoiceNode cn1 = (ChoiceNode) cn.getChildByArg(pa1); + for (DataContainerChild data1 : cn1.body()) { + // recurseChoiceData(data1, cn1, namePath); + recurseDOMData(notifContainer, data1, cn1, result, namePath); + } + } catch (VerifyException ve) { + LOG.debug("{} does not exist", pa1); + } + } + + if (domData.getClass().getSimpleName().equals("ImmutableUnkeyedListNode")) { + try { + UnkeyedListNode cn1 = (UnkeyedListNode) cn.getChildByArg(pa1); + for (UnkeyedListEntryNode data1 : cn1.body()) { + recurseUnkeyedListEntryNodeData(data1, cn1, result, namePath); + } + } catch (VerifyException ve) { + LOG.debug("{} does not exist", pa1); + } + } + + if (domData.getClass().getSimpleName().equals("ImmutableMapNode")) { + try { + MapNode cn1 = (MapNode) cn.getChildByArg(pa1); + for (MapEntryNode data1 : cn1.body()) { + recurseMapEntryNodeData(notifContainer, data1, cn1, result, namePath); + } + } catch (VerifyException ve) { + LOG.debug("{} does not exist", pa1); + } + } + + if (domData.getClass().getSimpleName().equals("ImmutableLeafSetNode")) { + try { + LeafSetNode cn1 = (LeafSetNode) cn.getChildByArg(pa1); + for (LeafSetEntryNode data1 : cn1.body()) { + recurseLeafSetEntryNodeData(data1, cn1, result, namePath); + } + } catch (VerifyException ve) { + LOG.debug("{} does not exist", pa1); + } + } + + if (domData.getClass().getSimpleName().equals("ImmutableLeafNode")) { + recurseLeafNode(domData, result, namePath); + } + } + + private void recurseLeafSetEntryNodeData(LeafSetEntryNode data, LeafSetNode cn1, + HashMap result, String namePath) { + PathArgument pa1 = data.getIdentifier(); + namePath += "/" + pa1.getNodeType().getLocalName(); + + if (data.getClass().getSimpleName().equals("ImmutableLeafSetEntryNode")) { + LOG.debug("{}={}", namePath, data.body()); + result.put(namePath, data.body().toString()); + } + } + + private void recurseMapEntryNodeData(@NonNull ContainerNode notifContainer, MapEntryNode data, MapNode cn1, + HashMap result, String namePath) { + PathArgument pa1 = data.getIdentifier(); + NodeIdentifierWithPredicates ni = data.getIdentifier(); + + for (QName qn : ni.keySet()) { + namePath += "/" + ni.getValue(qn); + } + + if (data.getClass().getSimpleName().equals("ImmutableMapEntryNode")) { + for (DataContainerChild data1 : data.body()) { + if (data1.getClass().getSimpleName().equals("ImmutableLeafSetNode")) { + try { + LeafSetNode cn2 = (LeafSetNode) data.getChildByArg(data1.getIdentifier()); + for (LeafSetEntryNode data2 : cn2.body()) { + recurseLeafSetEntryNodeData(data2, cn2, result, namePath); + } + } catch (VerifyException ve) { + LOG.debug("{} does not exist", data1.getIdentifier()); + } + } else { + recurseLeafNode(data1, result, namePath); + } + } + } + + if (data.getClass().getSimpleName().equals("ImmutableLeafSetNode")) { + try { + LeafSetNode cn2 = (LeafSetNode) notifContainer.getChildByArg(pa1); + for (LeafSetEntryNode data1 : cn2.body()) { + recurseLeafSetEntryNodeData(data1, cn2, result, namePath); + } + } catch (VerifyException ve) { + LOG.debug("{} does not exist", pa1); + } + } + + if (data.getClass().getSimpleName().equals("ImmutableLeafNode")) { + LOG.debug("{}={}", namePath, data.body()); + result.put(namePath, data.body().toString()); + } + } + + private void recurseUnkeyedListEntryNodeData(UnkeyedListEntryNode data, UnkeyedListNode cn1, + HashMap result, String namePath) { + PathArgument pa1 = data.getIdentifier(); + namePath += "/" + pa1.getNodeType().getLocalName(); + + if (data.getClass().getSimpleName().equals("ImmutableUnkeyedListEntryNode")) { + for (DataContainerChild data1 : data.body()) { + recurseLeafNode(data1, result, namePath); + } + } + + if (data.getClass().getSimpleName().equals("ImmutableLeafNode")) { + LOG.debug("{}={}", namePath, data.body()); + result.put(namePath, data.body().toString()); + } + } + + public void recurseLeafNode(DataContainerChild data, HashMap result, String namePath) { + PathArgument pa1 = data.getIdentifier(); + if (!(data.getClass().getSimpleName().equals("ImmutableAugmentationNode"))) + namePath += "/" + pa1.getNodeType().getLocalName(); + if (data.getClass().getSimpleName().equals("ImmutableLeafNode")) { + LOG.debug("{}={}", namePath, data.body()); + result.put(namePath, data.body().toString()); + } + } + + public void recurseChoiceData(HashMap result, DataContainerChild data, ChoiceNode cn, + String namePath) { + PathArgument pa1 = data.getIdentifier(); + namePath += "/" + pa1.getNodeType().getLocalName(); + // NodeIdentifier nodeId = new NodeIdentifier(pa1.getNodeType()); + if (data.getClass().getSimpleName().equals("ImmutableLeafNode")) { + LOG.debug("{}={}", namePath, data.body()); + result.put(namePath, data.body().toString()); + } + } + + public Instant getTime(@NonNull DOMNotification domNotification) { + @NonNull + Instant eventTime; + if (domNotification instanceof DOMEvent) { + eventTime = ((DOMEvent) domNotification).getEventInstant(); + LOG.debug("Event time {}", eventTime); + } else { + eventTime = Instant.now(); + LOG.debug("Defaulting to actual time of processing the notification - {}", eventTime); + } + return eventTime; + } +} diff --git a/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/notification/ORanDOMSupervisionNotificationListener.java b/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/notification/ORanDOMSupervisionNotificationListener.java new file mode 100644 index 000000000..a0a075d0b --- /dev/null +++ b/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/notification/ORanDOMSupervisionNotificationListener.java @@ -0,0 +1,105 @@ +package org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.notification; + +import com.fasterxml.jackson.core.JsonProcessingException; +import java.time.Instant; +import java.time.format.DateTimeParseException; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Iterator; +import java.util.List; +import org.eclipse.jdt.annotation.NonNull; +import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.DataProvider; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.config.ORanDMConfig; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.dataprovider.ORanDOMToInternalDataModel; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.util.ORanDMDOMUtility; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.util.ORanDeviceManagerQNames; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.vesmapper.ORanDOMSupervisionNotifToVESMapper; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.VESCollectorService; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.types.VESCommonEventHeaderPOJO; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.types.VESMessage; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.types.VESStndDefinedFieldsPOJO; +import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfDomAccessor; +import org.opendaylight.mdsal.dom.api.DOMNotification; +import org.opendaylight.mdsal.dom.api.DOMNotificationListener; +import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class ORanDOMSupervisionNotificationListener implements DOMNotificationListener, ORanNotificationReceivedService { + private static final Logger LOG = LoggerFactory.getLogger(ORanDOMSupervisionNotificationListener.class); + + private @NonNull NetconfDomAccessor netconfDomAccessor; + private @NonNull DataProvider databaseService; + private @NonNull VESCollectorService vesCollectorService; + private List notificationObserverList; + private Integer counter; //Local counter is assigned to Notifications + + private @NonNull ORanDOMSupervisionNotifToVESMapper mapper; + + public ORanDOMSupervisionNotificationListener(@NonNull NetconfDomAccessor netconfDomAccessor, + @NonNull VESCollectorService vesCollectorService, @NonNull DataProvider databaseService, + ORanDMConfig oranSupervisionConfig) { + this.netconfDomAccessor = netconfDomAccessor; + this.databaseService = databaseService; + this.vesCollectorService = vesCollectorService; + this.mapper = new ORanDOMSupervisionNotifToVESMapper(netconfDomAccessor.getNodeId(), vesCollectorService, "o-ran-supervision"); + notificationObserverList = new ArrayList<>(); + this.counter = 0; + } + + public void setComponentList(Collection componentList) { + for (MapEntryNode component : ORanDOMToInternalDataModel.getRootComponents(componentList)) { + mapper.setMfgName( + ORanDMDOMUtility.getLeafValue(component, ORanDeviceManagerQNames.IETF_HW_COMPONENT_LIST_MFG_NAME)); + mapper.setUuid(ORanDMDOMUtility.getLeafValue(component, + ORanDeviceManagerQNames.IETF_HW_COMPONENT_LIST_UUID) != null + ? ORanDMDOMUtility.getLeafValue(component, + ORanDeviceManagerQNames.IETF_HW_COMPONENT_LIST_UUID) + : netconfDomAccessor.getNodeId().getValue()); + mapper.setModelName(ORanDMDOMUtility.getLeafValue(component, + ORanDeviceManagerQNames.IETF_HW_COMPONENT_LIST_MODEL_NAME)); + } + } + + @Override + public void onNotification(@NonNull DOMNotification notification) { + LOG.trace("Notification Type = {}", notification.getType().toString()); + notifyObservers(); + Instant eventTimeInstant = ORanDMDOMUtility.getNotificationInstant(notification); + try { + if (vesCollectorService.getConfig().isVESCollectorEnabled()) { + VESCommonEventHeaderPOJO header = mapper.mapCommonEventHeader(notification, eventTimeInstant, counter); + VESStndDefinedFieldsPOJO body = mapper.mapStndDefinedFields(eventTimeInstant); + VESMessage vesMsg = vesCollectorService.generateVESEvent(header, body); + vesCollectorService.publishVESMessage(vesMsg); + LOG.debug("VES Message is {}", vesMsg.getMessage()); + } + } catch (JsonProcessingException | DateTimeParseException e) { + LOG.debug("Cannot convert event into VES message {}", notification, e); + } + } + + private void notifyObservers() { + Iterator it = notificationObserverList.iterator(); + while (it.hasNext()) { + ORanNotificationObserver o = it.next(); + new Thread() { + @Override + public void run() { + o.observer(); + } + }.start(); + } + } + + @Override + public void registerForNotificationReceivedEvent(ORanNotificationObserver o) { + notificationObserverList.add(o); + } + + @Override + public void deregisterNotificationReceivedEvent(ORanNotificationObserver o) { + notificationObserverList.remove(o); + } + +} diff --git a/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/notification/ORanNotificationObserver.java b/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/notification/ORanNotificationObserver.java new file mode 100644 index 000000000..ea56c983e --- /dev/null +++ b/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/notification/ORanNotificationObserver.java @@ -0,0 +1,31 @@ +/* + * ============LICENSE_START======================================================= + * ONAP : ccsdk features + * ================================================================================ + * Copyright (C) 2023 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========================================================= + * + */ + +/* + * Interface to be implemented by those interested in knowing the occurrence of Notifications + */ +package org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.notification; + +public interface ORanNotificationObserver { + + public void observer(); +} diff --git a/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/notification/ORanNotificationObserverImpl.java b/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/notification/ORanNotificationObserverImpl.java new file mode 100644 index 000000000..f7f840c90 --- /dev/null +++ b/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/notification/ORanNotificationObserverImpl.java @@ -0,0 +1,43 @@ +/* + * ============LICENSE_START======================================================= + * ONAP : ccsdk features + * ================================================================================ + * Copyright (C) 2023 highstreet technologies GmbH Intellectual Property. + * All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + * + */ +package org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.notification; + +import org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.config.ORanDMConfig; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.rpc.ORanSupervisionRPCImpl; +import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfDomAccessor; + +public class ORanNotificationObserverImpl implements ORanNotificationObserver { + + private NetconfDomAccessor netconfDomAccessor; + private ORanDMConfig oruSupervisionConfig; + + public ORanNotificationObserverImpl(NetconfDomAccessor netconfDomAccessor, ORanDMConfig oruSupervisionConfig) { + this.netconfDomAccessor = netconfDomAccessor; + this.oruSupervisionConfig = oruSupervisionConfig; + } + + @Override + public void observer() { + ORanSupervisionRPCImpl.invokeWatchdogReset(netconfDomAccessor, oruSupervisionConfig); + } + +} diff --git a/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/notification/ORanNotificationReceivedService.java b/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/notification/ORanNotificationReceivedService.java new file mode 100644 index 000000000..9c52c2daf --- /dev/null +++ b/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/notification/ORanNotificationReceivedService.java @@ -0,0 +1,33 @@ +/* + * ============LICENSE_START======================================================= + * ONAP : ccsdk features + * ================================================================================ + * Copyright (C) 2023 highstreet technologies GmbH Intellectual Property. + * All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + * + */ +package org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.notification; + +/* + * Interface for registering and de-registering for listening of occurrence of notifications + */ +public interface ORanNotificationReceivedService { + + void registerForNotificationReceivedEvent(ORanNotificationObserver o); + + void deregisterNotificationReceivedEvent(ORanNotificationObserver o); + +} diff --git a/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/rpc/ORanSupervisionRPCImpl.java b/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/rpc/ORanSupervisionRPCImpl.java new file mode 100644 index 000000000..30d413828 --- /dev/null +++ b/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/rpc/ORanSupervisionRPCImpl.java @@ -0,0 +1,82 @@ +/* + * ============LICENSE_START======================================================= + * ONAP : ccsdk features + * ================================================================================ + * Copyright (C) 2023 highstreet technologies GmbH Intellectual Property. + * All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + * + */ +package org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.rpc; + +import com.google.common.util.concurrent.ListenableFuture; +import java.util.concurrent.TimeUnit; +import org.eclipse.jdt.annotation.NonNull; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.config.ORanDMConfig; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.util.ORanDeviceManagerQNames; +import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfDomAccessor; +import org.opendaylight.mdsal.dom.api.DOMRpcResult; +import org.opendaylight.mdsal.dom.api.DOMRpcService; +import org.opendaylight.yangtools.yang.common.QName; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier; +import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode; +import org.opendaylight.yangtools.yang.data.impl.schema.Builders; +import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class ORanSupervisionRPCImpl { + + private static final Logger LOG = LoggerFactory.getLogger(ORanSupervisionRPCImpl.class); + private static NodeIdentifier inputNodeIdentifier = + NodeIdentifier.create(QName.create(ORanDeviceManagerQNames.ORAN_SUPERVISION_MODULE, "input")); + private static NodeIdentifier supervisionNotificationIntervalIdentifier = NodeIdentifier + .create(QName.create(ORanDeviceManagerQNames.ORAN_SUPERVISION_MODULE, "supervision-notification-interval")); + private static NodeIdentifier guardTimerOverheadIdentifier = NodeIdentifier + .create(QName.create(ORanDeviceManagerQNames.ORAN_SUPERVISION_MODULE, "guard-timer-overhead")); + + public static void invokeWatchdogReset(@NonNull NetconfDomAccessor netconfDomAccessor, + ORanDMConfig oruSupervisionConfig) { + + LOG.debug( + "Resetting suppervision-notification-interval and guard-timer-overhead watchdog timers with values {} and {} respectively", + oruSupervisionConfig.getNotificationInterval(), oruSupervisionConfig.getWatchdogTimer()); + ContainerNode rpcInputNode = Builders.containerBuilder().withNodeIdentifier(inputNodeIdentifier) + .withChild(ImmutableNodes.leafNode(supervisionNotificationIntervalIdentifier, + oruSupervisionConfig.getNotificationInterval())) + .withChild( + ImmutableNodes.leafNode(guardTimerOverheadIdentifier, oruSupervisionConfig.getWatchdogTimer())) + .build(); + + try { + DOMRpcService rpcService = netconfDomAccessor.getRpcService(); + QName supervisionWatchdogResetQN = + QName.create(ORanDeviceManagerQNames.ORAN_SUPERVISION_MODULE, "supervision-watchdog-reset"); + + ListenableFuture result = + rpcService.invokeRpc(supervisionWatchdogResetQN, rpcInputNode); + DOMRpcResult rpcResult = result.get(60000, TimeUnit.MILLISECONDS); + if (rpcResult.value() != null) { + ContainerNode rpcResultCn = (ContainerNode) rpcResult.value(); + LOG.debug("Result of Supervision-Watchdog-Reset = {}", rpcResultCn.prettyTree()); + } + } catch (Exception e) { + LOG.error("{}", e); + } + return; + + } + +} diff --git a/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/util/ORanDMDOMUtility.java b/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/util/ORanDMDOMUtility.java new file mode 100644 index 000000000..708ba8a47 --- /dev/null +++ b/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/util/ORanDMDOMUtility.java @@ -0,0 +1,89 @@ +/* + * ============LICENSE_START======================================================= + * ONAP : ccsdk features + * ================================================================================ + * Copyright (C) 2021 highstreet technologies GmbH Intellectual Property. + * All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + * + */ +package org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.util; + +import com.google.common.base.VerifyException; +import java.time.Instant; +import java.util.Collection; +import java.util.HashSet; +import java.util.Iterator; +import java.util.Set; +import org.opendaylight.mdsal.dom.api.DOMEvent; +import org.opendaylight.mdsal.dom.api.DOMNotification; +import org.opendaylight.yangtools.yang.common.QName; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates; +import org.opendaylight.yangtools.yang.data.api.schema.DataContainerChild; +import org.opendaylight.yangtools.yang.data.api.schema.DataContainerNode; +import org.opendaylight.yangtools.yang.data.api.schema.LeafNode; +import org.opendaylight.yangtools.yang.data.api.schema.LeafSetEntryNode; +import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class ORanDMDOMUtility { + public static final Logger LOG = LoggerFactory.getLogger(ORanDMDOMUtility.class); + + public static String getKeyValue(MapEntryNode componentEntry) { + NodeIdentifierWithPredicates componentKey = componentEntry.getIdentifier(); // list key + return (String) componentKey.getValue(ORanDeviceManagerQNames.IETF_HW_COMPONENT_LIST_KEY); + } + + public static String getLeafValue(DataContainerNode componentEntry, QName leafQName) { + NodeIdentifier leafNodeIdentifier = new NodeIdentifier(leafQName); + try { + LeafNode optLeafNode = (LeafNode) componentEntry.getChildByArg(leafNodeIdentifier); + if (optLeafNode.body() instanceof QName) { + LOG.debug("Leaf is of type QName"); + } + return optLeafNode.body().toString(); + } catch (VerifyException ve) { + LOG.debug("Leaf with QName {} not found", leafQName.toString()); + return null; + } + } + + public static Set getLeafListValue(DataContainerNode componentEntry, QName leafListQName) { + Set containsChildList = new HashSet(); + try { + DataContainerChild childSet = componentEntry.getChildByArg(new NodeIdentifier(leafListQName)); + Collection childEntry = (Collection) childSet.body(); + Iterator childEntryItr = childEntry.iterator(); + while (childEntryItr.hasNext()) { + LeafSetEntryNode childEntryNode = (LeafSetEntryNode) childEntryItr.next(); + containsChildList.add(childEntryNode.body().toString()); + } + } catch (VerifyException ve) { + LOG.debug("Child for {} does not exist", leafListQName); + } + return containsChildList; + } + + public static Instant getNotificationInstant(DOMNotification notification) { + if (notification instanceof DOMEvent) { + return ((DOMEvent) notification).getEventInstant(); + } else { + return Instant.now(); + } + } + +} diff --git a/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/util/ORanDeviceManagerQNames.java b/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/util/ORanDeviceManagerQNames.java new file mode 100644 index 000000000..e2ad092dc --- /dev/null +++ b/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/util/ORanDeviceManagerQNames.java @@ -0,0 +1,101 @@ +/* + * ============LICENSE_START======================================================= + * ONAP : ccsdk features + * ================================================================================ + * Copyright (C) 2021 highstreet technologies GmbH Intellectual Property. + * All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + * + */ +package org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.util; + +import org.eclipse.jdt.annotation.NonNull; +import org.opendaylight.yangtools.yang.common.QName; + +public class ORanDeviceManagerQNames { + + //ietf-system + public static final String IETF_SYSTEM_NS = "urn:ietf:params:xml:ns:yang:ietf-system"; + public static final String IETF_SYSTEM_REVISION = "2014-08-06"; + public static final @NonNull QName IETF_SYSTEM_QNAME = + QName.create(IETF_SYSTEM_NS, IETF_SYSTEM_REVISION, "ietf-system"); + public static final @NonNull QName IETF_SYSTEM_CONTAINER = QName.create(IETF_SYSTEM_QNAME, "system"); + + //ietf-hardware.yang + public static final String IETF_HW_NS = "urn:ietf:params:xml:ns:yang:ietf-hardware"; + public static final String IETF_HW_REVISION = "2018-03-13"; + public static final @NonNull QName IETF_HW_MODULE_NAME = + QName.create(IETF_HW_NS, IETF_HW_REVISION, "ietf-hardware"); + public static final @NonNull QName IETF_HW_CONTAINER = QName.create(IETF_HW_MODULE_NAME, "hardware"); + public static final @NonNull QName IETF_HW_COMPONENT_LIST = QName.create(IETF_HW_MODULE_NAME, "component"); + public static final @NonNull QName IETF_HW_COMPONENT_LIST_KEY = QName.create(IETF_HW_MODULE_NAME, "name"); + public static final @NonNull QName IETF_HW_COMPONENT_LIST_MFG_NAME = QName.create(IETF_HW_MODULE_NAME, "mfg-name"); //leaf:String + public static final @NonNull QName IETF_HW_COMPONENT_LIST_UUID = QName.create(IETF_HW_MODULE_NAME, "uuid"); //leaf:yang:uuid + public static final @NonNull QName IETF_HW_COMPONENT_LIST_MODEL_NAME = QName.create(IETF_HW_MODULE_NAME, "model-name"); //leaf:String + public static final @NonNull QName IETF_HW_COMPONENT_LIST_SER_NUM = QName.create(IETF_HW_MODULE_NAME, "serial-num"); //leaf:String + public static final @NonNull QName IETF_HW_COMPONENT_LIST_SW_REV = QName.create(IETF_HW_MODULE_NAME, "software-rev"); //leaf:String + public static final @NonNull QName IETF_HW_COMPONENT_LIST_ALIAS = QName.create(IETF_HW_MODULE_NAME, "alias"); //leaf:String + public static final @NonNull QName IETF_HW_COMPONENT_LIST_CLASS = QName.create(IETF_HW_MODULE_NAME, "class"); + public static final @NonNull QName IETF_HW_COMPONENT_LIST_MFG_DATE = QName.create(IETF_HW_MODULE_NAME, "mfg-date"); //leaf:yang:date-and-time + public static final @NonNull QName IETF_HW_COMPONENT_LIST_CONTAINS_CHILD = QName.create(IETF_HW_MODULE_NAME, "contains-child"); //leaf-list:leafref + public static final @NonNull QName IETF_HW_COMPONENT_LIST_PARENT = QName.create(IETF_HW_MODULE_NAME, "parent"); //leaf:leafref + public static final @NonNull QName IETF_HW_COMPONENT_LIST_DESC = QName.create(IETF_HW_MODULE_NAME, "description"); //leaf:String + public static final @NonNull QName IETF_HW_COMPONENT_LIST_HW_REV = QName.create(IETF_HW_MODULE_NAME, "hardware-rev"); //leaf:String + + //odl-netconf-callhome-server.yang + public static final String CALLHOME_SERVER_NS = "urn:opendaylight:params:xml:ns:yang:netconf-callhome-server"; + public static final String CALLHOME_SERVER_REVISION = "2020-10-15"; + public static final @NonNull QName CALLHOME_SERVER_MODULE = + QName.create(CALLHOME_SERVER_NS, CALLHOME_SERVER_REVISION, "odl-netconf-callhome-server"); + public static final @NonNull QName CALLHOME_SERVER_CONTAINER = + QName.create(CALLHOME_SERVER_MODULE, "netconf-callhome-server"); + public static final @NonNull QName CALLHOME_SERVER_ALLOWED_DEVICE = + QName.create(CALLHOME_SERVER_MODULE, "allowed-devices"); + public static final @NonNull QName CALLHOME_SERVER_ALLOWED_DEVICE_DEVICE_LIST = + QName.create(CALLHOME_SERVER_MODULE, "device"); + public static final @NonNull QName CALLHOME_SERVER_ALLOWED_DEVICE_KEY = + QName.create(CALLHOME_SERVER_MODULE, "unique-id"); + + //o-ran-hardware.yang + public static final String ORAN_HW_NS = "urn:o-ran:hardware:1.0"; + public static final String ORAN_HW_REVISION = "2019-03-28"; + public static final @NonNull QName ORAN_HW_MODULE = QName.create(ORAN_HW_NS, ORAN_HW_REVISION, "o-ran-hardware").intern(); + public static final @NonNull QName ORAN_HW_COMPONENT = QName.create(ORAN_HW_MODULE, "O-RAN-HW-COMPONENT"); + + //ietf-netconf-notifications.yang + public static final String IETF_NETCONF_NOTIFICATIONS_NS = "urn:ietf:params:xml:ns:yang:ietf-netconf-notifications"; + public static final String IETF_NETCONF_NOTIFICATIONS_REVISION = "2012-02-06"; + public static final @NonNull QName IETF_NETCONF_NOTIFICATIONS_MODULE = QName.create(IETF_NETCONF_NOTIFICATIONS_NS, IETF_NETCONF_NOTIFICATIONS_REVISION, "ietf-netconf-notifications").intern(); + public static final @NonNull QName IETF_NETCONF_NOTIFICATIONS_NETCONF_CONFIG_CHANGE = QName.create(IETF_NETCONF_NOTIFICATIONS_MODULE, "netconf-config-change"); + public static final @NonNull QName IETF_NETCONF_NOTIFICATIONS_NETCONF_CONFIRMED_COMMIT = QName.create(IETF_NETCONF_NOTIFICATIONS_MODULE, "netconf-confirmed-commit"); + public static final @NonNull QName IETF_NETCONF_NOTIFICATIONS_NETCONF_SESSION_START = QName.create(IETF_NETCONF_NOTIFICATIONS_MODULE, "netconf-session-start"); + public static final @NonNull QName IETF_NETCONF_NOTIFICATIONS_NETCONF_SESSION_END = QName.create(IETF_NETCONF_NOTIFICATIONS_MODULE, "netconf-session-end"); + public static final @NonNull QName IETF_NETCONF_NOTIFICATIONS_NETCONF_CAPABILITY_CHANGE = QName.create(IETF_NETCONF_NOTIFICATIONS_MODULE, "netconf-capability-change"); + public static final @NonNull QName IETF_NETCONF_NOTIFICATIONS_CHANGEDBY = QName.create(IETF_NETCONF_NOTIFICATIONS_MODULE, "changed-by"); + public static final @NonNull QName IETF_NETCONF_NOTIFICATIONS_SERVERORUSER = QName.create(IETF_NETCONF_NOTIFICATIONS_MODULE, "server-or-user"); + public static final @NonNull QName IETF_NETCONF_NOTIFICATIONS_EDITNODE = QName.create(IETF_NETCONF_NOTIFICATIONS_MODULE, "edit"); + public static final @NonNull QName IETF_NETCONF_NOTIFICATIONS_USERNAME = QName.create(IETF_NETCONF_NOTIFICATIONS_MODULE, "username"); + public static final @NonNull QName IETF_NETCONF_NOTIFICATIONS_SESSIONID = QName.create(IETF_NETCONF_NOTIFICATIONS_MODULE, "session-id"); + public static final @NonNull QName IETF_NETCONF_NOTIFICATIONS_OPERATION = QName.create(IETF_NETCONF_NOTIFICATIONS_MODULE, "operation"); + public static final @NonNull QName IETF_NETCONF_NOTIFICATIONS_TARGET = QName.create(IETF_NETCONF_NOTIFICATIONS_MODULE, "target"); + public static final @NonNull QName IETF_NETCONF_NOTIFICATIONS_DATASTORE = QName.create(IETF_NETCONF_NOTIFICATIONS_MODULE, "datastore"); + + //o-ran-supervision.yang + public static final String ORAN_SUPERVISION_NS = "urn:o-ran:supervision:1.0"; + public static final String ORAN_SUPERVISION_REVISION = "2022-12-05"; + public static final @NonNull QName ORAN_SUPERVISION_MODULE = QName.create(ORAN_SUPERVISION_NS, ORAN_SUPERVISION_REVISION, "o-ran-supervision"); + public static final @NonNull QName ORAN_SUPERVISION_NOTIFICATION = QName.create(ORAN_SUPERVISION_MODULE, "supervision-notification"); + +} diff --git a/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/vesmapper/ORanDOMFaultToVESFaultMapper.java b/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/vesmapper/ORanDOMFaultToVESFaultMapper.java new file mode 100644 index 000000000..fabe26463 --- /dev/null +++ b/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/vesmapper/ORanDOMFaultToVESFaultMapper.java @@ -0,0 +1,153 @@ +/* + * ============LICENSE_START======================================================= + * ONAP : ccsdk features + * ================================================================================ + * Copyright (C) 2021 highstreet technologies GmbH Intellectual Property. + * All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + * + */ +package org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.vesmapper; + +import java.time.Instant; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.util.ORanDMDOMUtility; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.yangspecs.ORANFM; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.VESCollectorService; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.types.VESCommonEventHeaderPOJO; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.types.VESFaultFieldsPOJO; +import org.opendaylight.mdsal.dom.api.DOMNotification; +import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId; +import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +//@formatter:off +/* +* Maps ORAN Fault fields to VES fault domain fields and VES commonEventHeader fields +* +* +* VES Fields Mapping +* ---------- ------- +* domain "fault" +* eventId "nt:network-topology/nt:topology/nt:node/nt:node-id" +* eventName "nt:network-topology/nt:topology/nt:node/nt:node-id" +* eventType "O-RAN-RU-Fault" +* lastEpochMicrosec TimeStamp represented by field in NetConf notification header in unix time format - as microseconds elapsed since 1 Jan 1970 not including leap seconds. +* nfcNamingCode always "" +* nfNamingCode always "" +* nfVendorName /ietf-hardware:hardware/component[not(parent)][1]/mfg-name +* priority "Normal" +* reportingEntityId The OAM-Controller identifier with in the SMO - e.g. the fully qualified domain name or IP-Address. +* reportingEntityName as configured by helm charts for the OpenDaylight cluster name ?????? +* sequence As per NetConf notification increasing sequence number as unsigned integer 32 bits. The value is reused in the eventId field. +* sourceId Value of ietf-hardware (RFC8348) /hardware/component[not(parent)][1]/uuid or 'nt:network-topology/nt:topology/nt:node/nt:node-id' if ietf component not found. +* sourceName "nt:network-topology/nt:topology/nt:node/nt:node-id" +* startEpochMicrosec Current OAM-Controller Node timestamp in unix time format - as microseconds elapsed since 1 Jan 1970 not including leap seconds. +* timeZoneOffset Static text: "+00:00" +* version "4.1" +* vesEventListenerVersion "7.2.1" +* +* +* alarmAdditionalInformation +* alarmCondition Value of "o-ran-fm:alarm-notif/fault-id" +* alarmInterfaceA Value of "o-ran-fm:alarm-notif/fault-source" +* eventCategory Static text "O-RU failure" +* eventSeverity Value of "o-ran-fm:alarm-notif/fault-severity". But if "o-ran-fm:alarm-notif/is-cleared" then "NORMAL" +* eventSourceType The value of ietf-hardware (RFC8348) /hardware/component[not(parent)][1]/model-name or "O-RU" if not found. +* faultFieldsVersion "4.0" +* specificProblem A mapping of the fault-id to its description according to O-RAN OpenFronthaul specification. +* vfStatus "Active" +* +*/ +//@formatter:on + +public class ORanDOMFaultToVESFaultMapper { + @SuppressWarnings("unused") + private static final Logger LOG = LoggerFactory.getLogger(ORanDOMFaultToVESFaultMapper.class); + private static final String VES_EVENT_DOMAIN = "fault"; + private static final String VES_EVENTTYPE = "ORAN_Fault"; + private static final String VES_EVENT_PRIORITY = "Normal"; + private static final String VES_EVENT_CATEGORY = "O-RU Failure"; + private static final String VES_FAULT_FIELDS_VERSION = "4.0"; + private static final String VES_FAULT_FIELDS_VFSTATUS = "Active"; //virtual function status + + private final VESCollectorService vesProvider; + private final String notifName; // Name + private final String nodeIdString; // Sourcename + //Initialized during registration + private String mfgName; + private String uuid; + private String modelName; + + public ORanDOMFaultToVESFaultMapper(NodeId nodeId, VESCollectorService vesCollectorService, String notifName) { + this.nodeIdString = nodeId.getValue(); + this.vesProvider = vesCollectorService; + this.notifName = notifName; + } + + public void setMfgName(String mfgName) { + this.mfgName = mfgName; + } + + public void setUuid(String uuid) { + this.uuid = uuid; + } + + public void setModelName(String modelName) { + this.modelName = modelName; + } + + public VESCommonEventHeaderPOJO mapCommonEventHeader(DOMNotification notification, Instant eventTime, + int sequenceNo) { + VESCommonEventHeaderPOJO vesCEH = new VESCommonEventHeaderPOJO(); + vesCEH.setDomain(VES_EVENT_DOMAIN); + vesCEH.setEventName(notifName); + vesCEH.setEventType(VES_EVENTTYPE); + vesCEH.setPriority(VES_EVENT_PRIORITY); + + String eventId = notifName + "-" + Long.toUnsignedString(sequenceNo); + + vesCEH.setEventId(eventId); + vesCEH.setStartEpochMicrosec(eventTime.toEpochMilli() * 1000); + vesCEH.setLastEpochMicrosec(eventTime.toEpochMilli() * 1000); + vesCEH.setNfVendorName(mfgName); + vesCEH.setReportingEntityName(vesProvider.getConfig().getReportingEntityName()); + vesCEH.setSequence(sequenceNo); + vesCEH.setSourceId(uuid); + vesCEH.setSourceName(nodeIdString); + + return vesCEH; + } + + public VESFaultFieldsPOJO mapFaultFields(DOMNotification alarmNotif, ORANFM oranfm) { + VESFaultFieldsPOJO vesFaultFields = new VESFaultFieldsPOJO(); + ContainerNode cn = alarmNotif.getBody(); + vesFaultFields.setAlarmCondition(ORanDMDOMUtility.getLeafValue(cn, oranfm.getFaultIdQName())); + vesFaultFields.setAlarmInterfaceA(ORanDMDOMUtility.getLeafValue(cn, oranfm.getFaultSourceQName())); + vesFaultFields.setEventCategory(VES_EVENT_CATEGORY); + if (ORanDMDOMUtility.getLeafValue(cn, oranfm.getFaultIsClearedQName()).equals("true")) { + vesFaultFields.setEventSeverity("NORMAL"); + } else { + vesFaultFields.setEventSeverity(ORanDMDOMUtility.getLeafValue(cn, oranfm.getFaultSeverityQName())); + } + vesFaultFields.setEventSourceType(modelName); + vesFaultFields.setFaultFieldsVersion(VES_FAULT_FIELDS_VERSION); + vesFaultFields.setSpecificProblem(ORanDMDOMUtility.getLeafValue(cn, oranfm.getFaultTextQName())); + vesFaultFields.setVfStatus(VES_FAULT_FIELDS_VFSTATUS); + + return vesFaultFields; + } + +} diff --git a/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/vesmapper/ORanDOMSupervisionNotifToVESMapper.java b/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/vesmapper/ORanDOMSupervisionNotifToVESMapper.java new file mode 100644 index 000000000..b87b93d80 --- /dev/null +++ b/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/vesmapper/ORanDOMSupervisionNotifToVESMapper.java @@ -0,0 +1,206 @@ +/* + * ============LICENSE_START======================================================= + * ONAP : ccsdk features + * ================================================================================ + * Copyright (C) 2023 highstreet technologies GmbH Intellectual Property. + * All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + * + */ +package org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.vesmapper; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.time.Instant; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.dataprovider.ORanDOMToInternalDataModel; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.VESCollectorService; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.types.VESCommonEventHeaderPOJO; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.types.VESStndDefinedFieldsPOJO; +import org.opendaylight.mdsal.dom.api.DOMNotification; +import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId; + +/* + * { + "event": { + "stndDefinedFields": { + "schemaReference": "https://gerrit.o-ran-sc.org/r/gitweb?p=scp/oam/modeling.git;a=blob_plain;f=data-model/yang/published/o-ran/ru-fh/o-ran-supervision.yang#components/schemas/ofhm-event-stream", + "stndDefinedFieldsVersion": "1.0", + "data": { + "ietf:notification": { + "eventTime": "2023-06-28T07:28:55.098Z", + "o-ran-supervision:supervision-notification": { + "session-id": 999999 + } + } + } + }, + "commonEventHeader": { + "domain": "stndDefined", + "eventType": "o-ran-supervision:supervision-notification", + "eventId": "pnf2_o-ran-supervision:supervision-notification_fed2ab31f6e1da56", + "eventName": "stndDefined_o-ran-supervision:supervision-notification", + "sequence": 1687937335098, + "priority": "Low", + "reportingEntityId": "c2b7d6e9-ee35-459a-ab8e-717a6fc1fde6", + "reportingEntityName": "flows", + "sourceId": "378e9904-6d39-40ea-9994-0596fe2235a3", + "sourceName": "O-RAN-SC-OAM-Test-Component-01", + "startEpochMicrosec": 1687937335098000, + "lastEpochMicrosec": 1687937335098000, + "nfNamingCode": "pnf2", + "nfVendorName": "O-RAN-SC-OAM-Project", + "timeZoneOffset": "+00:00", + "stndDefinedNamespace": "o-ran-supervision:supervision-notification", + "version": "4.1", + "vesEventListenerVersion": "7.2.1" + } + } +} + */ +public class ORanDOMSupervisionNotifToVESMapper { + + private static final String VES_EVENT_DOMAIN = "stndDefined"; + private static final String VES_EVENTTYPE = "o-ran-supervision:supervision-notification"; + private static final String VES_EVENT_PRIORITY = "Low"; + private static final String O_RU_SUPERVISION_SCHEMA_REFERENCE = + "https://gerrit.o-ran-sc.org/r/gitweb?p=scp/oam/modeling.git;a=blob_plain;f=data-model/yang/published/o-ran/ru-fh/o-ran-supervision.yang#components/schemas/ofhm-event-stream"; + private final VESCollectorService vesProvider; + private final String notifName; + private final String nodeIdString; + //Initialized during registration + private String mfgName; + private String uuid; + private String modelName; + + public ORanDOMSupervisionNotifToVESMapper(NodeId nodeId, VESCollectorService vesCollectorService, + String notifName) { + this.nodeIdString = nodeId.getValue(); + this.vesProvider = vesCollectorService; + this.notifName = notifName; + } + + public void setMfgName(String mfgName) { + this.mfgName = mfgName; + } + + public void setUuid(String uuid) { + this.uuid = uuid; + } + + public void setModelName(String modelName) { + this.modelName = modelName; + } + + public VESCommonEventHeaderPOJO mapCommonEventHeader(DOMNotification notification, Instant eventTime, + int sequenceNo) { + VESCommonEventHeaderPOJO vesCEH = new VESCommonEventHeaderPOJO(); + vesCEH.setDomain(VES_EVENT_DOMAIN); + vesCEH.setEventName(VES_EVENT_DOMAIN + "_" + VES_EVENTTYPE); + vesCEH.setEventType(VES_EVENTTYPE); + vesCEH.setPriority(VES_EVENT_PRIORITY); + + String eventId = notifName + "-" + Long.toUnsignedString(sequenceNo); + + vesCEH.setEventId(eventId); + vesCEH.setStartEpochMicrosec(eventTime.toEpochMilli() * 1000); + vesCEH.setLastEpochMicrosec(eventTime.toEpochMilli() * 1000); + vesCEH.setNfVendorName(mfgName); + vesCEH.setReportingEntityName(vesProvider.getConfig().getReportingEntityName()); + vesCEH.setSequence(sequenceNo); + vesCEH.setSourceId(uuid); + vesCEH.setSourceName(nodeIdString); + + return vesCEH; + } + + public VESStndDefinedFieldsPOJO mapStndDefinedFields(Instant eventTimeInstant) { + VESStndDefinedFieldsPOJO vesStndDefFields = new VESStndDefinedFieldsPOJO(); + vesStndDefFields.setSchemaReference(O_RU_SUPERVISION_SCHEMA_REFERENCE); + vesStndDefFields.setData(getSupervisionData(eventTimeInstant)); + + return vesStndDefFields; + } + + private DataObject getSupervisionData(Instant eventTimeInstant) { + ORanSupervisionNotification oruSuperNotif = new ORanSupervisionNotification(); + oruSuperNotif.setSessionId(999999); // Hardcoded due to limitation in NTS Simulator. Ideally should be NETCONF Session ID + + IetfNotification ietfNotif = new IetfNotification(); + ietfNotif.setOranSupervisionNotif(oruSuperNotif); + ietfNotif.setEventTime(ORanDOMToInternalDataModel.getDateAndTimeOfInstant(eventTimeInstant).getValue()); + + DataObject data = new DataObject(); + data.setIetfNotification(ietfNotif); + return data; + } + +} + +/* Classes for serialization of stndDefinedFields "data" object */ +class DataObject { + @JsonProperty("ietf:notification") + IetfNotification ietfNotification; + + public DataObject() {} + + public IetfNotification getIetfNotification() { + return ietfNotification; + } + + public void setIetfNotification(IetfNotification ietfNotification) { + this.ietfNotification = ietfNotification; + } +} + + +class IetfNotification { + String eventTime; + @JsonProperty("o-ran-supervision:supervision-notification") + ORanSupervisionNotification oranSupervisionNotif; + + public IetfNotification() {} + + public String getEventTime() { + return eventTime; + } + + public void setEventTime(String eventTime) { + this.eventTime = eventTime; + } + + public ORanSupervisionNotification getOranSupervisionNotif() { + return oranSupervisionNotif; + } + + public void setOranSupervisionNotif(ORanSupervisionNotification oranSupervisionNotif) { + this.oranSupervisionNotif = oranSupervisionNotif; + } + +} + + +class ORanSupervisionNotification { + @JsonProperty("session-id") + int sessionId; + + public ORanSupervisionNotification() {} + + public int getSessionId() { + return sessionId; + } + + public void setSessionId(int sessionId) { + this.sessionId = sessionId; + } +} diff --git a/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/vesmapper/ORanRegistrationToVESpnfRegistrationMapper.java b/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/vesmapper/ORanRegistrationToVESpnfRegistrationMapper.java new file mode 100644 index 000000000..9cbb45d55 --- /dev/null +++ b/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/vesmapper/ORanRegistrationToVESpnfRegistrationMapper.java @@ -0,0 +1,115 @@ +/* + * ============LICENSE_START======================================================= + * ONAP : ccsdk features + * ================================================================================ + * Copyright (C) 2021 highstreet technologies GmbH Intellectual Property. + * All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + * + */ +package org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.vesmapper; + +import java.time.Instant; + +import org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.util.ORanDMDOMUtility; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.util.ORanDeviceManagerQNames; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.VESCollectorService; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.types.VESCommonEventHeaderPOJO; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.types.VESPNFRegistrationFieldsPOJO; +import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfAccessor; +import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class ORanRegistrationToVESpnfRegistrationMapper { + + @SuppressWarnings("unused") + private static final Logger LOG = LoggerFactory.getLogger(ORanRegistrationToVESpnfRegistrationMapper.class); + //CommonEventHeader fields + private static final String VES_EVENT_DOMAIN = "pnfRegistration"; + private static final String VES_EVENTTYPE = "NetConf Callhome Registration"; + private static final String VES_EVENT_PRIORITY = "Normal"; + + private final VESCollectorService vesProvider; + private final NetconfAccessor netconfAccessor; + + private Integer sequenceNo; + + + public ORanRegistrationToVESpnfRegistrationMapper(NetconfAccessor netconfAccessor, + VESCollectorService vesCollectorService) { + this.netconfAccessor = netconfAccessor; + this.vesProvider = vesCollectorService; + + this.sequenceNo = 0; + } + + public VESCommonEventHeaderPOJO mapCommonEventHeader(MapEntryNode component) { + VESCommonEventHeaderPOJO vesCEH = new VESCommonEventHeaderPOJO(); + vesCEH.setDomain(VES_EVENT_DOMAIN); + vesCEH.setEventId(netconfAccessor.getNodeId().getValue()); + vesCEH.setEventName(netconfAccessor.getNodeId().getValue()); + vesCEH.setEventType(VES_EVENTTYPE); + vesCEH.setPriority(VES_EVENT_PRIORITY); + + vesCEH.setStartEpochMicrosec(Instant.now().toEpochMilli() * 1000); + vesCEH.setLastEpochMicrosec(Instant.now().toEpochMilli() * 1000); + vesCEH.setNfVendorName( + ORanDMDOMUtility.getLeafValue(component, ORanDeviceManagerQNames.IETF_HW_COMPONENT_LIST_MFG_NAME)); + vesCEH.setReportingEntityName(vesProvider.getConfig().getReportingEntityName()); + vesCEH.setSequence(sequenceNo++); + vesCEH.setSourceId( + ORanDMDOMUtility.getLeafValue(component, ORanDeviceManagerQNames.IETF_HW_COMPONENT_LIST_UUID) != null + ? ORanDMDOMUtility.getLeafValue(component, ORanDeviceManagerQNames.IETF_HW_COMPONENT_LIST_UUID) + : netconfAccessor.getNodeId().getValue()); + vesCEH.setSourceName(netconfAccessor.getNodeId().getValue()); + + return vesCEH; + } + + public VESPNFRegistrationFieldsPOJO mapPNFRegistrationFields(MapEntryNode component) { + VESPNFRegistrationFieldsPOJO vesPnfFields = new VESPNFRegistrationFieldsPOJO(); + vesPnfFields.setModelNumber( + ORanDMDOMUtility.getLeafValue(component, ORanDeviceManagerQNames.IETF_HW_COMPONENT_LIST_MFG_NAME)); + vesPnfFields + .setOamV4IpAddress(netconfAccessor.getNetconfNode().getHost().getIpAddress().getIpv4Address() != null + ? netconfAccessor.getNetconfNode().getHost().getIpAddress().getIpv4Address().getValue() + : null); + vesPnfFields + .setOamV6IpAddress(netconfAccessor.getNetconfNode().getHost().getIpAddress().getIpv6Address() != null + ? netconfAccessor.getNetconfNode().getHost().getIpAddress().getIpv6Address().getValue() + : null); + vesPnfFields.setSerialNumber( + ORanDMDOMUtility.getLeafValue(component, ORanDeviceManagerQNames.IETF_HW_COMPONENT_LIST_SER_NUM)); + vesPnfFields.setVendorName( + ORanDMDOMUtility.getLeafValue(component, ORanDeviceManagerQNames.IETF_HW_COMPONENT_LIST_MFG_NAME)); + vesPnfFields.setSoftwareVersion( + ORanDMDOMUtility.getLeafValue(component, ORanDeviceManagerQNames.IETF_HW_COMPONENT_LIST_SW_REV)); + vesPnfFields.setUnitType( + ORanDMDOMUtility.getLeafValue(component, ORanDeviceManagerQNames.IETF_HW_COMPONENT_LIST_ALIAS)); + vesPnfFields.setUnitFamily( + ORanDMDOMUtility.getLeafValue(component, ORanDeviceManagerQNames.IETF_HW_COMPONENT_LIST_CLASS)); + vesPnfFields + .setManufactureDate( + ORanDMDOMUtility.getLeafValue(component, + ORanDeviceManagerQNames.IETF_HW_COMPONENT_LIST_MFG_DATE) != null + ? ORanDMDOMUtility.getLeafValue(component, + ORanDeviceManagerQNames.IETF_HW_COMPONENT_LIST_MFG_DATE) + : "Unknown"); + //vesPnfFields.setLastServiceDate(component.getLastChange()); + + return vesPnfFields; + } +} diff --git a/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/yangspecs/ORANFM.java b/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/yangspecs/ORANFM.java new file mode 100644 index 000000000..5be18e75b --- /dev/null +++ b/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/yangspecs/ORANFM.java @@ -0,0 +1,113 @@ +/* + * ============LICENSE_START======================================================= + * ONAP : ccsdk features + * ================================================================================ + * Copyright (C) 2023 highstreet technologies GmbH Intellectual Property. + * All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + * + */ +package org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.yangspecs; + +import java.util.Arrays; +import java.util.List; +import java.util.Optional; +import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.Capabilities; +import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfDomAccessor; +import org.opendaylight.yangtools.yang.common.QName; +import org.opendaylight.yangtools.yang.common.QNameModule; +import org.opendaylight.yangtools.yang.common.Revision; +import org.opendaylight.yangtools.yang.common.XMLNamespace; + +public class ORANFM extends YangModule { + + public static final String NAMESPACE = "urn:o-ran:fm:1.0"; + public static final QNameModule ORANFM_2019_02_04 = + QNameModule.create(XMLNamespace.of(NAMESPACE), Revision.of("2019-02-04")); + public static final QNameModule ORANFM_2022_08_15 = + QNameModule.create(XMLNamespace.of(NAMESPACE), Revision.of("2022-08-15")); + private static final List MODULES = Arrays.asList(ORANFM_2019_02_04, ORANFM_2022_08_15); +// private final QName ORAN_FM_ALARM_NOTIF; +// private final QName ORAN_FM_FAULT_ID; +// private final QName ORAN_FM_FAULT_SOURCE; +// private final QName ORAN_FM_FAULT_SEVERITY; +// private final QName ORAN_FM_FAULT_TEXT; +// private final QName ORAN_FM_FAULT_IS_CLEARED; + + + + ORANFM(NetconfDomAccessor netconfDomAccessor, QNameModule module) { + super(netconfDomAccessor, module); +// ORAN_FM_ALARM_NOTIF = QName.create(module, "alarm-notif"); +// ORAN_FM_FAULT_ID = QName.create(module, "fault-id"); +// ORAN_FM_FAULT_SOURCE = QName.create(module, "fault-source"); +// ORAN_FM_FAULT_SEVERITY = QName.create(module, "fault-severity"); +// ORAN_FM_FAULT_TEXT = QName.create(module, "fault-text"); +// ORAN_FM_FAULT_IS_CLEARED = QName.create(module, "is-cleared"); + } + + public QName getFaultSourceQName() { + return getQName("fault-source"); + } + + public QName getFaultIdQName() { + return getQName("fault-id"); + } + + public QName getFaultSeverityQName() { + return getQName("fault-severity"); + } + + public QName getFaultTextQName() { + return getQName("fault-text"); + } + + public QName getAlarmNotifQName() { + return getQName("alarm-notif"); + } + + public QName getFaultIsClearedQName() { + return getQName("is-cleared"); + } + + public QName getFaultEventTimeQName() { + return getQName("event-time"); + } + + public QName getFaultActiveAlarmListQName() { + return getQName("active-alarm-list"); + } + + public QName getFaultActiveAlarmsQName() { + return getQName("active-alarms"); + } + + /** + * Get specific instance, depending on capabilities + * + * @param capabilities + * @return + */ + public static Optional getModule(NetconfDomAccessor netconfDomAccessor) { + Capabilities capabilities = netconfDomAccessor.getCapabilites(); + for (QNameModule module : MODULES) { + if (capabilities.isSupportingNamespaceAndRevision(module)) { + return Optional.of(new ORANFM(netconfDomAccessor, module)); + } + } + return Optional.empty(); + } + +} diff --git a/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/yangspecs/OnapSystem.java b/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/yangspecs/OnapSystem.java new file mode 100644 index 000000000..03ed89111 --- /dev/null +++ b/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/yangspecs/OnapSystem.java @@ -0,0 +1,127 @@ +/* + * ============LICENSE_START======================================================= + * ONAP : ccsdk features + * ================================================================================ + * Copyright (C) 2023 highstreet technologies GmbH Intellectual Property. + * All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + * + */ +package org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.yangspecs; + +import com.google.common.collect.Sets; +import java.util.Arrays; +import java.util.List; +import java.util.Optional; +import org.eclipse.jdt.annotation.NonNull; +import org.eclipse.jdt.annotation.Nullable; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.util.ORanDeviceManagerQNames; +import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.Capabilities; +import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfDomAccessor; +import org.opendaylight.mdsal.common.api.LogicalDatastoreType; +import org.opendaylight.yangtools.yang.common.QName; +import org.opendaylight.yangtools.yang.common.QNameModule; +import org.opendaylight.yangtools.yang.common.Revision; +import org.opendaylight.yangtools.yang.common.XMLNamespace; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.AugmentationIdentifier; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.InstanceIdentifierBuilder; +import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + + + +public class OnapSystem extends YangModule { + + private static final Logger LOG = LoggerFactory.getLogger(OnapSystem.class); + public static final String NAMESPACE = "urn:onap:system"; + public static final QNameModule ONAPSYSTEM_2020_10_26 = + QNameModule.create(XMLNamespace.of(NAMESPACE), Revision.of("2020-10-26")); + public static final QNameModule ONAPSYSTEM_2022_11_04 = + QNameModule.create(XMLNamespace.of(NAMESPACE), Revision.of("2022-11-04")); + private static final List MODULES = Arrays.asList(ONAPSYSTEM_2020_10_26, ONAPSYSTEM_2022_11_04); + + private final QName NAME; + private final QName WEB_UI; + private final QName GEOGRAPHICAL_LOCATION; + + OnapSystem(NetconfDomAccessor netconfDomAccessor, QNameModule module) { + super(netconfDomAccessor, module); + + NAME = QName.create(module, "name"); + WEB_UI = QName.create(module, "web-ui"); + GEOGRAPHICAL_LOCATION = QName.create(module, "geographical-location"); + } + + public QName getName() { + return NAME; + } + + public QName getWebUi() { + return WEB_UI; + } + + public QName getGeoLocation() { + return GEOGRAPHICAL_LOCATION; + } + + // Read from device + /** + * Read system data with GUI cut through information from device if ONAP_SYSTEM YANG is supported. + * + * @return NormalizedNode data with GUI cut through information or null if not available. + */ + public @Nullable NormalizedNode getOnapSystemData() { + LOG.debug("Get System1 for mountpoint {}", netconfDomAccessor.getNodeId().getValue()); + @NonNull + InstanceIdentifierBuilder ietfSystemIID = + YangInstanceIdentifier.builder().node(ORanDeviceManagerQNames.IETF_SYSTEM_CONTAINER); + @NonNull + AugmentationIdentifier onapSystemIID = null; + if (netconfDomAccessor.getCapabilites().isSupportingNamespaceAndRevision(ONAPSYSTEM_2020_10_26)) + onapSystemIID = YangInstanceIdentifier.AugmentationIdentifier.create(Sets.newHashSet(NAME, WEB_UI)); + else if (netconfDomAccessor.getCapabilites().isSupportingNamespaceAndRevision(ONAPSYSTEM_2022_11_04)) + onapSystemIID = YangInstanceIdentifier.AugmentationIdentifier + .create(Sets.newHashSet(NAME, WEB_UI, GEOGRAPHICAL_LOCATION)); + + InstanceIdentifierBuilder augmentedOnapSystem = + YangInstanceIdentifier.builder(ietfSystemIID.build()).node(onapSystemIID); + + Optional res = + netconfDomAccessor.readDataNode(LogicalDatastoreType.OPERATIONAL, augmentedOnapSystem.build()); + LOG.debug("Result of System1 = {}", res); + return res.isPresent() ? res.get() : null; + + } + + /** + * Get specific instance, depending on capabilities + * + * @param capabilities + * @return + */ + public static Optional getModule(NetconfDomAccessor netconfDomAccessor) { + Capabilities capabilities = netconfDomAccessor.getCapabilites(); + for (QNameModule module : MODULES) { + if (capabilities.isSupportingNamespaceAndRevision(module)) { + return Optional.of(new OnapSystem(netconfDomAccessor, module)); + } + } + return Optional.empty(); + } + + +} diff --git a/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/yangspecs/YangModule.java b/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/yangspecs/YangModule.java new file mode 100644 index 000000000..31010ab1d --- /dev/null +++ b/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/yangspecs/YangModule.java @@ -0,0 +1,51 @@ +/* + * ============LICENSE_START======================================================= + * ONAP : ccsdk features + * ================================================================================ + * Copyright (C) 2023 highstreet technologies GmbH Intellectual Property. + * All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + * + */ +package org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.yangspecs; + +import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfDomAccessor; +import org.opendaylight.yangtools.yang.common.QName; +import org.opendaylight.yangtools.yang.common.QNameModule; + +public class YangModule { + + protected final NetconfDomAccessor netconfDomAccessor; + protected final QNameModule module; + + YangModule(NetconfDomAccessor netconfDomAccessor, QNameModule module) { + super(); + this.netconfDomAccessor = netconfDomAccessor; + this.module = module; + } + + NetconfDomAccessor getNetconfDomAccessor() { + return netconfDomAccessor; + } + + public QNameModule getQNameModule() { + return module; + } + + public QName getQName(String localName) { + return QName.create(module, localName); + } + +} diff --git a/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/dom/TestORanDOMFaultNotificationListener.java b/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/dom/TestORanDOMFaultNotificationListener.java index 89ff6dc90..de19bf1a2 100644 --- a/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/dom/TestORanDOMFaultNotificationListener.java +++ b/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/dom/TestORanDOMFaultNotificationListener.java @@ -22,6 +22,7 @@ package org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.impl.dom; import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import com.google.common.io.Files; @@ -29,6 +30,7 @@ import java.io.File; import java.io.IOException; import java.nio.charset.StandardCharsets; import java.time.Instant; +import java.util.Optional; import org.junit.After; import org.junit.Before; import org.junit.Test; @@ -37,17 +39,22 @@ import org.mockito.Mock; import org.mockito.junit.MockitoJUnitRunner; import org.onap.ccsdk.features.sdnr.wt.common.configuration.ConfigurationFileRepresentation; import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.DataProvider; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.notification.ORanDOMFaultNotificationListener; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.yangspecs.ORANFM; import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.DeviceManagerServiceProvider; import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.FaultService; import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.VESCollectorService; import org.onap.ccsdk.features.sdnr.wt.devicemanager.vescollectorconnector.impl.VESCollectorServiceImpl; +import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.Capabilities; import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfDomAccessor; import org.onap.ccsdk.features.sdnr.wt.websocketmanager.model.WebsocketManagerService; import org.opendaylight.mdsal.dom.api.DOMEvent; import org.opendaylight.mdsal.dom.api.DOMNotification; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.FaultlogEntity; import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId; -import org.opendaylight.yangtools.yang.common.QName; +import org.opendaylight.yangtools.yang.common.QNameModule; +import org.opendaylight.yangtools.yang.common.Revision; +import org.opendaylight.yangtools.yang.common.XMLNamespace; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier; import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode; import org.opendaylight.yangtools.yang.data.impl.schema.Builders; @@ -89,6 +96,8 @@ public class TestORanDOMFaultNotificationListener { @Mock DataProvider databaseService; VESCollectorService vesCollectorService; + static Optional oranfm; + private Capabilities capabilities; @After @Before @@ -98,6 +107,11 @@ public class TestORanDOMFaultNotificationListener { LOG.info("Remove {}", f.getAbsolutePath()); f.delete(); } + capabilities = mock(Capabilities.class); + when(domAccessor.getCapabilites()).thenReturn(capabilities); + when(capabilities.isSupportingNamespaceAndRevision( + QNameModule.create(XMLNamespace.of(ORANFM.NAMESPACE), Revision.of("2022-08-15")))).thenReturn(true); + oranfm = ORANFM.getModule(domAccessor); } @Test @@ -105,7 +119,7 @@ public class TestORanDOMFaultNotificationListener { Files.asCharSink(new File(TESTFILENAME), StandardCharsets.UTF_8).write(TESTCONFIG_CONTENT); vesCollectorService = new VESCollectorServiceImpl(new ConfigurationFileRepresentation(TESTFILENAME)); when(domAccessor.getNodeId()).thenReturn(new NodeId("nSky")); - ORanDOMFaultNotificationListener faultListener = new ORanDOMFaultNotificationListener(domAccessor, + ORanDOMFaultNotificationListener faultListener = new ORanDOMFaultNotificationListener(domAccessor, oranfm, vesCollectorService, faultService, websocketManagerService, databaseService); NetconfDeviceNotification ndn = new NetconfDeviceNotification(createORANDOMFault(), Instant.now()); faultListener.onNotification(ndn); @@ -114,20 +128,14 @@ public class TestORanDOMFaultNotificationListener { } public static ContainerNode createORANDOMFault() { - final QName fault_id = QName.create(ORanDeviceManagerQNames.ORAN_FM_ALARM_NOTIF, "fault-id"); - final QName fault_source = QName.create(ORanDeviceManagerQNames.ORAN_FM_ALARM_NOTIF, "fault-source"); - final QName fault_severity = QName.create(ORanDeviceManagerQNames.ORAN_FM_ALARM_NOTIF, "fault-severity"); - final QName is_cleared = QName.create(ORanDeviceManagerQNames.ORAN_FM_ALARM_NOTIF, "is-cleared"); - final QName fault_text = QName.create(ORanDeviceManagerQNames.ORAN_FM_ALARM_NOTIF, "fault-text"); - return Builders.containerBuilder().withNodeIdentifier(NodeIdentifier.create(ORanDeviceManagerQNames.ORAN_FM_ALARM_NOTIF)) - .withChild(ImmutableNodes.leafNode(fault_id, "47")) - .withChild(ImmutableNodes.leafNode(fault_source, "Slot-2-Port-B")) - .withChild(ImmutableNodes.leafNode(fault_severity, "MAJOR")) - .withChild(ImmutableNodes.leafNode(is_cleared, "true")) - .withChild(ImmutableNodes.leafNode(fault_text, "CPRI Port Down")).build(); + return Builders.containerBuilder().withNodeIdentifier(NodeIdentifier.create(oranfm.get().getAlarmNotifQName())) + .withChild(ImmutableNodes.leafNode(oranfm.get().getFaultIdQName(), "47")) + .withChild(ImmutableNodes.leafNode(oranfm.get().getFaultSourceQName(), "Slot-2-Port-B")) + .withChild(ImmutableNodes.leafNode(oranfm.get().getFaultSeverityQName(), "MAJOR")) + .withChild(ImmutableNodes.leafNode(oranfm.get().getFaultIsClearedQName(), "true")) + .withChild(ImmutableNodes.leafNode(oranfm.get().getFaultTextQName(), "CPRI Port Down")).build(); } - public static class NetconfDeviceNotification implements DOMNotification, DOMEvent { private final ContainerNode content; private final Absolute schemaPath; diff --git a/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/dom/TestORanDOMNetworkElement.java b/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/dom/TestORanDOMNetworkElement.java index 283d122b0..7fd947211 100644 --- a/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/dom/TestORanDOMNetworkElement.java +++ b/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/dom/TestORanDOMNetworkElement.java @@ -21,17 +21,25 @@ */ package org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.impl.dom; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; +import com.google.common.io.Files; +import java.io.File; import java.io.IOException; +import java.nio.charset.StandardCharsets; import java.util.Optional; import org.eclipse.jdt.annotation.NonNull; import org.junit.BeforeClass; import org.junit.Test; +import org.onap.ccsdk.features.sdnr.wt.common.configuration.ConfigurationFileRepresentation; import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.DataProvider; import org.onap.ccsdk.features.sdnr.wt.devicemanager.ne.service.NetworkElement; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.config.ORanDMConfig; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.util.ORanDeviceManagerQNames; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.yangspecs.ORANFM; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.yangspecs.OnapSystem; import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.DeviceManagerServiceProvider; import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.FaultService; import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.NotificationProxyParser; @@ -43,12 +51,15 @@ import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfDomAccesso import org.onap.ccsdk.features.sdnr.wt.websocketmanager.model.WebsocketManagerService; import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId; import org.opendaylight.yangtools.yang.common.QName; +import org.opendaylight.yangtools.yang.common.QNameModule; +import org.opendaylight.yangtools.yang.common.Revision; +import org.opendaylight.yangtools.yang.common.XMLNamespace; public class TestORanDOMNetworkElement { private static final QName OneCell = QName.create("urn:onf:otcc:wireless:yang:radio-access:commscope-onecell", "2020-06-22", "onecell").intern(); - private static final @NonNull QName OnapSystem = + private static final @NonNull QName OnapSystem1 = QName.create("urn:onap:system", "2020-10-26", "onap-system").intern(); private static String NODEIDSTRING = "nSky"; private static NodeId nodeId = new NodeId(NODEIDSTRING); @@ -61,6 +72,16 @@ public class TestORanDOMNetworkElement { private static NotificationProxyParser notificationProxyParser; private static VESCollectorCfgService vesCfgService; private static WebsocketManagerService websocketManagerService; + private static ORanDMConfig oranDmConfig; + private static ConfigurationFileRepresentation oranCfg; + + private static String fileName = "test1.properties"; + // @formatter:off + private static final String TESTCONFIG_CONTENT = "[ORAN-SUPERVISION]\n" + + "supervision-notification-interval=60\n" + + "guard-timer-overhead=10\n" + + ""; + // @formatter:on @BeforeClass public static void init() throws InterruptedException, IOException { @@ -72,6 +93,7 @@ public class TestORanDOMNetworkElement { notificationProxyParser = mock(NotificationProxyParser.class); vesCfgService = mock(VESCollectorCfgService.class); websocketManagerService = mock(WebsocketManagerService.class); + oranDmConfig = mock(ORanDMConfig.class); when(accessor.getCapabilites()).thenReturn(capabilities); when(accessor.getNodeId()).thenReturn(nodeId); @@ -79,6 +101,10 @@ public class TestORanDOMNetworkElement { when(domAccessor.getNodeId()).thenReturn(nodeId); when(domAccessor.getCapabilites()).thenReturn(capabilities); when(vesCollectorService.getNotificationProxyParser()).thenReturn(notificationProxyParser); + when(capabilities.isSupportingNamespaceAndRevision( + QNameModule.create(XMLNamespace.of(ORANFM.NAMESPACE), Revision.of("2022-08-15")))).thenReturn(true); + when(capabilities.isSupportingNamespaceAndRevision( + QNameModule.create(XMLNamespace.of(OnapSystem.NAMESPACE), Revision.of("2022-11-04")))).thenReturn(true); DataProvider dataProvider = mock(DataProvider.class); FaultService faultService = mock(FaultService.class); @@ -89,6 +115,8 @@ public class TestORanDOMNetworkElement { when(vesCollectorService.getConfig()).thenReturn(vesCfgService); when(vesCfgService.isVESCollectorEnabled()).thenReturn(true); + Files.asCharSink(new File(fileName), StandardCharsets.UTF_8).write(TESTCONFIG_CONTENT); + oranCfg = new ConfigurationFileRepresentation(fileName); } @Test @@ -96,9 +124,9 @@ public class TestORanDOMNetworkElement { Optional oRanNe; when(capabilities.isSupportingNamespace(ORanDeviceManagerQNames.ORAN_HW_COMPONENT)).thenReturn(true); when(capabilities.isSupportingNamespace(OneCell)).thenReturn(false); - when(capabilities.isSupportingNamespace(OnapSystem)).thenReturn(false); + when(capabilities.isSupportingNamespace(OnapSystem1)).thenReturn(false); - ORanNetworkElementFactory factory = new ORanNetworkElementFactory(); + ORanNetworkElementFactory factory = new ORanNetworkElementFactory(oranCfg, oranDmConfig); oRanNe = factory.create(accessor, serviceProvider); assertTrue(factory.create(accessor, serviceProvider).isPresent()); oRanNe.get().register(); diff --git a/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/dom/TestORanDOMNotification.java b/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/dom/TestORanDOMNotification.java index 1665ac1ad..96983b1ba 100644 --- a/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/dom/TestORanDOMNotification.java +++ b/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/dom/TestORanDOMNotification.java @@ -29,6 +29,8 @@ import java.time.Instant; import org.junit.BeforeClass; import org.junit.Test; import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.DataProvider; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.notification.ORanDOMChangeNotificationListener; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.util.ORanDeviceManagerQNames; import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.VESCollectorCfgService; import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.VESCollectorService; import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfDomAccessor; @@ -141,7 +143,6 @@ public class TestORanDOMNotification { @Test public void test() { ContainerNode cn = createDOMNotificationBody(); - System.out.println(cn.toString()); NetconfDeviceNotification ndn = new NetconfDeviceNotification(cn, Instant.now()); ORanDOMChangeNotificationListener changeListener = new ORanDOMChangeNotificationListener(domAccessor, vesCollectorService, databaseService); changeListener.onNotification(ndn); diff --git a/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/dom/TestORanDOMToInternalDataModel.java b/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/dom/TestORanDOMToInternalDataModel.java index 5ce758210..01502e49c 100644 --- a/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/dom/TestORanDOMToInternalDataModel.java +++ b/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/dom/TestORanDOMToInternalDataModel.java @@ -22,6 +22,8 @@ package org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.impl.dom; import static org.junit.Assert.assertEquals; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; import com.google.common.collect.Sets; import java.io.IOException; import java.io.InputStream; @@ -33,9 +35,13 @@ import javax.xml.stream.XMLStreamException; import javax.xml.stream.XMLStreamReader; import org.junit.AfterClass; import org.junit.BeforeClass; -import org.junit.Ignore; import org.junit.Test; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.dataprovider.ORanDOMToInternalDataModel; import org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.impl.dom.util.TestYangParserUtil; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.yangspecs.ORANFM; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.yangspecs.OnapSystem; +import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.Capabilities; +import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfDomAccessor; import org.opendaylight.mdsal.dom.api.DOMEvent; import org.opendaylight.mdsal.dom.api.DOMNotification; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.FaultlogEntity; @@ -48,10 +54,12 @@ import org.opendaylight.yangtools.yang.common.QNameModule; import org.opendaylight.yangtools.yang.common.Revision; import org.opendaylight.yangtools.yang.common.XMLNamespace; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.AugmentationIdentifier; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier; +import org.opendaylight.yangtools.yang.data.api.schema.AugmentationNode; import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode; import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; +import org.opendaylight.yangtools.yang.data.api.schema.UnkeyedListEntryNode; +import org.opendaylight.yangtools.yang.data.api.schema.UnkeyedListNode; import org.opendaylight.yangtools.yang.data.api.schema.stream.NormalizedNodeStreamWriter; import org.opendaylight.yangtools.yang.data.codec.xml.XmlParserStream; import org.opendaylight.yangtools.yang.data.impl.schema.Builders; @@ -73,9 +81,18 @@ public class TestORanDOMToInternalDataModel { QNameModule.create(XMLNamespace.of("urn:ietf:params:xml:ns:yang:ietf-system"), Revision.of("2014-08-06")); private static final QName IETF_CONTAINER = QName.create(IETF_SYSTEM_MODULE, "system"); + private static final QNameModule ORAN_MODULE = + QNameModule.create(XMLNamespace.of("urn:o-ran:fm:1.0"), Revision.of("2022-08-15")); + private static final QName ORAN_ACTIVE_ALARM_CONTAINER = QName.create(ORAN_MODULE, "active-alarm-list"); + private static EffectiveModelContext schemaContext; private static Inference hwContainerSchema; private static Inference systemSchema; + private static Inference activeAlarmSchema; + private static Capabilities capabilities; + private static Optional onapSystem; + private static Optional oranfm; + private static NetconfDomAccessor domAccessor; private static final NodeId nodeId = new NodeId("nSky"); @@ -84,6 +101,18 @@ public class TestORanDOMToInternalDataModel { schemaContext = TestYangParserUtil.parseYangResourceDirectory("/"); hwContainerSchema = Inference.ofDataTreePath(schemaContext, HW_CONTAINER); systemSchema = Inference.ofDataTreePath(schemaContext, IETF_CONTAINER); + activeAlarmSchema = Inference.ofDataTreePath(schemaContext, ORAN_ACTIVE_ALARM_CONTAINER); + + capabilities = mock(Capabilities.class); + domAccessor = mock(NetconfDomAccessor.class); + when(domAccessor.getCapabilites()).thenReturn(capabilities); + when(capabilities.isSupportingNamespaceAndRevision( + QNameModule.create(XMLNamespace.of(OnapSystem.NAMESPACE), Revision.of("2022-11-04")))).thenReturn(true); + onapSystem = OnapSystem.getModule(domAccessor); + when(capabilities.isSupportingNamespaceAndRevision( + QNameModule.create(XMLNamespace.of(ORANFM.NAMESPACE), Revision.of("2022-08-15")))).thenReturn(true); + oranfm = ORANFM.getModule(domAccessor); + } @AfterClass @@ -91,12 +120,14 @@ public class TestORanDOMToInternalDataModel { schemaContext = null; hwContainerSchema = null; systemSchema = null; + activeAlarmSchema = null; } @Test public void testIetfHardwareFromXML() throws XMLStreamException, URISyntaxException, IOException, SAXException { - final InputStream resourceAsStream = TestORanDOMToInternalDataModel.class.getResourceAsStream("/ietf-hardware.xml"); + final InputStream resourceAsStream = + TestORanDOMToInternalDataModel.class.getResourceAsStream("/ietf-hardware.xml"); /* * final XMLInputFactory factory = XMLInputFactory.newInstance(); @@ -121,11 +152,11 @@ public class TestORanDOMToInternalDataModel { inventoryList.stream().filter(inventory -> inventory.getTreeLevel() == null).count()); } - @Ignore //TODO @Test public void testIetfSystemFromXML() throws XMLStreamException, URISyntaxException, IOException, SAXException { - final InputStream resourceAsStream = TestORanDOMToInternalDataModel.class.getResourceAsStream("/onap-system.xml"); + final InputStream resourceAsStream = + TestORanDOMToInternalDataModel.class.getResourceAsStream("/onap-system.xml"); final XMLStreamReader reader = UntrustedXML.createXMLStreamReader(resourceAsStream); @@ -140,9 +171,10 @@ public class TestORanDOMToInternalDataModel { NormalizedNode transformedInput = result.getResult(); ContainerNode cn = (ContainerNode) transformedInput; - AugmentationIdentifier onapSystemIID = YangInstanceIdentifier.AugmentationIdentifier.create( - Sets.newHashSet(ORanDeviceManagerQNames.ONAP_SYSTEM_NAME, ORanDeviceManagerQNames.ONAP_SYSTEM_WEB_UI)); - Optional gc = ORanDOMToInternalDataModel.getGuicutthrough(cn.getChildByArg(onapSystemIID)); + AugmentationNode gcData = (AugmentationNode) cn.childByArg( + YangInstanceIdentifier.AugmentationIdentifier.create(Sets.newHashSet(onapSystem.get().getName(), + onapSystem.get().getWebUi(), onapSystem.get().getGeoLocation()))); + Optional gc = ORanDOMToInternalDataModel.getGuicutthrough(gcData, onapSystem.get()); assertEquals(gc.isPresent(), true); } @@ -151,23 +183,40 @@ public class TestORanDOMToInternalDataModel { public void testORANFault() { ContainerNode cn = createORANDOMFault(); NetconfDeviceNotification faultNotif = new NetconfDeviceNotification(cn, Instant.now()); - FaultlogEntity fle = ORanDOMToInternalDataModel.getFaultLog(faultNotif, nodeId, 1); + FaultlogEntity fle = ORanDOMToInternalDataModel.getFaultLog(faultNotif, oranfm.get(), nodeId, 1); assertEquals(fle.getId(), "47"); } + @Test + public void testORANActiveAlarms() throws XMLStreamException, URISyntaxException, IOException, SAXException { + final InputStream resourceAsStream = + TestORanDOMToInternalDataModel.class.getResourceAsStream("/oran-fm-active-alarm.xml"); + + final XMLStreamReader reader = UntrustedXML.createXMLStreamReader(resourceAsStream); + final NormalizedNodeResult result = new NormalizedNodeResult(); + final NormalizedNodeStreamWriter streamWriter = ImmutableNormalizedNodeStreamWriter.from(result); + + final XmlParserStream xmlParser = XmlParserStream.create(streamWriter, activeAlarmSchema); + xmlParser.parse(reader); + + xmlParser.flush(); + xmlParser.close(); + NormalizedNode transformedInput = result.getResult(); + ContainerNode cn = (ContainerNode) transformedInput; + + UnkeyedListNode activeAlarmsList = + (UnkeyedListNode) cn.childByArg(new NodeIdentifier(oranfm.get().getFaultActiveAlarmsQName())); + for (UnkeyedListEntryNode activeAlarmEntry : activeAlarmsList.body()) + ORanDOMToInternalDataModel.getFaultLog(activeAlarmEntry, oranfm.get(), new NodeId("nSky"), Integer.valueOf(0)); + } + public static ContainerNode createORANDOMFault() { - final QName fault_id = QName.create(ORanDeviceManagerQNames.ORAN_FM_FAULT_ID, "fault-id"); - final QName fault_source = QName.create(ORanDeviceManagerQNames.ORAN_FM_FAULT_SOURCE, "fault-source"); - final QName fault_severity = QName.create(ORanDeviceManagerQNames.ORAN_FM_FAULT_SEVERITY, "fault-severity"); - final QName is_cleared = QName.create(ORanDeviceManagerQNames.ORAN_FM_FAULT_IS_CLEARED, "is-cleared"); - final QName fault_text = QName.create(ORanDeviceManagerQNames.ORAN_FM_FAULT_TEXT, "fault-text"); - return Builders.containerBuilder() - .withNodeIdentifier(NodeIdentifier.create(ORanDeviceManagerQNames.ORAN_FM_ALARM_NOTIF)) - .withChild(ImmutableNodes.leafNode(fault_id, "47")) - .withChild(ImmutableNodes.leafNode(fault_source, "Slot-2-Port-B")) - .withChild(ImmutableNodes.leafNode(fault_severity, "MAJOR")) - .withChild(ImmutableNodes.leafNode(is_cleared, "true")) - .withChild(ImmutableNodes.leafNode(fault_text, "CPRI Port Down")).build(); + return Builders.containerBuilder().withNodeIdentifier(NodeIdentifier.create(oranfm.get().getAlarmNotifQName())) + .withChild(ImmutableNodes.leafNode(oranfm.get().getFaultIdQName(), "47")) + .withChild(ImmutableNodes.leafNode(oranfm.get().getFaultSourceQName(), "Slot-2-Port-B")) + .withChild(ImmutableNodes.leafNode(oranfm.get().getFaultSeverityQName(), "MAJOR")) + .withChild(ImmutableNodes.leafNode(oranfm.get().getFaultIsClearedQName(), "true")) + .withChild(ImmutableNodes.leafNode(oranfm.get().getFaultTextQName(), "CPRI Port Down")).build(); } public static class NetconfDeviceNotification implements DOMNotification, DOMEvent { diff --git a/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/dom/TestORanNetworkElementFactory.java b/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/dom/TestORanNetworkElementFactory.java index 2ca2ee445..cad0994cc 100644 --- a/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/dom/TestORanNetworkElementFactory.java +++ b/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/dom/TestORanNetworkElementFactory.java @@ -17,83 +17,110 @@ */ package org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.impl.dom; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertTrue; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; +import com.google.common.io.Files; +import java.io.File; import java.io.IOException; +import java.nio.charset.StandardCharsets; import java.util.Optional; import org.junit.After; import org.junit.BeforeClass; import org.junit.Test; +import org.onap.ccsdk.features.sdnr.wt.common.configuration.ConfigurationFileRepresentation; import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.DataProvider; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.config.ORanDMConfig; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.util.ORanDeviceManagerQNames; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.yangspecs.ORANFM; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.yangspecs.OnapSystem; import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.DeviceManagerServiceProvider; import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.FaultService; import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.VESCollectorService; import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.Capabilities; import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfAccessor; -import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfBindingAccessor; import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfDomAccessor; -import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.TransactionUtils; import org.onap.ccsdk.features.sdnr.wt.websocketmanager.model.WebsocketManagerService; import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId; +import org.opendaylight.yangtools.yang.common.QNameModule; +import org.opendaylight.yangtools.yang.common.Revision; +import org.opendaylight.yangtools.yang.common.XMLNamespace; public class TestORanNetworkElementFactory { private static String NODEIDSTRING = "nSky"; private static NetconfAccessor accessor; + private static NetconfDomAccessor domAccessor; private static DeviceManagerServiceProvider serviceProvider; private static Capabilities capabilities; private static VESCollectorService vesCollectorService; private static FaultService faultService; private static WebsocketManagerService notificationService; private static DataProvider databaseService; + private static ORanDMConfig oranDmConfig; + private static ConfigurationFileRepresentation oranCfg; private static NodeId nodeId = new NodeId(NODEIDSTRING); - @BeforeClass - public static void init() throws InterruptedException, IOException { - NetconfBindingAccessor bindingAccessor = mock(NetconfBindingAccessor.class); - when(bindingAccessor.getTransactionUtils()).thenReturn(mock(TransactionUtils.class)); - when(bindingAccessor.getNodeId()).thenReturn(nodeId); + private static String fileName = "test1.properties"; + // @formatter:off + private static final String TESTCONFIG_CONTENT = "[ORAN-SUPERVISION]\n" + + "supervision-notification-interval=60\n" + + "guard-timer-overhead=10\n" + + ""; + // @formatter:on - NetconfDomAccessor domAccessor = mock(NetconfDomAccessor.class); - when(domAccessor.getNodeId()).thenReturn(nodeId); - capabilities = mock(Capabilities.class); - //accessor = mock(NetconfBindingAccessor.class); + @BeforeClass + public static void init() throws InterruptedException, IOException { accessor = mock(NetconfAccessor.class); + domAccessor = mock(NetconfDomAccessor.class); + capabilities = mock(Capabilities.class); serviceProvider = mock(DeviceManagerServiceProvider.class); vesCollectorService = mock(VESCollectorService.class); faultService = mock(FaultService.class); notificationService = mock(WebsocketManagerService.class); databaseService = mock(DataProvider.class); + oranDmConfig = mock(ORanDMConfig.class); + when(domAccessor.getCapabilites()).thenReturn(capabilities); + when(domAccessor.getNodeId()).thenReturn(nodeId); when(accessor.getCapabilites()).thenReturn(capabilities); - when(accessor.getNetconfBindingAccessor()).thenReturn(Optional.of(bindingAccessor)); when(accessor.getNetconfDomAccessor()).thenReturn(Optional.of(domAccessor)); when(serviceProvider.getFaultService()).thenReturn(faultService); when(serviceProvider.getWebsocketService()).thenReturn(notificationService); when(serviceProvider.getDataProvider()).thenReturn(databaseService); when(serviceProvider.getVESCollectorService()).thenReturn(vesCollectorService); + when(capabilities.isSupportingNamespaceAndRevision( + QNameModule.create(XMLNamespace.of(ORANFM.NAMESPACE), Revision.of("2022-08-15")))).thenReturn(true); + when(capabilities.isSupportingNamespaceAndRevision( + QNameModule.create(XMLNamespace.of(OnapSystem.NAMESPACE), Revision.of("2022-11-04")))).thenReturn(true); + Files.asCharSink(new File(fileName), StandardCharsets.UTF_8).write(TESTCONFIG_CONTENT); + oranCfg = new ConfigurationFileRepresentation(fileName); } @Test public void testCreateORANHWComponent() throws Exception { - when(accessor.getCapabilites().isSupportingNamespace(ORanDeviceManagerQNames.ORAN_HW_COMPONENT)).thenReturn(true); - ORanNetworkElementFactory factory = new ORanNetworkElementFactory(); + when(domAccessor.getCapabilites().isSupportingNamespace(ORanDeviceManagerQNames.ORAN_HW_COMPONENT)).thenReturn(true); + ORanNetworkElementFactory factory = new ORanNetworkElementFactory(oranCfg, oranDmConfig); assertTrue((factory.create(accessor, serviceProvider)).isPresent()); } @Test public void testCreateNone() throws Exception { - when(accessor.getCapabilites().isSupportingNamespace(ORanDeviceManagerQNames.ORAN_HW_COMPONENT)).thenReturn(false); - ORanNetworkElementFactory factory = new ORanNetworkElementFactory(); + when(domAccessor.getCapabilites().isSupportingNamespace(ORanDeviceManagerQNames.ORAN_HW_COMPONENT)).thenReturn(false); + ORanNetworkElementFactory factory = new ORanNetworkElementFactory(oranCfg, oranDmConfig); assertTrue(!(factory.create(accessor, serviceProvider).isPresent())); } @After public void cleanUp() throws Exception { + File file = new File(fileName); + if (file.exists()) { + System.out.println("File exists, Deleting it"); + file.delete(); + } } } diff --git a/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/dom/TestORanRegistrationToVESpnfRegistration.java b/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/dom/TestORanRegistrationToVESpnfRegistration.java index b46595293..ad1fcede3 100644 --- a/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/dom/TestORanRegistrationToVESpnfRegistration.java +++ b/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/dom/TestORanRegistrationToVESpnfRegistration.java @@ -22,12 +22,13 @@ package org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.impl.dom; import static org.junit.Assert.assertEquals; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; import org.mockito.junit.MockitoJUnitRunner; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.vesmapper.ORanRegistrationToVESpnfRegistrationMapper; import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.VESCollectorCfgService; import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.VESCollectorService; import org.onap.ccsdk.features.sdnr.wt.devicemanager.types.VESCommonEventHeaderPOJO; diff --git a/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/test/resources/o-ran-fm@2022-08-15.yang b/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/test/resources/o-ran-fm@2022-08-15.yang new file mode 100644 index 000000000..2abcc1ecc --- /dev/null +++ b/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/test/resources/o-ran-fm@2022-08-15.yang @@ -0,0 +1,153 @@ +module o-ran-fm { + yang-version 1.1; + namespace "urn:o-ran:fm:1.0"; + prefix o-ran-fm; + + import ietf-yang-types { + prefix yang; + revision-date 2013-07-15; + } + + organization + "O-RAN Alliance"; + contact + "www.o-ran.org"; + description + "This module defines alarm reporting mechanism. + + Copyright 2019 the O-RAN Alliance. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the above disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the above disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the Members of the O-RAN Alliance nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission."; + + revision 2022-08-15 { + description + "version 1.0.0 + + 1) imported model from xRAN + 2) changed namespace and reference from xran to o-ran"; + reference + "ORAN-WG4.M.0-v01.00"; + } + + grouping alarm { + description + "Gropuping which can uniquely identify alarm"; + leaf fault-id { + type uint16; + mandatory true; + description + "Fault specific Id that identifies the fault."; + } + + leaf fault-source { + type string { + length "1..255"; + } + mandatory true; + description + "Represents the Object or source that is suspected to be faulty."; + } + + list affected-objects { + min-elements 1; + max-elements 100; + description + "List of affected-objects"; + leaf name { + type string { + length "1..255"; + } + mandatory true; + description + "Represents the Object or source that is suspected to be affected by this fault"; + } + } + + leaf fault-severity { + type enumeration { + enum "CRITICAL" { + description + "Critical alarm means that this device is not able to perform any further service"; + } + enum "MAJOR" { + description + "Major alarm appeared on the device"; + } + enum "MINOR" { + description + "Minor alarm appeared on the device"; + } + enum "WARNING" { + description + "Warning is being reported by the device"; + } + } + mandatory true; + description + "Fault severity defines the severity level of the fault. A notification, whose fault severity has the value 'warning', + is a special type of an alarm notification. For these alarm notifications, + the Master Agent does not expect to receive a clear alarm notification."; + } + + leaf is-cleared { + type boolean; + mandatory true; + description + "Fault state determines the type of the event. Not used if faultSeverity is WARNING."; + } + + leaf fault-text { + type string { + length "0..255"; + } + description + "Textual description of the fault."; + } + + leaf event-time { + type yang:date-and-time; + mandatory true; + description + "Timestamp to indicate the time when the fault is detected/cleared."; + } + } + + container active-alarm-list { + config false; + description + "List of currently active alarms. An alarm is removed from this table when the state transitions to clear."; + list active-alarms { + description + "List of currenty active alarms"; + uses alarm; + } + } + + notification alarm-notif { + description + "Notification sent on initial alarm creation, as well as any time the alarm changes state, including clear"; + uses alarm; + } +} \ No newline at end of file diff --git a/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/test/resources/oran-fm-active-alarm.xml b/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/test/resources/oran-fm-active-alarm.xml new file mode 100644 index 000000000..263a75856 --- /dev/null +++ b/sdnr/wt/devicemanager-o-ran-sc/o-ran/ru-fh/provider/src/test/resources/oran-fm-active-alarm.xml @@ -0,0 +1,25 @@ + + + + 10001 + false + 2021-03-18T19:51:50.4Z + + slot0-logical0 + + MAJOR + /ietf-hardware:hardware/component[name='slot0-logical0'] + cpriPortDown + + + 10002 + false + 2021-03-18T19:52:50.4Z + + slot2-logical2 + + MAJOR + /ietf-hardware:hardware/component[name='slot2-logical2'] + cpriPortDown + + diff --git a/sdnr/wt/netconfnode-state-service/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/Capabilities.java b/sdnr/wt/netconfnode-state-service/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/Capabilities.java index 7448c9fb7..08b2df6d3 100644 --- a/sdnr/wt/netconfnode-state-service/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/Capabilities.java +++ b/sdnr/wt/netconfnode-state-service/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/Capabilities.java @@ -28,12 +28,14 @@ import java.util.Date; import java.util.List; import java.util.Optional; import javax.annotation.Nullable; +import org.eclipse.jdt.annotation.NonNull; import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.device.rev221225.connection.oper.AvailableCapabilities; import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.device.rev221225.connection.oper.UnavailableCapabilities; import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.device.rev221225.connection.oper.available.capabilities.AvailableCapability; import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.device.rev221225.connection.oper.unavailable.capabilities.UnavailableCapability; import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev221225.NetconfNode; import org.opendaylight.yangtools.yang.common.QName; +import org.opendaylight.yangtools.yang.common.QNameModule; import org.opendaylight.yangtools.yang.common.Revision; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -151,6 +153,19 @@ public class Capabilities { return revision == null ? false : isSupportingNamespaceAndRevision(namespace, revision); } + /** + * check if the namespace and its revision of module are supported by the given capabilities + * + * @param module + * @return true if supporting the model AND revision
+ * false if revision not available or both not found. + */ + public boolean isSupportingNamespaceAndRevision(QNameModule module) { + String namespace = module.getNamespace().toString(); + @NonNull Optional revision = module.getRevision(); + return revision.isEmpty() ? false : isSupportingNamespaceAndRevision(namespace, revision.get().toString()); + } + /** * Provide namespace and its revision as String. * diff --git a/sdnr/wt/netconfnode-state-service/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/DomContext.java b/sdnr/wt/netconfnode-state-service/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/DomContext.java new file mode 100644 index 000000000..fe016a917 --- /dev/null +++ b/sdnr/wt/netconfnode-state-service/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/DomContext.java @@ -0,0 +1,38 @@ +/* + * ============LICENSE_START======================================================= + * ONAP : ccsdk features + * ================================================================================ + * Copyright (C) 2023 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.netconfnodestateservice; + +import org.opendaylight.mdsal.binding.dom.codec.api.BindingNormalizedNodeSerializer; +import org.opendaylight.yangtools.yang.parser.api.YangParserFactory; + +public interface DomContext { + + /** + * @return BindingNormalizedNodeSerializer + */ + public BindingNormalizedNodeSerializer getBindingNormalizedNodeSerializer(); + + /** + * @return YangParserFactory + */ + public YangParserFactory getYangParserFactory(); +} diff --git a/sdnr/wt/netconfnode-state-service/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/NetconfDomAccessor.java b/sdnr/wt/netconfnode-state-service/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/NetconfDomAccessor.java index b7eba42b8..2a36cfd96 100644 --- a/sdnr/wt/netconfnode-state-service/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/NetconfDomAccessor.java +++ b/sdnr/wt/netconfnode-state-service/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/NetconfDomAccessor.java @@ -29,6 +29,7 @@ import org.opendaylight.mdsal.dom.api.DOMDataBroker; import org.opendaylight.mdsal.dom.api.DOMMountPoint; import org.opendaylight.mdsal.dom.api.DOMNotificationListener; import org.opendaylight.mdsal.dom.api.DOMRpcResult; +import org.opendaylight.mdsal.dom.api.DOMRpcService; 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.create.subscription.input.Filter; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netmod.notification.rev080714.netconf.streams.Stream; @@ -52,9 +53,19 @@ public interface NetconfDomAccessor extends NetconfAccessor { /** * @return the MDSAL Mountpoint service - **/ + */ DOMMountPoint getMountpoint(); + /** + * @return DOMRpcService + */ + DOMRpcService getRpcService(); + + /** + * @return DomContext + */ + DomContext getDomContext(); + /** * Deliver the data into a class * diff --git a/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/NetconfNodeStateServiceImpl.java b/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/NetconfNodeStateServiceImpl.java index a420867b5..c4ec06ff8 100644 --- a/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/NetconfNodeStateServiceImpl.java +++ b/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/NetconfNodeStateServiceImpl.java @@ -30,6 +30,7 @@ import org.onap.ccsdk.features.sdnr.wt.common.threading.GenericRunnableFactory; import org.onap.ccsdk.features.sdnr.wt.common.threading.KeyBasedThreadpool; import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.IEntityDataProvider; import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.StatusChangedHandler.StatusKey; +import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.DomContext; import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfAccessor; import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfNodeConnectListener; import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfNodeStateListener; @@ -37,7 +38,7 @@ import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfNodeStateS import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.VesNotificationListener; import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.impl.access.NetconfAccessorManager; import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.impl.access.NetconfCommunicatorManager; -import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.impl.access.dom.DomContext; +import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.impl.access.dom.DomContextImpl; import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.impl.conf.NetconfStateConfig; import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.impl.conf.odlAkka.AkkaConfig; import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.impl.conf.odlAkka.ClusterConfig; @@ -74,6 +75,7 @@ import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology. import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node; import org.opendaylight.yangtools.concepts.ListenerRegistration; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; +import org.opendaylight.yangtools.yang.parser.api.YangParserException; import org.opendaylight.yangtools.yang.parser.api.YangParserFactory; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -226,7 +228,7 @@ public class NetconfNodeStateServiceImpl public void init() { LOG.info("Session Initiated start {}", APPLICATION_NAME); - this.domContext = new DomContext(this.yangParserFactory, this.bindingNormalizedNodeSerializer); + this.domContext = new DomContextImpl(this.yangParserFactory, this.bindingNormalizedNodeSerializer); this.netconfCommunicatorManager = new NetconfCommunicatorManager(mountPointService, domMountPointService, domContext); this.accessorManager = new NetconfAccessorManager(netconfCommunicatorManager, domContext, this); diff --git a/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/access/NetconfAccessorImpl.java b/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/access/NetconfAccessorImpl.java index d2a3be7b9..f1d1c3a0d 100644 --- a/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/access/NetconfAccessorImpl.java +++ b/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/access/NetconfAccessorImpl.java @@ -20,11 +20,11 @@ package org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.impl.access; import java.util.Objects; import java.util.Optional; import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.Capabilities; +import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.DomContext; import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfAccessor; import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfBindingAccessor; import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfDomAccessor; import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.impl.NetconfNodeStateServiceImpl; -import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.impl.access.dom.DomContext; import org.opendaylight.mdsal.binding.api.DataBroker; import org.opendaylight.mdsal.dom.api.DOMDataBroker; import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.device.rev221225.ConnectionOper.ConnectionStatus; diff --git a/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/access/NetconfAccessorManager.java b/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/access/NetconfAccessorManager.java index 80be69480..2a97ec1d2 100644 --- a/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/access/NetconfAccessorManager.java +++ b/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/access/NetconfAccessorManager.java @@ -20,9 +20,9 @@ package org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.impl.access; import java.util.Objects; import java.util.concurrent.ConcurrentHashMap; import org.eclipse.jdt.annotation.NonNull; +import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.DomContext; import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfAccessor; import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.impl.NetconfNodeStateServiceImpl; -import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.impl.access.dom.DomContext; import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev221225.NetconfNode; import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev221225.network.topology.topology.topology.types.TopologyNetconf; import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NetworkTopology; diff --git a/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/access/NetconfCommunicatorManager.java b/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/access/NetconfCommunicatorManager.java index ba4e3207e..cb5743e7f 100644 --- a/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/access/NetconfCommunicatorManager.java +++ b/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/access/NetconfCommunicatorManager.java @@ -23,10 +23,10 @@ package org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.impl.access; import java.util.Optional; import org.eclipse.jdt.annotation.NonNull; +import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.DomContext; import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfBindingAccessor; import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfDomAccessor; import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.impl.access.binding.NetconfBindingAccessorImpl; -import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.impl.access.dom.DomContext; import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.impl.access.dom.NetconfDomAccessorImpl; import org.opendaylight.mdsal.binding.api.DataBroker; import org.opendaylight.mdsal.binding.api.MountPoint; diff --git a/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/access/dom/DomContext.java b/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/access/dom/DomContext.java deleted file mode 100644 index 602b2987f..000000000 --- a/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/access/dom/DomContext.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * ONAP : ccsdk features - * ================================================================================ - * Copyright (C) 2020 highstreet technologies GmbH Intellectual Property. - * All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - * - */ -package org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.impl.access.dom; - -import java.util.Objects; -import org.opendaylight.mdsal.binding.dom.codec.api.BindingNormalizedNodeSerializer; -import org.opendaylight.yangtools.yang.parser.api.YangParserFactory; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class DomContext { - @SuppressWarnings("unused") - private static final Logger LOG = LoggerFactory.getLogger(DomContext.class); - - private final YangParserFactory yangParserFactory; - private final BindingNormalizedNodeSerializer bindingNormalizedNodeSerializer; - - public DomContext(YangParserFactory yangParserFactory, BindingNormalizedNodeSerializer bindingNormalizedNodeSerializer) { - this.yangParserFactory = Objects.requireNonNull(yangParserFactory); - this.bindingNormalizedNodeSerializer = Objects.requireNonNull(bindingNormalizedNodeSerializer); - } - - public BindingNormalizedNodeSerializer getBindingNormalizedNodeSerializer() { - return bindingNormalizedNodeSerializer; - } - - public YangParserFactory getYangParserFactory() { - return yangParserFactory; - } - -} diff --git a/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/access/dom/DomContextImpl.java b/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/access/dom/DomContextImpl.java new file mode 100644 index 000000000..56fc9e91b --- /dev/null +++ b/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/access/dom/DomContextImpl.java @@ -0,0 +1,53 @@ +/* + * ============LICENSE_START======================================================= + * ONAP : ccsdk features + * ================================================================================ + * Copyright (C) 2020 highstreet technologies GmbH Intellectual Property. + * All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + * + */ +package org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.impl.access.dom; + +import java.util.Objects; +import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.DomContext; +import org.opendaylight.mdsal.binding.dom.codec.api.BindingNormalizedNodeSerializer; +import org.opendaylight.yangtools.yang.parser.api.YangParserFactory; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class DomContextImpl implements DomContext { + @SuppressWarnings("unused") + private static final Logger LOG = LoggerFactory.getLogger(DomContextImpl.class); + + private final YangParserFactory yangParserFactory; + private final BindingNormalizedNodeSerializer bindingNormalizedNodeSerializer; + + public DomContextImpl(YangParserFactory yangParserFactory, BindingNormalizedNodeSerializer bindingNormalizedNodeSerializer) { + this.yangParserFactory = Objects.requireNonNull(yangParserFactory); + this.bindingNormalizedNodeSerializer = Objects.requireNonNull(bindingNormalizedNodeSerializer); + } + + @Override + public BindingNormalizedNodeSerializer getBindingNormalizedNodeSerializer() { + return bindingNormalizedNodeSerializer; + } + + @Override + public YangParserFactory getYangParserFactory() { + return yangParserFactory; + } + +} diff --git a/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/access/dom/NetconfDomAccessorImpl.java b/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/access/dom/NetconfDomAccessorImpl.java index 00f743d33..f862a77bf 100644 --- a/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/access/dom/NetconfDomAccessorImpl.java +++ b/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/access/dom/NetconfDomAccessorImpl.java @@ -39,6 +39,7 @@ import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; import org.eclipse.jdt.annotation.NonNull; import org.eclipse.jdt.annotation.Nullable; +import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.DomContext; import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfDomAccessor; import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.impl.access.NetconfAccessorImpl; import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.impl.mdsal.MdsalApi; @@ -108,6 +109,16 @@ public class NetconfDomAccessorImpl extends NetconfAccessorImpl implements Netco return mountpoint; } + @Override + public DOMRpcService getRpcService() { + return rpcService; + } + + @Override + public DomContext getDomContext() { + return domContext; + } + @Override public Optional readData(LogicalDatastoreType dataStoreType, YangInstanceIdentifier path, Class clazz) { diff --git a/sdnr/wt/netconfnode-state-service/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/test/TestNetconfAccessorImpl.java b/sdnr/wt/netconfnode-state-service/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/test/TestNetconfAccessorImpl.java index 72a6f7b06..422c3bcf6 100644 --- a/sdnr/wt/netconfnode-state-service/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/test/TestNetconfAccessorImpl.java +++ b/sdnr/wt/netconfnode-state-service/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/test/TestNetconfAccessorImpl.java @@ -36,7 +36,7 @@ import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.impl.NetconfNodeS import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.impl.access.NetconfAccessorImpl; import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.impl.access.NetconfCommunicatorManager; import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.impl.access.binding.NetconfBindingAccessorImpl; -import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.impl.access.dom.DomContext; +import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.impl.access.dom.DomContextImpl; import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.impl.access.dom.NetconfDomAccessorImpl; import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.test.example.TestNetconfHelper; import org.opendaylight.mdsal.binding.api.DataBroker; @@ -64,7 +64,7 @@ public class TestNetconfAccessorImpl extends Mockito { @Test public void testConstruct() { NetconfCommunicatorManager netconfCommunicatorManager = mock(NetconfCommunicatorManager.class); - DomContext domContext = mock(DomContext.class); + DomContextImpl domContext = mock(DomContextImpl.class); String nodeIdString = "Test"; String capabilityStringForNetworkElement = "network-element"; NodeId nodeId = new NodeId(nodeIdString); @@ -147,7 +147,7 @@ public class TestNetconfAccessorImpl extends Mockito { public void testNetconfDomNotification() { DOMDataBroker domDataBroker = mock(DOMDataBroker.class); - DomContext domContext = mock(DomContext.class); + DomContextImpl domContext = mock(DomContextImpl.class); DOMRpcService domRpcService = mock(DOMRpcService.class); NetconfAccessorImpl netconfAccessor = TestNetconfHelper.getNetconfAcessorImpl(); DOMNotificationService domNotificationService = mock(DOMNotificationService.class); diff --git a/sdnr/wt/netconfnode-state-service/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/test/example/ExampleConfig.java b/sdnr/wt/netconfnode-state-service/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/test/example/ExampleConfig.java index 9630897fb..caf7d9c1b 100644 --- a/sdnr/wt/netconfnode-state-service/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/test/example/ExampleConfig.java +++ b/sdnr/wt/netconfnode-state-service/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/test/example/ExampleConfig.java @@ -24,7 +24,7 @@ package org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.test.example; import java.io.IOException; import java.net.URI; import java.util.Objects; -import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.impl.access.dom.DomContext; +import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.DomContext; import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.impl.access.dom.DomParser; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.config.rev201208.Configuration; import org.opendaylight.yangtools.yang.common.QName; @@ -34,6 +34,7 @@ import org.opendaylight.yangtools.yang.common.XMLNamespace; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext; +import org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource; import org.opendaylight.yangtools.yang.parser.api.YangParser; import org.opendaylight.yangtools.yang.parser.api.YangParserException; import org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource; diff --git a/sdnr/wt/netconfnode-state-service/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/test/example/TestNetconfHelper.java b/sdnr/wt/netconfnode-state-service/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/test/example/TestNetconfHelper.java index 4a061709a..5b7104621 100644 --- a/sdnr/wt/netconfnode-state-service/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/test/example/TestNetconfHelper.java +++ b/sdnr/wt/netconfnode-state-service/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/test/example/TestNetconfHelper.java @@ -26,7 +26,7 @@ import org.mockito.Mockito; import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.impl.NetconfNodeStateServiceImpl; import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.impl.access.NetconfAccessorImpl; import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.impl.access.NetconfCommunicatorManager; -import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.impl.access.dom.DomContext; +import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.impl.access.dom.DomContextImpl; import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.device.rev221225.ConnectionOper.ConnectionStatus; import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.device.rev221225.connection.oper.AvailableCapabilitiesBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.device.rev221225.connection.oper.available.capabilities.AvailableCapabilityBuilder; @@ -65,7 +65,7 @@ public class TestNetconfHelper extends Mockito { */ public static NetconfAccessorImpl getNetconfAcessorImpl() { NetconfCommunicatorManager netconfCommunicatorManager = mock(NetconfCommunicatorManager.class); - DomContext domContext = mock(DomContext.class); + DomContextImpl domContext = mock(DomContextImpl.class); String nodeIdString = "Test"; String capabilityStringForNetworkElement = "network-element"; NodeId nodeId = new NodeId(nodeIdString); -- cgit 1.2.3-korg