diff options
author | Ravi Pendurty <ravi.pendurty@highstreet-technologies.com> | 2021-02-03 15:29:21 +0100 |
---|---|---|
committer | Dan Timoney <dtimoney@att.com> | 2021-02-05 22:57:32 +0000 |
commit | ece5215df091114be3bffee073c8d3b0bc1ee1bc (patch) | |
tree | 0754b73eadae34a61df8703e3733cd237df56362 /sdnr/wt/devicemanager-onf14/provider/src/main | |
parent | f2b7adc8df29246e154011293c7a4afdd242df60 (diff) |
Migrate devicemanager-openroadm and devicemanager-onf14
Migrate devicemanager-openroadm and devicemanager-onf14 to Aluminium
Issue-ID: CCSDK-3134
Signed-off-by: Ravi Pendurty <ravi.pendurty@highstreet-technologies.com>
Change-Id: If5f7073d56c9a334e6a23cc0a2dd9b68e7f19512
Signed-off-by: Ravi Pendurty <ravi.pendurty@highstreet-technologies.com>
Diffstat (limited to 'sdnr/wt/devicemanager-onf14/provider/src/main')
19 files changed, 1146 insertions, 202 deletions
diff --git a/sdnr/wt/devicemanager-onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/impl/DeviceManagerOnf14Impl.java b/sdnr/wt/devicemanager-onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/impl/DeviceManagerOnf14Impl.java index df34ce5c8..5c57054ff 100644 --- a/sdnr/wt/devicemanager-onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/impl/DeviceManagerOnf14Impl.java +++ b/sdnr/wt/devicemanager-onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/impl/DeviceManagerOnf14Impl.java @@ -51,7 +51,7 @@ public class DeviceManagerOnf14Impl implements AutoCloseable { LOG.info("Session Initiated start {}", APPLICATION_NAME); - resOnf = netconfNetworkElementService.registerNetworkElementFactory(new Onf14NetworkElementFactory()); + resOnf = netconfNetworkElementService.registerBindingNetworkElementFactory(new Onf14NetworkElementFactory()); netconfNetworkElementService.writeToEventLog(APPLICATION_NAME, "startup", "done"); diff --git a/sdnr/wt/devicemanager-onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/impl/Onf14AirInterface.java b/sdnr/wt/devicemanager-onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/impl/Onf14AirInterface.java deleted file mode 100644 index ca00ae87c..000000000 --- a/sdnr/wt/devicemanager-onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/impl/Onf14AirInterface.java +++ /dev/null @@ -1,58 +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.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.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * @author alexs - * - */ -public class Onf14AirInterface { - - private static final Logger log = LoggerFactory.getLogger(Onf14AirInterface.class); - - public static org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.SeverityType mapSeverity( - Class<? extends SEVERITYTYPE> severity) { - - if (severity != null) { - if (severity.getTypeName() == SEVERITYTYPECRITICAL.class.getName()) { - return org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.SeverityType.Critical; - } else if (severity.getTypeName() == SEVERITYTYPEMAJOR.class.getName()) { - return org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.SeverityType.Major; - } else if (severity.getTypeName() == SEVERITYTYPEMINOR.class.getName()) { - return org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.SeverityType.Minor; - } else if (severity.getTypeName() == SEVERITYTYPEWARNING.class.getName()) { - return org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.SeverityType.Warning; - } else if (severity.getTypeName() == SEVERITYTYPENONALARMED.class.getName()) { - return org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.SeverityType.NonAlarmed; - } - } - - return org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.SeverityType.NonAlarmed; - } - - -} diff --git a/sdnr/wt/devicemanager-onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/impl/Onf14DomNetworkElement.java b/sdnr/wt/devicemanager-onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/impl/Onf14DomNetworkElement.java new file mode 100644 index 000000000..0a63b7449 --- /dev/null +++ b/sdnr/wt/devicemanager-onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/impl/Onf14DomNetworkElement.java @@ -0,0 +1,209 @@ +/* + * ============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.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.Capabilities; +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.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.netconf.node.topology.rev150114.NetconfNode; +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.common.QName; +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> 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; + + + public Onf14DomNetworkElement(NetconfDomAccessor netconfDomAccessor, DeviceManagerServiceProvider serviceProvider) { + log.info("Create {}", Onf14DomNetworkElement.class.getSimpleName()); + this.netconfDomAccessor = netconfDomAccessor; + this.databaseService = serviceProvider.getDataProvider(); + this.notificationService = serviceProvider.getNotificationService(); + this.faultService = serviceProvider.getFaultService(); + this.onf14Mapper = new Onf14ToInternalDataModel(); + 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() { + + //Read complete device tree + Optional<ControlConstruct> oControlConstruct = readControlConstruct(netconfDomAccessor); + + if (oControlConstruct.isPresent()) { + ControlConstruct controlConstruct = oControlConstruct.get(); + + equipmentManager.setEquipmentData(controlConstruct); + + //-- Start For test purpose + for (UniversalId uuid : equipmentManager.getEquipmentUuidList()) { + log.info("Read data with id {}", uuid); + Optional<Equipment> res1 = equipmentManager.readEquipmentInstance(netconfDomAccessor, uuid); + log.info("Res1: {}", res1.isPresent() ? res1.get() : "No data1"); + + Optional<ControlConstruct> res2 = equipmentManager.readEquipmentList(netconfDomAccessor, uuid); + log.info("Res2: {}", res2.isPresent() ? res2.get() : "No data2"); + + equipmentManager.readTopLevelEquipment(netconfDomAccessor); + //Do it only once for test purpose + break; + } + //-- End For test 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(@NonNull NetconfNode nNode) { + NetworkElementConnectionBuilder eb = new NetworkElementConnectionBuilder(); + 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); + + if (Capabilities.isNamespaceSupported(namespaceRevision)) { + eb.setCoreModelCapability(namespaceRevision); + } else { + eb.setCoreModelCapability("Unsupported"); + } + databaseService.updateNetworkConnection22(eb.build(), netconfDomAccessor.getNodeId().getValue()); + } + + @Override + public void register() { + // Set core-model revision value in "core-model-capability" field + setCoreModel(netconfDomAccessor.getNetconfNode()); + initialReadFromNetworkElement(); + + // Register netconf stream + // airInterfaceNotificationListenerHandler = + // netconfDomAccessor.doRegisterNotificationListener(airInterfaceNotificationListener); + // etherneContainerNotificationListenerHandler = + // netconfDomAccessor.doRegisterNotificationListener(ethernetContainerNotificationListener); + // wireInterfaceNotificationListenerHandler = + // netconfDomAccessor.doRegisterNotificationListener(wireInterfaceNotificationListener); + // Optional<NetconfNotifications> notificationsSupport = netconfDomAccessor.getNotificationAccessor(); + // if (notificationsSupport.isPresent()) { + // notificationsSupport.get().registerNotificationsStream(NetconfBindingAccessor.DefaultNotificationsStream); + // } + } + + @Override + public void deregister() {} + + + @Override + public NodeId getNodeId() { + return netconfDomAccessor.getNodeId(); + } + + @Override + public <L extends NetworkElementService> Optional<L> getService(Class<L> clazz) { + return Optional.empty(); + } + + @Override + public void warmstart() {} + + @Override + public Optional<NetconfAccessor> getAcessor() { + return Optional.of(netconfDomAccessor); + } + + @Override + public NetworkElementDeviceType getDeviceType() { + return NetworkElementDeviceType.Wireless; + } + + private static Optional<ControlConstruct> readControlConstruct(NetconfDomAccessor netconfDomAccessor) { + return netconfDomAccessor.readData(LogicalDatastoreType.CONFIGURATION, CONTROLCONSTRUCT_IID, ControlConstruct.class); + } + + + +} diff --git a/sdnr/wt/devicemanager-onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/impl/Onf14EthernetContainer.java b/sdnr/wt/devicemanager-onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/impl/Onf14EthernetContainer.java deleted file mode 100644 index 27d61be48..000000000 --- a/sdnr/wt/devicemanager-onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/impl/Onf14EthernetContainer.java +++ /dev/null @@ -1,58 +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.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.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * @author alexs - * - */ -public class Onf14EthernetContainer { - - private static final Logger log = LoggerFactory.getLogger(Onf14EthernetContainer.class); - - public static org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.SeverityType mapSeverity( - Class<? extends SEVERITYTYPE> severity) { - - if (severity != null) { - if (severity.getTypeName() == SEVERITYTYPECRITICAL.class.getName()) { - return org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.SeverityType.Critical; - } else if (severity.getTypeName() == SEVERITYTYPEMAJOR.class.getName()) { - return org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.SeverityType.Major; - } else if (severity.getTypeName() == SEVERITYTYPEMINOR.class.getName()) { - return org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.SeverityType.Minor; - } else if (severity.getTypeName() == SEVERITYTYPEWARNING.class.getName()) { - return org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.SeverityType.Warning; - } else if (severity.getTypeName() == SEVERITYTYPENONALARMED.class.getName()) { - return org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.SeverityType.NonAlarmed; - } - } - - return org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.SeverityType.NonAlarmed; - } - - -} diff --git a/sdnr/wt/devicemanager-onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/impl/Onf14NetworkElement.java b/sdnr/wt/devicemanager-onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/impl/Onf14NetworkElement.java index d2db231bc..a5599be30 100644 --- a/sdnr/wt/devicemanager-onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/impl/Onf14NetworkElement.java +++ b/sdnr/wt/devicemanager-onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/impl/Onf14NetworkElement.java @@ -27,11 +27,20 @@ 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.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfNotifications; 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; @@ -76,7 +85,7 @@ public class Onf14NetworkElement implements NetworkElement { private static final int EQUIPMENTROOTLEVEL = 0; - private final NetconfAccessor netconfAccessor; + private final NetconfBindingAccessor netconfAccessor; private final DataProvider databaseService; private final Onf14ToInternalDataModel onf14Mapper; private final @NonNull FaultService faultService; @@ -86,27 +95,30 @@ public class Onf14NetworkElement implements NetworkElement { // air interface related members private final List<TechnologySpecificPacKeys> airInterfaceList = new ArrayList<TechnologySpecificPacKeys>(); + @SuppressWarnings("unused") private ListenerRegistration<NotificationListener> airInterfaceNotificationListenerHandler; private @NonNull final Onf14AirInterfaceNotificationListener airInterfaceNotificationListener; // ethernet container related members private final List<TechnologySpecificPacKeys> ethernetContainerList = new ArrayList<TechnologySpecificPacKeys>(); + @SuppressWarnings("unused") private ListenerRegistration<NotificationListener> etherneContainerNotificationListenerHandler; private @NonNull final Onf14EthernetContainerNotificationListener ethernetContainerNotificationListener; // wire interface related members private final List<TechnologySpecificPacKeys> wireInterfaceList = new ArrayList<TechnologySpecificPacKeys>(); + @SuppressWarnings("unused") private ListenerRegistration<NotificationListener> wireInterfaceNotificationListenerHandler; private @NonNull final Onf14WireInterfaceNotificationListener wireInterfaceNotificationListener; - Onf14NetworkElement(NetconfAccessor netconfAccess, DeviceManagerServiceProvider serviceProvider) { + 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; - airInterfaceNotificationListener = new Onf14AirInterfaceNotificationListener(netconfAccess, serviceProvider); + this.airInterfaceNotificationListener = new Onf14AirInterfaceNotificationListener(netconfAccess, serviceProvider); this.etherneContainerNotificationListenerHandler = null; ethernetContainerNotificationListener = new Onf14EthernetContainerNotificationListener(netconfAccess, serviceProvider); @@ -211,7 +223,10 @@ public class Onf14NetworkElement implements NetworkElement { netconfAccessor.doRegisterNotificationListener(ethernetContainerNotificationListener); wireInterfaceNotificationListenerHandler = netconfAccessor.doRegisterNotificationListener(wireInterfaceNotificationListener); - netconfAccessor.registerNotificationsStream(NetconfAccessor.DefaultNotificationsStream); + Optional<NetconfNotifications> notificationsSupport = netconfAccessor.getNotificationAccessor(); + if (notificationsSupport.isPresent()) { + notificationsSupport.get().registerNotificationsStream(NetconfBindingAccessor.DefaultNotificationsStream); + } } @Override @@ -459,12 +474,12 @@ public class Onf14NetworkElement implements NetworkElement { } } - private Optional<ControlConstruct> readControlConstruct(NetconfAccessor netconfAccessor) { + private Optional<ControlConstruct> readControlConstruct(NetconfBindingAccessor netconfAccessor) { return Optional.ofNullable(netconfAccessor.getTransactionUtils().readData(netconfAccessor.getDataBroker(), LogicalDatastoreType.CONFIGURATION, CONTROLCONSTRUCT_IID)); } - private @Nullable Equipment readEquipmentInstance(NetconfAccessor accessData, UniversalId equipmentUuid) { + private @Nullable Equipment readEquipmentInstance(NetconfBindingAccessor accessData, UniversalId equipmentUuid) { final Class<?> clazzPac = Equipment.class; @@ -497,10 +512,12 @@ public class Onf14NetworkElement implements NetworkElement { return localId; } + @SuppressWarnings("unused") public void setLtpUuid(UniversalId uuid) { this.ltpUuid = uuid; } + @SuppressWarnings("unused") public void setLocalId(String lId) { this.localId = lId; } diff --git a/sdnr/wt/devicemanager-onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/impl/Onf14NetworkElementFactory.java b/sdnr/wt/devicemanager-onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/impl/Onf14NetworkElementFactory.java index 5505cecd6..514100292 100644 --- a/sdnr/wt/devicemanager-onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/impl/Onf14NetworkElementFactory.java +++ b/sdnr/wt/devicemanager-onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/impl/Onf14NetworkElementFactory.java @@ -23,21 +23,25 @@ import org.onap.ccsdk.features.sdnr.wt.devicemanager.ne.factory.NetworkElementFa 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.NetconfAccessor; +import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfBindingAccessor; 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 static final Logger log = LoggerFactory.getLogger(Onf14NetworkElementFactory.class); - @Override - public Optional<NetworkElement> create(NetconfAccessor acessor, DeviceManagerServiceProvider serviceProvider) { - if (acessor.getCapabilites().isSupportingNamespace(ControlConstruct.QNAME)) { - log.info("Create device {} ", Onf14NetworkElement.class.getName()); - return Optional.of(new Onf14NetworkElement(acessor, serviceProvider)); - } else { - return Optional.empty(); - } - } + @Override + public Optional<NetworkElement> create(NetconfAccessor accessor, DeviceManagerServiceProvider serviceProvider) { + if (accessor.getCapabilites().isSupportingNamespace(ControlConstruct.QNAME)) { + log.info("Create device {} ", Onf14NetworkElement.class.getName()); + Optional<NetconfBindingAccessor> bindingAccessor = accessor.getNetconfBindingAccessor(); + if (bindingAccessor.isPresent()) { + return Optional.of(new Onf14NetworkElement(bindingAccessor.get(), serviceProvider)); + } + } + return Optional.empty(); + + } } diff --git a/sdnr/wt/devicemanager-onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/impl/Onf14WireInterface.java b/sdnr/wt/devicemanager-onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/impl/Onf14WireInterface.java deleted file mode 100644 index 4446c2087..000000000 --- a/sdnr/wt/devicemanager-onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/impl/Onf14WireInterface.java +++ /dev/null @@ -1,58 +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.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.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * @author alexs - * - */ -public class Onf14WireInterface { - - private static final Logger log = LoggerFactory.getLogger(Onf14WireInterface.class); - - public static org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.SeverityType mapSeverity( - Class<? extends SEVERITYTYPE> severity) { - - if (severity != null) { - if (severity.getTypeName() == SEVERITYTYPECRITICAL.class.getName()) { - return org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.SeverityType.Critical; - } else if (severity.getTypeName() == SEVERITYTYPEMAJOR.class.getName()) { - return org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.SeverityType.Major; - } else if (severity.getTypeName() == SEVERITYTYPEMINOR.class.getName()) { - return org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.SeverityType.Minor; - } else if (severity.getTypeName() == SEVERITYTYPEWARNING.class.getName()) { - return org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.SeverityType.Warning; - } else if (severity.getTypeName() == SEVERITYTYPENONALARMED.class.getName()) { - return org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.SeverityType.NonAlarmed; - } - } - - return org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.SeverityType.NonAlarmed; - } - - -} diff --git a/sdnr/wt/devicemanager-onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/impl/dataprovider/InternalDataModelSeverity.java b/sdnr/wt/devicemanager-onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/impl/dataprovider/InternalDataModelSeverity.java new file mode 100644 index 000000000..97395f496 --- /dev/null +++ b/sdnr/wt/devicemanager-onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/impl/dataprovider/InternalDataModelSeverity.java @@ -0,0 +1,55 @@ +/* + * ============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<String, SeverityType> 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<? extends BaseIdentity> 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-onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/impl/Onf14ToInternalDataModel.java b/sdnr/wt/devicemanager-onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/impl/dataprovider/Onf14ToInternalDataModel.java index 52b159c73..36eaf2fd3 100644 --- a/sdnr/wt/devicemanager-onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/impl/Onf14ToInternalDataModel.java +++ b/sdnr/wt/devicemanager-onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/impl/dataprovider/Onf14ToInternalDataModel.java @@ -15,7 +15,7 @@ * the License. * ============LICENSE_END========================================================================== */ -package org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.impl; +package org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.impl.dataprovider; import java.util.ArrayList; import java.util.Collection; @@ -34,6 +34,7 @@ import org.opendaylight.yang.gen.v1.urn.onf.yang.core.model._1._4.rev191127.equi 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; @@ -43,7 +44,7 @@ import org.slf4j.LoggerFactory; */ public class Onf14ToInternalDataModel { - private static final Logger log = LoggerFactory.getLogger(Onf14ToInternalDataModel.class); + private static final Logger LOG = LoggerFactory.getLogger(Onf14ToInternalDataModel.class); public Inventory getInternalEquipment(NodeId nodeId, Equipment currentEq, Equipment parentEq, long treeLevel) { @@ -56,7 +57,7 @@ public class Onf14ToInternalDataModel { // General inventoryBuilder.setNodeId(nodeId.getValue()); - inventoryBuilder.setTreeLevel(treeLevel); + inventoryBuilder.setTreeLevel(Uint32.valueOf(treeLevel)); inventoryBuilder.setUuid(currentEq.getUuid().getValue()); if (parentEq != null) { @@ -88,7 +89,7 @@ public class Onf14ToInternalDataModel { inventoryBuilder.setManufacturerName(manProp.getManufacturerName()); inventoryBuilder.setManufacturerIdentifier(manProp.getManufacturerIdentifier()); } else { - log.debug("manufacturer-properties is not present in Equipment with uuid={}", + LOG.debug("manufacturer-properties is not present in Equipment with uuid={}", currentEq.getUuid().getValue()); } @@ -99,7 +100,7 @@ public class Onf14ToInternalDataModel { inventoryBuilder.setSerial(eqInstance.getSerialNumber()); inventoryBuilder.setDate(eqInstance.getManufactureDate().getValue()); } else { - log.debug("equipment-instance is not present in Equipment with uuid={}", + LOG.debug("equipment-instance is not present in Equipment with uuid={}", currentEq.getUuid().getValue()); } @@ -113,15 +114,15 @@ public class Onf14ToInternalDataModel { inventoryBuilder.setModelIdentifier(eqType.getModelIdentifier()); inventoryBuilder.setTypeName(eqType.getTypeName()); } else { - log.debug("equipment-type is not present in Equipment with uuid={}", + 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={}", + 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()); + LOG.debug("actual-equipment is not present in Equipment with uuid={}", currentEq.getUuid().getValue()); } return inventoryBuilder.build(); diff --git a/sdnr/wt/devicemanager-onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/impl/equipment/Onf14DomEquipmentManager.java b/sdnr/wt/devicemanager-onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/impl/equipment/Onf14DomEquipmentManager.java new file mode 100644 index 000000000..72ffdf6bc --- /dev/null +++ b/sdnr/wt/devicemanager-onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/impl/equipment/Onf14DomEquipmentManager.java @@ -0,0 +1,231 @@ +/* + * ============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.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +import org.eclipse.jdt.annotation.NonNull; +import org.eclipse.jdt.annotation.Nullable; +import org.onap.ccsdk.features.sdnr.wt.common.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.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.yangtools.util.UnmodifiableCollection; +import org.opendaylight.yangtools.yang.binding.CodeHelpers; +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.NodeIdentifierWithPredicates; +import org.opendaylight.yangtools.yang.data.api.schema.LeafSetEntryNode; +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<UniversalId> equipmentUuidList = new ArrayList<>(); + // end of variables + + // 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); + } + // end of constructors + + // getters and setters + public List<UniversalId> getEquipmentUuidList() { + return equipmentUuidList; + } + // end of getters and setters + + // private methods + private void addEquipmentToDb(Equipment currentEq, Equipment parentEq, long treeLevel, + Map<EquipmentKey, Equipment> equipmentMap, EquipmentKey equipmentKey) { + if (currentEq == null) { + log.info("Ignore empty equipment with key {}", equipmentKey); + return; + } + + // 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; + } + + // 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 + databaseService.writeInventory( + 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); + addEquipmentToDb(equipmentMap.get(equipmentKey), currentEq, treeLevel + 1, equipmentMap, equipmentKey); + } + } + } + // 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<EquipmentKey, Equipment> equipmentMap = controlConstruct.nonnullEquipment(); + // recursively adding the root equipment and all its children into the DB + addEquipmentToDb(equipmentMap.get(equipmentKey), null, EQUIPMENTROOTLEVEL, equipmentMap, equipmentKey); + } + } + + /** + * Read one equipment from device + * + * @param accessData to access device + * @param equipmentUuid uuid of equipment to be read + * @return Optional Equipment + */ + public Optional<Equipment> 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); + } + + /** + * Read one equipment list from device + * + * @param accessData to access device + * @param equipmentUuid uuid of equipment to be read + * @return Optional Equipment + */ + public Optional<ControlConstruct> readEquipmentList(NetconfDomAccessor accessData, UniversalId equipmentUuid) { + + log.info("DBRead Get equipment-list for mountpoint {} for uuid {}", accessData.getNodeId().getValue(), + equipmentUuid.getValue()); + + YangInstanceIdentifier equipmentIIDBuilder = YangInstanceIdentifier.builder() + .node(ControlConstruct.QNAME) + .node(Equipment.QNAME) + .node(NodeIdentifierWithPredicates.of(Equipment.QNAME)) + .build(); + + return accessData.readData(LogicalDatastoreType.CONFIGURATION, equipmentIIDBuilder, + ControlConstruct.class); + } + + /** + * 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<NormalizedNode<?, ?>> oData = + accessData.readDataNode(LogicalDatastoreType.CONFIGURATION, equipmentIIDBuilder.build()); + 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<LeafSetEntryNode<String>> topLevelEquipmentCollection = (UnmodifiableCollection<LeafSetEntryNode<String>>) value; + @NonNull + Iterator<LeafSetEntryNode<String>> it = topLevelEquipmentCollection.iterator(); + while (it.hasNext()) { + LeafSetEntryNode<String> 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-onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/impl/interfaces/Onf14AirInterface.java b/sdnr/wt/devicemanager-onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/impl/interfaces/Onf14AirInterface.java new file mode 100644 index 000000000..2d0d3c52d --- /dev/null +++ b/sdnr/wt/devicemanager-onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/impl/interfaces/Onf14AirInterface.java @@ -0,0 +1,39 @@ +/* + * ============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<? extends SEVERITYTYPE> severity) { + return InternalDataModelSeverity.mapSeverity(severity); + } +} diff --git a/sdnr/wt/devicemanager-onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/impl/Onf14AirInterfaceNotificationListener.java b/sdnr/wt/devicemanager-onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/impl/interfaces/Onf14AirInterfaceNotificationListener.java index dc37949cd..c72976732 100644 --- a/sdnr/wt/devicemanager-onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/impl/Onf14AirInterfaceNotificationListener.java +++ b/sdnr/wt/devicemanager-onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/impl/interfaces/Onf14AirInterfaceNotificationListener.java @@ -19,7 +19,7 @@ * ============LICENSE_END========================================================= * */ -package org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.impl; +package org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.impl.interfaces; import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.DeviceManagerServiceProvider; import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfAccessor; diff --git a/sdnr/wt/devicemanager-onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/impl/interfaces/Onf14DomInterfacePacManager.java b/sdnr/wt/devicemanager-onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/impl/interfaces/Onf14DomInterfacePacManager.java new file mode 100644 index 000000000..f4e697aec --- /dev/null +++ b/sdnr/wt/devicemanager-onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/impl/interfaces/Onf14DomInterfacePacManager.java @@ -0,0 +1,356 @@ +/* + * ============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.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.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.concepts.ListenerRegistration; +import org.opendaylight.yangtools.yang.binding.NotificationListener; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class Onf14DomInterfacePacManager { + + // 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<TechnologySpecificPacKeys> airInterfaceList = new ArrayList<TechnologySpecificPacKeys>(); + @SuppressWarnings("unused") + private ListenerRegistration<NotificationListener> airInterfaceNotificationListenerHandler; + private @NonNull final Onf14AirInterfaceNotificationListener airInterfaceNotificationListener; + + // ethernet container related members + private final List<TechnologySpecificPacKeys> ethernetContainerList = new ArrayList<TechnologySpecificPacKeys>(); + @SuppressWarnings("unused") + private ListenerRegistration<NotificationListener> etherneContainerNotificationListenerHandler; + private @NonNull final Onf14EthernetContainerNotificationListener ethernetContainerNotificationListener; + + // wire interface related members + private final List<TechnologySpecificPacKeys> wireInterfaceList = new ArrayList<TechnologySpecificPacKeys>(); + @SuppressWarnings("unused") + private ListenerRegistration<NotificationListener> wireInterfaceNotificationListenerHandler; + private @NonNull final Onf14WireInterfaceNotificationListener wireInterfaceNotificationListener; + // end of variables + + // constructors + public Onf14DomInterfacePacManager(@NonNull NetconfDomAccessor netconfDomAccessor, + @NonNull DeviceManagerServiceProvider serviceProvider) { + + this.netconfDomAccessor = Objects.requireNonNull(netconfDomAccessor); + this.serviceProvider = Objects.requireNonNull(serviceProvider); + + this.airInterfaceNotificationListenerHandler = null; + this.airInterfaceNotificationListener = + new Onf14AirInterfaceNotificationListener(netconfDomAccessor, serviceProvider); + this.etherneContainerNotificationListenerHandler = null; + ethernetContainerNotificationListener = + new Onf14EthernetContainerNotificationListener(netconfDomAccessor, serviceProvider); + this.wireInterfaceNotificationListenerHandler = null; + 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<LogicalTerminationPoint> 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<LayerProtocol> 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<? extends LAYERPROTOCOLNAMETYPE> layerProtocolName = lp.getLayerProtocolName(); + if (layerProtocolName != null) { + // if the LTP has an airInterface technology extension, the layer protocol name is air-layer + if (layerProtocolName.getTypeName() == 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() == 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() == 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<AirInterfacePac> 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<AirInterfaceCurrentProblems> 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<LogicalTerminationPointKey, LogicalTerminationPoint> ltpMap = + controlConstruct.nonnullLogicalTerminationPoint(); + LogicalTerminationPoint ltp = ltpMap.get(new LogicalTerminationPointKey(ltpUuid)); + if (ltp != null) { + @NonNull + Map<LayerProtocolKey, LayerProtocol> 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())); + } + } + } + } + } + } + + /* + private void readEthernetConainerCurrentProblemForLtp(UniversalId ltpUuid, String localId, FaultData resultList) { + + final Class<EthernetContainerPac> 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<EthernetContainerCurrentProblems> 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<WireInterfacePac> 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<WireInterfaceCurrentProblems> 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-onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/impl/interfaces/Onf14EthernetContainer.java b/sdnr/wt/devicemanager-onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/impl/interfaces/Onf14EthernetContainer.java new file mode 100644 index 000000000..f9769951f --- /dev/null +++ b/sdnr/wt/devicemanager-onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/impl/interfaces/Onf14EthernetContainer.java @@ -0,0 +1,40 @@ +/* + * ============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<? extends SEVERITYTYPE> severity) { + return InternalDataModelSeverity.mapSeverity(severity); + } + +} diff --git a/sdnr/wt/devicemanager-onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/impl/Onf14EthernetContainerNotificationListener.java b/sdnr/wt/devicemanager-onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/impl/interfaces/Onf14EthernetContainerNotificationListener.java index f68d6f306..7cc3c9b4e 100644 --- a/sdnr/wt/devicemanager-onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/impl/Onf14EthernetContainerNotificationListener.java +++ b/sdnr/wt/devicemanager-onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/impl/interfaces/Onf14EthernetContainerNotificationListener.java @@ -19,7 +19,7 @@ * ============LICENSE_END========================================================= * */ -package org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.impl; +package org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.impl.interfaces; import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.DeviceManagerServiceProvider; import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfAccessor; diff --git a/sdnr/wt/devicemanager-onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/impl/interfaces/Onf14WireInterface.java b/sdnr/wt/devicemanager-onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/impl/interfaces/Onf14WireInterface.java new file mode 100644 index 000000000..acb262fcb --- /dev/null +++ b/sdnr/wt/devicemanager-onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/impl/interfaces/Onf14WireInterface.java @@ -0,0 +1,40 @@ +/* + * ============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<? extends SEVERITYTYPE> severity) { + return InternalDataModelSeverity.mapSeverity(severity); + } + +} diff --git a/sdnr/wt/devicemanager-onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/impl/Onf14WireInterfaceNotificationListener.java b/sdnr/wt/devicemanager-onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/impl/interfaces/Onf14WireInterfaceNotificationListener.java index 1d4d5d8e4..0db482afb 100644 --- a/sdnr/wt/devicemanager-onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/impl/Onf14WireInterfaceNotificationListener.java +++ b/sdnr/wt/devicemanager-onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/impl/interfaces/Onf14WireInterfaceNotificationListener.java @@ -19,7 +19,7 @@ * ============LICENSE_END========================================================= * */ -package org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.impl; +package org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.impl.interfaces; import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.DeviceManagerServiceProvider; import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfAccessor; diff --git a/sdnr/wt/devicemanager-onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/impl/interfaces/TechnologySpecificPacKeys.java b/sdnr/wt/devicemanager-onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/impl/interfaces/TechnologySpecificPacKeys.java new file mode 100644 index 000000000..552ba6604 --- /dev/null +++ b/sdnr/wt/devicemanager-onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/impl/interfaces/TechnologySpecificPacKeys.java @@ -0,0 +1,54 @@ +/* + * ============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-onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/impl/util/Debug.java b/sdnr/wt/devicemanager-onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/impl/util/Debug.java new file mode 100644 index 000000000..efa3cf169 --- /dev/null +++ b/sdnr/wt/devicemanager-onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/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.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 +} |