From eb2a7c97c0007b013bd1784ac17d57be02b63d03 Mon Sep 17 00:00:00 2001 From: Michael DÜrre Date: Thu, 10 Mar 2022 10:39:16 +0100 Subject: migrate sdnr features to phosphorus MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fix mapper and switch to dom api Updated to use phosphorus version of parent poms Issue-ID: CCSDK-3566 Signed-off-by: Michael DÜrre Change-Id: I98c5bef9286622e0d66b53db687557d798cd53f5 Signed-off-by: Michael DÜrre --- .../onf14/dom/impl/DeviceManagerOnf14Impl.java | 88 ++++ .../Onf14DomAirInterfaceNotificationListener.java | 168 +++++++ ...14DomEthernetContainerNotificationListener.java | 151 ++++++ .../onf14/dom/impl/Onf14DomNetworkElement.java | 163 ++++++ .../dom/impl/Onf14DomNetworkElementFactory.java | 54 ++ .../Onf14DomWireInterfaceNotificationListener.java | 145 ++++++ .../dataprovider/InternalDataModelSeverity.java | 46 ++ .../dataprovider/Onf14DomToInternalDataModel.java | 126 +++++ .../impl/equipment/Onf14DomEquipmentManager.java | 171 +++++++ .../interfaces/Onf14DomInterfacePacManager.java | 458 +++++++++++++++++ .../impl/interfaces/TechnologySpecificPacKeys.java | 53 ++ .../devicemanager/onf14/dom/impl/util/Debug.java | 72 +++ .../onf14/dom/impl/util/Onf14DMDOMUtility.java | 77 +++ .../dom/impl/util/Onf14DevicemanagerQNames.java | 251 ++++++++++ .../onf14/impl/DeviceManagerOnf14Impl.java | 89 ---- .../onf14/impl/Onf14Configuration.java | 54 -- .../onf14/impl/Onf14DomNetworkElement.java | 218 -------- .../onf14/impl/Onf14NetworkElement.java | 552 --------------------- .../onf14/impl/Onf14NetworkElementFactory.java | 66 --- .../dataprovider/InternalDataModelSeverity.java | 55 -- .../dataprovider/Onf14ToInternalDataModel.java | 130 ----- .../impl/equipment/Onf14DomEquipmentManager.java | 265 ---------- .../onf14/impl/interfaces/Onf14AirInterface.java | 39 -- .../Onf14AirInterfaceNotificationListener.java | 146 ------ .../interfaces/Onf14DomInterfacePacManager.java | 419 ---------------- .../impl/interfaces/Onf14EthernetContainer.java | 40 -- ...Onf14EthernetContainerNotificationListener.java | 141 ------ .../onf14/impl/interfaces/Onf14WireInterface.java | 40 -- .../Onf14WireInterfaceNotificationListener.java | 149 ------ .../impl/interfaces/TechnologySpecificPacKeys.java | 54 -- .../wt/devicemanager/onf14/impl/util/Debug.java | 72 --- .../sdnr/wt/devicemanager/onf14/yang/Control.java | 26 - .../wt/devicemanager/onf14/yang/OperatorState.java | 22 - .../sdnr/wt/devicemanager/onf14/yang/Resource.java | 22 - .../wt/devicemanager/onf14/yang/ResourceMatch.java | 22 - .../onf14/yang/SeverityWithClear.java | 22 - .../wt/devicemanager/onf14/yang/package-info.java | 18 - .../org/opendaylight/blueprint/impl-blueprint.xml | 2 +- 38 files changed, 2024 insertions(+), 2662 deletions(-) create mode 100644 sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/dom/impl/DeviceManagerOnf14Impl.java create mode 100644 sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/dom/impl/Onf14DomAirInterfaceNotificationListener.java create mode 100644 sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/dom/impl/Onf14DomEthernetContainerNotificationListener.java create mode 100644 sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/dom/impl/Onf14DomNetworkElement.java create mode 100644 sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/dom/impl/Onf14DomNetworkElementFactory.java create mode 100644 sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/dom/impl/Onf14DomWireInterfaceNotificationListener.java create mode 100644 sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/dom/impl/dataprovider/InternalDataModelSeverity.java create mode 100644 sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/dom/impl/dataprovider/Onf14DomToInternalDataModel.java create mode 100644 sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/dom/impl/equipment/Onf14DomEquipmentManager.java create mode 100644 sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/dom/impl/interfaces/Onf14DomInterfacePacManager.java create mode 100644 sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/dom/impl/interfaces/TechnologySpecificPacKeys.java create mode 100644 sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/dom/impl/util/Debug.java create mode 100644 sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/dom/impl/util/Onf14DMDOMUtility.java create mode 100644 sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/dom/impl/util/Onf14DevicemanagerQNames.java delete mode 100644 sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/impl/DeviceManagerOnf14Impl.java delete mode 100644 sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/impl/Onf14Configuration.java delete mode 100644 sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/impl/Onf14DomNetworkElement.java delete mode 100644 sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/impl/Onf14NetworkElement.java delete mode 100644 sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/impl/Onf14NetworkElementFactory.java delete mode 100644 sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/impl/dataprovider/InternalDataModelSeverity.java delete mode 100644 sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/impl/dataprovider/Onf14ToInternalDataModel.java delete mode 100644 sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/impl/equipment/Onf14DomEquipmentManager.java delete mode 100644 sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/impl/interfaces/Onf14AirInterface.java delete mode 100644 sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/impl/interfaces/Onf14AirInterfaceNotificationListener.java delete mode 100644 sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/impl/interfaces/Onf14DomInterfacePacManager.java delete mode 100644 sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/impl/interfaces/Onf14EthernetContainer.java delete mode 100644 sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/impl/interfaces/Onf14EthernetContainerNotificationListener.java delete mode 100644 sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/impl/interfaces/Onf14WireInterface.java delete mode 100644 sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/impl/interfaces/Onf14WireInterfaceNotificationListener.java delete mode 100644 sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/impl/interfaces/TechnologySpecificPacKeys.java delete mode 100644 sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/impl/util/Debug.java delete mode 100644 sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/yang/Control.java delete mode 100644 sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/yang/OperatorState.java delete mode 100644 sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/yang/Resource.java delete mode 100644 sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/yang/ResourceMatch.java delete mode 100644 sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/yang/SeverityWithClear.java delete mode 100644 sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/yang/package-info.java (limited to 'sdnr/wt/devicemanager-onap/onf14/provider/src/main') diff --git a/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/dom/impl/DeviceManagerOnf14Impl.java b/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/dom/impl/DeviceManagerOnf14Impl.java new file mode 100644 index 000000000..a974f4b8c --- /dev/null +++ b/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/dom/impl/DeviceManagerOnf14Impl.java @@ -0,0 +1,88 @@ +/* + * ============LICENSE_START======================================================================== + * ONAP : ccsdk feature sdnr wt + * ================================================================================================= + * Copyright (C) 2020 highstreet technologies GmbH Intellectual Property. All rights reserved. + * ================================================================================================= + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. + * ============LICENSE_END========================================================================== + */ +package org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.dom.impl; + +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.service.NetconfNetworkElementService; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class DeviceManagerOnf14Impl implements AutoCloseable { + + private static final Logger LOG = LoggerFactory.getLogger(DeviceManagerOnf14Impl.class); + private static final String APPLICATION_NAME = "DeviceManagerOnf14"; + @SuppressWarnings("unused") + private static final String CONFIGURATIONFILE = "etc/devicemanager-onf14.properties"; + + + private NetconfNetworkElementService netconfNetworkElementService; + + private HtDatabaseClient htDatabaseClient; + private Boolean devicemanagerInitializationOk = false; + private FactoryRegistration resOnf; + + // Blueprint begin + public DeviceManagerOnf14Impl() { + LOG.info("Creating provider for {}", APPLICATION_NAME); + resOnf = null; + } + + public void setNetconfNetworkElementService(NetconfNetworkElementService netconfNetworkElementService) { + this.netconfNetworkElementService = netconfNetworkElementService; + } + + public void init() throws Exception { + + LOG.info("Session Initiated start {}", APPLICATION_NAME); + + resOnf = netconfNetworkElementService.registerBindingNetworkElementFactory(new Onf14DomNetworkElementFactory()); + + netconfNetworkElementService.writeToEventLog(APPLICATION_NAME, "startup", "done"); + this.devicemanagerInitializationOk = true; + + LOG.info("Session Initiated end. Initialization done {}", devicemanagerInitializationOk); + } + // Blueprint end + + @Override + public void close() throws Exception { + LOG.info("closing ..."); + close(htDatabaseClient); + close(resOnf); + LOG.info("closing done"); + } + + /** + * Used to close all Services, that should support AutoCloseable Pattern + * + * @param toClose + * @throws Exception + */ + private void close(AutoCloseable... toCloseList) { + for (AutoCloseable element : toCloseList) { + if (element != null) { + try { + element.close(); + } catch (Exception e) { + LOG.warn("Fail during close: ", e); + } + } + } + } +} diff --git a/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/dom/impl/Onf14DomAirInterfaceNotificationListener.java b/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/dom/impl/Onf14DomAirInterfaceNotificationListener.java new file mode 100644 index 000000000..f72158e06 --- /dev/null +++ b/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/dom/impl/Onf14DomAirInterfaceNotificationListener.java @@ -0,0 +1,168 @@ +/* + * ============LICENSE_START======================================================= + * ONAP : ccsdk feature sdnr wt + * ================================================================================ + * Copyright (C) 2020 highstreet technologies GmbH Intellectual Property. + * All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + * + */ +package org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.dom.impl; + +import org.eclipse.jdt.annotation.NonNull; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.dom.impl.dataprovider.InternalDataModelSeverity; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.dom.impl.util.Onf14DMDOMUtility; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.dom.impl.util.Onf14DevicemanagerQNames; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.DeviceManagerServiceProvider; +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.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.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.SourceType; +import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode; +import org.opendaylight.yangtools.yang.model.api.stmt.SchemaNodeIdentifier.Absolute; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class Onf14DomAirInterfaceNotificationListener implements DOMNotificationListener { + + private static final Logger log = LoggerFactory.getLogger(Onf14DomAirInterfaceNotificationListener.class); + + private final NetconfDomAccessor netconfDomAccessor; + private final DeviceManagerServiceProvider serviceProvider; + + public Onf14DomAirInterfaceNotificationListener(NetconfDomAccessor netconfDomAccessor, + DeviceManagerServiceProvider serviceProvider) { + this.netconfDomAccessor = netconfDomAccessor; + this.serviceProvider = serviceProvider; + } + + @Override + public void onNotification(@NonNull DOMNotification domNotification) { + if (domNotification.getType() + .equals(Absolute.of(Onf14DevicemanagerQNames.AIR_INTERFACE_OBJECT_CREATE_NOTIFICATION))) { + onObjectCreateNotification(domNotification); + } else if (domNotification.getType() + .equals(Absolute.of(Onf14DevicemanagerQNames.AIR_INTERFACE_OBJECT_AVC_NOTIFICATION))) { + onObjectAVCNotification(domNotification); + } else if (domNotification.getType() + .equals(Absolute.of(Onf14DevicemanagerQNames.AIR_INTERFACE_OBJECT_PROBLEM_NOTIFICATION))) { + onObjectProblemNotification(domNotification); + } else if (domNotification.getType() + .equals(Absolute.of(Onf14DevicemanagerQNames.AIR_INTERFACE_OBJECT_DELETE_NOTIFICATION))) { + onObjectDeletionNotification(domNotification); + } + } + + private void onObjectCreateNotification(@NonNull DOMNotification domNotification) { + + ContainerNode cn = domNotification.getBody(); + + EventlogBuilder eventlogBuilder = new EventlogBuilder(); + eventlogBuilder.setNodeId(netconfDomAccessor.getNodeId().getValue()) + .setAttributeName(Onf14DMDOMUtility.getLeafValue(cn, + Onf14DevicemanagerQNames.AIR_INTERFACE_OBJECT_CREATE_NOTIFICATION_OBJECT_TYPE)) + .setCounter(Integer.parseInt(Onf14DMDOMUtility.getLeafValue(cn, + Onf14DevicemanagerQNames.AIR_INTERFACE_OBJECT_CREATE_NOTIFICATION_COUNTER))) + .setNewValue("created") + .setObjectId(Onf14DMDOMUtility.getLeafValue(cn, + Onf14DevicemanagerQNames.AIR_INTERFACE_OBJECT_CREATE_NOTIFICATION_OBJECT_ID_REF)) + .setSourceType(SourceType.Netconf).setTimestamp(new DateAndTime(Onf14DMDOMUtility.getLeafValue(cn, + Onf14DevicemanagerQNames.AIR_INTERFACE_OBJECT_CREATE_NOTIFICATION_TIMESTAMP))); + + serviceProvider.getDataProvider().writeEventLog(eventlogBuilder.build()); + serviceProvider.getWebsocketService().sendNotification(domNotification, netconfDomAccessor.getNodeId(), + Onf14DevicemanagerQNames.AIR_INTERFACE_OBJECT_CREATE_NOTIFICATION, + new DateAndTime(Onf14DMDOMUtility.getLeafValue(cn, + Onf14DevicemanagerQNames.AIR_INTERFACE_OBJECT_CREATE_NOTIFICATION_TIMESTAMP))); + log.debug("onObjectCreationNotification log entry written"); + } + + private void onObjectAVCNotification(@NonNull DOMNotification domNotification) { + + ContainerNode cn = domNotification.getBody(); + EventlogBuilder eventlogBuilder = new EventlogBuilder(); + eventlogBuilder.setNodeId(netconfDomAccessor.getNodeId().getValue()) + .setAttributeName(Onf14DMDOMUtility.getLeafValue(cn, + Onf14DevicemanagerQNames.AIR_INTERFACE_OBJECT_AVC_NOTIFICATION_ATTRIBUTE_NAME)) + .setCounter(Integer.parseInt(Onf14DMDOMUtility.getLeafValue(cn, + Onf14DevicemanagerQNames.AIR_INTERFACE_OBJECT_AVC_NOTIFICATION_COUNTER))) + .setNewValue(Onf14DMDOMUtility.getLeafValue(cn, + Onf14DevicemanagerQNames.AIR_INTERFACE_OBJECT_AVC_NOTIFICATION_NEW_VALUE)) + .setObjectId(Onf14DMDOMUtility.getLeafValue(cn, + Onf14DevicemanagerQNames.AIR_INTERFACE_OBJECT_AVC_NOTIFICATION_OBJECT_ID_REF)) + .setSourceType(SourceType.Netconf).setTimestamp(new DateAndTime(Onf14DMDOMUtility.getLeafValue(cn, + Onf14DevicemanagerQNames.AIR_INTERFACE_OBJECT_AVC_NOTIFICATION_TIMESTAMP))); + + serviceProvider.getDataProvider().writeEventLog(eventlogBuilder.build()); + serviceProvider.getWebsocketService().sendNotification(domNotification, netconfDomAccessor.getNodeId(), + Onf14DevicemanagerQNames.AIR_INTERFACE_OBJECT_AVC_NOTIFICATION, new DateAndTime(Onf14DMDOMUtility + .getLeafValue(cn, Onf14DevicemanagerQNames.AIR_INTERFACE_OBJECT_AVC_NOTIFICATION_TIMESTAMP))); + log.debug("onAttributeValueChangedNotification log entry written"); + } + + private void onObjectProblemNotification(@NonNull DOMNotification domNotification) { + + ContainerNode cn = domNotification.getBody(); + FaultlogEntity faultAlarm = + new FaultlogBuilder() + .setObjectId(Onf14DMDOMUtility.getLeafValue(cn, + Onf14DevicemanagerQNames.AIR_INTERFACE_OBJECT_PROBLEM_NOTIFICATION_OBJECT_ID_REF)) + .setProblem(Onf14DMDOMUtility.getLeafValue(cn, + Onf14DevicemanagerQNames.AIR_INTERFACE_OBJECT_PROBLEM_NOTIFICATION_PROBLEM)) + .setSourceType(SourceType.Netconf) + .setTimestamp(new DateAndTime(Onf14DMDOMUtility.getLeafValue(cn, + Onf14DevicemanagerQNames.AIR_INTERFACE_OBJECT_PROBLEM_NOTIFICATION_TIMESTAMP))) + .setNodeId(this.netconfDomAccessor.getNodeId().getValue()) + .setSeverity(InternalDataModelSeverity.mapSeverity(Onf14DMDOMUtility.getLeafValue(cn, + Onf14DevicemanagerQNames.AIR_INTERFACE_OBJECT_PROBLEM_NOTIFICATION_SEVERITY))) + .setCounter(Integer.parseInt(Onf14DMDOMUtility.getLeafValue(cn, + Onf14DevicemanagerQNames.AIR_INTERFACE_OBJECT_PROBLEM_NOTIFICATION_COUNTER))) + .build(); + + serviceProvider.getFaultService().faultNotification(faultAlarm); + serviceProvider.getWebsocketService().sendNotification(domNotification, netconfDomAccessor.getNodeId(), + Onf14DevicemanagerQNames.AIR_INTERFACE_OBJECT_PROBLEM_NOTIFICATION, + new DateAndTime(Onf14DMDOMUtility.getLeafValue(cn, + Onf14DevicemanagerQNames.AIR_INTERFACE_OBJECT_PROBLEM_NOTIFICATION_TIMESTAMP))); + } + + private void onObjectDeletionNotification(@NonNull DOMNotification domNotification) { + + ContainerNode cn = domNotification.getBody(); + EventlogBuilder eventlogBuilder = new EventlogBuilder(); + eventlogBuilder.setNodeId(netconfDomAccessor.getNodeId().getValue()).setAttributeName("") + .setCounter(Integer.parseInt(Onf14DMDOMUtility.getLeafValue(cn, + Onf14DevicemanagerQNames.AIR_INTERFACE_OBJECT_DELETE_NOTIFICATION_COUNTER))) + .setNewValue("deleted") + .setObjectId(Onf14DMDOMUtility.getLeafValue(cn, + Onf14DevicemanagerQNames.AIR_INTERFACE_OBJECT_DELETE_NOTIFICATION_OBJECT_ID_REF)) + + .setSourceType(SourceType.Netconf).setTimestamp(new DateAndTime(Onf14DMDOMUtility.getLeafValue(cn, + Onf14DevicemanagerQNames.AIR_INTERFACE_OBJECT_DELETE_NOTIFICATION_TIMESTAMP))); + + serviceProvider.getDataProvider().writeEventLog(eventlogBuilder.build()); + serviceProvider.getWebsocketService().sendNotification(domNotification, netconfDomAccessor.getNodeId(), + Onf14DevicemanagerQNames.AIR_INTERFACE_OBJECT_DELETE_NOTIFICATION, + new DateAndTime(Onf14DMDOMUtility.getLeafValue(cn, + Onf14DevicemanagerQNames.AIR_INTERFACE_OBJECT_DELETE_NOTIFICATION_TIMESTAMP))); + + log.debug("onObjectDeletionNotification log entry written"); + } + +} diff --git a/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/dom/impl/Onf14DomEthernetContainerNotificationListener.java b/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/dom/impl/Onf14DomEthernetContainerNotificationListener.java new file mode 100644 index 000000000..218ece4e7 --- /dev/null +++ b/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/dom/impl/Onf14DomEthernetContainerNotificationListener.java @@ -0,0 +1,151 @@ +package org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.dom.impl; + +import org.eclipse.jdt.annotation.NonNull; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.dom.impl.dataprovider.InternalDataModelSeverity; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.dom.impl.util.Onf14DMDOMUtility; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.dom.impl.util.Onf14DevicemanagerQNames; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.DeviceManagerServiceProvider; +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.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.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.SourceType; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier; +import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode; +import org.opendaylight.yangtools.yang.model.api.stmt.SchemaNodeIdentifier.Absolute; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class Onf14DomEthernetContainerNotificationListener implements DOMNotificationListener { + + private static final Logger log = LoggerFactory.getLogger(Onf14DomEthernetContainerNotificationListener.class); + + private final NetconfDomAccessor netconfDomAccessor; + private final DeviceManagerServiceProvider serviceProvider; + + public Onf14DomEthernetContainerNotificationListener(NetconfDomAccessor netconfDomAccessor, + DeviceManagerServiceProvider serviceProvider) { + this.netconfDomAccessor = netconfDomAccessor; + this.serviceProvider = serviceProvider; + } + + @Override + public void onNotification(@NonNull DOMNotification domNotification) { + log.debug("Got event of type :: {}", domNotification.getType()); + if (domNotification.getType() + .equals(Absolute.of(Onf14DevicemanagerQNames.ETHERNET_CONTAINER_OBJECT_CREATE_NOTIFICATION))) { + onObjectCreationNotification(domNotification); + } else if (domNotification.getType() + .equals(Absolute.of(Onf14DevicemanagerQNames.ETHERNET_CONTAINER_OBJECT_AVC_NOTIFICATION))) { + onAttributeValueChangedNotification(domNotification); + } else if (domNotification.getType() + .equals(Absolute.of(Onf14DevicemanagerQNames.ETHERNET_CONTAINER_OBJECT_PROBLEM_NOTIFICATION))) { + onProblemNotification(domNotification); + } else if (domNotification.getType() + .equals(Absolute.of(Onf14DevicemanagerQNames.ETHERNET_CONTAINER_OBJECT_DELETE_NOTIFICATION))) { + onObjectDeletionNotification(domNotification); + } + } + + public void onObjectDeletionNotification(DOMNotification notification) { + + ContainerNode cn = notification.getBody(); + EventlogBuilder eventlogBuilder = new EventlogBuilder(); + eventlogBuilder.setNodeId(netconfDomAccessor.getNodeId().getValue()).setAttributeName("") + .setCounter(Integer.parseInt(Onf14DMDOMUtility.getLeafValue(cn, + Onf14DevicemanagerQNames.ETHERNET_CONTAINER_OBJECT_DELETE_NOTIFICATION_COUNTER))) + .setNewValue("deleted") + .setObjectId(Onf14DMDOMUtility.getLeafValue(cn, + Onf14DevicemanagerQNames.ETHERNET_CONTAINER_OBJECT_DELETE_NOTIFICATION_OBJECT_ID_REF)) + + .setSourceType(SourceType.Netconf).setTimestamp(new DateAndTime(Onf14DMDOMUtility.getLeafValue(cn, + Onf14DevicemanagerQNames.ETHERNET_CONTAINER_OBJECT_DELETE_NOTIFICATION_TIMESTAMP))); + serviceProvider.getDataProvider().writeEventLog(eventlogBuilder.build()); + serviceProvider.getNotificationService().deletionNotification(netconfDomAccessor.getNodeId(), + Integer.parseInt(Onf14DMDOMUtility.getLeafValue(cn, + Onf14DevicemanagerQNames.ETHERNET_CONTAINER_OBJECT_DELETE_NOTIFICATION_COUNTER)), + new DateAndTime(Onf14DMDOMUtility.getLeafValue(cn, + Onf14DevicemanagerQNames.ETHERNET_CONTAINER_OBJECT_DELETE_NOTIFICATION_TIMESTAMP)), + Onf14DMDOMUtility.getLeafValue(cn, + Onf14DevicemanagerQNames.ETHERNET_CONTAINER_OBJECT_DELETE_NOTIFICATION_OBJECT_ID_REF)); + + log.debug("onObjectDeletionNotification log entry written"); + } + + public void onProblemNotification(DOMNotification notification) { + + ContainerNode cn = notification.getBody(); + FaultlogEntity faultAlarm = new FaultlogBuilder() + .setObjectId(Onf14DMDOMUtility.getLeafValue(cn, + Onf14DevicemanagerQNames.ETHERNET_CONTAINER_OBJECT_PROBLEM_NOTIFICATION_OBJECT_ID_REF)) + .setProblem(Onf14DMDOMUtility.getLeafValue(cn, + Onf14DevicemanagerQNames.ETHERNET_CONTAINER_OBJECT_PROBLEM_NOTIFICATION_PROBLEM)) + .setTimestamp(new DateAndTime(Onf14DMDOMUtility.getLeafValue(cn, + Onf14DevicemanagerQNames.ETHERNET_CONTAINER_OBJECT_PROBLEM_NOTIFICATION_TIMESTAMP))) + .setNodeId(this.netconfDomAccessor.getNodeId().getValue()).setSourceType(SourceType.Netconf) + .setSeverity(InternalDataModelSeverity.mapSeverity(Onf14DMDOMUtility.getLeafValue(cn, + Onf14DevicemanagerQNames.ETHERNET_CONTAINER_OBJECT_PROBLEM_NOTIFICATION_SEVERITY))) + .setCounter(Integer.parseInt(Onf14DMDOMUtility.getLeafValue(cn, + Onf14DevicemanagerQNames.ETHERNET_CONTAINER_OBJECT_PROBLEM_NOTIFICATION_COUNTER))) + .build(); + serviceProvider.getFaultService().faultNotification(faultAlarm); + serviceProvider.getWebsocketService() + .sendNotification(notification, netconfDomAccessor.getNodeId(), + Onf14DevicemanagerQNames.ETHERNET_CONTAINER_OBJECT_PROBLEM_NOTIFICATION_OBJECT_ID_REF, + new DateAndTime(cn.childByArg(new NodeIdentifier( + Onf14DevicemanagerQNames.ETHERNET_CONTAINER_OBJECT_PROBLEM_NOTIFICATION_TIMESTAMP)) + .body().toString())); + + } + + public void onAttributeValueChangedNotification(DOMNotification notification) { + + ContainerNode cn = notification.getBody(); + EventlogBuilder eventlogBuilder = new EventlogBuilder(); + eventlogBuilder.setNodeId(netconfDomAccessor.getNodeId().getValue()) + .setAttributeName(Onf14DMDOMUtility.getLeafValue(cn, + Onf14DevicemanagerQNames.ETHERNET_CONTAINER_OBJECT_AVC_NOTIFICATION_ATTRIBUTE_NAME)) + .setCounter(Integer.parseInt(Onf14DMDOMUtility.getLeafValue(cn, + Onf14DevicemanagerQNames.ETHERNET_CONTAINER_OBJECT_PROBLEM_NOTIFICATION_COUNTER))) + .setNewValue(Onf14DMDOMUtility.getLeafValue(cn, + Onf14DevicemanagerQNames.ETHERNET_CONTAINER_OBJECT_AVC_NOTIFICATION_NEW_VALUE)) + .setObjectId(Onf14DMDOMUtility.getLeafValue(cn, + Onf14DevicemanagerQNames.ETHERNET_CONTAINER_OBJECT_AVC_NOTIFICATION_OBJECT_ID_REF)) + .setSourceType(SourceType.Netconf).setTimestamp(new DateAndTime(Onf14DMDOMUtility.getLeafValue(cn, + Onf14DevicemanagerQNames.ETHERNET_CONTAINER_OBJECT_AVC_NOTIFICATION_TIMESTAMP))); + serviceProvider.getDataProvider().writeEventLog(eventlogBuilder.build()); + serviceProvider.getWebsocketService().sendNotification(notification, netconfDomAccessor.getNodeId(), + Onf14DevicemanagerQNames.ETHERNET_CONTAINER_OBJECT_AVC_NOTIFICATION, + new DateAndTime(Onf14DMDOMUtility.getLeafValue(cn, + Onf14DevicemanagerQNames.ETHERNET_CONTAINER_OBJECT_AVC_NOTIFICATION_TIMESTAMP))); + + log.debug("onAttributeValueChangedNotification log entry written"); + } + + public void onObjectCreationNotification(DOMNotification notification) { + + ContainerNode cn = notification.getBody(); + EventlogBuilder eventlogBuilder = new EventlogBuilder(); + eventlogBuilder.setNodeId(netconfDomAccessor.getNodeId().getValue()) + .setAttributeName(Onf14DMDOMUtility.getLeafValue(cn, + Onf14DevicemanagerQNames.ETHERNET_CONTAINER_OBJECT_CREATE_NOTIFICATION_OBJECT_ID_REF)) + .setCounter(Integer.parseInt(Onf14DMDOMUtility.getLeafValue(cn, + Onf14DevicemanagerQNames.ETHERNET_CONTAINER_OBJECT_CREATE_NOTIFICATION_COUNTER))) + .setNewValue("created") + .setObjectId(Onf14DMDOMUtility.getLeafValue(cn, + Onf14DevicemanagerQNames.ETHERNET_CONTAINER_OBJECT_CREATE_NOTIFICATION_OBJECT_ID_REF)) + + .setSourceType(SourceType.Netconf).setTimestamp(new DateAndTime(Onf14DMDOMUtility.getLeafValue(cn, + Onf14DevicemanagerQNames.ETHERNET_CONTAINER_OBJECT_CREATE_NOTIFICATION_TIMESTAMP))); + serviceProvider.getDataProvider().writeEventLog(eventlogBuilder.build()); + serviceProvider.getWebsocketService().sendNotification(notification, netconfDomAccessor.getNodeId(), + Onf14DevicemanagerQNames.ETHERNET_CONTAINER_OBJECT_CREATE_NOTIFICATION, + new DateAndTime(Onf14DMDOMUtility.getLeafValue(cn, + Onf14DevicemanagerQNames.ETHERNET_CONTAINER_OBJECT_CREATE_NOTIFICATION_TIMESTAMP))); + + log.debug("onObjectCreationNotification log entry written"); + } +} diff --git a/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/dom/impl/Onf14DomNetworkElement.java b/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/dom/impl/Onf14DomNetworkElement.java new file mode 100644 index 000000000..56834a13d --- /dev/null +++ b/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/dom/impl/Onf14DomNetworkElement.java @@ -0,0 +1,163 @@ +/* + * ============LICENSE_START======================================================================== + * ONAP : ccsdk feature sdnr wt + * ================================================================================================= + * Copyright (C) 2020 highstreet technologies GmbH Intellectual Property. All rights reserved. + * ================================================================================================= + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. + * ============LICENSE_END========================================================================== + */ +package org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.dom.impl; + +import java.util.Map; +import java.util.Optional; +import org.eclipse.jdt.annotation.NonNull; +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.onf14.dom.impl.dataprovider.Onf14DomToInternalDataModel; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.dom.impl.equipment.Onf14DomEquipmentManager; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.dom.impl.interfaces.Onf14DomInterfacePacManager; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.dom.impl.util.Onf14DevicemanagerQNames; +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; +import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfAccessor; +import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfDomAccessor; +import org.opendaylight.mdsal.common.api.LogicalDatastoreType; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netmod.notification.rev080714.netconf.streams.Stream; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netmod.notification.rev080714.netconf.streams.StreamKey; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.NetworkElementConnectionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.NetworkElementDeviceType; +import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; +import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Representation of ONF Core model 1.4 device Top level element is "ControlConstruct" (replaces "NetworkElement" of + * older ONF Version) NOTE: + */ +public class Onf14DomNetworkElement implements NetworkElement { + + private static final Logger log = LoggerFactory.getLogger(Onf14DomNetworkElement.class); + + protected static final YangInstanceIdentifier TOPLEVELEQUIPMENT_IID = + YangInstanceIdentifier.builder().node(Onf14DevicemanagerQNames.CORE_MODEL_CONTROL_CONSTRUCT_CONTAINER) + .node(Onf14DevicemanagerQNames.CORE_MODEL_CC_TOP_LEVEL_EQPT).build(); + + private final NetconfDomAccessor netconfDomAccessor; + private final DataProvider databaseService; + private final @NonNull FaultService faultService; + private final @NonNull NotificationService notificationService; + + private final Onf14DomToInternalDataModel onf14Mapper; + + private final @NonNull Onf14DomEquipmentManager equipmentManager; + private final @NonNull Onf14DomInterfacePacManager interfacePacManager; + private final @NonNull String namespaceRevision; + + public Onf14DomNetworkElement(NetconfDomAccessor netconfDomAccessor, DeviceManagerServiceProvider serviceProvider, + String namespaceRevision) { + log.info("Create {}", Onf14DomNetworkElement.class.getSimpleName()); + this.netconfDomAccessor = netconfDomAccessor; + this.databaseService = serviceProvider.getDataProvider(); + this.notificationService = serviceProvider.getNotificationService(); + this.faultService = serviceProvider.getFaultService(); + this.namespaceRevision = namespaceRevision; + this.onf14Mapper = new Onf14DomToInternalDataModel(); + this.equipmentManager = new Onf14DomEquipmentManager(netconfDomAccessor, databaseService, onf14Mapper); + this.interfacePacManager = new Onf14DomInterfacePacManager(netconfDomAccessor, serviceProvider); + + } + + /** + * reading the inventory (CoreModel 1.4 Equipment Model) and adding it to the DB + */ + public void initialReadFromNetworkElement() { + log.info("Calling read equipment"); + // Read complete device tree + readEquipmentData(); + + // Read fault data and subscribe for notifications + interfacePacManager.register(); + + int problems = faultService.removeAllCurrentProblemsOfNode(netconfDomAccessor.getNodeId()); + log.debug("Removed all {} problems from database at registration", problems); + + } + + /** + * @param nNode set core-model-capability + */ + public void setCoreModel() { + NetworkElementConnectionBuilder eb = new NetworkElementConnectionBuilder(); + eb.setCoreModelCapability(namespaceRevision); + databaseService.updateNetworkConnection22(eb.build(), netconfDomAccessor.getNodeId().getValue()); + } + + @Override + public void register() { + // Set core-model revision value in "core-model-capability" field + setCoreModel(); + initialReadFromNetworkElement(); + + if (netconfDomAccessor.isNotificationsRFC5277Supported()) { + // Output notification streams to LOG + Map streams = netconfDomAccessor.getNotificationStreamsAsMap(); + log.info("Available notifications streams: {}", streams); + // Register to default stream + netconfDomAccessor.invokeCreateSubscription(); + } + } + + @Override + public void deregister() {} + + @Override + public NodeId getNodeId() { + return netconfDomAccessor.getNodeId(); + } + + @Override + public Optional getService(Class clazz) { + return Optional.empty(); + } + + @Override + public void warmstart() {} + + @Override + public Optional getAcessor() { + return Optional.of(netconfDomAccessor); + } + + @Override + public NetworkElementDeviceType getDeviceType() { + return NetworkElementDeviceType.Wireless; + } + + private void readEquipmentData() { + Optional topLevelEquipment = readTopLevelEquipment(netconfDomAccessor); + log.info("Top level equipment data is {}", topLevelEquipment.isPresent() ? topLevelEquipment.get() : null); + if (topLevelEquipment.isPresent()) { + equipmentManager.setEquipmentData(topLevelEquipment.get()); + } + + } + + private Optional readTopLevelEquipment(NetconfDomAccessor netconfDomAccessor) { + log.info("Reading Top level equipment data"); + return netconfDomAccessor.readDataNode(LogicalDatastoreType.CONFIGURATION, TOPLEVELEQUIPMENT_IID); + } + +} diff --git a/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/dom/impl/Onf14DomNetworkElementFactory.java b/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/dom/impl/Onf14DomNetworkElementFactory.java new file mode 100644 index 000000000..b47f56d31 --- /dev/null +++ b/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/dom/impl/Onf14DomNetworkElementFactory.java @@ -0,0 +1,54 @@ +/* + * ============LICENSE_START======================================================================== + * ONAP : ccsdk feature sdnr wt + * ================================================================================================= + * Copyright (C) 2022 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.onf14.dom.impl; + +import java.util.Optional; +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.onf14.dom.impl.util.Onf14DevicemanagerQNames; +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; +import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfDomAccessor; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class Onf14DomNetworkElementFactory implements NetworkElementFactory { + + private static final Logger log = LoggerFactory.getLogger(Onf14DomNetworkElementFactory.class); + + @Override + public Optional create(NetconfAccessor accessor, DeviceManagerServiceProvider serviceProvider) { + + Optional ne = Optional.empty(); + Capabilities capabilities = accessor.getCapabilites(); + if (capabilities.isSupportingNamespace(Onf14DevicemanagerQNames.CORE_MODEL_CONTROL_CONSTRUCT_CONTAINER)) { + String namespaceRevision = capabilities.getRevisionForNamespace(Onf14DevicemanagerQNames.CORE_MODEL_CONTROL_CONSTRUCT_CONTAINER); + + Optional domAccessor = accessor.getNetconfDomAccessor(); + if (domAccessor.isPresent()) { + ne = Optional.of(new Onf14DomNetworkElement(domAccessor.get(), serviceProvider, namespaceRevision)); + } + + log.info("Create device:{}", ne.isPresent() ? ne.get().getClass().getSimpleName() : "not"); + } + return ne; + } + +} diff --git a/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/dom/impl/Onf14DomWireInterfaceNotificationListener.java b/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/dom/impl/Onf14DomWireInterfaceNotificationListener.java new file mode 100644 index 000000000..5d148d3a3 --- /dev/null +++ b/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/dom/impl/Onf14DomWireInterfaceNotificationListener.java @@ -0,0 +1,145 @@ +package org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.dom.impl; + +import org.eclipse.jdt.annotation.NonNull; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.dom.impl.dataprovider.InternalDataModelSeverity; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.dom.impl.util.Onf14DMDOMUtility; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.dom.impl.util.Onf14DevicemanagerQNames; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.DeviceManagerServiceProvider; +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.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.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.SourceType; +import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode; +import org.opendaylight.yangtools.yang.model.api.stmt.SchemaNodeIdentifier.Absolute; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class Onf14DomWireInterfaceNotificationListener implements DOMNotificationListener { + + private static final Logger log = LoggerFactory.getLogger(Onf14DomWireInterfaceNotificationListener.class); + + private final NetconfDomAccessor netconfDomAccessor; + private final DeviceManagerServiceProvider serviceProvider; + + public Onf14DomWireInterfaceNotificationListener(NetconfDomAccessor netconfDomAccessor, + DeviceManagerServiceProvider serviceProvider) { + this.netconfDomAccessor = netconfDomAccessor; + this.serviceProvider = serviceProvider; + } + + @Override + public void onNotification(@NonNull DOMNotification domNotification) { + log.debug("Got event of type :: {}", domNotification.getType()); + if (domNotification.getType() + .equals(Absolute.of(Onf14DevicemanagerQNames.WIRE_INTERFACE_OBJECT_CREATE_NOTIFICATION))) { + onObjectCreationNotification(domNotification); + } else if (domNotification.getType() + .equals(Absolute.of(Onf14DevicemanagerQNames.WIRE_INTERFACE_OBJECT_AVC_NOTIFICATION))) { + onAttributeValueChangedNotification(domNotification); + } else if (domNotification.getType() + .equals(Absolute.of(Onf14DevicemanagerQNames.WIRE_INTERFACE_OBJECT_PROBLEM_NOTIFICATION))) { + onProblemNotification(domNotification); + } else if (domNotification.getType() + .equals(Absolute.of(Onf14DevicemanagerQNames.WIRE_INTERFACE_OBJECT_DELETE_NOTIFICATION))) { + onObjectDeletionNotification(domNotification); + } + } + + public void onObjectDeletionNotification(DOMNotification notification) { + + ContainerNode cn = notification.getBody(); + EventlogBuilder eventlogBuilder = new EventlogBuilder(); + eventlogBuilder.setNodeId(netconfDomAccessor.getNodeId().getValue()).setAttributeName("") + .setCounter(Integer.parseInt(Onf14DMDOMUtility.getLeafValue(cn, + Onf14DevicemanagerQNames.WIRE_INTERFACE_OBJECT_DELETE_NOTIFICATION_COUNTER))) + .setNewValue("deleted") + .setObjectId(Onf14DMDOMUtility.getLeafValue(cn, + Onf14DevicemanagerQNames.WIRE_INTERFACE_OBJECT_DELETE_NOTIFICATION_OBJECT_ID_REF)) + .setSourceType(SourceType.Netconf).setTimestamp(new DateAndTime(Onf14DMDOMUtility.getLeafValue(cn, + Onf14DevicemanagerQNames.WIRE_INTERFACE_OBJECT_DELETE_NOTIFICATION_TIMESTAMP))); + serviceProvider.getDataProvider().writeEventLog(eventlogBuilder.build()); + serviceProvider.getWebsocketService().sendNotification(notification, netconfDomAccessor.getNodeId(), + Onf14DevicemanagerQNames.WIRE_INTERFACE_OBJECT_DELETE_NOTIFICATION, + new DateAndTime(Onf14DMDOMUtility.getLeafValue(cn, + Onf14DevicemanagerQNames.WIRE_INTERFACE_OBJECT_DELETE_NOTIFICATION_TIMESTAMP))); + + log.debug("onObjectDeletionNotification log entry written"); + } + + public void onProblemNotification(DOMNotification notification) { + + ContainerNode cn = notification.getBody(); + FaultlogEntity faultAlarm = + new FaultlogBuilder() + .setObjectId(Onf14DMDOMUtility.getLeafValue(cn, + Onf14DevicemanagerQNames.WIRE_INTERFACE_OBJECT_PROBLEM_NOTIFICATION_OBJECT_ID_REF)) + .setProblem(Onf14DMDOMUtility.getLeafValue(cn, + Onf14DevicemanagerQNames.WIRE_INTERFACE_OBJECT_PROBLEM_NOTIFICATION_PROBLEM)) + .setTimestamp(new DateAndTime(Onf14DMDOMUtility.getLeafValue(cn, + Onf14DevicemanagerQNames.WIRE_INTERFACE_OBJECT_PROBLEM_NOTIFICATION_TIMESTAMP))) + .setNodeId(this.netconfDomAccessor.getNodeId().getValue()).setSourceType(SourceType.Netconf) + .setSeverity(InternalDataModelSeverity.mapSeverity(Onf14DMDOMUtility.getLeafValue(cn, + Onf14DevicemanagerQNames.WIRE_INTERFACE_OBJECT_PROBLEM_NOTIFICATION_SEVERITY))) + .setCounter(Integer.parseInt(Onf14DMDOMUtility.getLeafValue(cn, + Onf14DevicemanagerQNames.WIRE_INTERFACE_OBJECT_PROBLEM_NOTIFICATION_COUNTER))) + .build(); + serviceProvider.getFaultService().faultNotification(faultAlarm); + serviceProvider.getWebsocketService().sendNotification(notification, netconfDomAccessor.getNodeId(), + Onf14DevicemanagerQNames.WIRE_INTERFACE_OBJECT_PROBLEM_NOTIFICATION, + new DateAndTime(Onf14DMDOMUtility.getLeafValue(cn, + Onf14DevicemanagerQNames.WIRE_INTERFACE_OBJECT_PROBLEM_NOTIFICATION_TIMESTAMP))); + + } + + public void onAttributeValueChangedNotification(DOMNotification notification) { + + ContainerNode cn = notification.getBody(); + EventlogBuilder eventlogBuilder = new EventlogBuilder(); + eventlogBuilder.setNodeId(netconfDomAccessor.getNodeId().getValue()) + .setAttributeName(Onf14DMDOMUtility.getLeafValue(cn, + Onf14DevicemanagerQNames.WIRE_INTERFACE_OBJECT_AVC_NOTIFICATION_ATTRIBUTE_NAME)) + .setCounter(Integer.parseInt(Onf14DMDOMUtility.getLeafValue(cn, + Onf14DevicemanagerQNames.WIRE_INTERFACE_OBJECT_PROBLEM_NOTIFICATION_COUNTER))) + .setNewValue(Onf14DMDOMUtility.getLeafValue(cn, + Onf14DevicemanagerQNames.WIRE_INTERFACE_OBJECT_AVC_NOTIFICATION_NEW_VALUE)) + .setObjectId(Onf14DMDOMUtility.getLeafValue(cn, + Onf14DevicemanagerQNames.WIRE_INTERFACE_OBJECT_PROBLEM_NOTIFICATION_OBJECT_ID_REF)) + .setSourceType(SourceType.Netconf).setTimestamp(new DateAndTime(Onf14DMDOMUtility.getLeafValue(cn, + Onf14DevicemanagerQNames.WIRE_INTERFACE_OBJECT_PROBLEM_NOTIFICATION_TIMESTAMP))); + serviceProvider.getDataProvider().writeEventLog(eventlogBuilder.build()); + serviceProvider.getWebsocketService().sendNotification(notification, netconfDomAccessor.getNodeId(), + Onf14DevicemanagerQNames.WIRE_INTERFACE_OBJECT_AVC_NOTIFICATION, + new DateAndTime(Onf14DMDOMUtility.getLeafValue(cn, + Onf14DevicemanagerQNames.WIRE_INTERFACE_OBJECT_PROBLEM_NOTIFICATION_TIMESTAMP))); + + log.debug("onAttributeValueChangedNotification log entry written"); + } + + public void onObjectCreationNotification(DOMNotification notification) { + + ContainerNode cn = notification.getBody(); + EventlogBuilder eventlogBuilder = new EventlogBuilder(); + eventlogBuilder.setNodeId(netconfDomAccessor.getNodeId().getValue()) + .setAttributeName(Onf14DMDOMUtility.getLeafValue(cn, + Onf14DevicemanagerQNames.WIRE_INTERFACE_OBJECT_CREATE_NOTIFICATION_OBJECT_TYPE)) + .setCounter(Integer.parseInt(Onf14DMDOMUtility.getLeafValue(cn, + Onf14DevicemanagerQNames.WIRE_INTERFACE_OBJECT_PROBLEM_NOTIFICATION_COUNTER))) + .setNewValue("created") + .setObjectId(Onf14DMDOMUtility.getLeafValue(cn, + Onf14DevicemanagerQNames.WIRE_INTERFACE_OBJECT_PROBLEM_NOTIFICATION_OBJECT_ID_REF)) + + .setSourceType(SourceType.Netconf).setTimestamp(new DateAndTime(Onf14DMDOMUtility.getLeafValue(cn, + Onf14DevicemanagerQNames.WIRE_INTERFACE_OBJECT_PROBLEM_NOTIFICATION_TIMESTAMP))); + serviceProvider.getDataProvider().writeEventLog(eventlogBuilder.build()); + serviceProvider.getWebsocketService().sendNotification(notification, netconfDomAccessor.getNodeId(), + Onf14DevicemanagerQNames.WIRE_INTERFACE_OBJECT_CREATE_NOTIFICATION, + new DateAndTime(Onf14DMDOMUtility.getLeafValue(cn, + Onf14DevicemanagerQNames.WIRE_INTERFACE_OBJECT_PROBLEM_NOTIFICATION_TIMESTAMP))); + + log.debug("onObjectCreationNotification log entry written"); + } +} diff --git a/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/dom/impl/dataprovider/InternalDataModelSeverity.java b/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/dom/impl/dataprovider/InternalDataModelSeverity.java new file mode 100644 index 000000000..6d31d7392 --- /dev/null +++ b/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/dom/impl/dataprovider/InternalDataModelSeverity.java @@ -0,0 +1,46 @@ +/* + * ============LICENSE_START======================================================= + * ONAP : ccsdk features + * ================================================================================ + * Copyright (C) 2022 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.onf14.dom.impl.dataprovider; + +import java.util.Map; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.SeverityType; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class InternalDataModelSeverity { + + private static Logger log = LoggerFactory.getLogger(InternalDataModelSeverity.class); + private static final Map SEVERITYMAP = + Map.of("SEVERITY_TYPE_MAJOR", SeverityType.Major, "SEVERITY_TYPE_CRITICAL", SeverityType.Critical, + "SEVERITY_TYPE_MINOR", SeverityType.Minor, "SEVERITY_TYPE_WARNING", SeverityType.Warning); + + public static SeverityType mapSeverity(String severity) { + log.debug("Severity is - {}", severity); + SeverityType res = null; + if (severity != null) { + res = SEVERITYMAP.get(severity); + } + return res == null ? SeverityType.NonAlarmed : res; + } + +} diff --git a/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/dom/impl/dataprovider/Onf14DomToInternalDataModel.java b/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/dom/impl/dataprovider/Onf14DomToInternalDataModel.java new file mode 100644 index 000000000..8a75bbc11 --- /dev/null +++ b/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/dom/impl/dataprovider/Onf14DomToInternalDataModel.java @@ -0,0 +1,126 @@ +package org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.dom.impl.dataprovider; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; +import java.util.Objects; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.dom.impl.util.Onf14DMDOMUtility; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.dom.impl.util.Onf14DevicemanagerQNames; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.Inventory; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.InventoryBuilder; +import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId; +import org.opendaylight.yangtools.yang.common.Uint32; +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.MapEntryNode; +import org.opendaylight.yangtools.yang.data.api.schema.MapNode; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class Onf14DomToInternalDataModel { + private static final Logger LOG = LoggerFactory.getLogger(Onf14DomToInternalDataModel.class); + + public Inventory getInternalEquipment(NodeId nodeId, MapEntryNode currentEq, MapEntryNode parentEq, + long treeLevel) { + + Objects.requireNonNull(nodeId); + Objects.requireNonNull(currentEq); + + InventoryBuilder inventoryBuilder = new InventoryBuilder(); + String parentUuid = parentEq != null ? Onf14DMDOMUtility.getUuidFromEquipment(parentEq) : "None"; + + // General + inventoryBuilder.setNodeId(nodeId.getValue()); + inventoryBuilder.setTreeLevel(Uint32.valueOf(treeLevel)); + inventoryBuilder.setUuid(Onf14DMDOMUtility.getUuidFromEquipment(currentEq)); + inventoryBuilder.setParentUuid(parentUuid); + + List containedHolderKeyList = new ArrayList<>(); + MapNode containedHolderMap = (MapNode) currentEq + .childByArg(new NodeIdentifier(Onf14DevicemanagerQNames.CORE_MODEL_CC_EQPT_CONTAINED_HOLDER)); + if (containedHolderMap != null) { + Collection containedHolderCollection = containedHolderMap.body(); + for (MapEntryNode holder : containedHolderCollection) { + String occupyingFru = Onf14DMDOMUtility.getLeafValue(holder, + Onf14DevicemanagerQNames.CORE_MODEL_CC_EQPT_OCCUPYING_FRU); + + if (occupyingFru != null) { + containedHolderKeyList.add(occupyingFru); + } + } + } + inventoryBuilder.setContainedHolder(containedHolderKeyList); + + // actual-equipment + ContainerNode actualEquipment = (ContainerNode) currentEq + .childByArg(new NodeIdentifier(Onf14DevicemanagerQNames.CORE_MODEL_CC_EQPT_ACTUAL_EQUIPMENT)); + if (actualEquipment != null) { + ContainerNode manThing = (ContainerNode) actualEquipment + .childByArg(new NodeIdentifier(Onf14DevicemanagerQNames.CORE_MODEL_CC_EQPT_MANUFACTURED_THING)); + if (manThing != null) { + // Manufacturer properties + ContainerNode props = (ContainerNode) manThing + .childByArg(new NodeIdentifier(Onf14DevicemanagerQNames.CORE_MODEL_CC_EQPT_MANUFACTURER_PROPS)); + if (props != null) { + inventoryBuilder.setManufacturerName(Onf14DMDOMUtility.getLeafValue(props, + Onf14DevicemanagerQNames.CORE_MODEL_CC_EQPT_MANUFACTURER_NAME)); + + inventoryBuilder.setManufacturerIdentifier(Onf14DMDOMUtility.getLeafValue(props, + Onf14DevicemanagerQNames.CORE_MODEL_CC_EQPT_MANUFACTURER_ID)); + + } else { + LOG.debug("manufacturer-properties is not present in Equipment with uuid={}", + Onf14DMDOMUtility.getUuidFromEquipment(currentEq)); + } + + // Equipment instance + ContainerNode equipmentInstance = (ContainerNode) manThing.childByArg( + new NodeIdentifier(Onf14DevicemanagerQNames.CORE_MODEL_CC_EQPT_ACTUAL_EQPT_EQPT_INSTANCE)); + if (equipmentInstance != null) { + inventoryBuilder.setSerial(Onf14DMDOMUtility.getLeafValue(equipmentInstance, + Onf14DevicemanagerQNames.CORE_MODEL_CC_EQPT_ACTUAL_EQPT_EQPT_INSTANCE_SERIAL_NUM)); + + inventoryBuilder.setDate(Onf14DMDOMUtility.getLeafValue(equipmentInstance, + Onf14DevicemanagerQNames.CORE_MODEL_CC_EQPT_ACTUAL_EQPT_EQPT_INSTANCE_MANUFACTURED_DATE)); + + } else { + LOG.debug("equipment-instance is not present in Equipment with uuid={}", + Onf14DMDOMUtility.getUuidFromEquipment(currentEq)); + } + + // Equipment type + ContainerNode equipmentType = (ContainerNode) manThing.childByArg( + new NodeIdentifier(Onf14DevicemanagerQNames.CORE_MODEL_CC_EQPT_ACTUAL_EQPT_EQPT_TYPE)); + if (equipmentType != null) { + inventoryBuilder.setVersion(Onf14DMDOMUtility.getLeafValue(equipmentType, + Onf14DevicemanagerQNames.CORE_MODEL_CC_EQPT_ACTUAL_EQPT_EQPT_TYPE_VERSION)); + + inventoryBuilder.setDescription(Onf14DMDOMUtility.getLeafValue(equipmentType, + Onf14DevicemanagerQNames.CORE_MODEL_CC_EQPT_ACTUAL_EQPT_EQPT_TYPE_DESCRIPTION)); + + inventoryBuilder.setPartTypeId(Onf14DMDOMUtility.getLeafValue(equipmentType, + Onf14DevicemanagerQNames.CORE_MODEL_CC_EQPT_ACTUAL_EQPT_EQPT_TYPE_PART_TYPE_ID)); + + inventoryBuilder.setModelIdentifier(Onf14DMDOMUtility.getLeafValue(equipmentType, + + Onf14DevicemanagerQNames.CORE_MODEL_CC_EQPT_ACTUAL_EQPT_EQPT_TYPE_MODEL_ID)); + + inventoryBuilder.setTypeName(Onf14DMDOMUtility.getLeafValue(equipmentType, + Onf14DevicemanagerQNames.CORE_MODEL_CC_EQPT_ACTUAL_EQPT_EQPT_TYPE_TYPE_NAME)); + + } else { + LOG.debug("equipment-type is not present in Equipment with uuid={}", + Onf14DMDOMUtility.getUuidFromEquipment(currentEq)); + } + } else { + LOG.debug("manufactured-thing is not present in Equipment with uuid={}", + Onf14DMDOMUtility.getUuidFromEquipment(currentEq)); + } + } else { + LOG.debug("actual-equipment is not present in Equipment with uuid={}", + Onf14DMDOMUtility.getUuidFromEquipment(currentEq)); + } + + return inventoryBuilder.build(); + } +} diff --git a/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/dom/impl/equipment/Onf14DomEquipmentManager.java b/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/dom/impl/equipment/Onf14DomEquipmentManager.java new file mode 100644 index 000000000..8f7a44858 --- /dev/null +++ b/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/dom/impl/equipment/Onf14DomEquipmentManager.java @@ -0,0 +1,171 @@ +/* + * ============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.onf14.dom.impl.equipment; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Iterator; +import java.util.List; +import java.util.Objects; +import java.util.Optional; +import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.DataProvider; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.dom.impl.dataprovider.Onf14DomToInternalDataModel; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.dom.impl.util.Onf14DMDOMUtility; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.dom.impl.util.Onf14DevicemanagerQNames; +import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfDomAccessor; +import org.opendaylight.mdsal.common.api.LogicalDatastoreType; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.Inventory; +import org.opendaylight.yangtools.yang.common.QName; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; +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.LeafSetEntryNode; +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 Onf14DomEquipmentManager { + + private static final Logger log = LoggerFactory.getLogger(Onf14DomEquipmentManager.class); + private static final int EQUIPMENTROOTLEVEL = 0; + + private final NetconfDomAccessor netconfDomAccessor; + private final DataProvider databaseService; + private final Onf14DomToInternalDataModel onf14Mapper; + private final List equipmentUuidList; + + public Onf14DomEquipmentManager(NetconfDomAccessor netconfDomAccessor, DataProvider databaseService, + Onf14DomToInternalDataModel onf14Mapper) { + super(); + this.netconfDomAccessor = Objects.requireNonNull(netconfDomAccessor); + this.databaseService = Objects.requireNonNull(databaseService); + this.onf14Mapper = Objects.requireNonNull(onf14Mapper); + + this.equipmentUuidList = new ArrayList<>(); + } + + public List getEquipmentUuidList() { + return equipmentUuidList; + } + + private List collectEquipment(List list, MapEntryNode currentEq, MapEntryNode parentEq, + long treeLevel) { + + // if the Equipment UUID is already in the list, it was already processed + // needed for solving possible circular dependencies + if (equipmentUuidList.contains(Onf14DMDOMUtility.getUuidFromEquipment(currentEq))) { + log.debug("Not adding equipment with uuid {} because it was aleady added...", + Onf14DMDOMUtility.getUuidFromEquipment(currentEq)); + return list; + } + + // we add this to our internal list, such that we avoid circular dependencies + equipmentUuidList.add(Onf14DMDOMUtility.getUuidFromEquipment(currentEq)); + log.debug("Adding equipment with uuid {} to the database...", + Onf14DMDOMUtility.getUuidFromEquipment(currentEq)); + + // we add our current equipment to the database + list.add(onf14Mapper.getInternalEquipment(netconfDomAccessor.getNodeId(), currentEq, parentEq, treeLevel)); + + // we iterate the kids of our current equipment and add them to the database + // recursively + // the actual reference is here: + // /core-model:control-construct/equipment/contained-holder/occupying-fru + + MapNode containedHolderMap = (MapNode) currentEq + .childByArg(new NodeIdentifier(Onf14DevicemanagerQNames.CORE_MODEL_CC_EQPT_CONTAINED_HOLDER)); + if (containedHolderMap != null) { + Collection containedHolderCollection = containedHolderMap.body(); + for (MapEntryNode holder : containedHolderCollection) { + String occupyingFru = Onf14DMDOMUtility.getLeafValue(holder, + Onf14DevicemanagerQNames.CORE_MODEL_CC_EQPT_OCCUPYING_FRU); + + if (occupyingFru != null) { + Optional childEq = readEquipmentInstance(netconfDomAccessor, occupyingFru); + if (childEq.isPresent()) { + // current becomes parent and tree level increases by 1 + collectEquipment(list, (MapEntryNode) childEq.get(), currentEq, treeLevel + 1); + } + } + } + } + + return list; + } + + // public methods + /** + * Set all equipment data from controlConstruct into database and into this manager. + * + * @param controlConstruct with complete device data + */ + public void setEquipmentData(NormalizedNode controlConstruct) { + Objects.requireNonNull(controlConstruct); + + // the top-level-equipment list contains the root objects of the Equipment Model + log.debug("Getting list of topLevelEquipment for mountpoint {}", netconfDomAccessor.getNodeId()); + // adding all root Equipment objects to the DB + List inventoryList = new ArrayList<>(); + for (String uuid : getTopLevelEquipment(controlConstruct)) { + Optional equipment = readEquipmentInstance(netconfDomAccessor, uuid); + MapEntryNode equipmentEntry = (MapEntryNode) equipment.get(); + if (equipmentEntry != null) { + collectEquipment(inventoryList, equipmentEntry, null, EQUIPMENTROOTLEVEL); + } + } + this.databaseService.writeInventory(netconfDomAccessor.getNodeId().getValue(), inventoryList); + + } + + private List getTopLevelEquipment(NormalizedNode transformedInput) { + List topLvlEqptList = new ArrayList<>(); + Collection topLevelEqptListColl = (Collection) transformedInput.body(); + Iterator childEntryItr = topLevelEqptListColl.iterator(); + while (childEntryItr.hasNext()) { + LeafSetEntryNode childEntryNode = (LeafSetEntryNode) childEntryItr.next(); + topLvlEqptList.add((String) childEntryNode.body()); + } + return topLvlEqptList; + } + + /** + * @param accessData to access device + * @param equipmentUuid uuid of equipment to be read + * @return Optional Equipment + */ + private Optional readEquipmentInstance(NetconfDomAccessor accessData, String equipmentUuid) { + + log.info("DBRead Get equipment from mountpoint {} for uuid {}", accessData.getNodeId().getValue(), + equipmentUuid); + + InstanceIdentifierBuilder equipmentIIDBuilder = YangInstanceIdentifier.builder() + .node(Onf14DevicemanagerQNames.CORE_MODEL_CONTROL_CONSTRUCT_CONTAINER) + .node(Onf14DevicemanagerQNames.CORE_MODEL_CC_EQPT) + .nodeWithKey(Onf14DevicemanagerQNames.CORE_MODEL_CC_EQPT, + QName.create(Onf14DevicemanagerQNames.CORE_MODEL_CC_EQPT, "uuid").intern(), equipmentUuid); + + return accessData.readDataNode(LogicalDatastoreType.CONFIGURATION, equipmentIIDBuilder.build()); + } + +} diff --git a/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/dom/impl/interfaces/Onf14DomInterfacePacManager.java b/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/dom/impl/interfaces/Onf14DomInterfacePacManager.java new file mode 100644 index 000000000..eed6f5da3 --- /dev/null +++ b/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/dom/impl/interfaces/Onf14DomInterfacePacManager.java @@ -0,0 +1,458 @@ +/* + * ============LICENSE_START======================================================= + * ONAP : ccsdk features + * ================================================================================ + * Copyright (C) 2022 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.onf14.dom.impl.interfaces; + +import com.google.common.collect.Sets; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; +import java.util.Objects; +import java.util.Optional; +import org.eclipse.jdt.annotation.NonNull; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.dom.impl.Onf14DomAirInterfaceNotificationListener; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.dom.impl.Onf14DomEthernetContainerNotificationListener; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.dom.impl.Onf14DomWireInterfaceNotificationListener; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.dom.impl.dataprovider.InternalDataModelSeverity; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.dom.impl.util.Debug; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.dom.impl.util.Onf14DMDOMUtility; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.dom.impl.util.Onf14DevicemanagerQNames; +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.types.FaultData; +import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfDomAccessor; +import org.opendaylight.mdsal.common.api.LogicalDatastoreType; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DateAndTime; +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.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; + +/* +* Notifications streams provided by device NTSSim ONF14 +* Stream{getName=StreamNameType{_value=nc-notifications}, isReplaySupport=true, augmentation=[]}, +* Stream{getName=StreamNameType{_value=hybrid-mw-structure-2-0}, isReplaySupport=true, augmentation=[]}, +* Stream{getName=StreamNameType{_value=vlan-interface-1-0}, isReplaySupport=true, augmentation=[]}, +* Stream{getName=StreamNameType{_value=tdm-container-2-0}, isReplaySupport=true, augmentation=[]}, +* Stream{getName=StreamNameType{_value=ethernet-container-2-0}, isReplaySupport=true, augmentation=[]}, +* Stream{getName=StreamNameType{_value=ietf-yang-library}, isReplaySupport=false, augmentation=[]}, +* Stream{getDescription=Default NETCONF stream containing all the Event Notifications., getName=StreamNameType{_value=NETCONF}, isReplaySupport=true, augmentation=[]}, +* Stream{getName=StreamNameType{_value=vlan-fd-1-0}, isReplaySupport=true, augmentation=[]}, +* Stream{getName=StreamNameType{_value=wire-interface-2-0}, isReplaySupport=true, augmentation=[]}, +* Stream{getName=StreamNameType{_value=mac-fd-1-0}, isReplaySupport=true, augmentation=[]}, +* Stream{getName=StreamNameType{_value=co-channel-profile-1-0}, isReplaySupport=true, augmentation=[]}, +* Stream{getName=StreamNameType{_value=mac-interface-1-0}, isReplaySupport=true, augmentation=[]}, +* Stream{getName=StreamNameType{_value=ietf-keystore}, isReplaySupport=true, augmentation=[]}, +* Stream{getName=StreamNameType{_value=pure-ethernet-structure-2-0}, isReplaySupport=true, augmentation=[]}, +* Stream{getName=StreamNameType{_value=ietf-netconf-notifications}, isReplaySupport=true, augmentation=[]}, +* Stream{getName=StreamNameType{_value=mac-fc-1-0}, isReplaySupport=true, augmentation=[]}, +* Stream{getName=StreamNameType{_value=wred-profile-1-0}, isReplaySupport=true, augmentation=[]}, +* Stream{getName=StreamNameType{_value=air-interface-2-0}, isReplaySupport=true, augmentation=[]}, +* Stream{getName=StreamNameType{_value=ip-interface-1-0}, isReplaySupport=true, augmentation=[]}, +* Stream{getName=StreamNameType{_value=qos-profile-1-0}, isReplaySupport=true, augmentation=[]}, +* Stream{getName=StreamNameType{_value=vlan-fc-1-0}, isReplaySupport=true, augmentation=[]}, +* Stream{getName=StreamNameType{_value=l-3vpn-profile-1-0}, isReplaySupport=true, augmentation=[]}] +*/ + +public class Onf14DomInterfacePacManager { + + private static final Logger log = LoggerFactory.getLogger(Onf14DomInterfacePacManager.class); + + private static final YangInstanceIdentifier LTP_IID = + YangInstanceIdentifier.builder().node(Onf14DevicemanagerQNames.CORE_MODEL_CONTROL_CONSTRUCT_CONTAINER) + .node(Onf14DevicemanagerQNames.CORE_MODEL_CC_LTP).build(); + + private final NetconfDomAccessor netconfDomAccessor; + private final @NonNull DeviceManagerServiceProvider serviceProvider; + + // air interface related members + private final List airInterfaceList = new ArrayList<>(); + @NonNull + private final Onf14DomAirInterfaceNotificationListener airInterfaceNotificationListener; + + // ethernet container related members + private final List ethernetContainerList = new ArrayList<>(); + @NonNull + private final Onf14DomEthernetContainerNotificationListener ethernetContainerNotificationListener; + + // wire interface related members + private final List wireInterfaceList = new ArrayList<>(); + @NonNull + private final Onf14DomWireInterfaceNotificationListener wireInterfaceNotificationListener; + + private final @NonNull FaultService faultService; + + public Onf14DomInterfacePacManager(@NonNull NetconfDomAccessor netconfDomAccessor, + @NonNull DeviceManagerServiceProvider serviceProvider) { + + this.netconfDomAccessor = Objects.requireNonNull(netconfDomAccessor); + this.serviceProvider = Objects.requireNonNull(serviceProvider); + this.faultService = Objects.requireNonNull(serviceProvider.getFaultService()); + + this.airInterfaceNotificationListener = + new Onf14DomAirInterfaceNotificationListener(netconfDomAccessor, serviceProvider); + this.ethernetContainerNotificationListener = + new Onf14DomEthernetContainerNotificationListener(netconfDomAccessor, serviceProvider); + this.wireInterfaceNotificationListener = + new Onf14DomWireInterfaceNotificationListener(netconfDomAccessor, serviceProvider); + } + + public void register() { + // storing all the LTP UUIDs internally, for later usage, for air-interface and + // ethernet-container and wire-interface + readKeys(); + readAndWriteInterfaceCurrentProblems(); + registerForNotifications(); + } + + private void readAndWriteInterfaceCurrentProblems() { + // Read all fault data + FaultData resultList = new FaultData(); + int problems; + readAllAirInterfaceCurrentProblems(resultList); + problems = resultList.size(); + log.debug("NETCONF read air interface current problems completed. Got back {} problems.", problems); + + readAllEhernetContainerCurrentProblems(resultList); + problems = resultList.size() - problems; + log.debug("NETCONF read current problems completed. Got back {} problems.", problems); + + readAllWireInterfaceCurrentProblems(resultList); + problems = resultList.size(); + log.debug("NETCONF read wire interface current problems completed. Got back {} problems.", problems); + + faultService.initCurrentProblemStatus(netconfDomAccessor.getNodeId(), resultList); + log.debug("DB write current problems completed"); + + } + + private void readKeys() { + Optional ltpData = readLtpData(netconfDomAccessor); + log.info("LTP Data is - {}", ltpData); + if (ltpData.isPresent()) { + log.debug("In readKeys - ltpData = {}", ltpData.get()); + + MapNode ccLtp = (MapNode) ltpData.get(); + if (ccLtp != null) { + log.debug("Iterating the LTP list for node {}", netconfDomAccessor.getNodeId().getValue()); + Collection ltpList = ccLtp.body(); + + // iterating all the Logical Termination Point list + for (MapEntryNode ltp : ltpList) { + MapNode lpList = (MapNode) ltp + .childByArg(new NodeIdentifier(Onf14DevicemanagerQNames.CORE_MODEL_CC_LTP_LAYER_PROTOCOL)); + // the Layer Protocol list should contain only one item, since we have an 1:1 + // relationship between the LTP and the LP + if (lpList != null && lpList.size() != 1) { + log.debug("Layer protocol has no 1:1 relationship with the LTP."); + return; + } + // accessing the LP, which should be only 1 + Collection lp = lpList.body(); + for (MapEntryNode lpEntry : lp) { + String layerProtocolName = Onf14DMDOMUtility.getLeafValue(lpEntry, + + Onf14DevicemanagerQNames.CORE_MODEL_CC_LTP_LAYER_PROTOCOL_NAME); + if (layerProtocolName != null) { + // if the LTP has an airInterface technology extension, the layer protocol name + // is air-layer + if (layerProtocolName.contains("LAYER_PROTOCOL_NAME_TYPE_AIR_LAYER")) { + TechnologySpecificPacKeys airInterfaceKey = new TechnologySpecificPacKeys( + Onf14DMDOMUtility.getLeafValue(ltp, + Onf14DevicemanagerQNames.CORE_MODEL_CC_LTP_UUID), + Onf14DMDOMUtility.getLeafValue(lpEntry, + Onf14DevicemanagerQNames.CORE_MODEL_CC_LTP_LAYER_PROTOCOL_LOCAL_ID)); + airInterfaceList.add(airInterfaceKey); + log.debug("Adding Ltp with uuid {} and local-id {} to the air-interface list", + Onf14DMDOMUtility.getLeafValue(ltp, + Onf14DevicemanagerQNames.CORE_MODEL_CC_LTP_UUID), + Onf14DMDOMUtility.getLeafValue(lpEntry, + Onf14DevicemanagerQNames.CORE_MODEL_CC_LTP_LAYER_PROTOCOL_LOCAL_ID)); + } + // if the LTP has an ethernetContainier technology extension, the layer protocol + // name is ethernet-container-layer + else if (layerProtocolName.contains("LAYER_PROTOCOL_NAME_TYPE_ETHERNET_CONTAINER_LAYER")) { + TechnologySpecificPacKeys ethernetContainerKey = new TechnologySpecificPacKeys( + Onf14DMDOMUtility.getLeafValue(ltp, + Onf14DevicemanagerQNames.CORE_MODEL_CC_LTP_UUID), + Onf14DMDOMUtility.getLeafValue(lpEntry, + Onf14DevicemanagerQNames.CORE_MODEL_CC_LTP_LAYER_PROTOCOL_LOCAL_ID)); + ethernetContainerList.add(ethernetContainerKey); + log.debug("Adding Ltp with uuid {} and local-id {} to the ethernet-container list", + Onf14DMDOMUtility.getLeafValue(ltp, + Onf14DevicemanagerQNames.CORE_MODEL_CC_LTP_UUID), + Onf14DMDOMUtility.getLeafValue(lpEntry, + Onf14DevicemanagerQNames.CORE_MODEL_CC_LTP_LAYER_PROTOCOL_LOCAL_ID)); + } else if (layerProtocolName.contains("LAYER_PROTOCOL_NAME_TYPE_WIRE_LAYER")) { + TechnologySpecificPacKeys wireInterfaceKey = new TechnologySpecificPacKeys( + Onf14DMDOMUtility.getLeafValue(ltp, + Onf14DevicemanagerQNames.CORE_MODEL_CC_LTP_UUID), + Onf14DMDOMUtility.getLeafValue(lpEntry, + Onf14DevicemanagerQNames.CORE_MODEL_CC_LTP_LAYER_PROTOCOL_LOCAL_ID)); + wireInterfaceList.add(wireInterfaceKey); + log.debug("Adding Ltp with uuid {} and local-id {} to the wire-interface list", + Onf14DMDOMUtility.getLeafValue(ltp, + Onf14DevicemanagerQNames.CORE_MODEL_CC_LTP_UUID), + Onf14DMDOMUtility.getLeafValue(lpEntry, + Onf14DevicemanagerQNames.CORE_MODEL_CC_LTP_LAYER_PROTOCOL_LOCAL_ID)); + } + } + } + } + } + } + } + + private void readAllAirInterfaceCurrentProblems(FaultData resultList) { + + int idxStart; // Start index for debug messages + + for (TechnologySpecificPacKeys key : airInterfaceList) { + idxStart = resultList.size(); + + readAirInterfaceCurrentProblemForLtp(key.getLtpUuid(), key.getLocalId(), resultList); + Debug.debugResultList(key.getLtpUuid(), resultList, idxStart); + } + } + + private void readAllEhernetContainerCurrentProblems(FaultData resultList) { + + int idxStart; // Start index for debug messages + + for (TechnologySpecificPacKeys key : ethernetContainerList) { + idxStart = resultList.size(); + + readEthernetContainerCurrentProblemForLtp(key.getLtpUuid(), key.getLocalId(), resultList); + Debug.debugResultList(key.getLtpUuid(), resultList, idxStart); + } + } + + private void readAllWireInterfaceCurrentProblems(FaultData resultList) { + + int idxStart; // Start index for debug messages + + for (TechnologySpecificPacKeys key : wireInterfaceList) { + idxStart = resultList.size(); + + readWireInterfaceCurrentProblemForLtp(key.getLtpUuid(), key.getLocalId(), resultList); + Debug.debugResultList(key.getLtpUuid(), resultList, idxStart); + } + } + + private void readAirInterfaceCurrentProblemForLtp(String ltpUuid, String localId, FaultData resultList) { + + log.info("DBRead Get current problems for class {} from mountpoint {} for LTP uuid {} and local-id {}", + Onf14DevicemanagerQNames.AIR_INTERFACE_2_0_MODULE, netconfDomAccessor.getNodeId().getValue(), ltpUuid, + localId); + + // constructing the IID needs the augmentation exposed by the air-interface-2-0 + // model + + InstanceIdentifierBuilder layerProtocolIID = + YangInstanceIdentifier.builder().node(Onf14DevicemanagerQNames.CORE_MODEL_CONTROL_CONSTRUCT_CONTAINER) + .node(Onf14DevicemanagerQNames.CORE_MODEL_CC_LTP) + .nodeWithKey(Onf14DevicemanagerQNames.CORE_MODEL_CC_LTP, + QName.create(Onf14DevicemanagerQNames.CORE_MODEL_CC_LTP, "uuid").intern(), ltpUuid) + .node(Onf14DevicemanagerQNames.CORE_MODEL_CC_LTP_LAYER_PROTOCOL) + .nodeWithKey(Onf14DevicemanagerQNames.CORE_MODEL_CC_LTP_LAYER_PROTOCOL, QName + .create(Onf14DevicemanagerQNames.CORE_MODEL_CC_LTP_LAYER_PROTOCOL, "local-id").intern(), + localId); + + @NonNull + AugmentationIdentifier airInterfacePacIID = YangInstanceIdentifier.AugmentationIdentifier + .create(Sets.newHashSet(Onf14DevicemanagerQNames.AIR_INTERFACE_PAC)); + + InstanceIdentifierBuilder augmentedAirInterfacePacIID = + YangInstanceIdentifier.builder(layerProtocolIID.build()).node(airInterfacePacIID); + + // reading all the current-problems list for this specific LTP and LP + Optional airInterfacePacDataOpt = + netconfDomAccessor.readDataNode(LogicalDatastoreType.OPERATIONAL, augmentedAirInterfacePacIID.build()); + + if (airInterfacePacDataOpt.isPresent()) { + AugmentationNode airInterfacePacData = (AugmentationNode) airInterfacePacDataOpt.get(); + + MapNode airInterfaceCurrentProblemsList = (MapNode) airInterfacePacData + .childByArg(new NodeIdentifier(Onf14DevicemanagerQNames.AIR_INTERFACE_CURRENT_PROBLEMS_LIST)); + if (airInterfaceCurrentProblemsList != null) { + Collection airInterfaceProblemsCollection = airInterfaceCurrentProblemsList.body(); + for (MapEntryNode airInterfaceProblem : airInterfaceProblemsCollection) { + resultList.add(netconfDomAccessor.getNodeId(), + Integer.parseInt(Onf14DMDOMUtility.getLeafValue(airInterfaceProblem, + Onf14DevicemanagerQNames.AIR_INTERFACE_CURRENT_PROBLEMS_SEQ_NO)), + new DateAndTime(Onf14DMDOMUtility.getLeafValue(airInterfaceProblem, + Onf14DevicemanagerQNames.AIR_INTERFACE_CURRENT_PROBLEMS_TIMESTAMP)), + ltpUuid, + Onf14DMDOMUtility.getLeafValue(airInterfaceProblem, + Onf14DevicemanagerQNames.AIR_INTERFACE_CURRENT_PROBLEMS_PROBLEM_NAME), + InternalDataModelSeverity.mapSeverity(Onf14DMDOMUtility.getLeafValue(airInterfaceProblem, + Onf14DevicemanagerQNames.AIR_INTERFACE_CURRENT_PROBLEMS_PROBLEM_SEVERITY))); + } + } else { + log.debug("DBRead Id {} empty CurrentProblemList", ltpUuid); + } + } + } + + private void readEthernetContainerCurrentProblemForLtp(String ltpUuid, String localId, FaultData resultList) { + + log.info( + "DBRead Get current problems for Ethernet Container from mountpoint {} for LTP uuid {} and local-id {}", + netconfDomAccessor.getNodeId().getValue(), ltpUuid, localId); + + // constructing the IID needs the augmentation exposed by the + // ethernet-container-2-0 model + InstanceIdentifierBuilder layerProtocolIID = + YangInstanceIdentifier.builder().node(Onf14DevicemanagerQNames.CORE_MODEL_CONTROL_CONSTRUCT_CONTAINER) + .node(Onf14DevicemanagerQNames.CORE_MODEL_CC_LTP) + .nodeWithKey(Onf14DevicemanagerQNames.CORE_MODEL_CC_LTP, + QName.create(Onf14DevicemanagerQNames.CORE_MODEL_CC_LTP, "uuid").intern(), ltpUuid) + .node(Onf14DevicemanagerQNames.CORE_MODEL_CC_LTP_LAYER_PROTOCOL) + .nodeWithKey(Onf14DevicemanagerQNames.CORE_MODEL_CC_LTP_LAYER_PROTOCOL, QName + .create(Onf14DevicemanagerQNames.CORE_MODEL_CC_LTP_LAYER_PROTOCOL, "local-id").intern(), + localId); + + @NonNull + AugmentationIdentifier ethernetContainerIID = YangInstanceIdentifier.AugmentationIdentifier + .create(Sets.newHashSet(Onf14DevicemanagerQNames.ETHERNET_CONTAINER_PAC)); + + InstanceIdentifierBuilder augmentedEthernetContainerConfigurationIID = + YangInstanceIdentifier.builder(layerProtocolIID.build()).node(ethernetContainerIID); + + // reading all the current-problems list for this specific LTP and LP + Optional etherntContainerConfigurationOpt = netconfDomAccessor + .readDataNode(LogicalDatastoreType.OPERATIONAL, augmentedEthernetContainerConfigurationIID.build()); + + if (etherntContainerConfigurationOpt.isPresent()) { + AugmentationNode etherntContainerConfiguration = (AugmentationNode) etherntContainerConfigurationOpt.get(); + MapNode ethernetContainerCurrentProblemsList = (MapNode) etherntContainerConfiguration + .childByArg(new NodeIdentifier(Onf14DevicemanagerQNames.ETHERNET_CONTAINER_CURRENT_PROBLEMS_LIST)); + if (ethernetContainerCurrentProblemsList != null) { + Collection ethernetContainerProblemsCollection = + ethernetContainerCurrentProblemsList.body(); + for (MapEntryNode ethernetContainerProblem : ethernetContainerProblemsCollection) { + resultList.add(netconfDomAccessor.getNodeId(), + Integer.parseInt(Onf14DMDOMUtility.getLeafValue(ethernetContainerProblem, + Onf14DevicemanagerQNames.ETHERNET_CONTAINER_CURRENT_PROBLEMS_SEQ_NO)), + new DateAndTime(Onf14DMDOMUtility.getLeafValue(ethernetContainerProblem, + Onf14DevicemanagerQNames.ETHERNET_CONTAINER_CURRENT_PROBLEMS_TIMESTAMP)), + ltpUuid, + Onf14DMDOMUtility.getLeafValue(ethernetContainerProblem, + Onf14DevicemanagerQNames.ETHERNET_CONTAINER_CURRENT_PROBLEMS_PROBLEM_NAME), + InternalDataModelSeverity.mapSeverity(Onf14DMDOMUtility.getLeafValue( + ethernetContainerProblem, + Onf14DevicemanagerQNames.ETHERNET_CONTAINER_CURRENT_PROBLEMS_PROBLEM_SEVERITY))); + } + } else { + log.debug("DBRead Id {} empty CurrentProblemList", ltpUuid); + } + } + + } + + private void readWireInterfaceCurrentProblemForLtp(String ltpUuid, String localId, FaultData resultList) { + + log.info("DBRead Get current problems for Wire Interface from mountpoint {} for LTP uuid {} and local-id {}", + netconfDomAccessor.getNodeId().getValue(), ltpUuid, localId); + + // constructing the IID needs the augmentation exposed by the wire-interface-2-0 + // model + InstanceIdentifierBuilder layerProtocolIID = + YangInstanceIdentifier.builder().node(Onf14DevicemanagerQNames.CORE_MODEL_CONTROL_CONSTRUCT_CONTAINER) + .node(Onf14DevicemanagerQNames.CORE_MODEL_CC_LTP) + .nodeWithKey(Onf14DevicemanagerQNames.CORE_MODEL_CC_LTP, + QName.create(Onf14DevicemanagerQNames.CORE_MODEL_CC_LTP, "uuid").intern(), ltpUuid) + .node(Onf14DevicemanagerQNames.CORE_MODEL_CC_LTP_LAYER_PROTOCOL) + .nodeWithKey(Onf14DevicemanagerQNames.CORE_MODEL_CC_LTP_LAYER_PROTOCOL, QName + .create(Onf14DevicemanagerQNames.CORE_MODEL_CC_LTP_LAYER_PROTOCOL, "local-id").intern(), + localId); + + @NonNull + AugmentationIdentifier wireInterfacePacIID = YangInstanceIdentifier.AugmentationIdentifier + .create(Sets.newHashSet(Onf14DevicemanagerQNames.WIRE_INTERFACE_PAC)); + + InstanceIdentifierBuilder augmentedWireInterfaceConfigurationIID = + YangInstanceIdentifier.builder(layerProtocolIID.build()).node(wireInterfacePacIID); + + // reading all the current-problems list for this specific LTP and LP + Optional wireInterfaceConfigurationOpt = netconfDomAccessor + .readDataNode(LogicalDatastoreType.OPERATIONAL, augmentedWireInterfaceConfigurationIID.build()); + + if (wireInterfaceConfigurationOpt.isPresent()) { + AugmentationNode wireInterfaceConfiguration = (AugmentationNode) wireInterfaceConfigurationOpt.get(); + MapNode wireInterfaceCurrentProblemsList = (MapNode) wireInterfaceConfiguration + .childByArg(new NodeIdentifier(Onf14DevicemanagerQNames.WIRE_INTERFACE_CURRENT_PROBLEMS_LIST)); + if (wireInterfaceCurrentProblemsList != null) { + Collection wireInterfaceProblemsCollection = wireInterfaceCurrentProblemsList.body(); + for (MapEntryNode wireInterfaceProblem : wireInterfaceProblemsCollection) { + resultList.add(netconfDomAccessor.getNodeId(), + Integer.parseInt(Onf14DMDOMUtility.getLeafValue(wireInterfaceProblem, + Onf14DevicemanagerQNames.WIRE_INTERFACE_CURRENT_PROBLEMS_SEQ_NO)), + new DateAndTime(Onf14DMDOMUtility.getLeafValue(wireInterfaceProblem, + Onf14DevicemanagerQNames.WIRE_INTERFACE_CURRENT_PROBLEMS_TIMESTAMP)), + ltpUuid, + Onf14DMDOMUtility.getLeafValue(wireInterfaceProblem, + Onf14DevicemanagerQNames.WIRE_INTERFACE_CURRENT_PROBLEMS_PROBLEM_NAME), + InternalDataModelSeverity.mapSeverity(Onf14DMDOMUtility.getLeafValue(wireInterfaceProblem, + Onf14DevicemanagerQNames.WIRE_INTERFACE_CURRENT_PROBLEMS_PROBLEM_SEVERITY))); + } + } else { + log.debug("DBRead Id {} empty CurrentProblemList", ltpUuid); + } + } + + } + + private void registerForNotifications() { + QName[] airInterfaceNotifications = {Onf14DevicemanagerQNames.AIR_INTERFACE_OBJECT_CREATE_NOTIFICATION, + Onf14DevicemanagerQNames.AIR_INTERFACE_OBJECT_AVC_NOTIFICATION, + Onf14DevicemanagerQNames.AIR_INTERFACE_OBJECT_DELETE_NOTIFICATION, + Onf14DevicemanagerQNames.AIR_INTERFACE_OBJECT_PROBLEM_NOTIFICATION}; + netconfDomAccessor.doRegisterNotificationListener(airInterfaceNotificationListener, airInterfaceNotifications); + + QName[] ethernetContainerNotifications = + {Onf14DevicemanagerQNames.ETHERNET_CONTAINER_OBJECT_CREATE_NOTIFICATION, + Onf14DevicemanagerQNames.ETHERNET_CONTAINER_OBJECT_AVC_NOTIFICATION, + Onf14DevicemanagerQNames.ETHERNET_CONTAINER_OBJECT_DELETE_NOTIFICATION, + Onf14DevicemanagerQNames.ETHERNET_CONTAINER_OBJECT_PROBLEM_NOTIFICATION}; + netconfDomAccessor.doRegisterNotificationListener(ethernetContainerNotificationListener, + ethernetContainerNotifications); + + QName[] wireInterfaceNotifications = {Onf14DevicemanagerQNames.WIRE_INTERFACE_OBJECT_CREATE_NOTIFICATION, + Onf14DevicemanagerQNames.WIRE_INTERFACE_OBJECT_AVC_NOTIFICATION, + Onf14DevicemanagerQNames.WIRE_INTERFACE_OBJECT_DELETE_NOTIFICATION, + Onf14DevicemanagerQNames.WIRE_INTERFACE_OBJECT_PROBLEM_NOTIFICATION}; + netconfDomAccessor.doRegisterNotificationListener(wireInterfaceNotificationListener, + wireInterfaceNotifications); + } + + public Optional readLtpData(NetconfDomAccessor netconfDomAccessor) { + log.info("Reading Logical Termination Point data"); + return netconfDomAccessor.readDataNode(LogicalDatastoreType.CONFIGURATION, LTP_IID); + } +} diff --git a/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/dom/impl/interfaces/TechnologySpecificPacKeys.java b/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/dom/impl/interfaces/TechnologySpecificPacKeys.java new file mode 100644 index 000000000..3fcc332c0 --- /dev/null +++ b/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/dom/impl/interfaces/TechnologySpecificPacKeys.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.devicemanager.onf14.dom.impl.interfaces; + + +/** + * Defining a structure that can map the LP local-id and its corresponding LTP uuid + */ +public class TechnologySpecificPacKeys { + + private String ltpUuid; + private String localId; + + public TechnologySpecificPacKeys(String uuid, String lId) { + this.ltpUuid = uuid; + this.localId = lId; + } + + public String getLtpUuid() { + return ltpUuid; + } + + public String getLocalId() { + return localId; + } + + public void setLtpUuid(String uuid) { + this.ltpUuid = uuid; + } + + public void setLocalId(String lId) { + this.localId = lId; + } +} diff --git a/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/dom/impl/util/Debug.java b/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/dom/impl/util/Debug.java new file mode 100644 index 000000000..978c71e31 --- /dev/null +++ b/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/dom/impl/util/Debug.java @@ -0,0 +1,72 @@ +/* + * ============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.onf14.dom.impl.util; + +import org.onap.ccsdk.features.sdnr.wt.devicemanager.types.FaultData; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class Debug { + + // constants + private static final Logger log = LoggerFactory.getLogger(Debug.class); + // end of constants + + // variables + // end of variables + + // constructors + // end of constructors + + // getters and setters + // end of getters and setters + + // private methods + // end of private methods + + // public methods + /** + * LOG the newly added problems of the interface pac + * + * @param idxStart + * @param uuid + * @param resultList + */ + public static void debugResultList(String uuid, FaultData resultList, int idxStart) { + StringBuilder sb = new StringBuilder(); + int idx = 0; + for (int t = idxStart; t < resultList.size(); t++) { + sb.append(idx++); + sb.append(":{"); + sb.append(resultList.get(t)); + sb.append('}'); + } + log.debug("Found problems {} {}", uuid, sb); + } + // end of public methods + + // static methods + // end of static methods + + // private classes + // end of private classes +} diff --git a/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/dom/impl/util/Onf14DMDOMUtility.java b/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/dom/impl/util/Onf14DMDOMUtility.java new file mode 100644 index 000000000..1cae567ff --- /dev/null +++ b/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/dom/impl/util/Onf14DMDOMUtility.java @@ -0,0 +1,77 @@ +package org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.dom.impl.util; + +import com.google.common.base.VerifyException; +import java.time.Instant; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Iterator; +import java.util.List; +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 Onf14DMDOMUtility { + + public static final Logger LOG = LoggerFactory.getLogger(Onf14DMDOMUtility.class); + + private Onf14DMDOMUtility() {} + + 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"); //Ex: ImmutableLeafNode{identifier=(urn:onf:yang:air-interface-2-0?revision=2020-01-21)severity, body=(urn:onf:yang:air-interface-2-0?revision=2020-01-21)SEVERITY_TYPE_MAJOR} + String severity_ = optLeafNode.body().toString(); + return severity_.substring(severity_.indexOf(')')+1); //Any other solution?? + } + return optLeafNode.body().toString(); + } catch (VerifyException ve) { + LOG.debug("Leaf with QName {} not found", leafQName); + return null; + } + } + + public static List getLeafListValue(DataContainerNode componentEntry, QName leafListQName) { + List containsChildList = new ArrayList<>(); + 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 String getUuidFromEquipment(MapEntryNode equipment) { + LOG.debug("Equipment Identifier is {}", equipment.getIdentifier()); + NodeIdentifierWithPredicates componentKey = equipment.getIdentifier(); // list key + LOG.debug("Key Name is - {}", componentKey.keySet()); + LOG.debug("Key Value is - {}", + componentKey.getValue(Onf14DevicemanagerQNames.CORE_MODEL_CC_EQPT_GLOBAL_CLASS_UUID)); + + return componentKey.getValue(Onf14DevicemanagerQNames.CORE_MODEL_CC_EQPT_GLOBAL_CLASS_UUID).toString(); + } + + public static Instant getNotificationInstant(DOMNotification notification) { + if (notification instanceof DOMEvent) { + return ((DOMEvent) notification).getEventInstant(); + } else { + return Instant.now(); + } + } +} diff --git a/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/dom/impl/util/Onf14DevicemanagerQNames.java b/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/dom/impl/util/Onf14DevicemanagerQNames.java new file mode 100644 index 000000000..58abf021f --- /dev/null +++ b/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/dom/impl/util/Onf14DevicemanagerQNames.java @@ -0,0 +1,251 @@ +package org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.dom.impl.util; + +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 Onf14DevicemanagerQNames { + public static final QNameModule CORE_MODEL_1_4_MODULE = + QNameModule.create(XMLNamespace.of("urn:onf:yang:core-model-1-4"), Revision.of("2019-11-27")); + public static final QName CORE_MODEL_CONTROL_CONSTRUCT_CONTAINER = + QName.create(CORE_MODEL_1_4_MODULE, "control-construct"); + public static final QName CORE_MODEL_CC_TOP_LEVEL_EQPT = QName.create(CORE_MODEL_1_4_MODULE, "top-level-equipment"); + public static final QName CORE_MODEL_CC_EQPT = QName.create(CORE_MODEL_1_4_MODULE, "equipment"); + public static final QName CORE_MODEL_CC_EQPT_GLOBAL_CLASS_UUID = QName.create(CORE_MODEL_1_4_MODULE, "uuid"); + public static final QName CORE_MODEL_CC_EQPT_ACTUAL_EQUIPMENT = + QName.create(CORE_MODEL_1_4_MODULE, "actual-equipment"); + public static final QName CORE_MODEL_CC_EQPT_CONTAINED_HOLDER = + QName.create(CORE_MODEL_1_4_MODULE, "contained-holder"); + public static final QName CORE_MODEL_CC_EQPT_OCCUPYING_FRU = QName.create(CORE_MODEL_1_4_MODULE, "occupying-fru"); + public static final QName CORE_MODEL_CC_EQPT_MANUFACTURED_THING = + QName.create(CORE_MODEL_1_4_MODULE, "manufactured-thing"); + public static final QName CORE_MODEL_CC_EQPT_MANUFACTURER_PROPS = + QName.create(CORE_MODEL_1_4_MODULE, "manufacturer-properties"); + public static final QName CORE_MODEL_CC_EQPT_MANUFACTURER_NAME = + QName.create(CORE_MODEL_1_4_MODULE, "manufacturer-name"); + public static final QName CORE_MODEL_CC_EQPT_MANUFACTURER_ID = + QName.create(CORE_MODEL_1_4_MODULE, "manufacturer-identifier"); + public static final QName CORE_MODEL_CC_EQPT_ACTUAL_EQPT_EQPT_INSTANCE = + QName.create(CORE_MODEL_1_4_MODULE, "equipment-instance"); + public static final QName CORE_MODEL_CC_EQPT_ACTUAL_EQPT_EQPT_INSTANCE_SERIAL_NUM = + QName.create(CORE_MODEL_1_4_MODULE, "serial-number"); + public static final QName CORE_MODEL_CC_EQPT_ACTUAL_EQPT_EQPT_INSTANCE_MANUFACTURED_DATE = + QName.create(CORE_MODEL_1_4_MODULE, "manufactured-date"); + public static final QName CORE_MODEL_CC_EQPT_ACTUAL_EQPT_EQPT_TYPE = + QName.create(CORE_MODEL_1_4_MODULE, "equipment-type"); + public static final QName CORE_MODEL_CC_EQPT_ACTUAL_EQPT_EQPT_TYPE_VERSION = + QName.create(CORE_MODEL_1_4_MODULE, "version"); + public static final QName CORE_MODEL_CC_EQPT_ACTUAL_EQPT_EQPT_TYPE_DESCRIPTION = + QName.create(CORE_MODEL_1_4_MODULE, "description"); + public static final QName CORE_MODEL_CC_EQPT_ACTUAL_EQPT_EQPT_TYPE_MODEL_ID = + QName.create(CORE_MODEL_1_4_MODULE, "model-identifier"); + public static final QName CORE_MODEL_CC_EQPT_ACTUAL_EQPT_EQPT_TYPE_PART_TYPE_ID = + QName.create(CORE_MODEL_1_4_MODULE, "part-type-identifier"); + public static final QName CORE_MODEL_CC_EQPT_ACTUAL_EQPT_EQPT_TYPE_TYPE_NAME = + QName.create(CORE_MODEL_1_4_MODULE, "type-name"); + + + public static final QName CORE_MODEL_CC_LTP = QName.create(CORE_MODEL_1_4_MODULE, "logical-termination-point"); + public static final QName CORE_MODEL_CC_LTP_LAYER_PROTOCOL = QName.create(CORE_MODEL_1_4_MODULE, "layer-protocol"); + public static final QName CORE_MODEL_CC_LTP_LAYER_PROTOCOL_NAME = + QName.create(CORE_MODEL_1_4_MODULE, "layer-protocol-name"); + public static final QName CORE_MODEL_CC_LTP_LAYER_PROTOCOL_LOCAL_ID = + QName.create(CORE_MODEL_1_4_MODULE, "local-id"); + public static final QName CORE_MODEL_CC_LTP_UUID = QName.create(CORE_MODEL_1_4_MODULE, "uuid"); + + //Interface Notifications - common fields + private static String COUNTER = "counter"; + private static String OBJECT_ID_REF = "object-id-ref"; + private static String TIMESTAMP = "timestamp"; + // Air-interface + public static final QNameModule AIR_INTERFACE_2_0_MODULE = + QNameModule.create(XMLNamespace.of("urn:onf:yang:air-interface-2-0"), Revision.of("2020-01-21")); + public static final QName AIR_INTERFACE_PAC = QName.create(AIR_INTERFACE_2_0_MODULE, "air-interface-pac"); + public static final QName AIR_INTERFACE_CURRENT_PROBLEMS = + QName.create(AIR_INTERFACE_2_0_MODULE, "air-interface-current-problems"); + public static final QName AIR_INTERFACE_CURRENT_PROBLEMS_LIST = + QName.create(AIR_INTERFACE_2_0_MODULE, "current-problem-list"); + public static final QName AIR_INTERFACE_CURRENT_PROBLEMS_SEQ_NO = + QName.create(AIR_INTERFACE_2_0_MODULE, "sequence-number"); + public static final QName AIR_INTERFACE_CURRENT_PROBLEMS_TIMESTAMP = + QName.create(AIR_INTERFACE_2_0_MODULE, TIMESTAMP); + public static final QName AIR_INTERFACE_CURRENT_PROBLEMS_PROBLEM_NAME = + QName.create(AIR_INTERFACE_2_0_MODULE, "problem-name"); + public static final QName AIR_INTERFACE_CURRENT_PROBLEMS_PROBLEM_SEVERITY = + QName.create(AIR_INTERFACE_2_0_MODULE, "problem-severity"); + // Creation notification + public static final QName AIR_INTERFACE_OBJECT_CREATE_NOTIFICATION = + QName.create(AIR_INTERFACE_2_0_MODULE, "object-creation-notification"); + public static final QName AIR_INTERFACE_OBJECT_CREATE_NOTIFICATION_OBJECT_TYPE = + QName.create(AIR_INTERFACE_2_0_MODULE, "object-type"); + public static final QName AIR_INTERFACE_OBJECT_CREATE_NOTIFICATION_COUNTER = + QName.create(AIR_INTERFACE_2_0_MODULE, COUNTER); + public static final QName AIR_INTERFACE_OBJECT_CREATE_NOTIFICATION_TIMESTAMP = + QName.create(AIR_INTERFACE_2_0_MODULE, TIMESTAMP); + public static final QName AIR_INTERFACE_OBJECT_CREATE_NOTIFICATION_OBJECT_ID_REF = + QName.create(AIR_INTERFACE_2_0_MODULE, OBJECT_ID_REF); + //AVC notification + public static final QName AIR_INTERFACE_OBJECT_AVC_NOTIFICATION = + QName.create(AIR_INTERFACE_2_0_MODULE, "attribute-value-changed-notification"); + public static final QName AIR_INTERFACE_OBJECT_AVC_NOTIFICATION_COUNTER = + QName.create(AIR_INTERFACE_2_0_MODULE, COUNTER); + public static final QName AIR_INTERFACE_OBJECT_AVC_NOTIFICATION_TIMESTAMP = + QName.create(AIR_INTERFACE_2_0_MODULE, TIMESTAMP); + public static final QName AIR_INTERFACE_OBJECT_AVC_NOTIFICATION_OBJECT_ID_REF = + QName.create(AIR_INTERFACE_2_0_MODULE, OBJECT_ID_REF); + public static final QName AIR_INTERFACE_OBJECT_AVC_NOTIFICATION_ATTRIBUTE_NAME = + QName.create(AIR_INTERFACE_2_0_MODULE, "attribute-name"); + public static final QName AIR_INTERFACE_OBJECT_AVC_NOTIFICATION_NEW_VALUE = + QName.create(AIR_INTERFACE_2_0_MODULE, "new-value"); + //problem notification + public static final QName AIR_INTERFACE_OBJECT_PROBLEM_NOTIFICATION = + QName.create(AIR_INTERFACE_2_0_MODULE, "problem-notification"); + public static final QName AIR_INTERFACE_OBJECT_PROBLEM_NOTIFICATION_OBJECT_ID_REF = + QName.create(AIR_INTERFACE_2_0_MODULE, OBJECT_ID_REF); + public static final QName AIR_INTERFACE_OBJECT_PROBLEM_NOTIFICATION_PROBLEM = + QName.create(AIR_INTERFACE_2_0_MODULE, "problem"); + public static final QName AIR_INTERFACE_OBJECT_PROBLEM_NOTIFICATION_SEVERITY = + QName.create(AIR_INTERFACE_2_0_MODULE, "severity"); + public static final QName AIR_INTERFACE_OBJECT_PROBLEM_NOTIFICATION_COUNTER = + QName.create(AIR_INTERFACE_2_0_MODULE, COUNTER); + public static final QName AIR_INTERFACE_OBJECT_PROBLEM_NOTIFICATION_TIMESTAMP = + QName.create(AIR_INTERFACE_2_0_MODULE, TIMESTAMP); + // Delete notification + public static final QName AIR_INTERFACE_OBJECT_DELETE_NOTIFICATION = + QName.create(AIR_INTERFACE_2_0_MODULE, "object-deletion-notification"); + public static final QName AIR_INTERFACE_OBJECT_DELETE_NOTIFICATION_COUNTER = + QName.create(AIR_INTERFACE_2_0_MODULE, COUNTER); + public static final QName AIR_INTERFACE_OBJECT_DELETE_NOTIFICATION_OBJECT_ID_REF = + QName.create(AIR_INTERFACE_2_0_MODULE, OBJECT_ID_REF); + public static final QName AIR_INTERFACE_OBJECT_DELETE_NOTIFICATION_TIMESTAMP = + QName.create(AIR_INTERFACE_2_0_MODULE, TIMESTAMP); + + // Ethernet interface + public static final QNameModule ETHERNET_CONTAINER_2_0_MODULE = + QNameModule.create(XMLNamespace.of("urn:onf:yang:ethernet-container-2-0"), Revision.of("2020-01-21")); + public static final QName ETHERNET_CONTAINER_PAC = + QName.create(ETHERNET_CONTAINER_2_0_MODULE, "ethernet-container-pac"); + public static final QName ETHERNET_CONTAINER_CURRENT_PROBLEMS = + QName.create(ETHERNET_CONTAINER_2_0_MODULE, "ethernet-container-current-problems"); + public static final QName ETHERNET_CONTAINER_CURRENT_PROBLEMS_LIST = + QName.create(ETHERNET_CONTAINER_2_0_MODULE, "current-problem-list"); + public static final QName ETHERNET_CONTAINER_CURRENT_PROBLEMS_SEQ_NO = + QName.create(ETHERNET_CONTAINER_2_0_MODULE, "sequence-number"); + public static final QName ETHERNET_CONTAINER_CURRENT_PROBLEMS_TIMESTAMP = + QName.create(ETHERNET_CONTAINER_2_0_MODULE, TIMESTAMP); + public static final QName ETHERNET_CONTAINER_CURRENT_PROBLEMS_PROBLEM_NAME = + QName.create(ETHERNET_CONTAINER_2_0_MODULE, "problem-name"); + public static final QName ETHERNET_CONTAINER_CURRENT_PROBLEMS_PROBLEM_SEVERITY = + QName.create(ETHERNET_CONTAINER_2_0_MODULE, "problem-severity"); + // Creation notification + public static final QName ETHERNET_CONTAINER_OBJECT_CREATE_NOTIFICATION = + QName.create(ETHERNET_CONTAINER_2_0_MODULE, "object-creation-notification"); + public static final QName ETHERNET_CONTAINER_OBJECT_CREATE_NOTIFICATION_OBJECT_TYPE = + QName.create(ETHERNET_CONTAINER_2_0_MODULE, "object-type"); + public static final QName ETHERNET_CONTAINER_OBJECT_CREATE_NOTIFICATION_COUNTER = + QName.create(ETHERNET_CONTAINER_2_0_MODULE, COUNTER); + public static final QName ETHERNET_CONTAINER_OBJECT_CREATE_NOTIFICATION_TIMESTAMP = + QName.create(ETHERNET_CONTAINER_2_0_MODULE, TIMESTAMP); + public static final QName ETHERNET_CONTAINER_OBJECT_CREATE_NOTIFICATION_OBJECT_ID_REF = + QName.create(ETHERNET_CONTAINER_2_0_MODULE, OBJECT_ID_REF); + //AVC notification + public static final QName ETHERNET_CONTAINER_OBJECT_AVC_NOTIFICATION = + QName.create(ETHERNET_CONTAINER_2_0_MODULE, "attribute-value-changed-notification"); + public static final QName ETHERNET_CONTAINER_OBJECT_AVC_NOTIFICATION_COUNTER = + QName.create(ETHERNET_CONTAINER_2_0_MODULE, COUNTER); + public static final QName ETHERNET_CONTAINER_OBJECT_AVC_NOTIFICATION_TIMESTAMP = + QName.create(ETHERNET_CONTAINER_2_0_MODULE, TIMESTAMP); + public static final QName ETHERNET_CONTAINER_OBJECT_AVC_NOTIFICATION_OBJECT_ID_REF = + QName.create(ETHERNET_CONTAINER_2_0_MODULE, OBJECT_ID_REF); + public static final QName ETHERNET_CONTAINER_OBJECT_AVC_NOTIFICATION_ATTRIBUTE_NAME = + QName.create(ETHERNET_CONTAINER_2_0_MODULE, "attribute-name"); + public static final QName ETHERNET_CONTAINER_OBJECT_AVC_NOTIFICATION_NEW_VALUE = + QName.create(ETHERNET_CONTAINER_2_0_MODULE, "new-value"); + //problem notification + public static final QName ETHERNET_CONTAINER_OBJECT_PROBLEM_NOTIFICATION = + QName.create(ETHERNET_CONTAINER_2_0_MODULE, "problem-notification"); + public static final QName ETHERNET_CONTAINER_OBJECT_PROBLEM_NOTIFICATION_OBJECT_ID_REF = + QName.create(ETHERNET_CONTAINER_2_0_MODULE, OBJECT_ID_REF); + public static final QName ETHERNET_CONTAINER_OBJECT_PROBLEM_NOTIFICATION_PROBLEM = + QName.create(ETHERNET_CONTAINER_2_0_MODULE, "problem"); + public static final QName ETHERNET_CONTAINER_OBJECT_PROBLEM_NOTIFICATION_SEVERITY = + QName.create(ETHERNET_CONTAINER_2_0_MODULE, "severity"); + public static final QName ETHERNET_CONTAINER_OBJECT_PROBLEM_NOTIFICATION_COUNTER = + QName.create(ETHERNET_CONTAINER_2_0_MODULE, COUNTER); + public static final QName ETHERNET_CONTAINER_OBJECT_PROBLEM_NOTIFICATION_TIMESTAMP = + QName.create(ETHERNET_CONTAINER_2_0_MODULE, TIMESTAMP); + // Delete notification + public static final QName ETHERNET_CONTAINER_OBJECT_DELETE_NOTIFICATION = + QName.create(ETHERNET_CONTAINER_2_0_MODULE, "object-deletion-notification"); + public static final QName ETHERNET_CONTAINER_OBJECT_DELETE_NOTIFICATION_COUNTER = + QName.create(ETHERNET_CONTAINER_2_0_MODULE, COUNTER); + public static final QName ETHERNET_CONTAINER_OBJECT_DELETE_NOTIFICATION_OBJECT_ID_REF = + QName.create(ETHERNET_CONTAINER_2_0_MODULE, OBJECT_ID_REF); + public static final QName ETHERNET_CONTAINER_OBJECT_DELETE_NOTIFICATION_TIMESTAMP = + QName.create(ETHERNET_CONTAINER_2_0_MODULE, TIMESTAMP); + + //Wire interface + public static final QNameModule WIRE_INTERFACE_2_0_MODULE = + QNameModule.create(XMLNamespace.of("urn:onf:yang:wire-interface-2-0"), Revision.of("2020-01-23")); + public static final QName WIRE_INTERFACE_PAC = QName.create(WIRE_INTERFACE_2_0_MODULE, "wire-interface-pac"); + public static final QName WIRE_INTERFACE_CURRENT_PROBLEMS = + QName.create(WIRE_INTERFACE_2_0_MODULE, "wire-interface-current-problems"); + public static final QName WIRE_INTERFACE_CURRENT_PROBLEMS_LIST = + QName.create(WIRE_INTERFACE_2_0_MODULE, "current-problem-list"); + public static final QName WIRE_INTERFACE_CURRENT_PROBLEMS_SEQ_NO = + QName.create(WIRE_INTERFACE_2_0_MODULE, "sequence-number"); + public static final QName WIRE_INTERFACE_CURRENT_PROBLEMS_TIMESTAMP = + QName.create(WIRE_INTERFACE_2_0_MODULE, TIMESTAMP); + public static final QName WIRE_INTERFACE_CURRENT_PROBLEMS_PROBLEM_NAME = + QName.create(WIRE_INTERFACE_2_0_MODULE, "problem-name"); + public static final QName WIRE_INTERFACE_CURRENT_PROBLEMS_PROBLEM_SEVERITY = + QName.create(WIRE_INTERFACE_2_0_MODULE, "problem-severity"); + // Creation notification + public static final QName WIRE_INTERFACE_OBJECT_CREATE_NOTIFICATION = + QName.create(WIRE_INTERFACE_2_0_MODULE, "object-creation-notification"); + public static final QName WIRE_INTERFACE_OBJECT_CREATE_NOTIFICATION_OBJECT_TYPE = + QName.create(WIRE_INTERFACE_2_0_MODULE, "object-type"); + public static final QName WIRE_INTERFACE_OBJECT_CREATE_NOTIFICATION_COUNTER = + QName.create(WIRE_INTERFACE_2_0_MODULE, COUNTER); + public static final QName WIRE_INTERFACE_OBJECT_CREATE_NOTIFICATION_TIMESTAMP = + QName.create(WIRE_INTERFACE_2_0_MODULE, TIMESTAMP); + public static final QName WIRE_INTERFACE_OBJECT_CREATE_NOTIFICATION_OBJECT_ID_REF = + QName.create(WIRE_INTERFACE_2_0_MODULE, OBJECT_ID_REF); + //AVC notification + public static final QName WIRE_INTERFACE_OBJECT_AVC_NOTIFICATION = + QName.create(WIRE_INTERFACE_2_0_MODULE, "attribute-value-changed-notification"); + public static final QName WIRE_INTERFACE_OBJECT_AVC_NOTIFICATION_COUNTER = + QName.create(WIRE_INTERFACE_2_0_MODULE, COUNTER); + public static final QName WIRE_INTERFACE_OBJECT_AVC_NOTIFICATION_TIMESTAMP = + QName.create(WIRE_INTERFACE_2_0_MODULE, TIMESTAMP); + public static final QName WIRE_INTERFACE_OBJECT_AVC_NOTIFICATION_OBJECT_ID_REF = + QName.create(WIRE_INTERFACE_2_0_MODULE, OBJECT_ID_REF); + public static final QName WIRE_INTERFACE_OBJECT_AVC_NOTIFICATION_ATTRIBUTE_NAME = + QName.create(WIRE_INTERFACE_2_0_MODULE, "attribute-name"); + public static final QName WIRE_INTERFACE_OBJECT_AVC_NOTIFICATION_NEW_VALUE = + QName.create(WIRE_INTERFACE_2_0_MODULE, "new-value"); + //problem notification + public static final QName WIRE_INTERFACE_OBJECT_PROBLEM_NOTIFICATION = + QName.create(WIRE_INTERFACE_2_0_MODULE, "problem-notification"); + public static final QName WIRE_INTERFACE_OBJECT_PROBLEM_NOTIFICATION_OBJECT_ID_REF = + QName.create(WIRE_INTERFACE_2_0_MODULE, OBJECT_ID_REF); + public static final QName WIRE_INTERFACE_OBJECT_PROBLEM_NOTIFICATION_PROBLEM = + QName.create(WIRE_INTERFACE_2_0_MODULE, "problem"); + public static final QName WIRE_INTERFACE_OBJECT_PROBLEM_NOTIFICATION_SEVERITY = + QName.create(WIRE_INTERFACE_2_0_MODULE, "severity"); + public static final QName WIRE_INTERFACE_OBJECT_PROBLEM_NOTIFICATION_COUNTER = + QName.create(WIRE_INTERFACE_2_0_MODULE, COUNTER); + public static final QName WIRE_INTERFACE_OBJECT_PROBLEM_NOTIFICATION_TIMESTAMP = + QName.create(WIRE_INTERFACE_2_0_MODULE, TIMESTAMP); + // Delete notification + public static final QName WIRE_INTERFACE_OBJECT_DELETE_NOTIFICATION = + QName.create(WIRE_INTERFACE_2_0_MODULE, "object-deletion-notification"); + public static final QName WIRE_INTERFACE_OBJECT_DELETE_NOTIFICATION_COUNTER = + QName.create(WIRE_INTERFACE_2_0_MODULE, COUNTER); + public static final QName WIRE_INTERFACE_OBJECT_DELETE_NOTIFICATION_OBJECT_ID_REF = + QName.create(WIRE_INTERFACE_2_0_MODULE, OBJECT_ID_REF); + public static final QName WIRE_INTERFACE_OBJECT_DELETE_NOTIFICATION_TIMESTAMP = + QName.create(WIRE_INTERFACE_2_0_MODULE, TIMESTAMP); + +} diff --git a/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/impl/DeviceManagerOnf14Impl.java b/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/impl/DeviceManagerOnf14Impl.java deleted file mode 100644 index 5c57054ff..000000000 --- a/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/impl/DeviceManagerOnf14Impl.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - * ============LICENSE_START======================================================================== - * ONAP : ccsdk feature sdnr wt - * ================================================================================================= - * Copyright (C) 2020 highstreet technologies GmbH Intellectual Property. All rights reserved. - * ================================================================================================= - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License - * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express - * or implied. See the License for the specific language governing permissions and limitations under - * the License. - * ============LICENSE_END========================================================================== - */ -package org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.impl; - -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.service.NetconfNetworkElementService; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class DeviceManagerOnf14Impl implements AutoCloseable { - - private static final Logger LOG = LoggerFactory.getLogger(DeviceManagerOnf14Impl.class); - private static final String APPLICATION_NAME = "DeviceManagerOnf14"; - @SuppressWarnings("unused") - private static final String CONFIGURATIONFILE = "etc/devicemanager-onf14.properties"; - - - private NetconfNetworkElementService netconfNetworkElementService; - - private HtDatabaseClient htDatabaseClient; - private Boolean devicemanagerInitializationOk = false; - private FactoryRegistration resOnf; - - // Blueprint begin - public DeviceManagerOnf14Impl() { - LOG.info("Creating provider for {}", APPLICATION_NAME); - resOnf = null; - } - - public void setNetconfNetworkElementService(NetconfNetworkElementService netconfNetworkElementService) { - this.netconfNetworkElementService = netconfNetworkElementService; - } - - public void init() throws Exception { - - LOG.info("Session Initiated start {}", APPLICATION_NAME); - - resOnf = netconfNetworkElementService.registerBindingNetworkElementFactory(new Onf14NetworkElementFactory()); - - - netconfNetworkElementService.writeToEventLog(APPLICATION_NAME, "startup", "done"); - this.devicemanagerInitializationOk = true; - - LOG.info("Session Initiated end. Initialization done {}", devicemanagerInitializationOk); - } - // Blueprint end - - @Override - public void close() throws Exception { - LOG.info("closing ..."); - close(htDatabaseClient); - close(resOnf); - LOG.info("closing done"); - } - - /** - * Used to close all Services, that should support AutoCloseable Pattern - * - * @param toClose - * @throws Exception - */ - private void close(AutoCloseable... toCloseList) { - for (AutoCloseable element : toCloseList) { - if (element != null) { - try { - element.close(); - } catch (Exception e) { - LOG.warn("Fail during close: ", e); - } - } - } - } -} diff --git a/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/impl/Onf14Configuration.java b/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/impl/Onf14Configuration.java deleted file mode 100644 index 8396e8d9c..000000000 --- a/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/impl/Onf14Configuration.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * ============LICENSE_START======================================================================== - * ONAP : ccsdk feature sdnr wt - * ================================================================================================= - * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. All rights reserved. - * ================================================================================================= - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License - * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express - * or implied. See the License for the specific language governing permissions and limitations under - * the License. - * ============LICENSE_END========================================================================== - */ -package org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.impl; - -import org.onap.ccsdk.features.sdnr.wt.common.configuration.Configuration; -import org.onap.ccsdk.features.sdnr.wt.common.configuration.ConfigurationFileRepresentation; - -public class Onf14Configuration implements Configuration { - - private static final String SECTION_MARKER_DMONF = "dmonf14"; - - private static final String DEFAULT_VALUE_ENABLED = "${SDNR_ONF14_USEDOMAPI}"; - private static final String PROPERTY_KEY_USEDOMAPI = "useDomApi"; - - private final ConfigurationFileRepresentation configuration; - - public Onf14Configuration(ConfigurationFileRepresentation configuration) { - this.configuration = configuration; - this.configuration.addSection(SECTION_MARKER_DMONF); - defaults(); - } - - public boolean isUseDomApiEnabled() { - - return configuration.getPropertyBoolean(SECTION_MARKER_DMONF, PROPERTY_KEY_USEDOMAPI); - } - - @Override - public String getSectionName() { - return SECTION_MARKER_DMONF; - } - - @Override - public void defaults() { - //Add default if not available - configuration.setPropertyIfNotAvailable(SECTION_MARKER_DMONF, PROPERTY_KEY_USEDOMAPI, DEFAULT_VALUE_ENABLED); - } - -} diff --git a/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/impl/Onf14DomNetworkElement.java b/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/impl/Onf14DomNetworkElement.java deleted file mode 100644 index 177f25e1e..000000000 --- a/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/impl/Onf14DomNetworkElement.java +++ /dev/null @@ -1,218 +0,0 @@ -/* - * ============LICENSE_START======================================================================== - * ONAP : ccsdk feature sdnr wt - * ================================================================================================= - * Copyright (C) 2020 highstreet technologies GmbH Intellectual Property. All rights reserved. - * ================================================================================================= - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License - * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express - * or implied. See the License for the specific language governing permissions and limitations under - * the License. - * ============LICENSE_END========================================================================== - */ -package org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.impl; - -import java.util.List; -import java.util.Map; -import java.util.Optional; -import org.eclipse.jdt.annotation.NonNull; -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.onf14.impl.dataprovider.Onf14ToInternalDataModel; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.impl.equipment.Onf14DomEquipmentManager; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.impl.interfaces.Onf14DomInterfacePacManager; -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; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.types.FaultData; -import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfAccessor; -import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfDomAccessor; -import org.opendaylight.mdsal.common.api.LogicalDatastoreType; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netmod.notification.rev080714.netconf.streams.Stream; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netmod.notification.rev080714.netconf.streams.StreamKey; -import org.opendaylight.yang.gen.v1.urn.onf.yang.core.model._1._4.rev191127.ControlConstruct; -import org.opendaylight.yang.gen.v1.urn.onf.yang.core.model._1._4.rev191127.UniversalId; -import org.opendaylight.yang.gen.v1.urn.onf.yang.core.model._1._4.rev191127.control.construct.Equipment; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.NetworkElementConnectionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.NetworkElementDeviceType; -import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId; -import org.opendaylight.yangtools.yang.binding.DataObject; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * Representation of ONF Core model 1.4 device Top level element is "ControlConstruct" (replaces "NetworkElement" of - * older ONF Version) NOTE: This class is still under development due to unmet dependencies (especially the ones related - * to DOM notifications) in ODL. Once the dependencies are complete, this class will replace the ONF14NetworkElement - */ -public class Onf14DomNetworkElement implements NetworkElement { - - private static final Logger log = LoggerFactory.getLogger(Onf14DomNetworkElement.class); - - // protected static final InstanceIdentifier CONTROLCONSTRUCT_IID = - // InstanceIdentifier.builder(ControlConstruct.class).build(); - protected static final YangInstanceIdentifier CONTROLCONSTRUCT_IID = - YangInstanceIdentifier.builder().node(ControlConstruct.QNAME).build(); - - private final NetconfDomAccessor netconfDomAccessor; - private final DataProvider databaseService; - private final @NonNull FaultService faultService; - private final @NonNull NotificationService notificationService; - - private final Onf14ToInternalDataModel onf14Mapper; - - private final @NonNull Onf14DomEquipmentManager equipmentManager; - private final @NonNull Onf14DomInterfacePacManager interfacePacManager; - private final @NonNull String namespaceRevision; - - private boolean experimental; - - - public Onf14DomNetworkElement(NetconfDomAccessor netconfDomAccessor, DeviceManagerServiceProvider serviceProvider, - String namespaceRevision) { - log.info("Create {}", Onf14DomNetworkElement.class.getSimpleName()); - this.netconfDomAccessor = netconfDomAccessor; - this.databaseService = serviceProvider.getDataProvider(); - this.notificationService = serviceProvider.getNotificationService(); - this.faultService = serviceProvider.getFaultService(); - this.namespaceRevision = namespaceRevision; - this.onf14Mapper = new Onf14ToInternalDataModel(); - this.equipmentManager = new Onf14DomEquipmentManager(netconfDomAccessor, databaseService, onf14Mapper); - - this.interfacePacManager = new Onf14DomInterfacePacManager(netconfDomAccessor, serviceProvider); - this.experimental = false; - } - - /** - * reading the inventory (CoreModel 1.4 Equipment Model) and adding it to the DB - */ - public void initialReadFromNetworkElement() { - - //Read complete device tree - Optional oControlConstruct = readControlConstruct(netconfDomAccessor); - - if (oControlConstruct.isPresent()) { - ControlConstruct controlConstruct = oControlConstruct.get(); - - equipmentManager.setEquipmentData(controlConstruct); - - //-- Start for experimental purpose - if (experimental) { - log.warn("Experimental code activated"); - for (UniversalId uuid : equipmentManager.getEquipmentUuidList()) { - log.info("Read data with id {}", uuid); - Optional res1 = equipmentManager.readEquipmentInstance(netconfDomAccessor, uuid); - log.info("Res1: {}", res1.isPresent() ? res1.get() : "No data1"); - - /*List res2 = equipmentManager.readEquipmentList(netconfDomAccessor); - log.info("Res2: {}", res2.isPresent() ? res2.get() : "No data2");*/ - - equipmentManager.readTopLevelEquipment(netconfDomAccessor); - //Do it only once for test purpose and break - break; - } - List res2 = equipmentManager.readEquipmentList(netconfDomAccessor); - //log.info("Res2: {}", res2.isPresent() ? res2.get() : "No data2"); - for (DataObject dobj : res2) { - Equipment eqpt = (Equipment) dobj; - log.info("Equipment local ID is : {}", eqpt.getLocalId()); - } - - equipmentManager.readTopLevelEquipment(netconfDomAccessor); - } - //-- End for experimental purpose - - // storing all the LTP UUIDs internally, for later usage, for air-interface and ethernet-container - interfacePacManager.readKeys(controlConstruct); - - // Read all fault data - FaultData resultList = new FaultData(); - - int problems = faultService.removeAllCurrentProblemsOfNode(netconfDomAccessor.getNodeId()); - log.debug("Removed all {} problems from database at registration", problems); - - interfacePacManager.readAllAirInterfaceCurrentProblems(netconfDomAccessor, controlConstruct, resultList); - problems = resultList.size(); - log.debug("NETCONF read air interface current problems completed. Got back {} problems.", problems); - /* - readAllEhernetContainerCurrentProblems(resultList); - problems = resultList.size() - problems; - log.debug("NETCONF read current problems completed. Got back {} problems.", resultList.size()); - - readAllWireInterfaceCurrentProblems(resultList); - problems = resultList.size(); - log.debug("NETCONF read wire interface current problems completed. Got back {} problems.", problems); - */ - faultService.initCurrentProblemStatus(netconfDomAccessor.getNodeId(), resultList); - log.debug("DB write current problems completed"); - } - } - - /** - * @param nNode set core-model-capability - */ - public void setCoreModel() { - NetworkElementConnectionBuilder eb = new NetworkElementConnectionBuilder(); - eb.setCoreModelCapability(namespaceRevision); - databaseService.updateNetworkConnection22(eb.build(), netconfDomAccessor.getNodeId().getValue()); - } - - @Override - public void register() { - // Set core-model revision value in "core-model-capability" field - setCoreModel(); - initialReadFromNetworkElement(); - - if (netconfDomAccessor.isNotificationsRFC5277Supported()) { - // register listener - interfacePacManager.subscribeNotifications(); - // Output notification streams to LOG - Map streams = netconfDomAccessor.getNotificationStreamsAsMap(); - log.info("Available notifications streams: {}", streams); - // Register to default stream - netconfDomAccessor.invokeCreateSubscription(); - } - } - - @Override - public void deregister() {} - - - @Override - public NodeId getNodeId() { - return netconfDomAccessor.getNodeId(); - } - - @Override - public Optional getService(Class clazz) { - return Optional.empty(); - } - - @Override - public void warmstart() {} - - @Override - public Optional getAcessor() { - return Optional.of(netconfDomAccessor); - } - - @Override - public NetworkElementDeviceType getDeviceType() { - return NetworkElementDeviceType.Wireless; - } - - private static Optional readControlConstruct(NetconfDomAccessor netconfDomAccessor) { - return netconfDomAccessor.readData(LogicalDatastoreType.CONFIGURATION, CONTROLCONSTRUCT_IID, - ControlConstruct.class); - } - - - -} diff --git a/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/impl/Onf14NetworkElement.java b/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/impl/Onf14NetworkElement.java deleted file mode 100644 index 4a23b6b3c..000000000 --- a/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/impl/Onf14NetworkElement.java +++ /dev/null @@ -1,552 +0,0 @@ -/* - * ============LICENSE_START======================================================================== - * ONAP : ccsdk feature sdnr wt - * ================================================================================================= - * Copyright (C) 2020 highstreet technologies GmbH Intellectual Property. All rights reserved. - * ================================================================================================= - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License - * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express - * or implied. See the License for the specific language governing permissions and limitations under - * the License. - * ============LICENSE_END========================================================================== - */ -package org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.impl; - -import java.util.ArrayList; -import java.util.Collection; -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.common.YangHelper; -import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.DataProvider; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.ne.service.NetworkElement; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.ne.service.NetworkElementService; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.impl.dataprovider.Onf14ToInternalDataModel; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.impl.interfaces.Onf14AirInterface; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.impl.interfaces.Onf14AirInterfaceNotificationListener; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.impl.interfaces.Onf14EthernetContainer; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.impl.interfaces.Onf14EthernetContainerNotificationListener; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.impl.interfaces.Onf14WireInterface; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.impl.interfaces.Onf14WireInterfaceNotificationListener; -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.types.FaultData; -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.opendaylight.mdsal.common.api.LogicalDatastoreType; -import org.opendaylight.yang.gen.v1.urn.onf.yang.air._interface._2._0.rev200121.LAYERPROTOCOLNAMETYPEAIRLAYER; -import org.opendaylight.yang.gen.v1.urn.onf.yang.air._interface._2._0.rev200121.air._interface.lp.spec.AirInterfacePac; -import org.opendaylight.yang.gen.v1.urn.onf.yang.air._interface._2._0.rev200121.air._interface.pac.AirInterfaceCurrentProblems; -import org.opendaylight.yang.gen.v1.urn.onf.yang.core.model._1._4.rev191127.ControlConstruct; -import org.opendaylight.yang.gen.v1.urn.onf.yang.core.model._1._4.rev191127.LAYERPROTOCOLNAMETYPE; -import org.opendaylight.yang.gen.v1.urn.onf.yang.core.model._1._4.rev191127.UniversalId; -import org.opendaylight.yang.gen.v1.urn.onf.yang.core.model._1._4.rev191127.control.construct.Equipment; -import org.opendaylight.yang.gen.v1.urn.onf.yang.core.model._1._4.rev191127.control.construct.EquipmentKey; -import org.opendaylight.yang.gen.v1.urn.onf.yang.core.model._1._4.rev191127.control.construct.LogicalTerminationPoint; -import org.opendaylight.yang.gen.v1.urn.onf.yang.core.model._1._4.rev191127.control.construct.LogicalTerminationPointKey; -import org.opendaylight.yang.gen.v1.urn.onf.yang.core.model._1._4.rev191127.equipment.ContainedHolder; -import org.opendaylight.yang.gen.v1.urn.onf.yang.core.model._1._4.rev191127.logical.termination.point.LayerProtocol; -import org.opendaylight.yang.gen.v1.urn.onf.yang.core.model._1._4.rev191127.logical.termination.point.LayerProtocolKey; -import org.opendaylight.yang.gen.v1.urn.onf.yang.ethernet.container._2._0.rev200121.LAYERPROTOCOLNAMETYPEETHERNETCONTAINERLAYER; -import org.opendaylight.yang.gen.v1.urn.onf.yang.ethernet.container._2._0.rev200121.ethernet.container.lp.spec.EthernetContainerPac; -import org.opendaylight.yang.gen.v1.urn.onf.yang.ethernet.container._2._0.rev200121.ethernet.container.pac.EthernetContainerCurrentProblems; -import org.opendaylight.yang.gen.v1.urn.onf.yang.wire._interface._2._0.rev200123.LAYERPROTOCOLNAMETYPEWIRELAYER; -import org.opendaylight.yang.gen.v1.urn.onf.yang.wire._interface._2._0.rev200123.wire._interface.lp.spec.WireInterfacePac; -import org.opendaylight.yang.gen.v1.urn.onf.yang.wire._interface._2._0.rev200123.wire._interface.pac.WireInterfaceCurrentProblems; -import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.NetconfNode; -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.NetworkElementConnectionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.NetworkElementDeviceType; -import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId; -import org.opendaylight.yangtools.concepts.ListenerRegistration; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import org.opendaylight.yangtools.yang.binding.NotificationListener; -import org.opendaylight.yangtools.yang.common.QName; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * Repesentation of ONF Core model 1.4 device Top level element is "ControlConstruct" (replaces "NetworkElement" of - * older ONF Version) - */ -public class Onf14NetworkElement implements NetworkElement { - - private static final Logger log = LoggerFactory.getLogger(Onf14NetworkElement.class); - - protected static final InstanceIdentifier CONTROLCONSTRUCT_IID = - InstanceIdentifier.builder(ControlConstruct.class).build(); - - private static final int EQUIPMENTROOTLEVEL = 0; - - private final NetconfBindingAccessor netconfAccessor; - private final DataProvider databaseService; - private final Onf14ToInternalDataModel onf14Mapper; - @NonNull - private final FaultService faultService; - - // for storing the Equipment UUIDs that are inserted in the DB - private final List equipmentUuidList = new ArrayList<>(); - - // air interface related members - private final List airInterfaceList = new ArrayList<>(); - @SuppressWarnings("unused") - private ListenerRegistration airInterfaceNotificationListenerHandler; - @NonNull - private final Onf14AirInterfaceNotificationListener airInterfaceNotificationListener; - - // ethernet container related members - private final List ethernetContainerList = new ArrayList<>(); - @SuppressWarnings("unused") - private ListenerRegistration etherneContainerNotificationListenerHandler; - @NonNull - private final Onf14EthernetContainerNotificationListener ethernetContainerNotificationListener; - - // wire interface related members - private final List wireInterfaceList = new ArrayList<>(); - @SuppressWarnings("unused") - private ListenerRegistration wireInterfaceNotificationListenerHandler; - @NonNull - private final Onf14WireInterfaceNotificationListener wireInterfaceNotificationListener; - - Onf14NetworkElement(NetconfBindingAccessor netconfAccess, DeviceManagerServiceProvider serviceProvider) { - log.info("Create {}", Onf14NetworkElement.class.getSimpleName()); - this.netconfAccessor = netconfAccess; - this.databaseService = serviceProvider.getDataProvider(); - this.faultService = serviceProvider.getFaultService(); - this.onf14Mapper = new Onf14ToInternalDataModel(); - this.airInterfaceNotificationListenerHandler = null; - this.airInterfaceNotificationListener = - new Onf14AirInterfaceNotificationListener(netconfAccess, serviceProvider); - this.etherneContainerNotificationListenerHandler = null; - ethernetContainerNotificationListener = - new Onf14EthernetContainerNotificationListener(netconfAccess, serviceProvider); - this.wireInterfaceNotificationListenerHandler = null; - wireInterfaceNotificationListener = new Onf14WireInterfaceNotificationListener(netconfAccess, serviceProvider); - } - - public void initialReadFromNetworkElement() { - - // reading the inventory (CoreModel 1.4 Equipment Model) and adding it to the DB - readEquipmentData(); - - var resultList = new FaultData(); - - int problems = faultService.removeAllCurrentProblemsOfNode(netconfAccessor.getNodeId()); - log.debug("Removed all {} problems from database at registration", problems); - - readAllAirInterfaceCurrentProblems(resultList); - problems = resultList.size(); - log.debug("NETCONF read air interface current problems completed. Got back {} problems.", problems); - - readAllEhernetContainerCurrentProblems(resultList); - problems = resultList.size() - problems; - log.debug("NETCONF read current problems completed. Got back {} problems.", resultList.size()); - - readAllWireInterfaceCurrentProblems(resultList); - problems = resultList.size(); - log.debug("NETCONF read wire interface current problems completed. Got back {} problems.", problems); - - faultService.initCurrentProblemStatus(netconfAccessor.getNodeId(), resultList); - log.debug("DB write current problems completed"); - - } - - public void readAllAirInterfaceCurrentProblems(FaultData resultList) { - - int idxStart; // Start index for debug messages - - for (TechnologySpecificPacKeys key : airInterfaceList) { - idxStart = resultList.size(); - - readAirInterfaceCurrentProblemForLtp(key.getLtpUuid(), key.getLocalId(), resultList); - debugResultList(key.getLtpUuid().getValue(), resultList, idxStart); - } - } - - public void readAllEhernetContainerCurrentProblems(FaultData resultList) { - - int idxStart; // Start index for debug messages - - for (TechnologySpecificPacKeys key : ethernetContainerList) { - idxStart = resultList.size(); - - readEthernetConainerCurrentProblemForLtp(key.getLtpUuid(), key.getLocalId(), resultList); - debugResultList(key.getLtpUuid().getValue(), resultList, idxStart); - } - } - - public void readAllWireInterfaceCurrentProblems(FaultData resultList) { - - int idxStart; // Start index for debug messages - - for (TechnologySpecificPacKeys key : wireInterfaceList) { - idxStart = resultList.size(); - - readWireInterfaceCurrentProblemForLtp(key.getLtpUuid(), key.getLocalId(), resultList); - debugResultList(key.getLtpUuid().getValue(), resultList, idxStart); - } - } - - /** - * @param nNode set core-model-capability - */ - public void setCoreModel(@NonNull NetconfNode nNode) { - NetworkElementConnectionBuilder eb = new NetworkElementConnectionBuilder(); - log.info("In setCoreModel for Onf14NetworkElement"); - String namespaceRevision; - QName QNAME_COREMODEL14 = QName.create("urn:onf:yang:core-model-1-4", "2019-11-27", "core-model-1-4").intern(); - - Capabilities availableCapabilities = Capabilities.getAvailableCapabilities(nNode); - namespaceRevision = availableCapabilities.getRevisionForNamespace(QNAME_COREMODEL14); - log.info("In setCoreModel for Onf14NetworkElement- namespaceRevision = " + namespaceRevision); - if (Capabilities.isNamespaceSupported(namespaceRevision)) { - eb.setCoreModelCapability(namespaceRevision); - } else { - eb.setCoreModelCapability("Unsupported"); - } - databaseService.updateNetworkConnection22(eb.build(), netconfAccessor.getNodeId().getValue()); - } - - @Override - public void register() { - // Set core-model revision value in "core-model-capability" field - setCoreModel(netconfAccessor.getNetconfNode()); - initialReadFromNetworkElement(); - - // Register netconf stream - airInterfaceNotificationListenerHandler = - netconfAccessor.doRegisterNotificationListener(airInterfaceNotificationListener); - etherneContainerNotificationListenerHandler = - netconfAccessor.doRegisterNotificationListener(ethernetContainerNotificationListener); - wireInterfaceNotificationListenerHandler = - netconfAccessor.doRegisterNotificationListener(wireInterfaceNotificationListener); - // Register to default (NETCONF) stream - netconfAccessor.registerNotificationsStream(); - } - - @Override - public void deregister() {} - - - @Override - public NodeId getNodeId() { - return netconfAccessor.getNodeId(); - } - - @Override - public Optional getService(Class clazz) { - return Optional.empty(); - } - - @Override - public void warmstart() {} - - @Override - public Optional getAcessor() { - return Optional.of(netconfAccessor); - } - - @Override - public NetworkElementDeviceType getDeviceType() { - return NetworkElementDeviceType.Wireless; - } - - private void readEquipmentData() { - - Optional controlConstruct = readControlConstruct(netconfAccessor); - - if (controlConstruct.isPresent()) { - // the top-level-equipment list contains the root objects of the Equipment Model - log.debug("Getting list of topLevelEquipment for mountpoint {}", netconfAccessor.getNodeId()); - @Nullable - List topLevelEquipment = controlConstruct.get().getTopLevelEquipment(); - - if (topLevelEquipment != null) { - List inventoryList = new ArrayList<>(); - for (UniversalId uuid : topLevelEquipment) { - log.debug("Got back topLevelEquipment with uuid {}", uuid.getValue()); - - // adding all root Equipment objects to the DB - @Nullable - Equipment equipmentInstance = readEquipmentInstance(netconfAccessor, uuid); - if (equipmentInstance != null) { - // recursively adding the root equipment and all its children into the DB - collectEquipment(inventoryList, equipmentInstance, null, EQUIPMENTROOTLEVEL); - } - } - this.databaseService.writeInventory(this.netconfAccessor.getNodeId().getValue(), inventoryList); - } - } - - // storing all the LTP UUIDs internally, for later usage, for air-interface and ethernet-container - readKeys(controlConstruct); - } - - private List collectEquipment(List list, Equipment currentEq, Equipment parentEq, - long treeLevel) { - - // if the Equipment UUID is already in the list, it was already processed - // needed for solving possible circular dependencies - if (equipmentUuidList.contains(currentEq.getUuid().getValue())) { - log.debug("Not adding equipment with uuid {} because it was aleady added...", - currentEq.getUuid().getValue()); - return list; - } - - // we add this to our internal list, such that we avoid circular dependencies - equipmentUuidList.add(currentEq.getUuid().getValue()); - log.debug("Adding equipment with uuid {} to the database...", currentEq.getUuid().getValue()); - - // we add our current equipment to the database - list.add(onf14Mapper.getInternalEquipment(netconfAccessor.getNodeId(), currentEq, parentEq, treeLevel)); - - // we iterate the kids of our current equipment and add them to the database recursively - // the actual reference is here: /core-model:control-construct/equipment/contained-holder/occupying-fru - @NonNull - Collection holderList = YangHelper.getCollection(currentEq.nonnullContainedHolder()); - - for (ContainedHolder holder : holderList) { - @Nullable - UniversalId occupyingFru = holder.getOccupyingFru(); - if (occupyingFru != null) { - @Nullable - Equipment childEq = readEquipmentInstance(netconfAccessor, occupyingFru); - - if (childEq != null) { - // current becomes parent and tree level increases by 1 - collectEquipment(list, childEq, currentEq, treeLevel + 1); - } - } - } - return list; - } - - private void readKeys(Optional controlConstruct) { - - if (controlConstruct.isPresent()) { - @NonNull - Collection ltpList = - YangHelper.getCollection(controlConstruct.get().nonnullLogicalTerminationPoint()); - log.debug("Iterating the LTP list for node {}", netconfAccessor.getNodeId().getValue()); - - // iterating all the Logical Termination Point list - for (LogicalTerminationPoint ltp : ltpList) { - @NonNull - List lpList = YangHelper.getList(ltp.nonnullLayerProtocol()); - // the Layer Protocol list should contain only one item, since we have an 1:1 relationship between the LTP and the LP - if (lpList.size() != 1) { - log.debug("Layer protocol has no 1:1 relationship with the LTP."); - return; - } - // accessing the LP, which should be only 1 - LayerProtocol lp = lpList.get(0); - @Nullable - Class layerProtocolName = lp.getLayerProtocolName(); - if (layerProtocolName != null) { - // if the LTP has an airInterface technology extension, the layer protocol name is air-layer - if (layerProtocolName.getTypeName().equals(LAYERPROTOCOLNAMETYPEAIRLAYER.class.getName())) { - TechnologySpecificPacKeys airInterfaceKey = - new TechnologySpecificPacKeys(ltp.getUuid(), lp.getLocalId()); - airInterfaceList.add(airInterfaceKey); - log.debug("Adding Ltp with uuid {} and local-id {} to the air-interface list", - ltp.getUuid().getValue(), lp.getLocalId()); - } - // if the LTP has an ethernetContainier technology extension, the layer protocol name is ethernet-container-layer - else if (layerProtocolName.getTypeName().equals(LAYERPROTOCOLNAMETYPEETHERNETCONTAINERLAYER.class - .getName())) { - TechnologySpecificPacKeys ethernetContainerKey = - new TechnologySpecificPacKeys(ltp.getUuid(), lp.getLocalId()); - ethernetContainerList.add(ethernetContainerKey); - log.debug("Adding Ltp with uuid {} and local-id {} to the ethernet-contatinier list", - ltp.getUuid().getValue(), lp.getLocalId()); - } else if (layerProtocolName.getTypeName().equals(LAYERPROTOCOLNAMETYPEWIRELAYER.class.getName())) { - TechnologySpecificPacKeys wireInterfaceKey = - new TechnologySpecificPacKeys(ltp.getUuid(), lp.getLocalId()); - wireInterfaceList.add(wireInterfaceKey); - log.debug("Adding Ltp with uuid {} and local-id {} to the wire-interface list", - ltp.getUuid().getValue(), lp.getLocalId()); - } - } - } - } - } - - private void readAirInterfaceCurrentProblemForLtp(UniversalId ltpUuid, String localId, FaultData resultList) { - - final Class clazzPac = AirInterfacePac.class; - - log.info("DBRead Get current problems for class {} from mountpoint {} for LTP uuid {} and local-id {}", - clazzPac.getSimpleName(), netconfAccessor.getNodeId().getValue(), ltpUuid.getValue(), localId); - - // constructing the IID needs the augmentation exposed byy the air-interface-2-0 model - InstanceIdentifier airInterfaceCurrentProblem_IID = InstanceIdentifier - .builder(ControlConstruct.class) - .child(LogicalTerminationPoint.class, new LogicalTerminationPointKey(ltpUuid)) - .child(LayerProtocol.class, new LayerProtocolKey(localId)) - .augmentation( - org.opendaylight.yang.gen.v1.urn.onf.yang.air._interface._2._0.rev200121.LayerProtocol1.class) - .child(AirInterfacePac.class).child(AirInterfaceCurrentProblems.class).build(); - - // reading all the current-problems list for this specific LTP and LP - AirInterfaceCurrentProblems problems = netconfAccessor.getTransactionUtils().readData( - netconfAccessor.getDataBroker(), LogicalDatastoreType.OPERATIONAL, airInterfaceCurrentProblem_IID); - - if (problems == null) { - log.debug("DBRead Id {} no AirInterfaceCurrentProblems", ltpUuid); - } else if (problems.getCurrentProblemList() == null) { - log.debug("DBRead Id {} empty CurrentProblemList", ltpUuid); - } else { - for (org.opendaylight.yang.gen.v1.urn.onf.yang.air._interface._2._0.rev200121.air._interface.current.problems.CurrentProblemList problem : YangHelper - .getCollection(problems.nonnullCurrentProblemList())) { - resultList.add(netconfAccessor.getNodeId(), (int) problem.getSequenceNumber(), problem.getTimestamp(), - ltpUuid.getValue(), problem.getProblemName(), - Onf14AirInterface.mapSeverity(problem.getProblemSeverity())); - } - } - } - - private void readEthernetConainerCurrentProblemForLtp(UniversalId ltpUuid, String localId, FaultData resultList) { - - final Class clazzPac = EthernetContainerPac.class; - - log.info("DBRead Get current problems for class {} from mountpoint {} for LTP uuid {} and local-id {}", - clazzPac.getSimpleName(), netconfAccessor.getNodeId().getValue(), ltpUuid.getValue(), localId); - - // constructing the IID needs the augmentation exposed by the ethernet-container-2-0 model - InstanceIdentifier etherneContainerCurrentProblem_IID = InstanceIdentifier - .builder(ControlConstruct.class) - .child(LogicalTerminationPoint.class, new LogicalTerminationPointKey(ltpUuid)) - .child(LayerProtocol.class, new LayerProtocolKey(localId)) - .augmentation( - org.opendaylight.yang.gen.v1.urn.onf.yang.ethernet.container._2._0.rev200121.LayerProtocol1.class) - .child(EthernetContainerPac.class).child(EthernetContainerCurrentProblems.class).build(); - - // reading all the current-problems list for this specific LTP and LP - EthernetContainerCurrentProblems problems = netconfAccessor.getTransactionUtils().readData( - netconfAccessor.getDataBroker(), LogicalDatastoreType.OPERATIONAL, etherneContainerCurrentProblem_IID); - - if (problems == null) { - log.debug("DBRead Id {} no EthernetContainerCurrentProblems", ltpUuid); - } else if (problems.getCurrentProblemList() == null) { - log.debug("DBRead Id {} empty CurrentProblemList", ltpUuid); - } else { - for (org.opendaylight.yang.gen.v1.urn.onf.yang.ethernet.container._2._0.rev200121.ethernet.container.current.problems.CurrentProblemList problem : YangHelper - .getCollection(problems.nonnullCurrentProblemList())) { - resultList.add(netconfAccessor.getNodeId(), (int) problem.getSequenceNumber(), problem.getTimestamp(), - ltpUuid.getValue(), problem.getProblemName(), - Onf14EthernetContainer.mapSeverity(problem.getProblemSeverity())); - } - } - } - - private void readWireInterfaceCurrentProblemForLtp(UniversalId ltpUuid, String localId, FaultData resultList) { - - final Class clazzPac = WireInterfacePac.class; - - log.info("DBRead Get current problems for class {} from mountpoint {} for LTP uuid {} and local-id {}", - clazzPac.getSimpleName(), netconfAccessor.getNodeId().getValue(), ltpUuid.getValue(), localId); - - // constructing the IID needs the augmentation exposed by the wire-interface-2-0 model - InstanceIdentifier wireInterfaceCurrentProblem_IID = InstanceIdentifier - .builder(ControlConstruct.class) - .child(LogicalTerminationPoint.class, new LogicalTerminationPointKey(ltpUuid)) - .child(LayerProtocol.class, new LayerProtocolKey(localId)) - .augmentation( - org.opendaylight.yang.gen.v1.urn.onf.yang.wire._interface._2._0.rev200123.LayerProtocol1.class) - .child(WireInterfacePac.class).child(WireInterfaceCurrentProblems.class).build(); - - // reading all the current-problems list for this specific LTP and LP - WireInterfaceCurrentProblems problems = netconfAccessor.getTransactionUtils().readData( - netconfAccessor.getDataBroker(), LogicalDatastoreType.OPERATIONAL, wireInterfaceCurrentProblem_IID); - - if (problems == null) { - log.debug("DBRead Id {} no WireInterfaceCurrentProblems", ltpUuid); - } else if (problems.getCurrentProblemList() == null) { - log.debug("DBRead Id {} empty CurrentProblemList", ltpUuid); - } else { - for (org.opendaylight.yang.gen.v1.urn.onf.yang.wire._interface._2._0.rev200123.wire._interface.current.problems.CurrentProblemList problem : YangHelper - .getCollection(problems.nonnullCurrentProblemList())) { - resultList.add(netconfAccessor.getNodeId(), (int) problem.getSequenceNumber(), problem.getTimestamp(), - ltpUuid.getValue(), problem.getProblemName(), - Onf14WireInterface.mapSeverity(problem.getProblemSeverity())); - } - } - } - - private Optional readControlConstruct(NetconfBindingAccessor netconfAccessor) { - return Optional.ofNullable(netconfAccessor.getTransactionUtils().readData(netconfAccessor.getDataBroker(), - LogicalDatastoreType.CONFIGURATION, CONTROLCONSTRUCT_IID)); - } - - private @Nullable Equipment readEquipmentInstance(NetconfBindingAccessor accessData, UniversalId equipmentUuid) { - - final Class clazzPac = Equipment.class; - - log.info("DBRead Get equipment for class {} from mountpoint {} for uuid {}", clazzPac.getSimpleName(), - accessData.getNodeId().getValue(), equipmentUuid.getValue()); - - InstanceIdentifier equipmentIID = InstanceIdentifier.builder(ControlConstruct.class) - .child(Equipment.class, new EquipmentKey(equipmentUuid)).build(); - - return accessData.getTransactionUtils().readData(accessData.getDataBroker(), LogicalDatastoreType.CONFIGURATION, - equipmentIID); - } - - // defining a structure that can map the LP local-id and its corresponding LTP uuid - private class TechnologySpecificPacKeys { - - private UniversalId ltpUuid; - private String localId; - - public TechnologySpecificPacKeys(UniversalId uuid, String lId) { - this.ltpUuid = uuid; - this.localId = lId; - } - - public UniversalId getLtpUuid() { - return ltpUuid; - } - - public String getLocalId() { - return localId; - } - - @SuppressWarnings("unused") - public void setLtpUuid(UniversalId uuid) { - this.ltpUuid = uuid; - } - - @SuppressWarnings("unused") - public void setLocalId(String lId) { - this.localId = lId; - } - } - - - /** - * LOG the newly added problems of the interface pac - * - * @param idxStart - * @param uuid - * @param resultList - */ - private void debugResultList(String uuid, FaultData resultList, int idxStart) { - StringBuilder sb = new StringBuilder(); - int idx = 0; - for (int t = idxStart; t < resultList.size(); t++) { - sb.append(idx++); - sb.append(":{"); - sb.append(resultList.get(t)); - sb.append('}'); - } - log.debug("Found problems {} {}", uuid, sb); - } - -} diff --git a/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/impl/Onf14NetworkElementFactory.java b/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/impl/Onf14NetworkElementFactory.java deleted file mode 100644 index ecf53a1fa..000000000 --- a/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/impl/Onf14NetworkElementFactory.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * ============LICENSE_START======================================================================== - * ONAP : ccsdk feature sdnr wt - * ================================================================================================= - * Copyright (C) 2020 highstreet technologies GmbH Intellectual Property. All rights reserved. - * ================================================================================================= - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License - * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express - * or implied. See the License for the specific language governing permissions and limitations under - * the License. - * ============LICENSE_END========================================================================== - */ - -package org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.impl; - -import java.util.Optional; -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.service.DeviceManagerServiceProvider; -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.opendaylight.yang.gen.v1.urn.onf.yang.core.model._1._4.rev191127.ControlConstruct; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class Onf14NetworkElementFactory implements NetworkElementFactory { - - private static final Logger log = LoggerFactory.getLogger(Onf14NetworkElementFactory.class); - private Optional configuration = Optional.empty(); - - @Override - public Optional create(NetconfAccessor accessor, DeviceManagerServiceProvider serviceProvider) { - - Optional ne = Optional.empty(); - Capabilities capabilities = accessor.getCapabilites(); - if (capabilities.isSupportingNamespace(ControlConstruct.QNAME)) { - String namespaceRevision = capabilities.getRevisionForNamespace(ControlConstruct.QNAME); - - if (configuration.isPresent() && configuration.get().isUseDomApiEnabled()) { - Optional domAccessor = accessor.getNetconfDomAccessor(); - if (domAccessor.isPresent()) { - ne = Optional.of(new Onf14DomNetworkElement(domAccessor.get(), serviceProvider, namespaceRevision)); - } - } else { - Optional bindingAccessor = accessor.getNetconfBindingAccessor(); - if (bindingAccessor.isPresent()) { - ne = Optional.of(new Onf14NetworkElement(bindingAccessor.get(), serviceProvider)); - } - } - log.info("Create device:{}", ne.isPresent() ? ne.get().getClass().getSimpleName() : "not"); - } - return ne; - } - - @Override - public void init(DeviceManagerServiceProvider serviceProvider) { - configuration = Optional.of(new Onf14Configuration(serviceProvider.getConfigurationFileRepresentation())); - } -} diff --git a/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/impl/dataprovider/InternalDataModelSeverity.java b/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/impl/dataprovider/InternalDataModelSeverity.java deleted file mode 100644 index 97395f496..000000000 --- a/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/impl/dataprovider/InternalDataModelSeverity.java +++ /dev/null @@ -1,55 +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.onf14.impl.dataprovider; - -import java.util.Map; -import org.eclipse.jdt.annotation.Nullable; -import org.opendaylight.yang.gen.v1.urn.onf.yang.wire._interface._2._0.rev200123.SEVERITYTYPECRITICAL; -import org.opendaylight.yang.gen.v1.urn.onf.yang.wire._interface._2._0.rev200123.SEVERITYTYPEMAJOR; -import org.opendaylight.yang.gen.v1.urn.onf.yang.wire._interface._2._0.rev200123.SEVERITYTYPEMINOR; -import org.opendaylight.yang.gen.v1.urn.onf.yang.wire._interface._2._0.rev200123.SEVERITYTYPEWARNING; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.SeverityType; -import org.opendaylight.yangtools.yang.binding.BaseIdentity; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class InternalDataModelSeverity { - - @SuppressWarnings("unused") - private static final Logger LOG = LoggerFactory.getLogger(InternalDataModelSeverity.class); - - private static final Map SEVERITYMAP = Map.of( - SEVERITYTYPEMAJOR.class.getSimpleName(), SeverityType.Major, - SEVERITYTYPECRITICAL.class.getSimpleName(), SeverityType.Critical, - SEVERITYTYPEMINOR.class.getSimpleName(), SeverityType.Minor, - SEVERITYTYPEWARNING.class.getSimpleName(), SeverityType.Warning); - - public static SeverityType mapSeverity(@Nullable Class severity) { - SeverityType res = null; - if (severity != null) { - String severityName = severity.getSimpleName(); - res = severityName != null ? SEVERITYMAP.get(severity.getSimpleName()) : null; - } - return res == null ? SeverityType.NonAlarmed : res; - } - -} diff --git a/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/impl/dataprovider/Onf14ToInternalDataModel.java b/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/impl/dataprovider/Onf14ToInternalDataModel.java deleted file mode 100644 index 52436da61..000000000 --- a/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/impl/dataprovider/Onf14ToInternalDataModel.java +++ /dev/null @@ -1,130 +0,0 @@ -/* - * ============LICENSE_START======================================================================== - * ONAP : ccsdk feature sdnr wt - * ================================================================================================= - * Copyright (C) 2020 highstreet technologies GmbH Intellectual Property. All rights reserved. - * ================================================================================================= - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License - * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express - * or implied. See the License for the specific language governing permissions and limitations under - * the License. - * ============LICENSE_END========================================================================== - */ -package org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.impl.dataprovider; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; -import java.util.Objects; -import org.eclipse.jdt.annotation.NonNull; -import org.eclipse.jdt.annotation.Nullable; -import org.onap.ccsdk.features.sdnr.wt.common.YangHelper; -import org.opendaylight.yang.gen.v1.urn.onf.yang.core.model._1._4.rev191127.Equipment; -import org.opendaylight.yang.gen.v1.urn.onf.yang.core.model._1._4.rev191127.EquipmentInstance; -import org.opendaylight.yang.gen.v1.urn.onf.yang.core.model._1._4.rev191127.EquipmentType; -import org.opendaylight.yang.gen.v1.urn.onf.yang.core.model._1._4.rev191127.ManufacturedThing; -import org.opendaylight.yang.gen.v1.urn.onf.yang.core.model._1._4.rev191127.ManufacturerProperties; -import org.opendaylight.yang.gen.v1.urn.onf.yang.core.model._1._4.rev191127.UniversalId; -import org.opendaylight.yang.gen.v1.urn.onf.yang.core.model._1._4.rev191127.equipment.ActualEquipment; -import org.opendaylight.yang.gen.v1.urn.onf.yang.core.model._1._4.rev191127.equipment.ContainedHolder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.Inventory; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.InventoryBuilder; -import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId; -import org.opendaylight.yangtools.yang.common.Uint32; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * @author alexs - * - */ -public class Onf14ToInternalDataModel { - - private static final Logger LOG = LoggerFactory.getLogger(Onf14ToInternalDataModel.class); - - public Inventory getInternalEquipment(NodeId nodeId, Equipment currentEq, Equipment parentEq, long treeLevel) { - - Objects.requireNonNull(nodeId); - Objects.requireNonNull(currentEq); - - InventoryBuilder inventoryBuilder = new InventoryBuilder(); - String parentUuid = parentEq != null ? parentEq.getUuid().getValue() : "None"; - - @Nullable - ActualEquipment component = currentEq.getActualEquipment(); - if (component != null) { - // General - inventoryBuilder.setNodeId(nodeId.getValue()); - inventoryBuilder.setTreeLevel(Uint32.valueOf(treeLevel)); - inventoryBuilder.setUuid(currentEq.getUuid().getValue()); - inventoryBuilder.setParentUuid(parentUuid); - - List containedHolderKeyList = new ArrayList(); - @NonNull - Collection containedHolderList = - YangHelper.getCollection(currentEq.nonnullContainedHolder()); - for (ContainedHolder holder : containedHolderList) { - @Nullable - UniversalId occupyingFru = holder.getOccupyingFru(); - - if (occupyingFru != null) { - containedHolderKeyList.add(occupyingFru.getValue()); - } - } - inventoryBuilder.setContainedHolder(containedHolderKeyList); - - @Nullable - ManufacturedThing manThing = component.getManufacturedThing(); - if (manThing != null) { - // Manufacturer properties - @Nullable - ManufacturerProperties manProp = manThing.getManufacturerProperties(); - if (manProp != null) { - inventoryBuilder.setManufacturerName(manProp.getManufacturerName()); - inventoryBuilder.setManufacturerIdentifier(manProp.getManufacturerIdentifier()); - } else { - LOG.debug("manufacturer-properties is not present in Equipment with uuid={}", - currentEq.getUuid().getValue()); - } - - // Equipment instance - @Nullable - EquipmentInstance eqInstance = manThing.getEquipmentInstance(); - if (eqInstance != null) { - inventoryBuilder.setSerial(eqInstance.getSerialNumber()); - inventoryBuilder.setDate(eqInstance.getManufactureDate().getValue()); - } else { - LOG.debug("equipment-instance is not present in Equipment with uuid={}", - currentEq.getUuid().getValue()); - } - - // Equipment type - @Nullable - EquipmentType eqType = manThing.getEquipmentType(); - if (eqType != null) { - inventoryBuilder.setVersion(eqType.getVersion()); - inventoryBuilder.setDescription(eqType.getDescription()); - inventoryBuilder.setPartTypeId(eqType.getPartTypeIdentifier()); - inventoryBuilder.setModelIdentifier(eqType.getModelIdentifier()); - inventoryBuilder.setTypeName(eqType.getTypeName()); - } else { - LOG.debug("equipment-type is not present in Equipment with uuid={}", - currentEq.getUuid().getValue()); - } - } else { - LOG.debug("manufactured-thing is not present in Equipment with uuid={}", - currentEq.getUuid().getValue()); - } - } else { - LOG.debug("actual-equipment is not present in Equipment with uuid={}", currentEq.getUuid().getValue()); - } - - return inventoryBuilder.build(); - } - -} diff --git a/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/impl/equipment/Onf14DomEquipmentManager.java b/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/impl/equipment/Onf14DomEquipmentManager.java deleted file mode 100644 index 092ad4a8f..000000000 --- a/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/impl/equipment/Onf14DomEquipmentManager.java +++ /dev/null @@ -1,265 +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.onf14.impl.equipment; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; -import java.util.stream.Collectors; -import org.eclipse.jdt.annotation.NonNull; -import org.eclipse.jdt.annotation.Nullable; -import org.onap.ccsdk.features.sdnr.wt.common.YangHelper; -import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.DataProvider; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.impl.dataprovider.Onf14ToInternalDataModel; -import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfDomAccessor; -import org.opendaylight.mdsal.binding.dom.codec.api.BindingNormalizedNodeSerializer; -import org.opendaylight.mdsal.common.api.LogicalDatastoreType; -import org.opendaylight.yang.gen.v1.urn.onf.yang.core.model._1._4.rev191127.ControlConstruct; -import org.opendaylight.yang.gen.v1.urn.onf.yang.core.model._1._4.rev191127.UniversalId; -import org.opendaylight.yang.gen.v1.urn.onf.yang.core.model._1._4.rev191127.control.construct.Equipment; -import org.opendaylight.yang.gen.v1.urn.onf.yang.core.model._1._4.rev191127.control.construct.EquipmentKey; -import org.opendaylight.yang.gen.v1.urn.onf.yang.core.model._1._4.rev191127.equipment.ContainedHolder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.Inventory; -import org.opendaylight.yangtools.util.UnmodifiableCollection; -import org.opendaylight.yangtools.yang.binding.CodeHelpers; -import org.opendaylight.yangtools.yang.binding.DataObject; -import org.opendaylight.yangtools.yang.common.QName; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.InstanceIdentifierBuilder; -import org.opendaylight.yangtools.yang.data.api.schema.LeafSetEntryNode; -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 Onf14DomEquipmentManager { - - - // constants - private static final Logger log = LoggerFactory.getLogger(Onf14DomEquipmentManager.class); - private static final int EQUIPMENTROOTLEVEL = 0; - // end of constants - - // variables - private final NetconfDomAccessor netconfDomAccessor; - private final DataProvider databaseService; - private final Onf14ToInternalDataModel onf14Mapper; - // for storing the Equipment UUIDs that are inserted in the DB - private final List equipmentUuidList; - // end of variables - private final BindingNormalizedNodeSerializer serializer; - - // constructors - public Onf14DomEquipmentManager(NetconfDomAccessor netconfDomAccessor, DataProvider databaseService, - Onf14ToInternalDataModel onf14Mapper) { - super(); - this.netconfDomAccessor = Objects.requireNonNull(netconfDomAccessor); - this.databaseService = Objects.requireNonNull(databaseService); - this.onf14Mapper = Objects.requireNonNull(onf14Mapper); - this.serializer = Objects.requireNonNull(netconfDomAccessor.getBindingNormalizedNodeSerializer()); - - this.equipmentUuidList = new ArrayList<>(); - } - // end of constructors - - // getters and setters - public List getEquipmentUuidList() { - return equipmentUuidList; - } - // end of getters and setters - - // private methods - private List collectEquipment(List list, Equipment currentEq, Equipment parentEq, - long treeLevel, Map equipmentMap, EquipmentKey equipmentKey) { - Objects.requireNonNull(list); - if (currentEq == null) { - log.info("Ignore empty equipment with key {}", equipmentKey); - return list; - } - - // if the Equipment UUID is already in the list, it was already processed - // needed for solving possible circular dependencies - if (equipmentUuidList.contains(currentEq.getUuid())) { - log.debug("Not adding equipment with uuid {} because it was aleady added...", - currentEq.getUuid().getValue()); - return list; - } - - // we add this to our internal list, such that we avoid circular dependencies - equipmentUuidList.add(currentEq.getUuid()); - log.debug("Adding equipment with uuid {} to the database...", currentEq.getUuid().getValue()); - - // we add our current equipment to the database - list.add(onf14Mapper.getInternalEquipment(netconfDomAccessor.getNodeId(), currentEq, parentEq, treeLevel)); - - // we iterate the kids of our current equipment and add them to the database recursively - // the actual reference is here: /core-model:control-construct/equipment/contained-holder/occupying-fru - for (ContainedHolder holder : YangHelper.getCollection(currentEq.nonnullContainedHolder())) { - @Nullable - UniversalId occupyingFru = holder.getOccupyingFru(); - if (occupyingFru != null) { - equipmentKey = new EquipmentKey(occupyingFru); - collectEquipment(list, equipmentMap.get(equipmentKey), currentEq, treeLevel + 1, equipmentMap, - equipmentKey); - } - } - return list; - } - // end of private methods - - // public methods - /** - * Set all equipment data from controlConstruct into database and into this manager. - * - * @param controlConstruct with complete device data - */ - public void setEquipmentData(ControlConstruct controlConstruct) { - Objects.requireNonNull(controlConstruct); - - // the top-level-equipment list contains the root objects of the Equipment Model - log.debug("Getting list of topLevelEquipment for mountpoint {}", netconfDomAccessor.getNodeId()); - // adding all root Equipment objects to the DB - for (UniversalId uuid : CodeHelpers.nonnull(controlConstruct.getTopLevelEquipment())) { - log.debug("Got back topLevelEquipment with uuid {}", uuid.getValue()); - EquipmentKey equipmentKey = new EquipmentKey(uuid); - - // adding all root Equipment objects to the DB - Map equipmentMap = controlConstruct.nonnullEquipment(); - // recursively adding the root equipment and all its children into the DB - List dbInventory = collectEquipment(new ArrayList<>(), equipmentMap.get(equipmentKey), null, - EQUIPMENTROOTLEVEL, equipmentMap, equipmentKey); - this.databaseService.writeInventory(netconfDomAccessor.getNodeId().getValue(), dbInventory); - } - } - - /** - * Experimental see section in {@link #Onf14DomNetworkElement.initialReadFromNetworkElement()} - * Read one equipment from device - * - * @param accessData to access device - * @param equipmentUuid uuid of equipment to be read - * @return Optional Equipment - */ - public Optional readEquipmentInstance(NetconfDomAccessor accessData, UniversalId equipmentUuid) { - - final Class clazzPac = Equipment.class; - - log.info("DBRead Get equipment for class {} from mountpoint {} for uuid {}", clazzPac.getSimpleName(), - accessData.getNodeId().getValue(), equipmentUuid.getValue()); - - InstanceIdentifierBuilder equipmentIIDBuilder = - YangInstanceIdentifier.builder().node(ControlConstruct.QNAME).node(Equipment.QNAME).nodeWithKey( - Equipment.QNAME, QName.create(Equipment.QNAME, "uuid").intern(), equipmentUuid.getValue()); - - return accessData.readData(LogicalDatastoreType.CONFIGURATION, equipmentIIDBuilder.build(), Equipment.class); - } - - /** - * Experimental see section in {@link #Onf14DomNetworkElement.initialReadFromNetworkElement()} - * Read one equipment list from device. - * - * @param accessData to access device - * @param equipmentUuid uuid of equipment to be read - * @return Optional Equipment - */ - public List readEquipmentList(NetconfDomAccessor accessData) { - log.info("DBRead Get equipment-list for mountpoint {} ", accessData.getNodeId().getValue()); - - InstanceIdentifierBuilder equipmentIIDBuilder = - YangInstanceIdentifier.builder().node(ControlConstruct.QNAME).node(Equipment.QNAME); - - InstanceIdentifierBuilder equipmentIIDBuilderOnly = YangInstanceIdentifier.builder().node(Equipment.QNAME); - - Optional> oData = - accessData.readDataNode(LogicalDatastoreType.CONFIGURATION, equipmentIIDBuilder.build()); - if (oData.isPresent()) { - NormalizedNode data = oData.get(); - - log.debug("convertNormalizedNode data identifier: {} data nodetype: {}", data.getIdentifier(), - data.getNodeType()); - final List mapEntries1 = ((MapNode) data).getValue().stream().map(mapEntryNode -> { - final YangInstanceIdentifier mapEntryPath = - equipmentIIDBuilderOnly.build().node(mapEntryNode.getIdentifier()); - return serializer.fromNormalizedNode(mapEntryPath, mapEntryNode).getValue(); - }).collect(Collectors.toList()); - return mapEntries1; - } else { - log.warn("Device does not provide any equipment"); - return Collections.emptyList(); - } - } - - /** - * Experimental see section in {@link #Onf14DomNetworkElement.initialReadFromNetworkElement()} - * Read one equipment list from device - * - * @param accessData to access device - * @param equipmentUuid uuid of equipment to be read - * @return Optional Equipment - */ - public void readTopLevelEquipment(NetconfDomAccessor accessData) { - - log.info("DBRead Get top-level-equipment for mountpoint {}", accessData.getNodeId().getValue()); - - InstanceIdentifierBuilder equipmentIIDBuilder = YangInstanceIdentifier.builder().node(ControlConstruct.QNAME) - .node(QName.create(ControlConstruct.QNAME, "top-level-equipment")); - - Optional> oData = - accessData.readDataNode(LogicalDatastoreType.CONFIGURATION, equipmentIIDBuilder.build()); - log.info("Checking for existence of data"); - if (oData.isPresent()) { - log.info("data exists"); - NormalizedNode data = oData.get(); - Object value = data.getValue(); - log.info("DataNode: {} {}", data.getNodeType(), data.getIdentifier()); - if (value != null) { - log.info("DataNode value: {} {}", value.getClass().getName(), value); - if (value instanceof UnmodifiableCollection) { - @SuppressWarnings("unchecked") - UnmodifiableCollection> topLevelEquipmentCollection = - (UnmodifiableCollection>) value; - @NonNull - Iterator> it = topLevelEquipmentCollection.iterator(); - while (it.hasNext()) { - LeafSetEntryNode topLevelEquipmentUuid = it.next(); - if (topLevelEquipmentUuid != null) { - log.info("LeafSetEntryNode: {} {} {}", topLevelEquipmentUuid.getValue(), - topLevelEquipmentUuid.getNodeType(), - topLevelEquipmentUuid.getValue().getClass().getName()); - } - } - } - } - } - } - // end of public methods - - // static methods - // end of static methods - - // private classes - // end of private classes -} diff --git a/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/impl/interfaces/Onf14AirInterface.java b/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/impl/interfaces/Onf14AirInterface.java deleted file mode 100644 index 2d0d3c52d..000000000 --- a/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/impl/interfaces/Onf14AirInterface.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * ============LICENSE_START======================================================================== - * ONAP : ccsdk feature sdnr wt - * ================================================================================================= - * Copyright (C) 2020 highstreet technologies GmbH Intellectual Property. All rights reserved. - * ================================================================================================= - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License - * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express - * or implied. See the License for the specific language governing permissions and limitations under - * the License. - * ============LICENSE_END========================================================================== - */ -package org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.impl.interfaces; - -import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.impl.dataprovider.InternalDataModelSeverity; -import org.opendaylight.yang.gen.v1.urn.onf.yang.air._interface._2._0.rev200121.SEVERITYTYPE; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.SeverityType; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * @author alexs - * - */ -public class Onf14AirInterface { - - @SuppressWarnings("unused") - private static final Logger LOG = LoggerFactory.getLogger(Onf14AirInterface.class); - - public static SeverityType mapSeverity( - Class severity) { - return InternalDataModelSeverity.mapSeverity(severity); - } -} diff --git a/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/impl/interfaces/Onf14AirInterfaceNotificationListener.java b/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/impl/interfaces/Onf14AirInterfaceNotificationListener.java deleted file mode 100644 index 1f3f30927..000000000 --- a/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/impl/interfaces/Onf14AirInterfaceNotificationListener.java +++ /dev/null @@ -1,146 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * ONAP : ccsdk feature sdnr wt - * ================================================================================ - * Copyright (C) 2020 highstreet technologies GmbH Intellectual Property. - * All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - * - */ -package org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.impl.interfaces; - -import java.util.HashMap; -import java.util.Map; -import org.eclipse.jdt.annotation.NonNull; -import org.eclipse.jdt.annotation.Nullable; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.DeviceManagerServiceProvider; -import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfAccessor; -import org.opendaylight.mdsal.dom.api.DOMNotification; -import org.opendaylight.mdsal.dom.api.DOMNotificationListener; -import org.opendaylight.yang.gen.v1.urn.onf.yang.air._interface._2._0.rev200121.AirInterface20Listener; -import org.opendaylight.yang.gen.v1.urn.onf.yang.air._interface._2._0.rev200121.AttributeValueChangedNotification; -import org.opendaylight.yang.gen.v1.urn.onf.yang.air._interface._2._0.rev200121.ObjectCreationNotification; -import org.opendaylight.yang.gen.v1.urn.onf.yang.air._interface._2._0.rev200121.ObjectDeletionNotification; -import org.opendaylight.yang.gen.v1.urn.onf.yang.air._interface._2._0.rev200121.ProblemNotification; -import org.opendaylight.yang.gen.v1.urn.onf.yang.air._interface._2._0.rev200121.SEVERITYTYPE; -import org.opendaylight.yang.gen.v1.urn.onf.yang.air._interface._2._0.rev200121.SEVERITYTYPECRITICAL; -import org.opendaylight.yang.gen.v1.urn.onf.yang.air._interface._2._0.rev200121.SEVERITYTYPEMAJOR; -import org.opendaylight.yang.gen.v1.urn.onf.yang.air._interface._2._0.rev200121.SEVERITYTYPEMINOR; -import org.opendaylight.yang.gen.v1.urn.onf.yang.air._interface._2._0.rev200121.SEVERITYTYPENONALARMED; -import org.opendaylight.yang.gen.v1.urn.onf.yang.air._interface._2._0.rev200121.SEVERITYTYPEWARNING; -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.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.SeverityType; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.SourceType; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class Onf14AirInterfaceNotificationListener implements AirInterface20Listener, DOMNotificationListener { - - private static final Logger log = LoggerFactory.getLogger(Onf14AirInterfaceNotificationListener.class); - - private final NetconfAccessor netconfAccessor; - private final DeviceManagerServiceProvider serviceProvider; - - private static final Map,SeverityType> severityMap = initSeverityMap(); - - public Onf14AirInterfaceNotificationListener(NetconfAccessor netconfAccessor, - DeviceManagerServiceProvider serviceProvider) { - this.netconfAccessor = netconfAccessor; - this.serviceProvider = serviceProvider; - } - - private static Map, SeverityType> initSeverityMap() { - Map, SeverityType> map = new HashMap<>(); - map.put(SEVERITYTYPECRITICAL.class,SeverityType.Critical); - map.put(SEVERITYTYPEMAJOR.class,SeverityType.Major); - map.put(SEVERITYTYPEMINOR.class,SeverityType.Minor); - map.put(SEVERITYTYPEWARNING.class,SeverityType.Warning); - map.put(SEVERITYTYPENONALARMED.class,SeverityType.NonAlarmed); - return map; - } - - @Override - public void onObjectDeletionNotification(ObjectDeletionNotification notification) { - log.debug("Got event of type :: {}", ObjectDeletionNotification.class.getSimpleName()); - - EventlogBuilder eventlogBuilder = new EventlogBuilder(); - eventlogBuilder.setNodeId(netconfAccessor.getNodeId().getValue()).setAttributeName("") - .setCounter(notification.getCounter()).setNewValue("deleted") - .setObjectId(notification.getObjectIdRef().getValue()).setSourceType(SourceType.Netconf) - .setTimestamp(notification.getTimestamp()); - serviceProvider.getDataProvider().writeEventLog(eventlogBuilder.build()); - serviceProvider.getWebsocketService().sendNotification(notification, netconfAccessor.getNodeId(), - ObjectDeletionNotification.QNAME, notification.getTimestamp()); - - log.debug("onObjectDeletionNotification log entry written"); - } - - @Override - public void onProblemNotification(ProblemNotification notification) { - log.debug("Got event of type :: {}", ProblemNotification.class.getSimpleName()); - FaultlogEntity faultAlarm = new FaultlogBuilder().setObjectId(notification.getObjectIdRef().getValue()) - .setProblem(notification.getProblem()).setSourceType(SourceType.Netconf) - .setTimestamp(notification.getTimestamp()) - .setNodeId(this.netconfAccessor.getNodeId().getValue()) - .setSeverity(mapSeverity(notification.getSeverity())).setCounter(notification.getCounter()) - .build(); - serviceProvider.getFaultService().faultNotification(faultAlarm); - serviceProvider.getWebsocketService().sendNotification(notification, netconfAccessor.getNodeId(), - ProblemNotification.QNAME, notification.getTimestamp()); - - } - - private SeverityType mapSeverity(@Nullable Class severity) { - return severityMap.getOrDefault(severity,SeverityType.NonAlarmed); - } - - @Override - public void onAttributeValueChangedNotification(AttributeValueChangedNotification notification) { - log.debug("Got event of type :: {}", AttributeValueChangedNotification.class.getSimpleName()); - - EventlogBuilder eventlogBuilder = new EventlogBuilder(); - eventlogBuilder.setNodeId(netconfAccessor.getNodeId().getValue()) - .setAttributeName(notification.getAttributeName()).setCounter(notification.getCounter()) - .setNewValue(notification.getNewValue()).setObjectId(notification.getObjectIdRef().getValue()) - .setSourceType(SourceType.Netconf).setTimestamp(notification.getTimestamp()); - serviceProvider.getDataProvider().writeEventLog(eventlogBuilder.build()); - serviceProvider.getWebsocketService().sendNotification(notification, netconfAccessor.getNodeId(), - AttributeValueChangedNotification.QNAME, notification.getTimestamp()); - log.debug("onAttributeValueChangedNotification log entry written"); - } - - @Override - public void onObjectCreationNotification(ObjectCreationNotification notification) { - log.debug("Got event of type :: {}", ObjectCreationNotification.class.getSimpleName()); - - EventlogBuilder eventlogBuilder = new EventlogBuilder(); - eventlogBuilder.setNodeId(netconfAccessor.getNodeId().getValue()).setAttributeName(notification.getObjectType()) - .setCounter(notification.getCounter()).setNewValue("created") - .setObjectId(notification.getObjectIdRef().getValue()).setSourceType(SourceType.Netconf) - .setTimestamp(notification.getTimestamp()); - serviceProvider.getDataProvider().writeEventLog(eventlogBuilder.build()); - serviceProvider.getWebsocketService().sendNotification(notification, netconfAccessor.getNodeId(), - ObjectCreationNotification.QNAME, notification.getTimestamp()); - log.debug("onObjectCreationNotification log entry written"); - } - - @Override - public void onNotification(@NonNull DOMNotification notification) { - - } - -} diff --git a/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/impl/interfaces/Onf14DomInterfacePacManager.java b/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/impl/interfaces/Onf14DomInterfacePacManager.java deleted file mode 100644 index 422f6b0fa..000000000 --- a/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/impl/interfaces/Onf14DomInterfacePacManager.java +++ /dev/null @@ -1,419 +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.onf14.impl.interfaces; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import org.eclipse.jdt.annotation.NonNull; -import org.eclipse.jdt.annotation.Nullable; -import org.onap.ccsdk.features.sdnr.wt.common.YangHelper; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.impl.equipment.Onf14DomEquipmentManager; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.impl.util.Debug; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.DeviceManagerServiceProvider; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.types.FaultData; -import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfDomAccessor; -import org.opendaylight.mdsal.binding.dom.codec.api.BindingNormalizedNodeSerializer; -import org.opendaylight.mdsal.dom.api.DOMNotification; -import org.opendaylight.mdsal.dom.api.DOMNotificationListener; -import org.opendaylight.yang.gen.v1.urn.onf.yang.air._interface._2._0.rev200121.AttributeValueChangedNotification; -import org.opendaylight.yang.gen.v1.urn.onf.yang.air._interface._2._0.rev200121.LAYERPROTOCOLNAMETYPEAIRLAYER; -import org.opendaylight.yang.gen.v1.urn.onf.yang.air._interface._2._0.rev200121.LayerProtocol1; -import org.opendaylight.yang.gen.v1.urn.onf.yang.air._interface._2._0.rev200121.ObjectCreationNotification; -import org.opendaylight.yang.gen.v1.urn.onf.yang.air._interface._2._0.rev200121.ObjectDeletionNotification; -import org.opendaylight.yang.gen.v1.urn.onf.yang.air._interface._2._0.rev200121.ProblemNotification; -import org.opendaylight.yang.gen.v1.urn.onf.yang.air._interface._2._0.rev200121.air._interface.lp.spec.AirInterfacePac; -import org.opendaylight.yang.gen.v1.urn.onf.yang.air._interface._2._0.rev200121.air._interface.pac.AirInterfaceCurrentProblems; -import org.opendaylight.yang.gen.v1.urn.onf.yang.core.model._1._4.rev191127.ControlConstruct; -import org.opendaylight.yang.gen.v1.urn.onf.yang.core.model._1._4.rev191127.LAYERPROTOCOLNAMETYPE; -import org.opendaylight.yang.gen.v1.urn.onf.yang.core.model._1._4.rev191127.UniversalId; -import org.opendaylight.yang.gen.v1.urn.onf.yang.core.model._1._4.rev191127.control.construct.LogicalTerminationPoint; -import org.opendaylight.yang.gen.v1.urn.onf.yang.core.model._1._4.rev191127.control.construct.LogicalTerminationPointKey; -import org.opendaylight.yang.gen.v1.urn.onf.yang.core.model._1._4.rev191127.logical.termination.point.LayerProtocol; -import org.opendaylight.yang.gen.v1.urn.onf.yang.core.model._1._4.rev191127.logical.termination.point.LayerProtocolKey; -import org.opendaylight.yang.gen.v1.urn.onf.yang.ethernet.container._2._0.rev200121.LAYERPROTOCOLNAMETYPEETHERNETCONTAINERLAYER; -import org.opendaylight.yang.gen.v1.urn.onf.yang.wire._interface._2._0.rev200123.LAYERPROTOCOLNAMETYPEWIRELAYER; -import org.opendaylight.yangtools.yang.binding.Notification; -import org.opendaylight.yangtools.yang.common.QName; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/* -* Notifications streams provided by device NTSSim ONF14 -* Stream{getName=StreamNameType{_value=nc-notifications}, isReplaySupport=true, augmentation=[]}, -* Stream{getName=StreamNameType{_value=hybrid-mw-structure-2-0}, isReplaySupport=true, augmentation=[]}, -* Stream{getName=StreamNameType{_value=vlan-interface-1-0}, isReplaySupport=true, augmentation=[]}, -* Stream{getName=StreamNameType{_value=tdm-container-2-0}, isReplaySupport=true, augmentation=[]}, -* Stream{getName=StreamNameType{_value=ethernet-container-2-0}, isReplaySupport=true, augmentation=[]}, -* Stream{getName=StreamNameType{_value=ietf-yang-library}, isReplaySupport=false, augmentation=[]}, -* Stream{getDescription=Default NETCONF stream containing all the Event Notifications., getName=StreamNameType{_value=NETCONF}, isReplaySupport=true, augmentation=[]}, -* Stream{getName=StreamNameType{_value=vlan-fd-1-0}, isReplaySupport=true, augmentation=[]}, -* Stream{getName=StreamNameType{_value=wire-interface-2-0}, isReplaySupport=true, augmentation=[]}, -* Stream{getName=StreamNameType{_value=mac-fd-1-0}, isReplaySupport=true, augmentation=[]}, -* Stream{getName=StreamNameType{_value=co-channel-profile-1-0}, isReplaySupport=true, augmentation=[]}, -* Stream{getName=StreamNameType{_value=mac-interface-1-0}, isReplaySupport=true, augmentation=[]}, -* Stream{getName=StreamNameType{_value=ietf-keystore}, isReplaySupport=true, augmentation=[]}, -* Stream{getName=StreamNameType{_value=pure-ethernet-structure-2-0}, isReplaySupport=true, augmentation=[]}, -* Stream{getName=StreamNameType{_value=ietf-netconf-notifications}, isReplaySupport=true, augmentation=[]}, -* Stream{getName=StreamNameType{_value=mac-fc-1-0}, isReplaySupport=true, augmentation=[]}, -* Stream{getName=StreamNameType{_value=wred-profile-1-0}, isReplaySupport=true, augmentation=[]}, -* Stream{getName=StreamNameType{_value=air-interface-2-0}, isReplaySupport=true, augmentation=[]}, -* Stream{getName=StreamNameType{_value=ip-interface-1-0}, isReplaySupport=true, augmentation=[]}, -* Stream{getName=StreamNameType{_value=qos-profile-1-0}, isReplaySupport=true, augmentation=[]}, -* Stream{getName=StreamNameType{_value=vlan-fc-1-0}, isReplaySupport=true, augmentation=[]}, -* Stream{getName=StreamNameType{_value=l-3vpn-profile-1-0}, isReplaySupport=true, augmentation=[]}] -*/ - -public class Onf14DomInterfacePacManager implements DOMNotificationListener { - - // constants - private static final Logger log = LoggerFactory.getLogger(Onf14DomEquipmentManager.class); - // end of constants - - // variables - private final NetconfDomAccessor netconfDomAccessor; - private final @NonNull DeviceManagerServiceProvider serviceProvider; - - // air interface related members - private final List airInterfaceList = new ArrayList(); - private @NonNull final Onf14AirInterfaceNotificationListener airInterfaceNotificationListener; - - // ethernet container related members - private final List ethernetContainerList = new ArrayList(); - private @NonNull final Onf14EthernetContainerNotificationListener ethernetContainerNotificationListener; - - // wire interface related members - private final List wireInterfaceList = new ArrayList(); - private @NonNull final Onf14WireInterfaceNotificationListener wireInterfaceNotificationListener; - private @NonNull final BindingNormalizedNodeSerializer serializer; - // end of variables - - - // constructors - public Onf14DomInterfacePacManager(@NonNull NetconfDomAccessor netconfDomAccessor, - @NonNull DeviceManagerServiceProvider serviceProvider) { - - this.netconfDomAccessor = Objects.requireNonNull(netconfDomAccessor); - this.serviceProvider = Objects.requireNonNull(serviceProvider); - this.serializer = Objects.requireNonNull(netconfDomAccessor.getBindingNormalizedNodeSerializer()); - - this.airInterfaceNotificationListener = - new Onf14AirInterfaceNotificationListener(netconfDomAccessor, serviceProvider); - this.ethernetContainerNotificationListener = - new Onf14EthernetContainerNotificationListener(netconfDomAccessor, serviceProvider); - this.wireInterfaceNotificationListener = - new Onf14WireInterfaceNotificationListener(netconfDomAccessor, serviceProvider); - } - // end of constructors - - // getters and setters - // end of getters and setters - - // private methods - // end of private methods - - // public methods - public void readAllAirInterfaceCurrentProblems(NetconfDomAccessor netconfDomAccessor, - ControlConstruct controlConstruct, FaultData resultList) { - - int idxStart; // Start index for debug messages - - for (TechnologySpecificPacKeys key : airInterfaceList) { - idxStart = resultList.size(); - - readAirInterfaceCurrentProblemForLtp(netconfDomAccessor, controlConstruct, key.getLtpUuid(), - key.getLocalId(), resultList); - Debug.debugResultList(key.getLtpUuid().getValue(), resultList, idxStart); - } - } - - /* - public void readAllEhernetContainerCurrentProblems(FaultData resultList) { - - int idxStart; // Start index for debug messages - - for (TechnologySpecificPacKeys key : ethernetContainerList) { - idxStart = resultList.size(); - - readEthernetConainerCurrentProblemForLtp(key.getLtpUuid(), key.getLocalId(), resultList); - debugResultList(key.getLtpUuid().getValue(), resultList, idxStart); - } - } - - public void readAllWireInterfaceCurrentProblems(FaultData resultList) { - - int idxStart; // Start index for debug messages - - for (TechnologySpecificPacKeys key : wireInterfaceList) { - idxStart = resultList.size(); - - readWireInterfaceCurrentProblemForLtp(key.getLtpUuid(), key.getLocalId(), resultList); - debugResultList(key.getLtpUuid().getValue(), resultList, idxStart); - } - }*/ - public void readKeys(ControlConstruct controlConstruct) { - - @NonNull - Collection ltpList = - YangHelper.getCollection(controlConstruct.nonnullLogicalTerminationPoint()); - log.debug("Iterating the LTP list for node {}", netconfDomAccessor.getNodeId().getValue()); - - // iterating all the Logical Termination Point list - for (LogicalTerminationPoint ltp : ltpList) { - @NonNull - List lpList = YangHelper.getList(ltp.nonnullLayerProtocol()); - // the Layer Protocol list should contain only one item, since we have an 1:1 relationship between the LTP and the LP - if (lpList.size() != 1) { - log.debug("Layer protocol has no 1:1 relationship with the LTP."); - return; - } - // accessing the LP, which should be only 1 - LayerProtocol lp = lpList.get(0); - @Nullable - Class layerProtocolName = lp.getLayerProtocolName(); - if (layerProtocolName != null) { - // if the LTP has an airInterface technology extension, the layer protocol name is air-layer - if (layerProtocolName.getTypeName().equals(LAYERPROTOCOLNAMETYPEAIRLAYER.class.getName())) { - TechnologySpecificPacKeys airInterfaceKey = - new TechnologySpecificPacKeys(ltp.getUuid(), lp.getLocalId()); - airInterfaceList.add(airInterfaceKey); - log.debug("Adding Ltp with uuid {} and local-id {} to the air-interface list", - ltp.getUuid().getValue(), lp.getLocalId()); - } - // if the LTP has an ethernetContainier technology extension, the layer protocol name is ethernet-container-layer - else if (layerProtocolName.getTypeName().equals(LAYERPROTOCOLNAMETYPEETHERNETCONTAINERLAYER.class - .getName())) { - TechnologySpecificPacKeys ethernetContainerKey = - new TechnologySpecificPacKeys(ltp.getUuid(), lp.getLocalId()); - ethernetContainerList.add(ethernetContainerKey); - log.debug("Adding Ltp with uuid {} and local-id {} to the ethernet-contatinier list", - ltp.getUuid().getValue(), lp.getLocalId()); - } else if (layerProtocolName.getTypeName().equals(LAYERPROTOCOLNAMETYPEWIRELAYER.class.getName())) { - TechnologySpecificPacKeys wireInterfaceKey = - new TechnologySpecificPacKeys(ltp.getUuid(), lp.getLocalId()); - wireInterfaceList.add(wireInterfaceKey); - log.debug("Adding Ltp with uuid {} and local-id {} to the wire-interface list", - ltp.getUuid().getValue(), lp.getLocalId()); - } - } - } - } - - private static void readAirInterfaceCurrentProblemForLtp(NetconfDomAccessor netconfDomAccessor, - ControlConstruct controlConstruct, UniversalId ltpUuid, String localId, FaultData resultList) { - - final Class clazzPac = AirInterfacePac.class; - - log.info("DBRead Get current problems for class {} from mountpoint {} for LTP uuid {} and local-id {}", - clazzPac.getSimpleName(), netconfDomAccessor.getNodeId().getValue(), ltpUuid.getValue(), localId); - - // constructing the IID needs the augmentation exposed byy the air-interface-2-0 model - // InstanceIdentifier airInterfaceCurrentProblem_IID = InstanceIdentifier - // .builder(ControlConstruct.class) - // .child(LogicalTerminationPoint.class, new LogicalTerminationPointKey(ltpUuid)) - // .child(LayerProtocol.class, new LayerProtocolKey(localId)) - // .augmentation( - // org.opendaylight.yang.gen.v1.urn.onf.yang.air._interface._2._0.rev200121.LayerProtocol1.class) - // .child(AirInterfacePac.class) - // .child(AirInterfaceCurrentProblems.class).build(); - /* - final YangInstanceIdentifier airInterfaceCurrentProblem_IID = - YangInstanceIdentifier.builder().node(ControlConstruct.QNAME) - .nodeWithKey(LogicalTerminationPoint.QNAME, - QName.create(LogicalTerminationPoint.QNAME, "logical-termination-point-key").intern(), - ltpUuid.getValue()) - .nodeWithKey(LayerProtocol.QNAME, - QName.create(LayerProtocol.QNAME, "layer-protocol-key").intern(), localId) - //.node(org.opendaylight.yang.gen.v1.urn.onf.yang.air._interface._2._0.rev200121.LayerProtocol1.QNAME) - .node(AirInterfacePac.QNAME).node(AirInterfaceCurrentProblems.QNAME).build(); - - // reading all the current-problems list for this specific LTP and LP - AirInterfaceCurrentProblems problems = - netconfDomAccessor.readData(LogicalDatastoreType.OPERATIONAL, airInterfaceCurrentProblem_IID); - */ - - @NonNull - Map ltpMap = - controlConstruct.nonnullLogicalTerminationPoint(); - LogicalTerminationPoint ltp = ltpMap.get(new LogicalTerminationPointKey(ltpUuid)); - if (ltp != null) { - @NonNull - Map lpMap = ltp.nonnullLayerProtocol(); - LayerProtocol lp = lpMap.get(new LayerProtocolKey(localId)); - @Nullable - LayerProtocol1 lp1 = lp.augmentation( - org.opendaylight.yang.gen.v1.urn.onf.yang.air._interface._2._0.rev200121.LayerProtocol1.class); - if (lp1 != null) { - @Nullable - AirInterfacePac airInterfacePack = lp1.getAirInterfacePac(); - if (airInterfacePack != null) { - @Nullable - AirInterfaceCurrentProblems cp = airInterfacePack.getAirInterfaceCurrentProblems(); - if (cp == null) { - log.debug("DBRead Id {} no AirInterfaceCurrentProblems", ltpUuid); - } else { - for (org.opendaylight.yang.gen.v1.urn.onf.yang.air._interface._2._0.rev200121.air._interface.current.problems.CurrentProblemList problem : YangHelper - .getCollection(cp.nonnullCurrentProblemList())) { - resultList.add(netconfDomAccessor.getNodeId(), (int) problem.getSequenceNumber(), - problem.getTimestamp(), ltpUuid.getValue(), problem.getProblemName(), - Onf14AirInterface.mapSeverity(problem.getProblemSeverity())); - } - } - } - } - } - } - - @Override - public void onNotification(@NonNull DOMNotification domNotification) { - @Nullable - Notification notification = - serializer.fromNormalizedNodeNotification(domNotification.getType(), domNotification.getBody()); - if (notification instanceof ProblemNotification) { - ProblemNotification problemNotification = (ProblemNotification) notification; - log.debug("DOM ProblemNotification: {}", problemNotification); - airInterfaceNotificationListener.onProblemNotification(problemNotification); - } else if (notification instanceof AttributeValueChangedNotification) { - AttributeValueChangedNotification attributeValueChangeNotification = - (AttributeValueChangedNotification) notification; - log.debug("DOM AttributeValueChangedNotification: {}", attributeValueChangeNotification); - airInterfaceNotificationListener.onAttributeValueChangedNotification(attributeValueChangeNotification); - } else if (notification instanceof ObjectDeletionNotification) { - ObjectDeletionNotification objectDeletionNotification = (ObjectDeletionNotification) notification; - log.debug("DOM ObjectDeletionNotification: {}", objectDeletionNotification); - airInterfaceNotificationListener.onObjectDeletionNotification(objectDeletionNotification); - } else if (notification instanceof ObjectCreationNotification) { - ObjectCreationNotification objectCreationNotification = (ObjectCreationNotification) notification; - log.debug("DOM ObjectDeletionNotification: {}", objectCreationNotification); - airInterfaceNotificationListener.onObjectCreationNotification(objectCreationNotification); - } else { - log.warn("DOM Notification ignored: {}", domNotification); - } - } - - /** - * Register notifications to handle - */ - public void subscribeNotifications() { - QName[] notifications = { ObjectCreationNotification.QNAME, ObjectDeletionNotification.QNAME, - AttributeValueChangedNotification.QNAME, ProblemNotification.QNAME }; - netconfDomAccessor.doRegisterNotificationListener(this, notifications); - } - - /* - private void readEthernetConainerCurrentProblemForLtp(UniversalId ltpUuid, String localId, FaultData resultList) { - - final Class clazzPac = EthernetContainerPac.class; - - log.info("DBRead Get current problems for class {} from mountpoint {} for LTP uuid {} and local-id {}", - clazzPac.getSimpleName(), netconfDomAccessor.getNodeId().getValue(), ltpUuid.getValue(), localId); - - // constructing the IID needs the augmentation exposed by the ethernet-container-2-0 model - // InstanceIdentifier etherneContainerCurrentProblem_IID = InstanceIdentifier - // .builder(ControlConstruct.class) - // .child(LogicalTerminationPoint.class, new LogicalTerminationPointKey(ltpUuid)) - // .child(LayerProtocol.class, new LayerProtocolKey(localId)) - // .augmentation( - // org.opendaylight.yang.gen.v1.urn.onf.yang.ethernet.container._2._0.rev200121.LayerProtocol1.class) - // .child(EthernetContainerPac.class).child(EthernetContainerCurrentProblems.class).build(); - final YangInstanceIdentifier etherneContainerCurrentProblem_IID = - YangInstanceIdentifier.builder().node(ControlConstruct.QNAME) - .nodeWithKey(LogicalTerminationPoint.QNAME, - QName.create(LogicalTerminationPoint.QNAME, "logical-termination-point-key").intern(), - ltpUuid.getValue()) - .nodeWithKey(LayerProtocol.QNAME, - QName.create(LayerProtocol.QNAME, "layer-protocol-key").intern(), localId) - //.node(org.opendaylight.yang.gen.v1.urn.onf.yang.ethernet.container._2._0.rev200121.LayerProtocol1.QNAME) - .node(EthernetContainerPac.QNAME).node(EthernetContainerCurrentProblems.QNAME).build(); - - // reading all the current-problems list for this specific LTP and LP - EthernetContainerCurrentProblems problems = - netconfDomAccessor.readData(LogicalDatastoreType.OPERATIONAL, etherneContainerCurrentProblem_IID); - - if (problems == null) { - log.debug("DBRead Id {} no EthernetContainerCurrentProblems", ltpUuid); - } else if (problems.getCurrentProblemList() == null) { - log.debug("DBRead Id {} empty CurrentProblemList", ltpUuid); - } else { - for (org.opendaylight.yang.gen.v1.urn.onf.yang.ethernet.container._2._0.rev200121.ethernet.container.current.problems.CurrentProblemList problem : YangHelper - .getCollection(problems.nonnullCurrentProblemList())) { - resultList.add(netconfDomAccessor.getNodeId(), (int) problem.getSequenceNumber(), - problem.getTimestamp(), ltpUuid.getValue(), problem.getProblemName(), - Onf14EthernetContainer.mapSeverity(problem.getProblemSeverity())); - } - } - } - - private void readWireInterfaceCurrentProblemForLtp(UniversalId ltpUuid, String localId, FaultData resultList) { - - final Class clazzPac = WireInterfacePac.class; - - log.info("DBRead Get current problems for class {} from mountpoint {} for LTP uuid {} and local-id {}", - clazzPac.getSimpleName(), netconfDomAccessor.getNodeId().getValue(), ltpUuid.getValue(), localId); - - // constructing the IID needs the augmentation exposed by the wire-interface-2-0 model - // InstanceIdentifier wireInterfaceCurrentProblem_IID = InstanceIdentifier - // .builder(ControlConstruct.class) - // .child(LogicalTerminationPoint.class, new LogicalTerminationPointKey(ltpUuid)) - // .child(LayerProtocol.class, new LayerProtocolKey(localId)) - // .augmentation( - // org.opendaylight.yang.gen.v1.urn.onf.yang.wire._interface._2._0.rev200123.LayerProtocol1.class) - // .child(WireInterfacePac.class).child(WireInterfaceCurrentProblems.class).build(); - final YangInstanceIdentifier wireInterfaceCurrentProblem_IID = - YangInstanceIdentifier.builder().node(ControlConstruct.QNAME) - .nodeWithKey(LogicalTerminationPoint.QNAME, - QName.create(LogicalTerminationPoint.QNAME, "logical-termination-point-key").intern(), - ltpUuid.getValue()) - .nodeWithKey(LayerProtocol.QNAME, - QName.create(LayerProtocol.QNAME, "layer-protocol-key").intern(), localId) - //.node(org.opendaylight.yang.gen.v1.urn.onf.yang.wire._interface._2._0.rev200123.LayerProtocol1.QNAME) - .node(WireInterfacePac.QNAME).node(WireInterfaceCurrentProblems.QNAME).build(); - - // reading all the current-problems list for this specific LTP and LP - WireInterfaceCurrentProblems problems = - netconfDomAccessor.readData(LogicalDatastoreType.OPERATIONAL, wireInterfaceCurrentProblem_IID); - - if (problems == null) { - log.debug("DBRead Id {} no WireInterfaceCurrentProblems", ltpUuid); - } else if (problems.getCurrentProblemList() == null) { - log.debug("DBRead Id {} empty CurrentProblemList", ltpUuid); - } else { - for (org.opendaylight.yang.gen.v1.urn.onf.yang.wire._interface._2._0.rev200123.wire._interface.current.problems.CurrentProblemList problem : YangHelper - .getCollection(problems.nonnullCurrentProblemList())) { - resultList.add(netconfDomAccessor.getNodeId(), (int) problem.getSequenceNumber(), - problem.getTimestamp(), ltpUuid.getValue(), problem.getProblemName(), - Onf14WireInterface.mapSeverity(problem.getProblemSeverity())); - } - } - } - */ - - // end of public methods - - // static methods - // end of static methods - - // private classes - // end of private classes -} diff --git a/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/impl/interfaces/Onf14EthernetContainer.java b/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/impl/interfaces/Onf14EthernetContainer.java deleted file mode 100644 index f9769951f..000000000 --- a/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/impl/interfaces/Onf14EthernetContainer.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * ============LICENSE_START======================================================================== - * ONAP : ccsdk feature sdnr wt - * ================================================================================================= - * Copyright (C) 2020 highstreet technologies GmbH Intellectual Property. All rights reserved. - * ================================================================================================= - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License - * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express - * or implied. See the License for the specific language governing permissions and limitations under - * the License. - * ============LICENSE_END========================================================================== - */ -package org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.impl.interfaces; - -import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.impl.dataprovider.InternalDataModelSeverity; -import org.opendaylight.yang.gen.v1.urn.onf.yang.ethernet.container._2._0.rev200121.SEVERITYTYPE; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.SeverityType; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * @author alexs - * - */ -public class Onf14EthernetContainer { - - @SuppressWarnings("unused") - private static final Logger LOG = LoggerFactory.getLogger(Onf14EthernetContainer.class); - - public static SeverityType mapSeverity( - Class severity) { - return InternalDataModelSeverity.mapSeverity(severity); - } - -} diff --git a/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/impl/interfaces/Onf14EthernetContainerNotificationListener.java b/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/impl/interfaces/Onf14EthernetContainerNotificationListener.java deleted file mode 100644 index b76572ba5..000000000 --- a/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/impl/interfaces/Onf14EthernetContainerNotificationListener.java +++ /dev/null @@ -1,141 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * ONAP : ccsdk feature sdnr wt - * ================================================================================ - * Copyright (C) 2020 highstreet technologies GmbH Intellectual Property. - * All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - * - */ -package org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.impl.interfaces; - -import java.util.HashMap; -import java.util.Map; -import org.eclipse.jdt.annotation.Nullable; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.DeviceManagerServiceProvider; -import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfAccessor; -import org.opendaylight.yang.gen.v1.urn.onf.yang.ethernet.container._2._0.rev200121.AttributeValueChangedNotification; -import org.opendaylight.yang.gen.v1.urn.onf.yang.ethernet.container._2._0.rev200121.EthernetContainer20Listener; -import org.opendaylight.yang.gen.v1.urn.onf.yang.ethernet.container._2._0.rev200121.ObjectCreationNotification; -import org.opendaylight.yang.gen.v1.urn.onf.yang.ethernet.container._2._0.rev200121.ObjectDeletionNotification; -import org.opendaylight.yang.gen.v1.urn.onf.yang.ethernet.container._2._0.rev200121.ProblemNotification; -import org.opendaylight.yang.gen.v1.urn.onf.yang.ethernet.container._2._0.rev200121.SEVERITYTYPE; -import org.opendaylight.yang.gen.v1.urn.onf.yang.ethernet.container._2._0.rev200121.SEVERITYTYPECRITICAL; -import org.opendaylight.yang.gen.v1.urn.onf.yang.ethernet.container._2._0.rev200121.SEVERITYTYPEMAJOR; -import org.opendaylight.yang.gen.v1.urn.onf.yang.ethernet.container._2._0.rev200121.SEVERITYTYPEMINOR; -import org.opendaylight.yang.gen.v1.urn.onf.yang.ethernet.container._2._0.rev200121.SEVERITYTYPENONALARMED; -import org.opendaylight.yang.gen.v1.urn.onf.yang.ethernet.container._2._0.rev200121.SEVERITYTYPEWARNING; -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.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.SeverityType; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.SourceType; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class Onf14EthernetContainerNotificationListener implements EthernetContainer20Listener { - - private static final Logger log = LoggerFactory.getLogger(Onf14EthernetContainerNotificationListener.class); - - private final NetconfAccessor netconfAccessor; - private final DeviceManagerServiceProvider serviceProvider; - - private static final Map, SeverityType> severityMap = initSeverityMap(); - - public Onf14EthernetContainerNotificationListener(NetconfAccessor netconfAccessor, - DeviceManagerServiceProvider serviceProvider) { - this.netconfAccessor = netconfAccessor; - this.serviceProvider = serviceProvider; - } - - private static Map, SeverityType> initSeverityMap() { - Map, SeverityType> map = new HashMap<>(); - map.put(SEVERITYTYPECRITICAL.class, SeverityType.Critical); - map.put(SEVERITYTYPEMAJOR.class, SeverityType.Major); - map.put(SEVERITYTYPEMINOR.class, SeverityType.Minor); - map.put(SEVERITYTYPEWARNING.class, SeverityType.Warning); - map.put(SEVERITYTYPENONALARMED.class, SeverityType.NonAlarmed); - return map; - } - - @Override - public void onObjectDeletionNotification(ObjectDeletionNotification notification) { - log.debug("Got event of type :: {}", ObjectDeletionNotification.class.getSimpleName()); - - EventlogBuilder eventlogBuilder = new EventlogBuilder(); - eventlogBuilder.setNodeId(netconfAccessor.getNodeId().getValue()).setAttributeName("") - .setCounter(notification.getCounter().intValue()).setNewValue("deleted") - .setObjectId(notification.getObjectIdRef().getValue()).setSourceType(SourceType.Netconf) - .setTimestamp(notification.getTimestamp()); - serviceProvider.getDataProvider().writeEventLog(eventlogBuilder.build()); - serviceProvider.getNotificationService().deletionNotification(netconfAccessor.getNodeId(), - notification.getCounter().intValue(), notification.getTimestamp(), - notification.getObjectIdRef().getValue()); - - log.debug("onObjectDeletionNotification log entry written"); - } - - @Override - public void onProblemNotification(ProblemNotification notification) { - log.debug("Got event of type :: {}", ProblemNotification.class.getSimpleName()); - FaultlogEntity faultAlarm = new FaultlogBuilder().setObjectId(notification.getObjectIdRef().getValue()) - .setProblem(notification.getProblem()).setTimestamp(notification.getTimestamp()) - .setNodeId(this.netconfAccessor.getNodeId().getValue()).setSourceType(SourceType.Netconf) - .setSeverity(mapSeverity(notification.getSeverity())).setCounter(notification.getCounter().intValue()) - .build(); - serviceProvider.getFaultService().faultNotification(faultAlarm); - serviceProvider.getWebsocketService().sendNotification(notification, netconfAccessor.getNodeId(), - ProblemNotification.QNAME, notification.getTimestamp()); - - } - - private SeverityType mapSeverity(@Nullable Class severity) { - return severityMap.getOrDefault(severity, SeverityType.NonAlarmed); - } - - @Override - public void onAttributeValueChangedNotification(AttributeValueChangedNotification notification) { - log.debug("Got event of type :: {}", AttributeValueChangedNotification.class.getSimpleName()); - - EventlogBuilder eventlogBuilder = new EventlogBuilder(); - eventlogBuilder.setNodeId(netconfAccessor.getNodeId().getValue()) - .setAttributeName(notification.getAttributeName()).setCounter(notification.getCounter().intValue()) - .setNewValue(notification.getNewValue()).setObjectId(notification.getObjectIdRef().getValue()) - .setSourceType(SourceType.Netconf).setTimestamp(notification.getTimestamp()); - serviceProvider.getDataProvider().writeEventLog(eventlogBuilder.build()); - serviceProvider.getWebsocketService().sendNotification(notification, netconfAccessor.getNodeId(), - AttributeValueChangedNotification.QNAME, notification.getTimestamp()); - - log.debug("onAttributeValueChangedNotification log entry written"); - } - - @Override - public void onObjectCreationNotification(ObjectCreationNotification notification) { - log.debug("Got event of type :: {}", ObjectCreationNotification.class.getSimpleName()); - - EventlogBuilder eventlogBuilder = new EventlogBuilder(); - eventlogBuilder.setNodeId(netconfAccessor.getNodeId().getValue()).setAttributeName(notification.getObjectType()) - .setCounter(notification.getCounter().intValue()).setNewValue("created") - .setObjectId(notification.getObjectIdRef().getValue()).setSourceType(SourceType.Netconf) - .setTimestamp(notification.getTimestamp()); - serviceProvider.getDataProvider().writeEventLog(eventlogBuilder.build()); - serviceProvider.getWebsocketService().sendNotification(notification, netconfAccessor.getNodeId(), - ObjectCreationNotification.QNAME, notification.getTimestamp()); - - log.debug("onObjectCreationNotification log entry written"); - } - - -} diff --git a/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/impl/interfaces/Onf14WireInterface.java b/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/impl/interfaces/Onf14WireInterface.java deleted file mode 100644 index acb262fcb..000000000 --- a/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/impl/interfaces/Onf14WireInterface.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * ============LICENSE_START======================================================================== - * ONAP : ccsdk feature sdnr wt - * ================================================================================================= - * Copyright (C) 2020 highstreet technologies GmbH Intellectual Property. All rights reserved. - * ================================================================================================= - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License - * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express - * or implied. See the License for the specific language governing permissions and limitations under - * the License. - * ============LICENSE_END========================================================================== - */ -package org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.impl.interfaces; - -import org.eclipse.jdt.annotation.Nullable; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.impl.dataprovider.InternalDataModelSeverity; -import org.opendaylight.yang.gen.v1.urn.onf.yang.wire._interface._2._0.rev200123.SEVERITYTYPE; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.SeverityType; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * @author alexs - * - */ -public class Onf14WireInterface { - - @SuppressWarnings("unused") - private static final Logger LOG = LoggerFactory.getLogger(Onf14WireInterface.class); - - public static SeverityType mapSeverity(@Nullable Class severity) { - return InternalDataModelSeverity.mapSeverity(severity); - } - -} diff --git a/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/impl/interfaces/Onf14WireInterfaceNotificationListener.java b/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/impl/interfaces/Onf14WireInterfaceNotificationListener.java deleted file mode 100644 index 6848e6765..000000000 --- a/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/impl/interfaces/Onf14WireInterfaceNotificationListener.java +++ /dev/null @@ -1,149 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * ONAP : ccsdk feature sdnr wt - * ================================================================================ - * Copyright (C) 2020 highstreet technologies GmbH Intellectual Property. - * All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - * - */ -package org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.impl.interfaces; - -import java.util.HashMap; -import java.util.Map; -import org.eclipse.jdt.annotation.Nullable; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.DeviceManagerServiceProvider; -import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfAccessor; -import org.opendaylight.yang.gen.v1.urn.onf.yang.wire._interface._2._0.rev200123.AttributeValueChangedNotification; -import org.opendaylight.yang.gen.v1.urn.onf.yang.wire._interface._2._0.rev200123.ObjectCreationNotification; -import org.opendaylight.yang.gen.v1.urn.onf.yang.wire._interface._2._0.rev200123.ObjectDeletionNotification; -import org.opendaylight.yang.gen.v1.urn.onf.yang.wire._interface._2._0.rev200123.ProblemNotification; -import org.opendaylight.yang.gen.v1.urn.onf.yang.wire._interface._2._0.rev200123.SEVERITYTYPE; -import org.opendaylight.yang.gen.v1.urn.onf.yang.wire._interface._2._0.rev200123.SEVERITYTYPECRITICAL; -import org.opendaylight.yang.gen.v1.urn.onf.yang.wire._interface._2._0.rev200123.SEVERITYTYPEMAJOR; -import org.opendaylight.yang.gen.v1.urn.onf.yang.wire._interface._2._0.rev200123.SEVERITYTYPEMINOR; -import org.opendaylight.yang.gen.v1.urn.onf.yang.wire._interface._2._0.rev200123.SEVERITYTYPENONALARMED; -import org.opendaylight.yang.gen.v1.urn.onf.yang.wire._interface._2._0.rev200123.SEVERITYTYPEWARNING; -import org.opendaylight.yang.gen.v1.urn.onf.yang.wire._interface._2._0.rev200123.WireInterface20Listener; -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.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.SeverityType; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.SourceType; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class Onf14WireInterfaceNotificationListener implements WireInterface20Listener { - - private static final Logger log = LoggerFactory.getLogger(Onf14WireInterfaceNotificationListener.class); - - private final NetconfAccessor netconfAccessor; - private final DeviceManagerServiceProvider serviceProvider; - - private static final Map,SeverityType> severityMap = initSeverityMap(); - - public Onf14WireInterfaceNotificationListener(NetconfAccessor netconfAccessor, - DeviceManagerServiceProvider serviceProvider) { - this.netconfAccessor = netconfAccessor; - this.serviceProvider = serviceProvider; - } - - private static Map, SeverityType> initSeverityMap() { - Map, SeverityType> map = new HashMap<>(); - map.put(SEVERITYTYPECRITICAL.class,SeverityType.Critical); - map.put(SEVERITYTYPEMAJOR.class,SeverityType.Major); - map.put(SEVERITYTYPEMINOR.class,SeverityType.Minor); - map.put(SEVERITYTYPEWARNING.class,SeverityType.Warning); - map.put(SEVERITYTYPENONALARMED.class,SeverityType.NonAlarmed); - return map; - } - - @Override - public void onObjectDeletionNotification(ObjectDeletionNotification notification) { - log.debug("Got event of type :: {}", ObjectDeletionNotification.class.getSimpleName()); - - EventlogBuilder eventlogBuilder = new EventlogBuilder(); - eventlogBuilder.setNodeId(netconfAccessor.getNodeId().getValue()) - .setAttributeName("") - .setCounter(notification.getCounter()) - .setNewValue("deleted") - .setObjectId(notification.getObjectIdRef().getValue()) - .setSourceType(SourceType.Netconf) - .setTimestamp(notification.getTimestamp()); - serviceProvider.getDataProvider().writeEventLog(eventlogBuilder.build()); - serviceProvider.getWebsocketService().sendNotification(notification, netconfAccessor.getNodeId(), - ObjectDeletionNotification.QNAME, notification.getTimestamp()); - - log.debug("onObjectDeletionNotification log entry written"); - } - - @Override - public void onProblemNotification(ProblemNotification notification) { - log.debug("Got event of type :: {}", ProblemNotification.class.getSimpleName()); - FaultlogEntity faultAlarm = new FaultlogBuilder().setObjectId(notification.getObjectIdRef().getValue()) - .setProblem(notification.getProblem()).setTimestamp(notification.getTimestamp()) - .setNodeId(this.netconfAccessor.getNodeId().getValue()).setSourceType(SourceType.Netconf) - .setSeverity(mapSeverity(notification.getSeverity())).setCounter(notification.getCounter()) - .build(); - serviceProvider.getFaultService().faultNotification(faultAlarm); - serviceProvider.getWebsocketService().sendNotification( notification, netconfAccessor.getNodeId(), - ProblemNotification.QNAME, notification.getTimestamp()); - - } - - private SeverityType mapSeverity(@Nullable Class severity) { - return severityMap.getOrDefault(severity,SeverityType.NonAlarmed); - } - - @Override - public void onAttributeValueChangedNotification(AttributeValueChangedNotification notification) { - log.debug("Got event of type :: {}", AttributeValueChangedNotification.class.getSimpleName()); - - EventlogBuilder eventlogBuilder = new EventlogBuilder(); - eventlogBuilder.setNodeId(netconfAccessor.getNodeId().getValue()) - .setAttributeName(notification.getAttributeName()) - .setCounter(notification.getCounter()) - .setNewValue(notification.getNewValue()) - .setObjectId(notification.getObjectIdRef().getValue()) - .setSourceType(SourceType.Netconf) - .setTimestamp(notification.getTimestamp()); - serviceProvider.getDataProvider().writeEventLog(eventlogBuilder.build()); - serviceProvider.getWebsocketService().sendNotification(notification, netconfAccessor.getNodeId(), - AttributeValueChangedNotification.QNAME, notification.getTimestamp()); - - - log.debug("onAttributeValueChangedNotification log entry written"); - } - - @Override - public void onObjectCreationNotification(ObjectCreationNotification notification) { - log.debug("Got event of type :: {}", ObjectCreationNotification.class.getSimpleName()); - - EventlogBuilder eventlogBuilder = new EventlogBuilder(); - eventlogBuilder.setNodeId(netconfAccessor.getNodeId().getValue()) - .setAttributeName(notification.getObjectType()) - .setCounter(notification.getCounter()) - .setNewValue("created") - .setObjectId(notification.getObjectIdRef().getValue()) - .setSourceType(SourceType.Netconf) - .setTimestamp(notification.getTimestamp()); - serviceProvider.getDataProvider().writeEventLog(eventlogBuilder.build()); - serviceProvider.getWebsocketService().sendNotification(notification, netconfAccessor.getNodeId(), - ObjectCreationNotification.QNAME, notification.getTimestamp()); - - log.debug("onObjectCreationNotification log entry written"); - } - -} diff --git a/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/impl/interfaces/TechnologySpecificPacKeys.java b/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/impl/interfaces/TechnologySpecificPacKeys.java deleted file mode 100644 index 552ba6604..000000000 --- a/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/impl/interfaces/TechnologySpecificPacKeys.java +++ /dev/null @@ -1,54 +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.onf14.impl.interfaces; - -import org.opendaylight.yang.gen.v1.urn.onf.yang.core.model._1._4.rev191127.UniversalId; - -/** - * Defining a structure that can map the LP local-id and its corresponding LTP uuid - */ -class TechnologySpecificPacKeys { - - private UniversalId ltpUuid; - private String localId; - - public TechnologySpecificPacKeys(UniversalId uuid, String lId) { - this.ltpUuid = uuid; - this.localId = lId; - } - - public UniversalId getLtpUuid() { - return ltpUuid; - } - - public String getLocalId() { - return localId; - } - - public void setLtpUuid(UniversalId uuid) { - this.ltpUuid = uuid; - } - - public void setLocalId(String lId) { - this.localId = lId; - } -} diff --git a/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/impl/util/Debug.java b/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/impl/util/Debug.java deleted file mode 100644 index efa3cf169..000000000 --- a/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/impl/util/Debug.java +++ /dev/null @@ -1,72 +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.onf14.impl.util; - -import org.onap.ccsdk.features.sdnr.wt.devicemanager.types.FaultData; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class Debug { - - // constants - private static final Logger log = LoggerFactory.getLogger(Debug.class); - // end of constants - - // variables - // end of variables - - // constructors - // end of constructors - - // getters and setters - // end of getters and setters - - // private methods - // end of private methods - - // public methods - /** - * LOG the newly added problems of the interface pac - * - * @param idxStart - * @param uuid - * @param resultList - */ - public static void debugResultList(String uuid, FaultData resultList, int idxStart) { - StringBuilder sb = new StringBuilder(); - int idx = 0; - for (int t = idxStart; t < resultList.size(); t++) { - sb.append(idx++); - sb.append(":{"); - sb.append(resultList.get(t)); - sb.append('}'); - } - log.debug("Found problems {} {}", uuid, sb); - } - // end of public methods - - // static methods - // end of static methods - - // private classes - // end of private classes -} diff --git a/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/yang/Control.java b/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/yang/Control.java deleted file mode 100644 index fc4de9104..000000000 --- a/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/yang/Control.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * ============LICENSE_START======================================================================== - * ONAP : ccsdk feature sdnr wt - * ================================================================================================= - * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. All rights reserved. - * ================================================================================================= - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License - * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express - * or implied. See the License for the specific language governing permissions and limitations under - * the License. - * ============LICENSE_END========================================================================== - */ -package org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.yang; - -public class Control { - - public class MaxAlarmStatusChanges { - - } - -} diff --git a/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/yang/OperatorState.java b/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/yang/OperatorState.java deleted file mode 100644 index 9b516bb67..000000000 --- a/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/yang/OperatorState.java +++ /dev/null @@ -1,22 +0,0 @@ -/* - * ============LICENSE_START======================================================================== - * ONAP : ccsdk feature sdnr wt - * ================================================================================================= - * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. All rights reserved. - * ================================================================================================= - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License - * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express - * or implied. See the License for the specific language governing permissions and limitations under - * the License. - * ============LICENSE_END========================================================================== - */ -package org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.yang; - -public enum OperatorState { - -} diff --git a/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/yang/Resource.java b/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/yang/Resource.java deleted file mode 100644 index 7966c1c71..000000000 --- a/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/yang/Resource.java +++ /dev/null @@ -1,22 +0,0 @@ -/* - * ============LICENSE_START======================================================================== - * ONAP : ccsdk feature sdnr wt - * ================================================================================================= - * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. All rights reserved. - * ================================================================================================= - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License - * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express - * or implied. See the License for the specific language governing permissions and limitations under - * the License. - * ============LICENSE_END========================================================================== - */ -package org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.yang; - -public class Resource { - -} diff --git a/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/yang/ResourceMatch.java b/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/yang/ResourceMatch.java deleted file mode 100644 index c7e9103a1..000000000 --- a/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/yang/ResourceMatch.java +++ /dev/null @@ -1,22 +0,0 @@ -/* - * ============LICENSE_START======================================================================== - * ONAP : ccsdk feature sdnr wt - * ================================================================================================= - * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. All rights reserved. - * ================================================================================================= - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License - * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express - * or implied. See the License for the specific language governing permissions and limitations under - * the License. - * ============LICENSE_END========================================================================== - */ -package org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.yang; - -public class ResourceMatch { - -} diff --git a/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/yang/SeverityWithClear.java b/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/yang/SeverityWithClear.java deleted file mode 100644 index 1b39bf928..000000000 --- a/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/yang/SeverityWithClear.java +++ /dev/null @@ -1,22 +0,0 @@ -/* - * ============LICENSE_START======================================================================== - * ONAP : ccsdk feature sdnr wt - * ================================================================================================= - * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. All rights reserved. - * ================================================================================================= - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License - * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express - * or implied. See the License for the specific language governing permissions and limitations under - * the License. - * ============LICENSE_END========================================================================== - */ -package org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.yang; - -public enum SeverityWithClear { - -} diff --git a/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/yang/package-info.java b/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/yang/package-info.java deleted file mode 100644 index 0769687e8..000000000 --- a/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/yang/package-info.java +++ /dev/null @@ -1,18 +0,0 @@ -/* - * ============LICENSE_START======================================================================== - * ONAP : ccsdk feature sdnr wt - * ================================================================================================= - * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. All rights reserved. - * ================================================================================================= - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License - * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express - * or implied. See the License for the specific language governing permissions and limitations under - * the License. - * ============LICENSE_END========================================================================== - */ -package org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.yang; diff --git a/sdnr/wt/devicemanager-onap/onf14/provider/src/main/resources/org/opendaylight/blueprint/impl-blueprint.xml b/sdnr/wt/devicemanager-onap/onf14/provider/src/main/resources/org/opendaylight/blueprint/impl-blueprint.xml index 0be800784..38c9e15c3 100644 --- a/sdnr/wt/devicemanager-onap/onf14/provider/src/main/resources/org/opendaylight/blueprint/impl-blueprint.xml +++ b/sdnr/wt/devicemanager-onap/onf14/provider/src/main/resources/org/opendaylight/blueprint/impl-blueprint.xml @@ -31,7 +31,7 @@ interface="org.onap.ccsdk.features.sdnr.wt.devicemanager.service.NetconfNetworkElementService"/> -- cgit 1.2.3-korg