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 | |
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>
52 files changed, 2007 insertions, 1022 deletions
diff --git a/sdnr/wt/devicemanager-onf14/feature/pom.xml b/sdnr/wt/devicemanager-onf14/feature/pom.xml index c826fe9b0..0a75a6ef4 100644 --- a/sdnr/wt/devicemanager-onf14/feature/pom.xml +++ b/sdnr/wt/devicemanager-onf14/feature/pom.xml @@ -29,7 +29,7 @@ <parent> <groupId>org.onap.ccsdk.parent</groupId> <artifactId>single-feature-parent</artifactId> - <version>2.1.0</version> + <version>2.1.1-SNAPSHOT</version> <relativePath/> </parent> diff --git a/sdnr/wt/devicemanager-onf14/installer/pom.xml b/sdnr/wt/devicemanager-onf14/installer/pom.xml index a199f8dad..ad906ab63 100755 --- a/sdnr/wt/devicemanager-onf14/installer/pom.xml +++ b/sdnr/wt/devicemanager-onf14/installer/pom.xml @@ -29,7 +29,7 @@ <parent> <groupId>org.onap.ccsdk.parent</groupId> <artifactId>odlparent-lite</artifactId> - <version>2.1.0</version> + <version>2.1.1-SNAPSHOT</version> <relativePath/> </parent> diff --git a/sdnr/wt/devicemanager-onf14/model/pom.xml b/sdnr/wt/devicemanager-onf14/model/pom.xml index 4a9cba8dd..7a0593d80 100644 --- a/sdnr/wt/devicemanager-onf14/model/pom.xml +++ b/sdnr/wt/devicemanager-onf14/model/pom.xml @@ -29,7 +29,7 @@ <parent> <groupId>org.onap.ccsdk.parent</groupId> <artifactId>binding-parent</artifactId> - <version>2.1.0</version> + <version>2.1.1-SNAPSHOT</version> <relativePath/> </parent> diff --git a/sdnr/wt/devicemanager-onf14/pom.xml b/sdnr/wt/devicemanager-onf14/pom.xml index 7b2801a89..7dbffe3d5 100755 --- a/sdnr/wt/devicemanager-onf14/pom.xml +++ b/sdnr/wt/devicemanager-onf14/pom.xml @@ -29,7 +29,7 @@ <parent> <groupId>org.onap.ccsdk.parent</groupId> <artifactId>odlparent-lite</artifactId> - <version>2.1.0</version> + <version>2.1.1-SNAPSHOT</version> <relativePath/> </parent> diff --git a/sdnr/wt/devicemanager-onf14/provider/pom.xml b/sdnr/wt/devicemanager-onf14/provider/pom.xml index 749011b40..c79dccf22 100644 --- a/sdnr/wt/devicemanager-onf14/provider/pom.xml +++ b/sdnr/wt/devicemanager-onf14/provider/pom.xml @@ -29,7 +29,7 @@ <parent> <groupId>org.onap.ccsdk.parent</groupId> <artifactId>binding-parent</artifactId> - <version>2.1.0</version> + <version>2.1.1-SNAPSHOT</version> <relativePath/> </parent> @@ -47,7 +47,6 @@ </licenses> <properties> - <checkstyle.skip>true</checkstyle.skip> <!-- POM configuration --> <maven.javadoc.skip>true</maven.javadoc.skip> <maven.build.timestamp.format>yyyy-MM-dd HH:mm</maven.build.timestamp.format> <buildtime>${maven.build.timestamp} UTC</buildtime> 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/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/test/mock/TransactionUtilsMock.java b/sdnr/wt/devicemanager-onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/impl/interfaces/Onf14WireInterface.java index 9546ae9f9..acb262fcb 100644 --- a/sdnr/wt/devicemanager-onf14/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/test/mock/TransactionUtilsMock.java +++ b/sdnr/wt/devicemanager-onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/impl/interfaces/Onf14WireInterface.java @@ -15,30 +15,26 @@ * the License. * ============LICENSE_END========================================================================== */ -package org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.test.mock; +package org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.impl.interfaces; -import java.util.concurrent.atomic.AtomicBoolean; -import java.util.concurrent.atomic.AtomicReference; import org.eclipse.jdt.annotation.Nullable; -import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.TransactionUtils; -import org.opendaylight.mdsal.binding.api.DataBroker; -import org.opendaylight.mdsal.common.api.LogicalDatastoreType; -import org.opendaylight.yangtools.yang.binding.DataObject; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; +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; -public class TransactionUtilsMock implements TransactionUtils { +/** + * @author alexs + * + */ +public class Onf14WireInterface { - @Override - public <T extends DataObject> @Nullable T readData(DataBroker dataBroker, LogicalDatastoreType dataStoreType, - InstanceIdentifier<T> iid) { - return null; - } + @SuppressWarnings("unused") + private static final Logger LOG = LoggerFactory.getLogger(Onf14WireInterface.class); - @Override - public <T extends DataObject> @Nullable T readDataOptionalWithStatus(DataBroker dataBroker, - LogicalDatastoreType dataStoreType, InstanceIdentifier<T> iid, AtomicBoolean noErrorIndication, - AtomicReference<String> statusIndicator) { - return null; + 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 +} diff --git a/sdnr/wt/devicemanager-onf14/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/TestDeviceManagerOnf14Impl.java b/sdnr/wt/devicemanager-onf14/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/TestDeviceManagerOnf14Impl.java index 8dbfa2f5c..4b69e4232 100644 --- a/sdnr/wt/devicemanager-onf14/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/TestDeviceManagerOnf14Impl.java +++ b/sdnr/wt/devicemanager-onf14/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/TestDeviceManagerOnf14Impl.java @@ -43,7 +43,6 @@ public class TestDeviceManagerOnf14Impl extends Mockito { devMgrOnf14.setNetconfNetworkElementService(netconfElemService); devMgrOnf14.init(); } catch (Exception e) { - // TODO Auto-generated catch block e.printStackTrace(); } } diff --git a/sdnr/wt/devicemanager-onf14/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/TestOnf14AirInterfaceNotificationListener.java b/sdnr/wt/devicemanager-onf14/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/TestOnf14AirInterfaceNotificationListener.java index 7dbbc22b3..d03d50c1a 100644 --- a/sdnr/wt/devicemanager-onf14/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/TestOnf14AirInterfaceNotificationListener.java +++ b/sdnr/wt/devicemanager-onf14/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/TestOnf14AirInterfaceNotificationListener.java @@ -23,12 +23,11 @@ import org.mockito.Mockito; import org.mockito.invocation.InvocationOnMock; import org.mockito.stubbing.Answer; import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.DataProvider; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.impl.Onf14AirInterfaceNotificationListener; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.test.mock.NetconfAccessorMock; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.impl.interfaces.Onf14AirInterfaceNotificationListener; 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.NetconfBindingAccessor; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DateAndTime; import org.opendaylight.yang.gen.v1.urn.onf.yang.air._interface._2._0.rev200121.AttributeValueChangedNotification; import org.opendaylight.yang.gen.v1.urn.onf.yang.air._interface._2._0.rev200121.ObjectCreationNotification; @@ -44,7 +43,7 @@ import org.opendaylight.yang.gen.v1.urn.onf.yang.core.model._1._4.rev191127.Univ import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId; public class TestOnf14AirInterfaceNotificationListener extends Mockito { - private NetconfAccessor accessor; + private NetconfBindingAccessor accessor; private NodeId nodeId; private DeviceManagerServiceProvider serviceProvider; private FaultService faultService; @@ -58,7 +57,7 @@ public class TestOnf14AirInterfaceNotificationListener extends Mockito { @Before public void init() { - accessor = mock(NetconfAccessorMock.class); + accessor = mock(NetconfBindingAccessor.class); nodeId = mock(NodeId.class); serviceProvider = mock(DeviceManagerServiceProvider.class); faultService = mock(FaultService.class); diff --git a/sdnr/wt/devicemanager-onf14/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/TestOnf14EthernetContainerNotificationListener.java b/sdnr/wt/devicemanager-onf14/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/TestOnf14EthernetContainerNotificationListener.java index dedcf79c8..f6f7d9045 100644 --- a/sdnr/wt/devicemanager-onf14/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/TestOnf14EthernetContainerNotificationListener.java +++ b/sdnr/wt/devicemanager-onf14/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/TestOnf14EthernetContainerNotificationListener.java @@ -23,12 +23,11 @@ import org.mockito.Mockito; import org.mockito.invocation.InvocationOnMock; import org.mockito.stubbing.Answer; import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.DataProvider; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.impl.Onf14EthernetContainerNotificationListener; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.test.mock.NetconfAccessorMock; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.impl.interfaces.Onf14EthernetContainerNotificationListener; 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.NetconfBindingAccessor; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DateAndTime; import org.opendaylight.yang.gen.v1.urn.onf.yang.core.model._1._4.rev191127.UniversalId; import org.opendaylight.yang.gen.v1.urn.onf.yang.ethernet.container._2._0.rev200121.AttributeValueChangedNotification; @@ -44,7 +43,7 @@ import org.opendaylight.yang.gen.v1.urn.onf.yang.ethernet.container._2._0.rev200 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId; public class TestOnf14EthernetContainerNotificationListener extends Mockito { - private NetconfAccessor accessor; + private NetconfBindingAccessor accessor; private NodeId nodeId; private DeviceManagerServiceProvider serviceProvider; private FaultService faultService; @@ -58,7 +57,7 @@ public class TestOnf14EthernetContainerNotificationListener extends Mockito { @Before public void init() { - accessor = mock(NetconfAccessorMock.class); + accessor = mock(NetconfBindingAccessor.class); nodeId = mock(NodeId.class); serviceProvider = mock(DeviceManagerServiceProvider.class); faultService = mock(FaultService.class); @@ -71,23 +70,23 @@ public class TestOnf14EthernetContainerNotificationListener extends Mockito { attrValChangedNotif = mock(AttributeValueChangedNotification.class); when(accessor.getNodeId()).thenReturn(nodeId); - when(problemNotif.getCounter()).thenReturn(new Long(10)); + when(problemNotif.getCounter()).thenReturn(10L); when(problemNotif.getTimestamp()).thenReturn(new DateAndTime("2020-02-05T12:30:45.283Z")); when(problemNotif.getObjectIdRef()).thenReturn(new UniversalId("12345678-0123-0abc-abcd-0123456789AB")); when(problemNotif.getProblem()).thenReturn("modulationIsDownShifted"); when(attrValChangedNotif.getAttributeName()).thenReturn("12345678-0123-2345-abcd-0123456789AB"); - when(attrValChangedNotif.getCounter()).thenReturn(new Long(20)); + when(attrValChangedNotif.getCounter()).thenReturn(20L); when(attrValChangedNotif.getNewValue()).thenReturn("new-value"); when(attrValChangedNotif.getObjectIdRef()).thenReturn(new UniversalId("12345678-0123-1234-abcd-0123456789AB")); when(attrValChangedNotif.getTimestamp()).thenReturn(new DateAndTime("2020-02-05T12:30:45.283Z")); when(creationNotif.getObjectType()).thenReturn("air-interface-name"); - when(creationNotif.getCounter()).thenReturn(new Long(20)); + when(creationNotif.getCounter()).thenReturn(20L); when(creationNotif.getObjectIdRef()).thenReturn(new UniversalId("12345678-0123-1234-abcd-0123456789AB")); when(creationNotif.getTimestamp()).thenReturn(new DateAndTime("2020-02-05T12:30:45.283Z")); - when(deletionNotif.getCounter()).thenReturn(new Long(20)); + when(deletionNotif.getCounter()).thenReturn(20L); when(deletionNotif.getObjectIdRef()).thenReturn(new UniversalId("12345678-0123-1234-abcd-0123456789AB")); when(deletionNotif.getTimestamp()).thenReturn(new DateAndTime("2020-02-05T12:30:45.283Z")); diff --git a/sdnr/wt/devicemanager-onf14/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/TestOnf14NetworkElement.java b/sdnr/wt/devicemanager-onf14/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/TestOnf14NetworkElement.java index d87e6d232..7a5658a4f 100644 --- a/sdnr/wt/devicemanager-onf14/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/TestOnf14NetworkElement.java +++ b/sdnr/wt/devicemanager-onf14/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/TestOnf14NetworkElement.java @@ -28,35 +28,36 @@ import org.mockito.Mockito; 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.onf14.impl.Onf14NetworkElementFactory; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.test.mock.NetconfAccessorMock; 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.netconfnodestateservice.Capabilities; +import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfBindingAccessor; +import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfDomAccessor; import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.TransactionUtils; -import org.opendaylight.mdsal.binding.api.DataBroker; import org.opendaylight.mdsal.common.api.LogicalDatastoreType; +import org.opendaylight.mdsal.dom.api.DOMDataBroker; 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.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import org.opendaylight.yangtools.yang.common.QName; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; public class TestOnf14NetworkElement extends Mockito { - static NetconfAccessorMock accessor; + private static String NODEIDSTRING = "nSky"; + + static NetconfDomAccessor accessor; static DeviceManagerServiceProvider serviceProvider; static Capabilities capabilities; - QName qCapability; static DataProvider dataProvider; static FaultService faultService; - static DataBroker dataBroker; + static DOMDataBroker dataBroker; static TransactionUtils transactionUtils; static ControlConstruct controlConstruct; @Before public void init() { capabilities = mock(Capabilities.class); - accessor = mock(NetconfAccessorMock.class); + accessor = mock(NetconfDomAccessor.class); serviceProvider = mock(DeviceManagerServiceProvider.class); NodeId nNodeId = new NodeId("nSky"); @@ -69,17 +70,16 @@ public class TestOnf14NetworkElement extends Mockito { faultService = mock(FaultService.class); when(serviceProvider.getFaultService()).thenReturn(faultService); - dataBroker = mock(DataBroker.class); + dataBroker = mock(DOMDataBroker.class); when(accessor.getDataBroker()).thenReturn(dataBroker); controlConstruct = mock(ControlConstruct.class); - transactionUtils = mock(TransactionUtils.class); - when(accessor.getTransactionUtils()).thenReturn(transactionUtils); - InstanceIdentifier<ControlConstruct> CONTROLCONSTRUCT_IID = - InstanceIdentifier.builder(ControlConstruct.class).build(); - when(accessor.getTransactionUtils().readData(accessor.getDataBroker(), LogicalDatastoreType.CONFIGURATION, - CONTROLCONSTRUCT_IID)).thenReturn(controlConstruct); + YangInstanceIdentifier CONTROLCONSTRUCT_IID = + YangInstanceIdentifier.builder().node(ControlConstruct.QNAME).build(); + + when(accessor.readData(LogicalDatastoreType.CONFIGURATION, CONTROLCONSTRUCT_IID, ControlConstruct.class)) + .thenReturn(Optional.of(controlConstruct)); List<UniversalId> topLevelEqList = null; UniversalId uuid = new UniversalId("0Aabcdef-0abc-0cfD-0abC-0123456789AB"); @@ -91,10 +91,21 @@ public class TestOnf14NetworkElement extends Mockito { @Test public void testGeneric() { Optional<NetworkElement> onfNe; + NodeId nodeId = new NodeId(NODEIDSTRING); + NetconfBindingAccessor bindingAccessor = mock(NetconfBindingAccessor.class); + when(bindingAccessor.getTransactionUtils()).thenReturn(mock(TransactionUtils.class)); + when(bindingAccessor.getNodeId()).thenReturn(nodeId); + + NetconfDomAccessor domAccessor = mock(NetconfDomAccessor.class); + when(domAccessor.getNodeId()).thenReturn(nodeId); + when(accessor.getCapabilites().isSupportingNamespace(ControlConstruct.QNAME)).thenReturn(true); + when(accessor.getNetconfBindingAccessor()).thenReturn(Optional.of(bindingAccessor)); + when(accessor.getNetconfDomAccessor()).thenReturn(Optional.of(domAccessor)); + Onf14NetworkElementFactory factory = new Onf14NetworkElementFactory(); onfNe = factory.create(accessor, serviceProvider); - assertTrue(factory.create(accessor, serviceProvider).isPresent()); + assertTrue(onfNe.isPresent()); onfNe.get().register(); onfNe.get().deregister(); diff --git a/sdnr/wt/devicemanager-onf14/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/TestOnf14NetworkElementFactory.java b/sdnr/wt/devicemanager-onf14/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/TestOnf14NetworkElementFactory.java index 59e57da11..4087607d1 100644 --- a/sdnr/wt/devicemanager-onf14/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/TestOnf14NetworkElementFactory.java +++ b/sdnr/wt/devicemanager-onf14/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/TestOnf14NetworkElementFactory.java @@ -19,20 +19,22 @@ package org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14; import static org.junit.Assert.assertTrue; import java.io.IOException; +import java.util.Optional; import org.junit.BeforeClass; import org.junit.Test; import org.mockito.Mockito; +import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.DataProvider; import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.impl.Onf14NetworkElementFactory; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.test.mock.NetconfAccessorMock; 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.opendaylight.yangtools.yang.common.QName; public class TestOnf14NetworkElementFactory extends Mockito { - static NetconfAccessor accessor; + static NetconfBindingAccessor accessor; static DeviceManagerServiceProvider serviceProvider; static Capabilities capabilities; QName qCapability; @@ -40,16 +42,18 @@ public class TestOnf14NetworkElementFactory extends Mockito { @BeforeClass public static void init() throws InterruptedException, IOException { capabilities = mock(Capabilities.class); - accessor = mock(NetconfAccessorMock.class); + accessor = mock(NetconfBindingAccessor.class); serviceProvider = mock(DeviceManagerServiceProvider.class); when(accessor.getCapabilites()).thenReturn(capabilities); - when(serviceProvider.getDataProvider()).thenReturn(null); + when(serviceProvider.getDataProvider()).thenReturn(mock(DataProvider.class)); } @Test public void testCreateOnf14Component() throws Exception { when(accessor.getCapabilites().isSupportingNamespace(ControlConstruct.QNAME)).thenReturn(true); + when(accessor.getNetconfBindingAccessor()).thenReturn(Optional.of(mock(NetconfBindingAccessor.class))); + when(accessor.getNetconfDomAccessor()).thenReturn(Optional.of(mock(NetconfDomAccessor.class))); Onf14NetworkElementFactory factory = new Onf14NetworkElementFactory(); assertTrue((factory.create(accessor, serviceProvider)).isPresent()); } @@ -58,7 +62,7 @@ public class TestOnf14NetworkElementFactory extends Mockito { public void testCreateNone() throws Exception { when(accessor.getCapabilites().isSupportingNamespace(ControlConstruct.QNAME)).thenReturn(false); Onf14NetworkElementFactory factory = new Onf14NetworkElementFactory(); - assertTrue(!(factory.create(accessor, serviceProvider).isPresent())); + assertTrue(factory.create(accessor, serviceProvider).isEmpty()); } } diff --git a/sdnr/wt/devicemanager-onf14/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/TestOnf14ToInternalDataModel2.java b/sdnr/wt/devicemanager-onf14/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/TestOnf14ToInternalDataModel2.java index ca36f7946..b0b00d935 100644 --- a/sdnr/wt/devicemanager-onf14/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/TestOnf14ToInternalDataModel2.java +++ b/sdnr/wt/devicemanager-onf14/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/TestOnf14ToInternalDataModel2.java @@ -18,17 +18,19 @@ package org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14; import static org.junit.Assert.assertEquals; -import java.util.ArrayList; -import java.util.List; +import java.util.HashMap; +import java.util.Map; +import org.eclipse.jdt.annotation.NonNull; import org.junit.BeforeClass; import org.junit.Test; import org.mockito.Mockito; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.impl.Onf14ToInternalDataModel; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.impl.dataprovider.Onf14ToInternalDataModel; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DateAndTime; import org.opendaylight.yang.gen.v1.urn.onf.yang.core.model._1._4.rev191127.Equipment; 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.onf.yang.core.model._1._4.rev191127.equipment.ContainedHolderKey; import org.opendaylight.yang.gen.v1.urn.onf.yang.core.model._1._4.rev191127.equipment.detail.ManufacturedThing; import org.opendaylight.yang.gen.v1.urn.onf.yang.core.model._1._4.rev191127.manufactured.thing.EquipmentInstance; import org.opendaylight.yang.gen.v1.urn.onf.yang.core.model._1._4.rev191127.manufactured.thing.EquipmentType; @@ -65,8 +67,8 @@ public class TestOnf14ToInternalDataModel2 extends Mockito { when(currentEq.getUuid()).thenReturn(new UniversalId("0Aabcdef-0abc-0cfD-0abC-0123456789AB")); when(parentEq.getUuid()).thenReturn(new UniversalId("0Aabcdef-0123-0abc-abcd-0123456789AB")); - List<ContainedHolder> containedHolderList = new ArrayList<ContainedHolder>(); - containedHolderList.add(holder); + @NonNull Map<ContainedHolderKey, ContainedHolder> containedHolderList = new HashMap<>(); + containedHolderList.put(holder.key(),holder); when(currentEq.nonnullContainedHolder()).thenReturn(containedHolderList); } diff --git a/sdnr/wt/devicemanager-onf14/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/TestOnf14WireInterfaceNotificationListener.java b/sdnr/wt/devicemanager-onf14/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/TestOnf14WireInterfaceNotificationListener.java index 267e9a813..e1b13f118 100644 --- a/sdnr/wt/devicemanager-onf14/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/TestOnf14WireInterfaceNotificationListener.java +++ b/sdnr/wt/devicemanager-onf14/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/TestOnf14WireInterfaceNotificationListener.java @@ -23,12 +23,11 @@ import org.mockito.Mockito; import org.mockito.invocation.InvocationOnMock; import org.mockito.stubbing.Answer; import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.DataProvider; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.impl.Onf14WireInterfaceNotificationListener; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.test.mock.NetconfAccessorMock; +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.service.NotificationService; -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.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DateAndTime; import org.opendaylight.yang.gen.v1.urn.onf.yang.core.model._1._4.rev191127.UniversalId; import org.opendaylight.yang.gen.v1.urn.onf.yang.wire._interface._2._0.rev200123.AttributeValueChangedNotification; @@ -44,7 +43,7 @@ import org.opendaylight.yang.gen.v1.urn.onf.yang.wire._interface._2._0.rev200123 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId; public class TestOnf14WireInterfaceNotificationListener extends Mockito { - private NetconfAccessor accessor; + private NetconfBindingAccessor accessor; private NodeId nodeId; private DeviceManagerServiceProvider serviceProvider; private FaultService faultService; @@ -58,7 +57,7 @@ public class TestOnf14WireInterfaceNotificationListener extends Mockito { @Before public void init() { - accessor = mock(NetconfAccessorMock.class); + accessor = mock(NetconfBindingAccessor.class); nodeId = mock(NodeId.class); serviceProvider = mock(DeviceManagerServiceProvider.class); faultService = mock(FaultService.class); diff --git a/sdnr/wt/devicemanager-onf14/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/TestSeverity.java b/sdnr/wt/devicemanager-onf14/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/TestSeverity.java new file mode 100644 index 000000000..686942a6b --- /dev/null +++ b/sdnr/wt/devicemanager-onf14/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/TestSeverity.java @@ -0,0 +1,80 @@ +/* + * ============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; + +import static org.junit.Assert.assertTrue; +import org.junit.Test; +import org.mockito.Mockito; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.impl.interfaces.Onf14AirInterface; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.impl.interfaces.Onf14WireInterface; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.SeverityType; + +public class TestSeverity extends Mockito { + + @Test + public void test1_1() { + assertTrue(Onf14WireInterface.mapSeverity( + org.opendaylight.yang.gen.v1.urn.onf.yang.wire._interface._2._0.rev200123.SEVERITYTYPECRITICAL.class) + .equals(SeverityType.Critical)); + } + + @Test + public void test1_2() { + assertTrue(Onf14WireInterface.mapSeverity( + org.opendaylight.yang.gen.v1.urn.onf.yang.wire._interface._2._0.rev200123.SEVERITYTYPEWARNING.class) + .equals(SeverityType.Warning)); + } + + @Test + public void test1_3() { + assertTrue(Onf14WireInterface.mapSeverity( + org.opendaylight.yang.gen.v1.urn.onf.yang.wire._interface._2._0.rev200123.SEVERITYTYPEMINOR.class) + .equals(SeverityType.Minor)); + } + + @Test + public void test1_4() { + assertTrue(Onf14WireInterface.mapSeverity( + org.opendaylight.yang.gen.v1.urn.onf.yang.wire._interface._2._0.rev200123.SEVERITYTYPEMAJOR.class) + .equals(SeverityType.Major)); + } + + public void test2_1() { + assertTrue(Onf14AirInterface.mapSeverity( + org.opendaylight.yang.gen.v1.urn.onf.yang.air._interface._2._0.rev200121.SEVERITYTYPECRITICAL.class) + .equals(SeverityType.Critical)); + } + + @Test + public void test2_2() { + assertTrue(Onf14AirInterface.mapSeverity( + org.opendaylight.yang.gen.v1.urn.onf.yang.air._interface._2._0.rev200121.SEVERITYTYPEMINOR.class) + .equals(SeverityType.Minor)); + } + + @Test + public void test2_3() { + assertTrue(Onf14AirInterface.mapSeverity(null).equals(SeverityType.NonAlarmed)); + } + + +} diff --git a/sdnr/wt/devicemanager-onf14/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/test/mock/NetconfAccessorMock.java b/sdnr/wt/devicemanager-onf14/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/test/mock/NetconfAccessorMock.java deleted file mode 100644 index 832485410..000000000 --- a/sdnr/wt/devicemanager-onf14/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/test/mock/NetconfAccessorMock.java +++ /dev/null @@ -1,112 +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.test.mock; - -import com.google.common.util.concurrent.ListenableFuture; -import java.util.List; -import org.eclipse.jdt.annotation.NonNull; -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.TransactionUtils; -import org.opendaylight.mdsal.binding.api.DataBroker; -import org.opendaylight.mdsal.binding.api.MountPoint; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netconf.notification._1._0.rev080714.CreateSubscriptionOutput; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netmod.notification.rev080714.netconf.streams.Stream; -import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.NetconfNode; -import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId; -import org.opendaylight.yangtools.concepts.ListenerRegistration; -import org.opendaylight.yangtools.yang.binding.NotificationListener; -import org.opendaylight.yangtools.yang.common.RpcResult; - -/** - */ -public class NetconfAccessorMock implements NetconfAccessor { - - private final NodeId nNodeId; - private final NetconfNode netconfNode; - private final MountPoint mountpoint; - private final DataBroker netconfNodeDataBroker; - - public NetconfAccessorMock(NodeId nNodeId, NetconfNode netconfNode, MountPoint mountpoint, - DataBroker netconfNodeDataBroker) { - this.nNodeId = nNodeId; - this.netconfNode = netconfNode; - this.mountpoint = mountpoint; - this.netconfNodeDataBroker = netconfNodeDataBroker; - } - - @Override - public NodeId getNodeId() { - return nNodeId; - } - - @Override - public NetconfNode getNetconfNode() { - return netconfNode; - } - - @Override - public Capabilities getCapabilites() { - return null; - } - - @Override - public DataBroker getDataBroker() { - return netconfNodeDataBroker; - } - - @Override - public MountPoint getMountpoint() { - return mountpoint; - } - - @Override - public TransactionUtils getTransactionUtils() { - return null; - } - - @Override - public <T extends NotificationListener> ListenerRegistration<NotificationListener> doRegisterNotificationListener( - @NonNull T listener) { - return null; - } - - @Override - public ListenableFuture<RpcResult<CreateSubscriptionOutput>> registerNotificationsStream(String streamName) { - return null; - } - - @Override - public void registerNotificationsStream(List<Stream> streamList) { - // TODO Auto-generated method stub - - } - - @Override - public boolean isNCNotificationsSupported() { - // TODO Auto-generated method stub - return false; - } - - @Override - public List<Stream> getNotificationStreams() { - // TODO Auto-generated method stub - return null; - } - -} diff --git a/sdnr/wt/devicemanager-openroadm/feature/pom.xml b/sdnr/wt/devicemanager-openroadm/feature/pom.xml index ba21bbcd7..0ef0c08a9 100644 --- a/sdnr/wt/devicemanager-openroadm/feature/pom.xml +++ b/sdnr/wt/devicemanager-openroadm/feature/pom.xml @@ -27,7 +27,7 @@ <parent> <groupId>org.onap.ccsdk.parent</groupId> <artifactId>single-feature-parent</artifactId> - <version>2.1.0</version> + <version>2.1.1-SNAPSHOT</version> <relativePath/> </parent> diff --git a/sdnr/wt/devicemanager-openroadm/installer/pom.xml b/sdnr/wt/devicemanager-openroadm/installer/pom.xml index 8f647d1ff..1aa53e4d7 100755 --- a/sdnr/wt/devicemanager-openroadm/installer/pom.xml +++ b/sdnr/wt/devicemanager-openroadm/installer/pom.xml @@ -20,14 +20,13 @@ ~ ============LICENSE_END======================================================= ~ --> - <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.onap.ccsdk.parent</groupId> <artifactId>odlparent-lite</artifactId> - <version>2.1.0</version> + <version>2.1.1-SNAPSHOT</version> <relativePath/> </parent> diff --git a/sdnr/wt/devicemanager-openroadm/model/pom.xml b/sdnr/wt/devicemanager-openroadm/model/pom.xml index 9fd87c129..d40aafd65 100644 --- a/sdnr/wt/devicemanager-openroadm/model/pom.xml +++ b/sdnr/wt/devicemanager-openroadm/model/pom.xml @@ -27,7 +27,7 @@ <parent> <groupId>org.onap.ccsdk.parent</groupId> <artifactId>binding-parent</artifactId> - <version>2.1.0</version> + <version>2.1.1-SNAPSHOT</version> <relativePath/> </parent> diff --git a/sdnr/wt/devicemanager-openroadm/pom.xml b/sdnr/wt/devicemanager-openroadm/pom.xml index 7dc90ff55..95b75ca3a 100755 --- a/sdnr/wt/devicemanager-openroadm/pom.xml +++ b/sdnr/wt/devicemanager-openroadm/pom.xml @@ -27,7 +27,7 @@ <parent> <groupId>org.onap.ccsdk.parent</groupId> <artifactId>odlparent-lite</artifactId> - <version>2.1.0</version> + <version>2.1.1-SNAPSHOT</version> <relativePath/> </parent> @@ -49,12 +49,12 @@ <feature-name>sdnr-wt-devicemanager-openroadm</feature-name> </properties> <!-- <reporting> - <plugins> + <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-project-info-reports-plugin</artifactId> <version>2.9</version> - </plugin> - </plugins> + </plugin> + </plugins> </reporting> --> </project> diff --git a/sdnr/wt/devicemanager-openroadm/provider/pom.xml b/sdnr/wt/devicemanager-openroadm/provider/pom.xml index 555ef9a8f..f5cfc6c33 100644 --- a/sdnr/wt/devicemanager-openroadm/provider/pom.xml +++ b/sdnr/wt/devicemanager-openroadm/provider/pom.xml @@ -27,7 +27,7 @@ <parent> <groupId>org.onap.ccsdk.parent</groupId> <artifactId>binding-parent</artifactId> - <version>2.1.0</version> + <version>2.1.1-SNAPSHOT</version> <relativePath/> </parent> @@ -45,7 +45,6 @@ </licenses> <properties> - <checkstyle.skip>true</checkstyle.skip> <!-- POM configuration --> <maven.javadoc.skip>true</maven.javadoc.skip> <maven.build.timestamp.format>yyyy-MM-dd HH:mm</maven.build.timestamp.format> <buildtime>${maven.build.timestamp} UTC</buildtime> @@ -60,8 +59,8 @@ <scope>test</scope> </dependency> <dependency> - <groupId>net.bytebuddy</groupId> <artifactId>byte-buddy</artifactId> + <groupId>net.bytebuddy</groupId> <version>1.9.10</version> <scope>test</scope> </dependency> @@ -90,6 +89,11 @@ <artifactId>sal-netconf-connector</artifactId> <scope>provided</scope> </dependency> + <dependency> + <groupId>org.osgi</groupId> + <artifactId>org.osgi.core</artifactId> + <scope>provided</scope> + </dependency> </dependencies> <build> diff --git a/sdnr/wt/devicemanager-openroadm/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm/impl/DeviceManagerOpenroadmImpl.java b/sdnr/wt/devicemanager-openroadm/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm/impl/DeviceManagerOpenroadmImpl.java index fc5aabaa7..e522f4bd7 100644 --- a/sdnr/wt/devicemanager-openroadm/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm/impl/DeviceManagerOpenroadmImpl.java +++ b/sdnr/wt/devicemanager-openroadm/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm/impl/DeviceManagerOpenroadmImpl.java @@ -62,7 +62,7 @@ public class DeviceManagerOpenroadmImpl implements AutoCloseable { LOG.info("Session Initiated start {}", APPLICATION_NAME); - resOpenRoadm = netconfNetworkElementService.registerNetworkElementFactory(new OpenroadmNetworkElementFactory()); + resOpenRoadm = netconfNetworkElementService.registerBindingNetworkElementFactory(new OpenroadmNetworkElementFactory()); netconfNetworkElementService.writeToEventLog(APPLICATION_NAME, "startup", "done"); diff --git a/sdnr/wt/devicemanager-openroadm/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm/impl/InitialDeviceAlarmReader.java b/sdnr/wt/devicemanager-openroadm/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm/impl/InitialDeviceAlarmReader.java index f1b3821b8..ccada31bc 100644 --- a/sdnr/wt/devicemanager-openroadm/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm/impl/InitialDeviceAlarmReader.java +++ b/sdnr/wt/devicemanager-openroadm/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm/impl/InitialDeviceAlarmReader.java @@ -29,7 +29,7 @@ import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.DataProvider; 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.NetconfAccessor; +import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfBindingAccessor; import org.opendaylight.mdsal.common.api.LogicalDatastoreType; import org.opendaylight.yang.gen.v1.http.org.openroadm.alarm.rev191129.ActiveAlarmList; import org.opendaylight.yang.gen.v1.http.org.openroadm.alarm.rev191129.OrgOpenroadmAlarmListener; @@ -52,13 +52,13 @@ public class InitialDeviceAlarmReader { // variables private Integer count = 1; private static final Logger log = LoggerFactory.getLogger(OrgOpenroadmAlarmListener.class); - private final NetconfAccessor netConfAccesor; + private final NetconfBindingAccessor netConfAccesor; private final @NonNull FaultService faultEventListener; private final DataProvider dataProvider; // end of variables // constructors - public InitialDeviceAlarmReader(NetconfAccessor accessor, DeviceManagerServiceProvider serviceProvider) { + public InitialDeviceAlarmReader(NetconfBindingAccessor accessor, DeviceManagerServiceProvider serviceProvider) { this.netConfAccesor = accessor; this.faultEventListener = serviceProvider.getFaultService(); this.dataProvider = serviceProvider.getDataProvider(); @@ -105,7 +105,7 @@ public class InitialDeviceAlarmReader { // private methods // Read Alarm Data - private ActiveAlarmList getActiveAlarmList(NetconfAccessor accessor) { + private ActiveAlarmList getActiveAlarmList(NetconfBindingAccessor accessor) { final Class<ActiveAlarmList> classAlarm = ActiveAlarmList.class; log.info("Get Alarm data for element {}", accessor.getNodeId().getValue()); InstanceIdentifier<ActiveAlarmList> alarmDataIid = InstanceIdentifier.builder(classAlarm).build(); diff --git a/sdnr/wt/devicemanager-openroadm/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm/impl/OpenroadmDeviceChangeNotificationListener.java b/sdnr/wt/devicemanager-openroadm/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm/impl/OpenroadmDeviceChangeNotificationListener.java index 924af99c2..a79bed706 100644 --- a/sdnr/wt/devicemanager-openroadm/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm/impl/OpenroadmDeviceChangeNotificationListener.java +++ b/sdnr/wt/devicemanager-openroadm/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm/impl/OpenroadmDeviceChangeNotificationListener.java @@ -24,6 +24,8 @@ package org.onap.ccsdk.features.sdnr.wt.devicemanager.openroadm.impl; import java.util.List; import org.eclipse.jdt.annotation.NonNull; import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.DataProvider; +import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.NetconfTimeStamp; +import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.types.NetconfTimeStampImpl; import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfAccessor; import org.opendaylight.yang.gen.v1.http.org.openroadm.alarm.rev191129.OrgOpenroadmAlarmListener; import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev191129.ChangeNotification; @@ -31,6 +33,7 @@ import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev191129.CreateTe import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev191129.OrgOpenroadmDeviceListener; import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev191129.OtdrScanResult; import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev191129.change.notification.Edit; +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.SourceType; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; @@ -50,6 +53,7 @@ public class OpenroadmDeviceChangeNotificationListener implements OrgOpenroadmDe private Integer counter = 1; private final NetconfAccessor netconfAccessor; private final DataProvider databaseProvider; + private static final NetconfTimeStamp ncTimeConverter = NetconfTimeStampImpl.getConverter(); // end of variables // constructors @@ -106,7 +110,8 @@ public class OpenroadmDeviceChangeNotificationListener implements OrgOpenroadmDe EventlogBuilder eventlogBuilder = new EventlogBuilder(); eventlogBuilder.setId(notification.getShelfId()).setAttributeName(notification.getShelfId()) .setObjectId(notification.getShelfId()).setNodeId(this.netconfAccessor.getNodeId().getValue()) - .setCounter(counter).setNewValue(notification.getStatus().getName()).setSourceType(SourceType.Netconf); + .setCounter(counter).setNewValue(notification.getStatus().getName()).setSourceType(SourceType.Netconf) + .setTimestamp(new DateAndTime(ncTimeConverter.getTimeStamp())); databaseProvider.writeEventLog(eventlogBuilder.build()); log.info("Create-techInfo Notification written "); counter++; diff --git a/sdnr/wt/devicemanager-openroadm/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm/impl/OpenroadmInventoryInput.java b/sdnr/wt/devicemanager-openroadm/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm/impl/OpenroadmInventoryInput.java index c62bb053f..9618ce2af 100644 --- a/sdnr/wt/devicemanager-openroadm/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm/impl/OpenroadmInventoryInput.java +++ b/sdnr/wt/devicemanager-openroadm/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm/impl/OpenroadmInventoryInput.java @@ -29,6 +29,7 @@ import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev191129.org.open import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev191129.shelves.Shelves; 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.yangtools.yang.common.Uint32; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -53,10 +54,11 @@ public class OpenroadmInventoryInput { // end of constructors // public methods - public Inventory getInventoryData(long treeLevel) { + public Inventory getInventoryData(Uint32 treeLevel) { InventoryBuilder inventoryBuilder = new InventoryBuilder(); inventoryBuilder.setNodeId(this.accessor.getNodeId().getValue()) - .setUuid(this.openRoadmDevice.getInfo().getNodeId().getValue()) + .setUuid(this.openRoadmDevice.getInfo().getNodeId() == null ? "N/A" + : this.openRoadmDevice.getInfo().getNodeId().getValue()) .setDate(this.openRoadmDevice.getInfo().getCurrentDatetime().getValue()) .setId(this.openRoadmDevice.getInfo().getNodeId().getValue()) .setManufacturerIdentifier(this.openRoadmDevice.getInfo().getVendor()) @@ -69,7 +71,7 @@ public class OpenroadmInventoryInput { return inventoryBuilder.build(); } - public Inventory getShelvesInventory(Shelves shelf, long treeLevel) { + public Inventory getShelvesInventory(Shelves shelf, Uint32 treeLevel) { InventoryBuilder inventoryBuilder = new InventoryBuilder(); inventoryBuilder.setNodeId(this.accessor.getNodeId().getValue()).setId(shelf.getShelfName()) .setDescription((shelf.getUserDescription() == null) @@ -85,12 +87,16 @@ public class OpenroadmInventoryInput { return inventoryBuilder.build(); } - public Inventory getInterfacesInventory(Interface deviceInterface, long treeLevel) { + public Inventory getInterfacesInventory(Interface deviceInterface, Uint32 treeLevel) { InventoryBuilder inventoryBuilder = new InventoryBuilder(); inventoryBuilder.setNodeId(this.accessor.getNodeId().getValue()).setId(deviceInterface.getName()) .setDescription((deviceInterface.getDescription() == null) ? "N/A" : deviceInterface.getDescription()) .setUuid(deviceInterface.getName()).setSerial(deviceInterface.getName()) - .setParentUuid(deviceInterface.getSupportingCircuitPackName()).setTreeLevel(treeLevel) + .setParentUuid((deviceInterface.getSupportingCircuitPackName() != null) + ? deviceInterface.getSupportingCircuitPackName() + : ((deviceInterface.getSupportingInterface() != null) ? deviceInterface.getSupportingInterface() + : this.openRoadmDevice.getInfo().getNodeId().getValue())) + .setTreeLevel(treeLevel) .setTypeName((deviceInterface.getType() == null) ? "Interface" : deviceInterface.getType().getName().substring(69, deviceInterface.getType().getName().length())) @@ -102,7 +108,7 @@ public class OpenroadmInventoryInput { return inventoryBuilder.build(); } - public Inventory getCircuitPackInventory(CircuitPacks circuitPack, long treeLevel) { + public Inventory getCircuitPackInventory(CircuitPacks circuitPack, Uint32 treeLevel) { InventoryBuilder inventoryBuilder = new InventoryBuilder(); inventoryBuilder.setNodeId(this.accessor.getNodeId().getValue()).setUuid(circuitPack.getCircuitPackName()) .setDate((circuitPack.getManufactureDate() == null) ? "N/A" @@ -116,14 +122,14 @@ public class OpenroadmInventoryInput { .setPartTypeId((circuitPack.getClei() == null) ? circuitPack.getType() : circuitPack.getClei()) .setParentUuid((circuitPack.getParentCircuitPack() != null) ? circuitPack.getParentCircuitPack().getCircuitPackName() - : (circuitPack.getShelf() != null) ? circuitPack.getShelf() - : this.openRoadmDevice.getInfo().getNodeId().getValue()); + : ((circuitPack.getShelf() != null) ? circuitPack.getShelf() + : this.openRoadmDevice.getInfo().getNodeId().getValue())); log.info("Inventory data written for CircuitPack {}", circuitPack.getCircuitPackName()); return inventoryBuilder.build(); } - public Inventory getXponderInventory(Xponder xpdr, long treeLevel) { + public Inventory getXponderInventory(Xponder xpdr, Uint32 treeLevel) { InventoryBuilder inventoryBuilder = new InventoryBuilder(); inventoryBuilder.setNodeId(this.accessor.getNodeId().getValue()).setId(xpdr.getXpdrNumber().toString()) .setDescription("Xponder\nLifecycleState: " + xpdr.getLifecycleState().getName()) diff --git a/sdnr/wt/devicemanager-openroadm/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm/impl/OpenroadmNetworkElement.java b/sdnr/wt/devicemanager-openroadm/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm/impl/OpenroadmNetworkElement.java index bc82cd11d..7b45c3e42 100644 --- a/sdnr/wt/devicemanager-openroadm/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm/impl/OpenroadmNetworkElement.java +++ b/sdnr/wt/devicemanager-openroadm/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm/impl/OpenroadmNetworkElement.java @@ -26,13 +26,15 @@ import java.util.Collection; import java.util.Hashtable; import java.util.List; import java.util.Optional; + import org.eclipse.jdt.annotation.NonNull; 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.dataprovider.model.NetconfTimeStamp; +import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.types.NetconfTimeStampImpl; 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.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfNotifications; import org.opendaylight.mdsal.common.api.LogicalDatastoreType; import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev191129.OrgOpenroadmDevice; import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev191129.circuit.packs.CircuitPacks; @@ -41,12 +43,14 @@ import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev191129.org.open import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev191129.shelf.Slots; import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev191129.shelves.Shelves; import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev191129.xponder.XpdrPort; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.NetworkElementDeviceType; +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.PmdataEntity; -import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.SourceType; 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.Uint32; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -57,13 +61,11 @@ import org.slf4j.LoggerFactory; * search db * **/ -public class OpenroadmNetworkElement implements NetworkElement { +public class OpenroadmNetworkElement extends OpenroadmNetworkElementBase { // variables - private final long equipmentLevel = 0; + private final long equipmentLevel = 1; private static final Logger log = LoggerFactory.getLogger(OpenroadmNetworkElement.class); - private final NetconfAccessor netconfAccessor; - private final DataProvider databaseService; private Hashtable<String, Long> circuitPacksRecord; private Hashtable<String, Long> shelfProvisionedcircuitPacks; private ListenerRegistration<NotificationListener> openRdmListenerRegistrationResult; @@ -76,35 +78,42 @@ public class OpenroadmNetworkElement implements NetworkElement { private PmDataBuilderOpenRoadm openRoadmPmData; private InitialDeviceAlarmReader initialAlarmReader; private List<PmdataEntity> pmDataEntity = new ArrayList<PmdataEntity>(); + private Optional<NetconfNotifications> notifications; + private static final NetconfTimeStamp ncTimeConverter = NetconfTimeStampImpl.getConverter(); + private int counter = 1; // end of variables // constructors - public OpenroadmNetworkElement(NetconfAccessor netconfAccess, DeviceManagerServiceProvider serviceProvider) { + public OpenroadmNetworkElement(NetconfBindingAccessor netconfAccess, DeviceManagerServiceProvider serviceProvider) { + + super(netconfAccess, serviceProvider); + + this.notifications = netconfAccess.getNotificationAccessor(); log.info("Create {}", OpenroadmNetworkElement.class.getSimpleName()); - this.netconfAccessor = netconfAccess; - this.databaseService = serviceProvider.getDataProvider(); this.openRdmListenerRegistrationResult = null; this.openRdmListener = new OpenroadmChangeNotificationListener(netconfAccessor, databaseService); this.opnRdmFaultListenerRegistrationResult = null; this.opnRdmFaultListener = new OpenroadmFaultNotificationListener(netconfAccessor, serviceProvider); this.opnRdmDeviceListenerRegistrationResult = null; this.opnRdmDeviceListener = new OpenroadmDeviceChangeNotificationListener(netconfAccessor, databaseService); - this.opnRdmInventoryInput = new OpenroadmInventoryInput(netconfAccess, readDevice(netconfAccess)); this.circuitPacksRecord = new Hashtable<String, Long>(); this.shelfProvisionedcircuitPacks = new Hashtable<String, Long>(); this.openRoadmPmData = new PmDataBuilderOpenRoadm(this.netconfAccessor); this.initialAlarmReader = new InitialDeviceAlarmReader(this.netconfAccessor, serviceProvider); log.info("NodeId {}", this.netconfAccessor.getNodeId().getValue()); - log.info("oScaMapper details{}", this.opnRdmInventoryInput.getClass().getName()); + } // end of constructors // public methods public void initialReadFromNetworkElement() { + OrgOpenroadmDevice device = readDevice(this.netconfAccessor); - databaseService.writeInventory(this.opnRdmInventoryInput.getInventoryData(equipmentLevel)); + this.opnRdmInventoryInput = new OpenroadmInventoryInput(this.netconfAccessor, device); + log.info("oScaMapper details{}", this.opnRdmInventoryInput.getClass().getName()); + databaseService.writeInventory(this.opnRdmInventoryInput.getInventoryData(Uint32.valueOf(equipmentLevel))); readShelvesData(device); readXpndrData(device); @@ -122,13 +131,8 @@ public class OpenroadmNetworkElement implements NetworkElement { } else { log.info("PmDatEntity is empty"); } - } - @Override - public NetworkElementDeviceType getDeviceType() { - return NetworkElementDeviceType.OROADM; - } @Override public void register() { @@ -140,8 +144,7 @@ public class OpenroadmNetworkElement implements NetworkElement { this.opnRdmDeviceListenerRegistrationResult = netconfAccessor.doRegisterNotificationListener(opnRdmDeviceListener); // Register netconf stream - netconfAccessor.registerNotificationsStream(NetconfAccessor.DefaultNotificationsStream); - + notifications.get().registerNotificationsStream(NetconfAccessor.DefaultNotificationsStream); } @Override @@ -157,23 +160,6 @@ public class OpenroadmNetworkElement implements NetworkElement { } } - @Override - public NodeId getNodeId() { - return netconfAccessor.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(netconfAccessor); - } // end of public methods // private methods @@ -187,12 +173,12 @@ public class OpenroadmNetworkElement implements NetworkElement { shelf.getShelfName(), shelf.getSerialId(), shelf.getProductCode(), shelf.getShelfPosition(), shelf.getEquipmentState(), shelf.getHardwareVersion(), shelf.getShelfType(), shelf.getVendor(), shelf.getLifecycleState()); - databaseService - .writeInventory(this.opnRdmInventoryInput.getShelvesInventory(shelf, equipmentLevel + 1)); + databaseService.writeInventory( + this.opnRdmInventoryInput.getShelvesInventory(shelf, Uint32.valueOf(equipmentLevel + 1))); Collection<Slots> slotList = YangHelper.getCollection(shelf.getSlots()); if (slotList != null) { for (Slots slot : slotList) { - if (!slot.getProvisionedCircuitPack().isEmpty()) { + if (slot.getProvisionedCircuitPack() != null) { this.shelfProvisionedcircuitPacks.put(slot.getProvisionedCircuitPack(), equipmentLevel + 2); } log.info("Slots for the shelf: {}", shelf.getShelfName()); @@ -200,87 +186,106 @@ public class OpenroadmNetworkElement implements NetworkElement { slot.getSlotStatus(), slot.getLabel()); } } - log.info("size of shelfProvisionedcircuitPacks: {} ", shelfProvisionedcircuitPacks.size()); - } - + log.info("size of shelfProvisionedcircuitPacks: {} ", shelfProvisionedcircuitPacks.size()); } + } private void readXpndrData(OrgOpenroadmDevice device) { Collection<Xponder> xponderList = YangHelper.getCollection(device.getXponder()); + if (xponderList != null) { for (Xponder xponder : xponderList) { - databaseService - .writeInventory(this.opnRdmInventoryInput.getXponderInventory(xponder, equipmentLevel + 1)); + + databaseService.writeInventory( + this.opnRdmInventoryInput.getXponderInventory(xponder, Uint32.valueOf(equipmentLevel + 1))); log.info("Xponders: No.: {} , \n Port: {} ,\n Type: {}", xponder.getXpdrNumber(), xponder.getXpdrPort(), xponder.getXpdrType()); Collection<XpdrPort> xpdrportlist = YangHelper.getCollection(xponder.getXpdrPort()); if (xpdrportlist != null) { for (XpdrPort xpdrport : xpdrportlist) - if (!xpdrport.getCircuitPackName().isEmpty()) { + if (xpdrport.getCircuitPackName() != null) { this.shelfProvisionedcircuitPacks.put(xpdrport.getCircuitPackName(), equipmentLevel + 2); log.info("Size of dict{}", this.shelfProvisionedcircuitPacks.size()); } - - } - } + } } } private void readCircuitPacketData(OrgOpenroadmDevice device) { Collection<CircuitPacks> circuitpacklist = YangHelper.getCollection(device.getCircuitPacks()); + List<String> cpNames = new ArrayList<String>(); if (circuitpacklist != null) { for (CircuitPacks cp : circuitpacklist) { + cpNames.add(cp.getCircuitPackName()); + log.info("CP Name:{}", cp.getCircuitPackName()); - if (!this.shelfProvisionedcircuitPacks.isEmpty() - && this.shelfProvisionedcircuitPacks.containsKey(cp.getCircuitPackName())) { - this.circuitPacksRecord.put(cp.getCircuitPackName(), (equipmentLevel + 2)); - databaseService.writeInventory(this.opnRdmInventoryInput.getCircuitPackInventory(cp, - this.shelfProvisionedcircuitPacks.get(cp.getCircuitPackName()))); - log.info("shelf has circuit pack"); + if (cp.getParentCircuitPack() == null + && !this.shelfProvisionedcircuitPacks.containsKey(cp.getCircuitPackName())) { + log.info("cp has no parent and no shelf"); + this.circuitPacksRecord.put(cp.getCircuitPackName(), (equipmentLevel + 1)); + databaseService.writeInventory( + this.opnRdmInventoryInput.getCircuitPackInventory(cp, Uint32.valueOf(equipmentLevel + 1))); } else { - if (cp.getParentCircuitPack() == null) { - this.circuitPacksRecord.put(cp.getCircuitPackName(), (equipmentLevel + 1)); - databaseService.writeInventory( - this.opnRdmInventoryInput.getCircuitPackInventory(cp, equipmentLevel + 1)); - log.info("Cp has no parent circuit pack and no shelf"); - + // check for missing valid parent circuit name + if (cp.getParentCircuitPack().getCpSlotName() != null + && cp.getParentCircuitPack().getCircuitPackName() == null) { + + log.info("Cp {} has slotname of the parent circuit pack but no parent circuit pack name", + cp.getCircuitPackName()); + this.circuitPacksRecord.put(cp.getCircuitPackName(), (equipmentLevel + 3)); + databaseService.writeInventory(this.opnRdmInventoryInput.getCircuitPackInventory(cp, + Uint32.valueOf(equipmentLevel + 3))); + databaseService.writeEventLog(writeIncorrectParentLog(cp.getCircuitPackName(), counter) + .setObjectId(device.getInfo().getNodeId().getValue()) + .setId(cp.getParentCircuitPack().getCpSlotName()) + .setNewValue("Missing parent circuit pack name").build()); + } else if (cp.getParentCircuitPack().getCircuitPackName() != null + && this.shelfProvisionedcircuitPacks + .containsKey(cp.getParentCircuitPack().getCircuitPackName())) { + log.info("Cp {} has parent circuit pack and shelf", cp.getCircuitPackName()); + this.circuitPacksRecord.put(cp.getCircuitPackName(), (equipmentLevel + 3)); + databaseService.writeInventory(this.opnRdmInventoryInput.getCircuitPackInventory(cp, + Uint32.valueOf(equipmentLevel + 3))); } else { - if (this.shelfProvisionedcircuitPacks - .containsKey(cp.getParentCircuitPack().getCircuitPackName())) { - this.circuitPacksRecord.put(cp.getCircuitPackName(), (equipmentLevel + 3)); - databaseService.writeInventory( - this.opnRdmInventoryInput.getCircuitPackInventory(cp, equipmentLevel + 3)); - log.info("Cp {} has parent circuit pack and shelf", cp.getCircuitPackName()); - } else { - this.circuitPacksRecord.put(cp.getCircuitPackName(), (equipmentLevel + 2)); - databaseService.writeInventory( - this.opnRdmInventoryInput.getCircuitPackInventory(cp, equipmentLevel + 2)); - log.info("Cp {} has parent circuit pack but no shelf", cp.getCircuitPackName()); - + // check for incorrect hierarchy + if (cp.getParentCircuitPack().getCircuitPackName() != null + && !cpNames.contains(cp.getParentCircuitPack().getCircuitPackName())) { + databaseService.writeEventLog(writeIncorrectParentLog(cp.getCircuitPackName(), counter) + .setObjectId(device.getInfo().getNodeId().getValue()) + .setId(cp.getParentCircuitPack().getCpSlotName()).build()); } - - + log.info("Cp has parent circuit pack but no shelf or a shelf but no parent circuit pack"); + this.circuitPacksRecord.put(cp.getCircuitPackName(), (equipmentLevel + 2)); + databaseService.writeInventory(this.opnRdmInventoryInput.getCircuitPackInventory(cp, + Uint32.valueOf(equipmentLevel + 2))); } - } - + } } - } + // for (String s : cpParentNames) { + // log.info("Parent cps {}:", s); + // + // if (!cpNames.contains(s)) { + // log.info("Invalid Hierarchy detected for {}", s); + // databaseService.writeEventLog(writeIncorrectParentLog(s, counter) + // .setObjectId(device.getInfo().getNodeId().getValue()).setId(s).build()); + // } + // } + } } private void readInterfaceData(OrgOpenroadmDevice device) { Collection<Interface> interfaceList = YangHelper.getCollection(device.getInterface()); if (interfaceList != null) { for (Interface deviceInterface : interfaceList) { - log.info("\n InterfaceName: {}", deviceInterface.getName()); log.info("Supporting CP {}", this.circuitPacksRecord.size()); for (String s : this.circuitPacksRecord.keySet()) { @@ -288,35 +293,38 @@ public class OpenroadmNetworkElement implements NetworkElement { } log.info("Interface {} and their supporting CP {}", deviceInterface.getName(), deviceInterface.getSupportingCircuitPackName()); - - if (deviceInterface.getSupportingCircuitPackName() != null) { if (this.circuitPacksRecord.containsKey(deviceInterface.getSupportingCircuitPackName())) { databaseService.writeInventory(this.opnRdmInventoryInput.getInterfacesInventory(deviceInterface, - this.circuitPacksRecord.get(deviceInterface.getSupportingCircuitPackName()) + 1)); + Uint32.valueOf( + this.circuitPacksRecord.get(deviceInterface.getSupportingCircuitPackName()) + + 1))); } - } else { - databaseService.writeInventory( - this.opnRdmInventoryInput.getInterfacesInventory(deviceInterface, equipmentLevel + 1)); + databaseService.writeInventory(this.opnRdmInventoryInput.getInterfacesInventory(deviceInterface, + Uint32.valueOf(equipmentLevel + 1))); } } } - } - private OrgOpenroadmDevice readDevice(NetconfAccessor accessor) { - + private OrgOpenroadmDevice readDevice(NetconfBindingAccessor accessor) { final Class<OrgOpenroadmDevice> openRoadmDev = OrgOpenroadmDevice.class; InstanceIdentifier<OrgOpenroadmDevice> deviceId = InstanceIdentifier.builder(openRoadmDev).build(); - OrgOpenroadmDevice device = accessor.getTransactionUtils().readData(accessor.getDataBroker(), LogicalDatastoreType.OPERATIONAL, deviceId); - return device; - } - // end of private methods + private EventlogBuilder writeIncorrectParentLog(String attributeName, Integer counter) { + EventlogBuilder eventlogBuilder = new EventlogBuilder(); + eventlogBuilder.setAttributeName(attributeName).setCounter(counter) + .setNodeId(this.netconfAccessor.getNodeId().getValue()).setSourceType(SourceType.Netconf) + .setNewValue("Invalid parent circuit-pack name") + .setTimestamp(new DateAndTime(ncTimeConverter.getTimeStamp())); + return eventlogBuilder; + + } + // end of private methods } diff --git a/sdnr/wt/devicemanager-openroadm/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm/impl/OpenroadmNetworkElementBase.java b/sdnr/wt/devicemanager-openroadm/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm/impl/OpenroadmNetworkElementBase.java new file mode 100644 index 000000000..9949056bb --- /dev/null +++ b/sdnr/wt/devicemanager-openroadm/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm/impl/OpenroadmNetworkElementBase.java @@ -0,0 +1,74 @@ +/* + * ============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.openroadm.impl; + +import java.util.Optional; +import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.DataProvider; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.ne.service.NetworkElement; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.ne.service.NetworkElementService; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.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.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; + +public class OpenroadmNetworkElementBase implements NetworkElement { + + protected final NetconfBindingAccessor netconfAccessor; + protected final DataProvider databaseService; + + public OpenroadmNetworkElementBase(NetconfBindingAccessor netconfAccess, + DeviceManagerServiceProvider serviceProvider) { + + this.netconfAccessor = netconfAccess; + this.databaseService = serviceProvider.getDataProvider(); + } + + @Override + public void register() {} + + @Override + public void deregister() {} + + @Override + public void warmstart() {} + + @Override + public NodeId getNodeId() { + return netconfAccessor.getNodeId(); + } + + @Override + public NetworkElementDeviceType getDeviceType() { + return NetworkElementDeviceType.OROADM; + } + + @Override + public <L extends NetworkElementService> Optional<L> getService(Class<L> clazz) { + return Optional.empty(); + } + + @Override + public Optional<NetconfAccessor> getAcessor() { + return Optional.of(netconfAccessor); + } +} diff --git a/sdnr/wt/devicemanager-openroadm/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm/impl/OpenroadmNetworkElementFactory.java b/sdnr/wt/devicemanager-openroadm/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm/impl/OpenroadmNetworkElementFactory.java index 5e1640192..cc8eaa68e 100644 --- a/sdnr/wt/devicemanager-openroadm/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm/impl/OpenroadmNetworkElementFactory.java +++ b/sdnr/wt/devicemanager-openroadm/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm/impl/OpenroadmNetworkElementFactory.java @@ -27,6 +27,7 @@ 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.http.org.openroadm.device.rev191129.OrgOpenroadmDevice; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -46,16 +47,24 @@ public class OpenroadmNetworkElementFactory implements NetworkElementFactory { // public methods @Override - public Optional<NetworkElement> create(NetconfAccessor acessor, DeviceManagerServiceProvider serviceProvider) { + public Optional<NetworkElement> create(NetconfAccessor accessor, DeviceManagerServiceProvider serviceProvider) { - if (acessor.getCapabilites().isSupportingNamespace(OrgOpenroadmDevice.QNAME)) { + if (accessor.getCapabilites().isSupportingNamespaceAndRevision(OrgOpenroadmDevice.QNAME)) { log.info("Create OpenRoadm device {} ", OpenroadmNetworkElement.class.getName()); - log.info("Node Id read by Acessor {}:", acessor.getNodeId().getValue()); - - return Optional.of(new OpenroadmNetworkElement(acessor, serviceProvider)); - } else { - return Optional.empty(); - } + log.info("Node Id read by Acessor {}:", accessor.getNodeId().getValue()); + Optional<NetconfBindingAccessor> bindingAccessor = accessor.getNetconfBindingAccessor(); + if (bindingAccessor.isPresent()) { + return Optional.of(new OpenroadmNetworkElement(bindingAccessor.get(), serviceProvider)); + } + } else if (accessor.getCapabilites().isSupportingNamespaceAndRevision("http://org/openroadm/device","2018-10-19")) { + log.info("Create OpenRoadm base device {} ", OpenroadmNetworkElementBase.class.getName()); + log.info("Node Id read by Acessor {}:", accessor.getNodeId().getValue()); + Optional<NetconfBindingAccessor> bindingAccessor = accessor.getNetconfBindingAccessor(); + if (bindingAccessor.isPresent()) { + return Optional.of(new OpenroadmNetworkElementBase(bindingAccessor.get(), serviceProvider)); + } + } + return Optional.empty(); } // end of public methods diff --git a/sdnr/wt/devicemanager-openroadm/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm/impl/PmDataBuilderOpenRoadm.java b/sdnr/wt/devicemanager-openroadm/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm/impl/PmDataBuilderOpenRoadm.java index b75e4c67e..7ad2003c4 100644 --- a/sdnr/wt/devicemanager-openroadm/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm/impl/PmDataBuilderOpenRoadm.java +++ b/sdnr/wt/devicemanager-openroadm/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm/impl/PmDataBuilderOpenRoadm.java @@ -21,24 +21,39 @@ */ package org.onap.ccsdk.features.sdnr.wt.devicemanager.openroadm.impl; +import java.net.URL; import java.util.ArrayList; import java.util.Collection; +import java.util.Enumeration; +import java.util.HashMap; import java.util.List; +import java.util.Map; import org.onap.ccsdk.features.sdnr.wt.common.YangHelper; import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.types.YangHelper2; -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.http.org.openroadm.pm.rev191129.HistoricalPmList; import org.opendaylight.yang.gen.v1.http.org.openroadm.pm.rev191129.historical.pm.group.HistoricalPm; import org.opendaylight.yang.gen.v1.http.org.openroadm.pm.rev191129.historical.pm.list.HistoricalPmEntry; import org.opendaylight.yang.gen.v1.http.org.openroadm.pm.rev191129.historical.pm.val.group.Measurement; +import org.opendaylight.yang.gen.v1.http.org.openroadm.pm.types.rev191129.PmDataType; import org.opendaylight.yang.gen.v1.http.org.openroadm.pm.types.rev191129.PmGranularity; +import org.opendaylight.yang.gen.v1.http.org.openroadm.pm.types.rev191129.PmNamesEnum; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.g836.pm.types.rev200413.ErroredSecond; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.g836.pm.types.rev200413.SeverelyErroredSecond; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.openroadm.pm.types.rev200413.PerformanceMeasurementTypeId; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.GranularityPeriodType; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.PmdataEntity; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.PmdataEntityBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.pmdata.entity.PerformanceData; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.pmdata.entity.PerformanceDataBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.pmdata.grp.MeasurementBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.pmdata.grp.MeasurementKey; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.units.rev200413.PerformanceMeasurementUnitId; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; +import org.osgi.framework.Bundle; +import org.osgi.framework.BundleContext; +import org.osgi.framework.FrameworkUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -51,10 +66,11 @@ public class PmDataBuilderOpenRoadm { // variables private static final Logger log = LoggerFactory.getLogger(OpenroadmNetworkElement.class); private PmdataEntityBuilder pmDataBuilder; + private Bundle b = FrameworkUtil.getBundle(this.getClass()); // end of variables // constructors - public PmDataBuilderOpenRoadm(NetconfAccessor accessor) { + public PmDataBuilderOpenRoadm(NetconfBindingAccessor accessor) { this.pmDataBuilder = new PmdataEntityBuilder(); this.pmDataBuilder.setNodeName(accessor.getNodeId().getValue()); } @@ -62,7 +78,7 @@ public class PmDataBuilderOpenRoadm { // end of constructors // public methods // Read PM data - public HistoricalPmList getPmData(NetconfAccessor accessor) { + public HistoricalPmList getPmData(NetconfBindingAccessor accessor) { final Class<HistoricalPmList> pmDataClass = HistoricalPmList.class; log.info("Get PM data for element {}", accessor.getNodeId().getValue()); InstanceIdentifier<HistoricalPmList> pmDataIid = InstanceIdentifier.builder(pmDataClass).build(); @@ -74,17 +90,24 @@ public class PmDataBuilderOpenRoadm { // Build PM entity for writing into the database public List<PmdataEntity> buildPmDataEntity(HistoricalPmList historicalPmEnitityList) { List<PmdataEntity> pmEntitiyList = new ArrayList<>(); - Collection<HistoricalPmEntry> pmDataEntryList = YangHelper.getCollection(historicalPmEnitityList.getHistoricalPmEntry()); + Collection<HistoricalPmEntry> pmDataEntryList = + YangHelper.getCollection(historicalPmEnitityList.getHistoricalPmEntry()); for (HistoricalPmEntry pmDataEntry : pmDataEntryList) { pmDataBuilder.setUuidInterface(pmDataEntry.getPmResourceType().getName()); Collection<HistoricalPm> historicalPmList = YangHelper.getCollection(pmDataEntry.getHistoricalPm()); for (HistoricalPm historicalPm : historicalPmList) { log.info("PmName:{}", historicalPm.getType()); - this.pmDataBuilder.setScannerId(historicalPm.getType().getName()); - writeperformanceData(historicalPm); - log.info("NodeName: {}, Scanner Id:{}, Period: {}", this.pmDataBuilder.getNodeName(), - this.pmDataBuilder.getScannerId(), this.pmDataBuilder.getGranularityPeriod().getName()); + // pmDataBuilder.setPerformanceData(value) + + try { + writeperformanceData(historicalPm); + } catch (ClassNotFoundException e) { + log.info("No relevant data found"); + } + // log.info("NodeName: {}, Scanner Id:{}, Period: {}", this.getNodeName(), + // this.getScannerId(), this.getGranularityPeriod().getName()); pmEntitiyList.add(this.pmDataBuilder.build()); + log.info("PmListSize before db writing: {}", pmEntitiyList.size()); } log.info("PmListSize before db writing: {}", pmEntitiyList.size()); @@ -94,21 +117,32 @@ public class PmDataBuilderOpenRoadm { // end of public methods // private methods - private void writeperformanceData(HistoricalPm historicalPm) { + private void writeperformanceData(HistoricalPm historicalPm) throws ClassNotFoundException { Collection<Measurement> measurementList = YangHelper.getCollection(historicalPm.getMeasurement()); - + Map<MeasurementKey, org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.pmdata.grp.Measurement> measurementMap=new HashMap<MeasurementKey, org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.pmdata.grp.Measurement>(); + // Map Performance data of PmDataEntity with MeasurmentData-HistoricalPm + PerformanceDataBuilder performanceDataBuilder = new PerformanceDataBuilder(); for (Measurement measurementData : measurementList) { this.pmDataBuilder.setGranularityPeriod(mapGranularityPeriod(measurementData.getGranularity())) - .setPerformanceData(getPerformancedata(measurementData)) .setTimeStamp(measurementData.getCompletionTime()); if (measurementData.getValidity().getName().equals("suspect")) { this.pmDataBuilder.setSuspectIntervalFlag(true); } - log.info("Time:d{}, \n Scannerid: {}, \n UUID: {}", this.pmDataBuilder.getGranularityPeriod().getName(), - this.pmDataBuilder.getScannerId(), this.pmDataBuilder.getUuidInterface()); + measurementMap.put(new MeasurementKey(measurementBuilder(historicalPm.getType(), measurementData.getPmParameterUnit(), + measurementData.getPmParameterValue()).getPmKey()), measurementBuilder(historicalPm.getType(), measurementData.getPmParameterUnit(), + measurementData.getPmParameterValue())); + + + + // log.info("Time:d{}, \n Scannerid: {}, \n UUID: {}", this.getGranularityPeriod().getName(), + // pmDataBuilder.getScannerId(), this.getUuidInterface()); } + + pmDataBuilder.setPerformanceData(performanceDataBuilder.setMeasurement(measurementMap).build()); } + + //Map Performance data of PmDataEntity with MeasurmentData-HistoricalPm private PerformanceData getPerformancedata(Measurement measurementData) { PerformanceData performanceData; @@ -138,5 +172,124 @@ public class PmDataBuilderOpenRoadm { } return granPeriod; } + + private List<Class<? extends PerformanceMeasurementTypeId>> setMeasurementTypeId() throws ClassNotFoundException { + String packageName = + "org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.openroadm.pm.types.rev200413"; + String packageName1 = + "/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/data/provider/openroadm/pm/types/rev200413/"; + List<Class<? extends PerformanceMeasurementTypeId>> measTypeObjList = + new ArrayList<Class<? extends PerformanceMeasurementTypeId>>(); + URL root = Thread.currentThread().getContextClassLoader().getResource(packageName1); + + log.info("path for type package: {}", root); + + Enumeration<URL> results = getFileURL(b, packageName); + log.info("FOund Packages {}", results); + while (results.hasMoreElements()) { + URL path = results.nextElement(); + // log.info("Enumeration URL-file {}", path.getFile()); + // log.info("Enumeration URL-String {}", path.toString()); + Class<?> cls1 = loadClass(b, path.getFile()); + + if (PerformanceMeasurementTypeId.class.isAssignableFrom(cls1)) { + measTypeObjList.add((Class<? extends PerformanceMeasurementTypeId>) cls1); + } + log.info("Class Added {}", cls1.getSimpleName()); + + } + + return measTypeObjList; + } + + private List<Class<? extends PerformanceMeasurementUnitId>> setMeasurementUnit() throws ClassNotFoundException { + String packageName = + "org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.units.rev200413"; + List<Class<? extends PerformanceMeasurementUnitId>> measUnitObjList = + new ArrayList<Class<? extends PerformanceMeasurementUnitId>>(); + URL root = Thread.currentThread().getContextClassLoader().getResource(packageName.replace(".", "/")); + log.info("path for unit package{}", root); + + Enumeration<URL> results_unit = getFileURL(b, packageName); + log.info("FOund Packages {}", results_unit); + while (results_unit.hasMoreElements()) { + URL path = results_unit.nextElement(); + Class<?> cls1 = loadClass(b, path.getFile()); + if (PerformanceMeasurementUnitId.class.isAssignableFrom(cls1)) { + measUnitObjList.add((Class<? extends PerformanceMeasurementUnitId>) cls1); + } + log.info("Class Added {}", cls1.getSimpleName()); + + } + + return measUnitObjList; + } + + private org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.pmdata.grp.Measurement measurementBuilder( + PmNamesEnum pmType, String pmUnit, PmDataType pmDataType) throws ClassNotFoundException { + + MeasurementBuilder measBuilder = new MeasurementBuilder(); + if (pmType.getName() == "erroredSeconds") { + measBuilder.setPmKey(ErroredSecond.class); + } else if (pmType.getName() == "severelyErroredSeconds") { + measBuilder.setPmKey(SeverelyErroredSecond.class); + } else { + for (Class<? extends PerformanceMeasurementTypeId> obj : setMeasurementTypeId()) { + if (obj.toString().contains(pmType.name())) { + measBuilder.setPmKey(obj); + } + } + } + for (Class<? extends PerformanceMeasurementUnitId> obj : setMeasurementUnit()) { + if (obj.toString().contains(pmUnit)) { + measBuilder.setPmUnit(obj); + } + } + measBuilder.setPmValue(pmDataType); + return measBuilder.build(); + + } + + private Class<?> loadClass(Bundle bundle, String classFilePath) { + String className = classFilePath.replaceFirst("^/", "").replace('/', '.').replaceFirst(".class$", ""); + try { + return bundle.loadClass(className); + } catch (Throwable e) { + log.info(String.format("Class [%s] could not be loaded. Message: [%s].", className, e.getMessage())); + } + return null; + } + + private static Enumeration<URL> getFileURL(Bundle b, String classPath) { + + BundleContext context = b == null ? null : b.getBundleContext(); + if (context == null) { + log.info("no bundle context available"); + return null; + } + Bundle[] bundles = context.getBundles(); + if (bundles == null || bundles.length <= 0) { + log.info("no bundles found"); + return null; + } + log.info("found {} bundles", bundles.length); + Enumeration<URL> resultUrl = null; + + for (Bundle bundle : bundles) { + resultUrl = bundle.findEntries("/" + classPath.replace(".", "/"), "*.class", false); + // resultUrl = bundle.getEntryPaths("/" + classPath.replace(".", "/")); + if (resultUrl != null) { + b = bundle; + break; + + } + + } + + return resultUrl; + } + + // end of private methods } + diff --git a/sdnr/wt/devicemanager-openroadm/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm/test/TestDeviceManagerOpenRoadmImpl.java b/sdnr/wt/devicemanager-openroadm/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm/test/TestDeviceManagerOpenRoadmImpl.java index 0f3401bb0..9967f780f 100644 --- a/sdnr/wt/devicemanager-openroadm/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm/test/TestDeviceManagerOpenRoadmImpl.java +++ b/sdnr/wt/devicemanager-openroadm/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm/test/TestDeviceManagerOpenRoadmImpl.java @@ -22,23 +22,13 @@ package org.onap.ccsdk.features.sdnr.wt.devicemanager.openroadm.test; import static org.mockito.Mockito.mock; -import java.io.File; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; import org.junit.After; import org.junit.Before; import org.junit.Test; import org.onap.ccsdk.features.sdnr.wt.devicemanager.openroadm.impl.DeviceManagerOpenroadmImpl; import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.NetconfNetworkElementService; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; public class TestDeviceManagerOpenRoadmImpl { - private static Path KARAF_ETC = Paths.get("etc"); - private static final Logger log = LoggerFactory.getLogger(TestDeviceManagerOpenRoadmImpl.class); DeviceManagerOpenroadmImpl devMgrOpenRdmImpl; NetconfNetworkElementService netcnfNtwrkElmntSrvc; @@ -50,9 +40,7 @@ public class TestDeviceManagerOpenRoadmImpl { @Test public void test() throws Exception { - devMgrOpenRdmImpl.setNetconfNetworkElementService(netcnfNtwrkElmntSrvc); - } @After @@ -60,22 +48,4 @@ public class TestDeviceManagerOpenRoadmImpl { devMgrOpenRdmImpl.close(); } - private static void delete(Path etc) throws IOException { - if (Files.exists(etc)) { - System.out.println("Found, removing:" + etc.toString()); - delete(etc.toFile()); - } - } - - private static void delete(File f) throws IOException { - if (f.isDirectory()) { - for (File c : f.listFiles()) { - delete(c); - } - } - if (!f.delete()) { - throw new FileNotFoundException("Failed to delete file: " + f); - } - } - } diff --git a/sdnr/wt/devicemanager-openroadm/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm/test/TestOpenRoadmInventory.java b/sdnr/wt/devicemanager-openroadm/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm/test/TestOpenRoadmInventory.java index f63eeb8b3..607e9ac03 100644 --- a/sdnr/wt/devicemanager-openroadm/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm/test/TestOpenRoadmInventory.java +++ b/sdnr/wt/devicemanager-openroadm/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm/test/TestOpenRoadmInventory.java @@ -44,6 +44,9 @@ import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types. import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DateAndTime; import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId; +import org.opendaylight.yangtools.yang.common.Uint16; +import org.opendaylight.yangtools.yang.common.Uint32; +import org.opendaylight.yangtools.yang.common.Uint8; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -58,8 +61,8 @@ public class TestOpenRoadmInventory { .setCurrentIpAddress(ipAddress).setCurrentDefaultGateway(new IpAddress(new Ipv4Address("127.0.0.20"))) .setCurrentDefaultGateway(new IpAddress(new Ipv4Address("127.0.0.20"))).setNodeType(NodeTypes.Rdm) .setCurrentDatetime(new DateAndTime("2017-10-22T15:23:43Z")).setSoftwareVersion("swversion1234") - .setPrefixLength((short) 28).setMaxDegrees(2).setMaxSrgs(3).setMaxNumBin15minHistoricalPm(32) - .setMaxNumBin24hourHistoricalPm(7).setOpenroadmVersion(OpenroadmVersionType._20).build(); + .setPrefixLength(Uint8.valueOf(28)).setMaxDegrees(Uint16.valueOf(2)).setMaxSrgs(Uint16.valueOf(3)).setMaxNumBin15minHistoricalPm(Uint16.valueOf(32)) + .setMaxNumBin24hourHistoricalPm(Uint16.valueOf(7)).setOpenroadmVersion(OpenroadmVersionType._20).build(); private OrgOpenroadmDevice device = mock(OrgOpenroadmDevice.class);; private Shelves shelf = mock(Shelves.class); @@ -73,7 +76,7 @@ public class TestOpenRoadmInventory { when(accessor.getNodeId()).thenReturn(nodeId); when(device.getInfo()).thenReturn(info); - roadmInventory.getInventoryData(value1); + roadmInventory.getInventoryData(Uint32.valueOf(value1)); assertEquals(device.getInfo(), info); } @@ -92,7 +95,7 @@ public class TestOpenRoadmInventory { when(shelf.getModel()).thenReturn("1"); when(shelf.getHardwareVersion()).thenReturn("0.1"); when(shelf.getManufactureDate()).thenReturn(new DateAndTime("2017-10-22T15:23:43Z")); - roadmInventory.getShelvesInventory(shelf, (value1 + 1)); + roadmInventory.getShelvesInventory(shelf, Uint32.valueOf(value1 + 1)); LOG.info("Shelves test completed"); } @@ -110,7 +113,7 @@ public class TestOpenRoadmInventory { when(cp.getProductCode()).thenReturn("oooooo"); when(cp.getCircuitPackMode()).thenReturn("inServiceMode"); when(device.getInfo()).thenReturn(info); - roadmInventory.getCircuitPackInventory(cp, value1 + 1); + roadmInventory.getCircuitPackInventory(cp, Uint32.valueOf(value1 + 1)); } @@ -121,17 +124,17 @@ public class TestOpenRoadmInventory { when(interfaces.getDescription()).thenReturn("Ethernet Interface"); when(interfaces.getSupportingCircuitPackName()).thenReturn("1/0"); when(device.getInfo()).thenReturn(info); - roadmInventory.getInterfacesInventory(interfaces, value1 + 2); + roadmInventory.getInterfacesInventory(interfaces, Uint32.valueOf(value1 + 2)); } @Test public void TestXponder() { - when(xpdr.getXpdrNumber()).thenReturn(1); + when(xpdr.getXpdrNumber()).thenReturn(Uint16.valueOf(1)); when(xpdr.getXpdrType()).thenReturn(XpdrNodeTypes.Mpdr); when(xpdr.getLifecycleState()).thenReturn(LifecycleState.Deployed); when(accessor.getNodeId()).thenReturn(nodeId); when(device.getInfo()).thenReturn(info); - roadmInventory.getXponderInventory(xpdr, value1 + 1); + roadmInventory.getXponderInventory(xpdr, Uint32.valueOf(value1 + 1)); } diff --git a/sdnr/wt/devicemanager-openroadm/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm/test/TestOpenRoadmNetworkElement.java b/sdnr/wt/devicemanager-openroadm/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm/test/TestOpenRoadmNetworkElement.java index ce03a9385..794c2eb1a 100644 --- a/sdnr/wt/devicemanager-openroadm/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm/test/TestOpenRoadmNetworkElement.java +++ b/sdnr/wt/devicemanager-openroadm/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm/test/TestOpenRoadmNetworkElement.java @@ -1,272 +1,304 @@ -/* - * ============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.openroadm.test; - -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; -import java.math.BigInteger; -import java.util.Arrays; -import java.util.List; -import org.junit.Before; -import org.junit.Test; -import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.DataProvider; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.openroadm.impl.OpenroadmInventoryInput; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.openroadm.impl.OpenroadmNetworkElement; -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.netconfnodestateservice.Capabilities; -import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfAccessor; -import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.TransactionUtils; -import org.opendaylight.mdsal.binding.api.DataBroker; -import org.opendaylight.mdsal.common.api.LogicalDatastoreType; -import org.opendaylight.yang.gen.v1.http.org.openroadm.alarm.rev191129.ActiveAlarmList; -import org.opendaylight.yang.gen.v1.http.org.openroadm.alarm.rev191129.Severity; -import org.opendaylight.yang.gen.v1.http.org.openroadm.alarm.rev191129.active.alarm.list.ActiveAlarms; -import org.opendaylight.yang.gen.v1.http.org.openroadm.alarm.rev191129.alarm.ProbableCauseBuilder; -import org.opendaylight.yang.gen.v1.http.org.openroadm.alarm.rev191129.alarm.ResourceBuilder; -import org.opendaylight.yang.gen.v1.http.org.openroadm.common.node.types.rev191129.NodeIdType; -import org.opendaylight.yang.gen.v1.http.org.openroadm.common.state.types.rev191129.LifecycleState; -import org.opendaylight.yang.gen.v1.http.org.openroadm.common.state.types.rev191129.State; -import org.opendaylight.yang.gen.v1.http.org.openroadm.common.types.rev191129.OpenroadmVersionType; -import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev191129.OrgOpenroadmDevice; -import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev191129.circuit.pack.ParentCircuitPack; -import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev191129.circuit.packs.CircuitPacks; -import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev191129.interfaces.grp.Interface; -import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev191129.org.openroadm.device.Info; -import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev191129.org.openroadm.device.InfoBuilder; -import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev191129.org.openroadm.device.Xponder; -import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev191129.shelf.Slots; -import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev191129.shelves.Shelves; -import org.opendaylight.yang.gen.v1.http.org.openroadm.device.types.rev191129.NodeTypes; -import org.opendaylight.yang.gen.v1.http.org.openroadm.device.types.rev191129.XpdrNodeTypes; -import org.opendaylight.yang.gen.v1.http.org.openroadm.pm.rev191129.HistoricalPmList; -import org.opendaylight.yang.gen.v1.http.org.openroadm.pm.rev191129.historical.pm.group.HistoricalPm; -import org.opendaylight.yang.gen.v1.http.org.openroadm.pm.rev191129.historical.pm.list.HistoricalPmEntry; -import org.opendaylight.yang.gen.v1.http.org.openroadm.pm.rev191129.historical.pm.val.group.Measurement; -import org.opendaylight.yang.gen.v1.http.org.openroadm.pm.types.rev191129.PmDataType; -import org.opendaylight.yang.gen.v1.http.org.openroadm.pm.types.rev191129.PmGranularity; -import org.opendaylight.yang.gen.v1.http.org.openroadm.pm.types.rev191129.PmNamesEnum; -import org.opendaylight.yang.gen.v1.http.org.openroadm.pm.types.rev191129.Validity; -import org.opendaylight.yang.gen.v1.http.org.openroadm.probablecause.rev191129.ProbableCauseEnum; -import org.opendaylight.yang.gen.v1.http.org.openroadm.resource.rev191129.resource.DeviceBuilder; -import org.opendaylight.yang.gen.v1.http.org.openroadm.resource.types.rev191129.ResourceTypeEnum; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address; -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.Inventory; -import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; - -public class TestOpenRoadmNetworkElement { - - NetconfAccessor accessor = mock(NetconfAccessor.class); - DeviceManagerServiceProvider serviceProvider = mock(DeviceManagerServiceProvider.class); - DataProvider dataprovider = mock(DataProvider.class); - Capabilities capabilities = mock(Capabilities.class); - TransactionUtils transactionUtils = mock(TransactionUtils.class); - DataBroker dataBroker = mock(DataBroker.class); - // OscaNetworkElement optionalNe = mock(OscaNetworkElement.class); - - FaultService faultService = mock(FaultService.class); - OrgOpenroadmDevice device; - // OscaInventoryInput inventoryData = mock(OscaInventoryInput.class); - OpenroadmInventoryInput inventoryData; - private Inventory equipment = mock(Inventory.class); - long level = 1; - private Shelves shelf = mock(Shelves.class); - private List<Shelves> shelfList; - private CircuitPacks cp, cp1, cp2, cp3; - private Interface interfaces = mock(Interface.class); - private Xponder xpdr = mock(Xponder.class); - private IpAddress ipAddress = new IpAddress(new Ipv4Address("127.0.0.11")); - private Info info = new InfoBuilder().setNodeId(NodeIdType.getDefaultInstance("zNhe2i5")).setClli("NodeB") - .setSerialId("0002").setModel("model2").setVendor("VendorA").setCurrentIpAddress(ipAddress) - .setCurrentIpAddress(ipAddress).setCurrentDefaultGateway(new IpAddress(new Ipv4Address("127.0.0.20"))) - .setCurrentDefaultGateway(new IpAddress(new Ipv4Address("127.0.0.20"))).setNodeType(NodeTypes.Rdm) - .setCurrentDatetime(new DateAndTime("2017-10-22T15:23:43Z")).setSoftwareVersion("swversion1234") - .setPrefixLength((short) 28).setMaxDegrees(2).setMaxSrgs(3).setMaxNumBin15minHistoricalPm(32) - .setMaxNumBin24hourHistoricalPm(7).setOpenroadmVersion(OpenroadmVersionType._20).build(); - private ActiveAlarmList alarmList = mock(ActiveAlarmList.class); - private ActiveAlarms activeAlarms = mock(ActiveAlarms.class); - private HistoricalPmList pmDataList = mock(HistoricalPmList.class); - private HistoricalPm historicalPm = mock(HistoricalPm.class); - @Before - public void init() { - when(accessor.getCapabilites()).thenReturn(capabilities); - when(serviceProvider.getFaultService()).thenReturn(faultService); - when(serviceProvider.getDataProvider()).thenReturn(dataprovider); - NodeId nNodeId = new NodeId("RoadmA"); - when(accessor.getNodeId()).thenReturn(nNodeId); - when(accessor.getDataBroker()).thenReturn(dataBroker); - when(accessor.getTransactionUtils()).thenReturn(transactionUtils); - when(accessor.getCapabilites().isSupportingNamespaceAndRevision(OrgOpenroadmDevice.QNAME)).thenReturn(true); - final Class<OrgOpenroadmDevice> openRoadmDev = OrgOpenroadmDevice.class; - // Reading data from device - InstanceIdentifier<OrgOpenroadmDevice> deviceId = InstanceIdentifier.builder(openRoadmDev).build(); - device = mock(OrgOpenroadmDevice.class); - when(accessor.getTransactionUtils().readData(accessor.getDataBroker(), LogicalDatastoreType.OPERATIONAL, - deviceId)).thenReturn(device); - - when(device.getInfo()).thenReturn(info); - inventoryData = new OpenroadmInventoryInput(accessor, device); - // Reading the shelfs data; - when(shelf.getShelfPosition()).thenReturn("10"); - when(shelf.getOperationalState()).thenReturn(State.InService); - when(shelf.getSerialId()).thenReturn("nodeid-1"); - when(shelf.getShelfName()).thenReturn("Shelf1"); - when(shelf.getShelfType()).thenReturn("Shelf"); - when(shelf.getClei()).thenReturn("1234567890"); - when(shelf.getVendor()).thenReturn("vendorA"); - when(shelf.getModel()).thenReturn("1"); - when(shelf.getHardwareVersion()).thenReturn("0.1"); - when(shelf.getManufactureDate()).thenReturn(new DateAndTime("2017-10-22T15:23:43Z")); - List<Slots> slotList = null; - Slots slots = mock(Slots.class); - when(slots.getLabel()).thenReturn("Slot56746"); - when(slots.getSlotName()).thenReturn("slotofRoadmA"); - when(slots.getProvisionedCircuitPack()).thenReturn("1/0"); - slotList = Arrays.asList(slots); - when(shelf.getSlots()).thenReturn(slotList); - shelfList = Arrays.asList(shelf); - when(device.getShelves()).thenReturn(shelfList); - - // Reading data from CircuitPacks - cp = mock(CircuitPacks.class); - when(cp.getCircuitPackName()).thenReturn("1/0"); - when(cp.getVendor()).thenReturn("VendorA"); - when(cp.getModel()).thenReturn("Model1"); - when(cp.getSerialId()).thenReturn("46277sgh6"); - when(cp.getClei()).thenReturn("136268785"); - when(cp.getHardwareVersion()).thenReturn("0.1"); - when(cp.getType()).thenReturn("WSS"); - when(cp.getProductCode()).thenReturn("oooooo"); - when(cp.getCircuitPackMode()).thenReturn("inServiceMode"); - - ParentCircuitPack parentCp = mock(ParentCircuitPack.class); - when(parentCp.getCircuitPackName()).thenReturn("1/0"); - when(parentCp.getCpSlotName()).thenReturn("Slot1"); - cp1 = mock(CircuitPacks.class); - when(cp1.getCircuitPackName()).thenReturn("1/0 EThernet"); - when(cp1.getVendor()).thenReturn("VendorA"); - when(cp1.getModel()).thenReturn("Model1678"); - when(cp1.getSerialId()).thenReturn("4627dgs7sgh6"); - when(cp1.getClei()).thenReturn("1362d68785"); - when(cp1.getHardwareVersion()).thenReturn("0.1"); - when(cp1.getType()).thenReturn("EthPlug"); - when(cp1.getProductCode()).thenReturn("oooooo"); - when(cp1.getCircuitPackMode()).thenReturn("inServiceMode"); - when(cp1.getParentCircuitPack()).thenReturn(parentCp); - - cp2 = mock(CircuitPacks.class); - when(cp2.getCircuitPackName()).thenReturn("2/0"); - when(cp2.getVendor()).thenReturn("VendorA"); - when(cp2.getModel()).thenReturn("Model1678"); - when(cp2.getSerialId()).thenReturn("4sads7sgh6"); - when(cp2.getClei()).thenReturn("1wew362d68785"); - when(cp2.getHardwareVersion()).thenReturn("0.1"); - when(cp2.getType()).thenReturn("WSS"); - when(cp2.getProductCode()).thenReturn("osooooo"); - when(cp2.getCircuitPackMode()).thenReturn("inServiceMode"); - - cp3 = mock(CircuitPacks.class); - when(parentCp.getCircuitPackName()).thenReturn("2/0"); - when(parentCp.getCpSlotName()).thenReturn("Slot1"); - when(cp3.getCircuitPackName()).thenReturn("2/0 OCS"); - when(cp3.getVendor()).thenReturn("VendorA"); - when(cp3.getModel()).thenReturn("Model1678"); - when(cp3.getSerialId()).thenReturn("dswsads7sgh6"); - when(cp3.getClei()).thenReturn("1ew62d68785"); - when(cp3.getHardwareVersion()).thenReturn("0.1"); - when(cp3.getType()).thenReturn("OCS Plug"); - when(cp3.getProductCode()).thenReturn("osooooo"); - when(cp3.getCircuitPackMode()).thenReturn("inServiceMode"); - when(cp3.getParentCircuitPack()).thenReturn(parentCp); - List<CircuitPacks> cpList = Arrays.asList(cp, cp1, cp2, cp3); - when(device.getCircuitPacks()).thenReturn(cpList); - - // Reading Interface Data - when(interfaces.getName()).thenReturn("1GE-interface-1"); - when(interfaces.getDescription()).thenReturn("Ethernet Interface"); - when(interfaces.getSupportingCircuitPackName()).thenReturn("1/0 EThernet"); - List<Interface> interfacesList = Arrays.asList(interfaces); - when(device.getInterface()).thenReturn(interfacesList); - - // Reading Xponder Data - when(xpdr.getXpdrNumber()).thenReturn(1); - when(xpdr.getXpdrType()).thenReturn(XpdrNodeTypes.Mpdr); - when(xpdr.getLifecycleState()).thenReturn(LifecycleState.Deployed); - List<Xponder> xpnderList = Arrays.asList(xpdr); - when(device.getXponder()).thenReturn(xpnderList); - - // Read initial Alarm data - final Class<ActiveAlarmList> classAlarm = ActiveAlarmList.class; - InstanceIdentifier<ActiveAlarmList> alarmDataIid = InstanceIdentifier.builder(classAlarm).build(); - when(accessor.getTransactionUtils().readData(accessor.getDataBroker(), LogicalDatastoreType.OPERATIONAL, - alarmDataIid)).thenReturn(alarmList); - when(activeAlarms.getId()).thenReturn("Alarm1"); - when(activeAlarms.getCircuitId()).thenReturn("1/0"); - when(activeAlarms.getRaiseTime()).thenReturn(new DateAndTime("2017-10-22T15:23:43Z")); - when(activeAlarms.getSeverity()).thenReturn(Severity.Critical); - when(activeAlarms.getProbableCause()) - .thenReturn(new ProbableCauseBuilder().setCause(ProbableCauseEnum.AutomaticLaserShutdown).build()); - when(activeAlarms.getAdditionalDetail()).thenReturn("LaserShutdown"); - when(activeAlarms.getResource()).thenReturn(new ResourceBuilder() - .setDevice(new DeviceBuilder().setNodeId(NodeIdType.getDefaultInstance("zNhe2i5")).build()).build()); - List<ActiveAlarms> activeAlarmlist = Arrays.asList(activeAlarms); - when(alarmList.getActiveAlarms()).thenReturn(activeAlarmlist); - - // Read PM Data - final Class<HistoricalPmList> pmDataClass = HistoricalPmList.class; - InstanceIdentifier<HistoricalPmList> pmDataIid = InstanceIdentifier.builder(pmDataClass).build(); - when(accessor.getTransactionUtils().readData(accessor.getDataBroker(), LogicalDatastoreType.OPERATIONAL, - pmDataIid)).thenReturn(pmDataList); - - Measurement measurement = mock(Measurement.class); - PmDataType pmDataType = mock(PmDataType.class); - when(pmDataType.getUint64()).thenReturn(BigInteger.valueOf(2425425)); - when(measurement.getBinNumber()).thenReturn(1452); - when(measurement.getCompletionTime()).thenReturn(new DateAndTime("2018-10-22T15:23:43Z")); - when(measurement.getGranularity()).thenReturn(PmGranularity._24Hour); - when(measurement.getPmParameterUnit()).thenReturn("6824545199534863756"); - when(measurement.getPmParameterValue()).thenReturn(pmDataType); - when(measurement.getValidity()).thenReturn(Validity.Partial); - - List<Measurement> measurementList = Arrays.asList(measurement); - when(historicalPm.getMeasurement()).thenReturn(measurementList); - when(historicalPm.getType()).thenReturn(PmNamesEnum.DelayTCM1Down); - when(historicalPm.getExtension()).thenReturn("OpticalPowerOutput"); - List<HistoricalPm> historicalPmList = Arrays.asList(historicalPm); - HistoricalPmEntry histPmEntry = mock(HistoricalPmEntry.class); - when(histPmEntry.getHistoricalPm()).thenReturn(historicalPmList); - when(histPmEntry.getPmResourceType()).thenReturn(ResourceTypeEnum.CircuitPack); - List<HistoricalPmEntry> histPmList = Arrays.asList(histPmEntry); - when(pmDataList.getHistoricalPmEntry()).thenReturn(histPmList); - - } - - @Test - public void test() { - OpenroadmNetworkElement optionalNe = new OpenroadmNetworkElement(accessor, serviceProvider); - optionalNe.initialReadFromNetworkElement(); - } - -} +///* +// * ============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.openroadm.test; +// +//import static org.mockito.Mockito.mock; +//import static org.mockito.Mockito.when; +//import java.math.BigInteger; +//import java.util.Arrays; +//import java.util.HashMap; +//import java.util.List; +//import java.util.Map; +// +//import org.eclipse.jdt.annotation.Nullable; +//import org.junit.Before; +//import org.junit.Test; +//import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.DataProvider; +//import org.onap.ccsdk.features.sdnr.wt.devicemanager.openroadm.impl.OpenroadmInventoryInput; +//import org.onap.ccsdk.features.sdnr.wt.devicemanager.openroadm.impl.OpenroadmNetworkElement; +//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.netconfnodestateservice.Capabilities; +//import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfAccessor; +//import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.TransactionUtils; +//import org.opendaylight.mdsal.binding.api.DataBroker; +//import org.opendaylight.mdsal.common.api.LogicalDatastoreType; +//import org.opendaylight.yang.gen.v1.http.org.openroadm.alarm.rev191129.ActiveAlarmList; +//import org.opendaylight.yang.gen.v1.http.org.openroadm.alarm.rev191129.Severity; +//import org.opendaylight.yang.gen.v1.http.org.openroadm.alarm.rev191129.active.alarm.list.ActiveAlarms; +//import org.opendaylight.yang.gen.v1.http.org.openroadm.alarm.rev191129.active.alarm.list.ActiveAlarmsKey; +//import org.opendaylight.yang.gen.v1.http.org.openroadm.alarm.rev191129.alarm.ProbableCauseBuilder; +//import org.opendaylight.yang.gen.v1.http.org.openroadm.alarm.rev191129.alarm.ResourceBuilder; +//import org.opendaylight.yang.gen.v1.http.org.openroadm.common.node.types.rev191129.NodeIdType; +//import org.opendaylight.yang.gen.v1.http.org.openroadm.common.state.types.rev191129.LifecycleState; +//import org.opendaylight.yang.gen.v1.http.org.openroadm.common.state.types.rev191129.State; +//import org.opendaylight.yang.gen.v1.http.org.openroadm.common.types.rev191129.OpenroadmVersionType; +//import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev191129.OrgOpenroadmDevice; +//import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev191129.circuit.pack.ParentCircuitPack; +//import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev191129.circuit.packs.CircuitPacks; +//import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev191129.circuit.packs.CircuitPacksKey; +//import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev191129.interfaces.grp.Interface; +//import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev191129.interfaces.grp.InterfaceKey; +//import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev191129.org.openroadm.device.Info; +//import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev191129.org.openroadm.device.InfoBuilder; +//import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev191129.org.openroadm.device.Xponder; +//import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev191129.org.openroadm.device.XponderKey; +//import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev191129.shelf.Slots; +//import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev191129.shelf.SlotsKey; +//import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev191129.shelves.Shelves; +//import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev191129.shelves.ShelvesKey; +//import org.opendaylight.yang.gen.v1.http.org.openroadm.device.types.rev191129.NodeTypes; +//import org.opendaylight.yang.gen.v1.http.org.openroadm.device.types.rev191129.XpdrNodeTypes; +//import org.opendaylight.yang.gen.v1.http.org.openroadm.pm.rev191129.HistoricalPmList; +//import org.opendaylight.yang.gen.v1.http.org.openroadm.pm.rev191129.historical.pm.group.HistoricalPm; +//import org.opendaylight.yang.gen.v1.http.org.openroadm.pm.rev191129.historical.pm.group.HistoricalPmKey; +//import org.opendaylight.yang.gen.v1.http.org.openroadm.pm.rev191129.historical.pm.list.HistoricalPmEntry; +//import org.opendaylight.yang.gen.v1.http.org.openroadm.pm.rev191129.historical.pm.list.HistoricalPmEntryKey; +//import org.opendaylight.yang.gen.v1.http.org.openroadm.pm.rev191129.historical.pm.val.group.Measurement; +//import org.opendaylight.yang.gen.v1.http.org.openroadm.pm.rev191129.historical.pm.val.group.MeasurementKey; +//import org.opendaylight.yang.gen.v1.http.org.openroadm.pm.types.rev191129.PmDataType; +//import org.opendaylight.yang.gen.v1.http.org.openroadm.pm.types.rev191129.PmGranularity; +//import org.opendaylight.yang.gen.v1.http.org.openroadm.pm.types.rev191129.PmNamesEnum; +//import org.opendaylight.yang.gen.v1.http.org.openroadm.pm.types.rev191129.Validity; +//import org.opendaylight.yang.gen.v1.http.org.openroadm.probablecause.rev191129.ProbableCauseEnum; +//import org.opendaylight.yang.gen.v1.http.org.openroadm.resource.rev191129.resource.DeviceBuilder; +//import org.opendaylight.yang.gen.v1.http.org.openroadm.resource.types.rev191129.ResourceTypeEnum; +//import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress; +//import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address; +//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.Inventory; +//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.binding.Identifiable; +//import org.opendaylight.yangtools.yang.binding.Identifier; +//import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; +//import org.opendaylight.yangtools.yang.common.Uint16; +//import org.opendaylight.yangtools.yang.common.Uint64; +// +//public class TestOpenRoadmNetworkElement { +// +// NetconfAccessor accessor = mock(NetconfAccessor.class); +// DeviceManagerServiceProvider serviceProvider = mock(DeviceManagerServiceProvider.class); +// DataProvider dataprovider = mock(DataProvider.class); +// Capabilities capabilities = mock(Capabilities.class); +// TransactionUtils transactionUtils = mock(TransactionUtils.class); +// DataBroker dataBroker = mock(DataBroker.class); +// // OscaNetworkElement optionalNe = mock(OscaNetworkElement.class); +// +// FaultService faultService = mock(FaultService.class); +// OrgOpenroadmDevice device; +// // OscaInventoryInput inventoryData = mock(OscaInventoryInput.class); +// OpenroadmInventoryInput inventoryData; +// private Inventory equipment = mock(Inventory.class); +// long level = 1; +// private Shelves shelf = mock(Shelves.class); +// private @Nullable Map<ShelvesKey, Shelves> shelfList; +// private CircuitPacks cp, cp1, cp2, cp3; +// private Interface interfaces = mock(Interface.class); +// private Xponder xpdr = mock(Xponder.class); +// private IpAddress ipAddress = new IpAddress(new Ipv4Address("127.0.0.11")); +// private Info info = new InfoBuilder().setNodeId(NodeIdType.getDefaultInstance("zNhe2i5")).setClli("NodeB") +// .setSerialId("0002").setModel("model2").setVendor("VendorA").setCurrentIpAddress(ipAddress) +// .setCurrentIpAddress(ipAddress).setCurrentDefaultGateway(new IpAddress(new Ipv4Address("127.0.0.20"))) +// .setCurrentDefaultGateway(new IpAddress(new Ipv4Address("127.0.0.20"))).setNodeType(NodeTypes.Rdm) +// .setCurrentDatetime(new DateAndTime("2017-10-22T15:23:43Z")).setSoftwareVersion("swversion1234") +// .setPrefixLength((short) 28).setMaxDegrees(2).setMaxSrgs(3).setMaxNumBin15minHistoricalPm(32) +// .setMaxNumBin24hourHistoricalPm(7).setOpenroadmVersion(OpenroadmVersionType._20).build(); +// private ActiveAlarmList alarmList = mock(ActiveAlarmList.class); +// private ActiveAlarms activeAlarms = mock(ActiveAlarms.class); +// private HistoricalPmList pmDataList = mock(HistoricalPmList.class); +// private HistoricalPm historicalPm = mock(HistoricalPm.class); +// @Before +// public void init() { +// when(accessor.getCapabilites()).thenReturn(capabilities); +// when(serviceProvider.getFaultService()).thenReturn(faultService); +// when(serviceProvider.getDataProvider()).thenReturn(dataprovider); +// NodeId nNodeId = new NodeId("RoadmA"); +// when(accessor.getNodeId()).thenReturn(nNodeId); +// when(accessor.getDataBroker()).thenReturn(dataBroker); +// when(accessor.getTransactionUtils()).thenReturn(transactionUtils); +// when(accessor.getCapabilites().isSupportingNamespaceAndRevision(OrgOpenroadmDevice.QNAME)).thenReturn(true); +// final Class<OrgOpenroadmDevice> openRoadmDev = OrgOpenroadmDevice.class; +// // Reading data from device +// InstanceIdentifier<OrgOpenroadmDevice> deviceId = InstanceIdentifier.builder(openRoadmDev).build(); +// device = mock(OrgOpenroadmDevice.class); +// when(accessor.getTransactionUtils().readData(accessor.getDataBroker(), LogicalDatastoreType.OPERATIONAL, +// deviceId)).thenReturn(device); +// +// when(device.getInfo()).thenReturn(info); +// inventoryData = new OpenroadmInventoryInput(accessor, device); +// // Reading the shelfs data; +// when(shelf.getShelfPosition()).thenReturn("10"); +// when(shelf.getOperationalState()).thenReturn(State.InService); +// when(shelf.getSerialId()).thenReturn("nodeid-1"); +// when(shelf.getShelfName()).thenReturn("Shelf1"); +// when(shelf.getShelfType()).thenReturn("Shelf"); +// when(shelf.getClei()).thenReturn("1234567890"); +// when(shelf.getVendor()).thenReturn("vendorA"); +// when(shelf.getModel()).thenReturn("1"); +// when(shelf.getHardwareVersion()).thenReturn("0.1"); +// when(shelf.getManufactureDate()).thenReturn(new DateAndTime("2017-10-22T15:23:43Z")); +// @Nullable Map<SlotsKey, Slots> slotList = null; +// Slots slots = mock(Slots.class); +// when(slots.getLabel()).thenReturn("Slot56746"); +// when(slots.getSlotName()).thenReturn("slotofRoadmA"); +// when(slots.getProvisionedCircuitPack()).thenReturn("1/0"); +// slotList = new HashMap<>(); +// slotList.put(slots.key(),slots); +// when(shelf.getSlots()).thenReturn(slotList); +// shelfList = new HashMap<>(); +// shelfList.put(shelf.key(),shelf); +// when(device.getShelves()).thenReturn(shelfList); +// +// // Reading data from CircuitPacks +// cp = mock(CircuitPacks.class); +// when(cp.getCircuitPackName()).thenReturn("1/0"); +// when(cp.getVendor()).thenReturn("VendorA"); +// when(cp.getModel()).thenReturn("Model1"); +// when(cp.getSerialId()).thenReturn("46277sgh6"); +// when(cp.getClei()).thenReturn("136268785"); +// when(cp.getHardwareVersion()).thenReturn("0.1"); +// when(cp.getType()).thenReturn("WSS"); +// when(cp.getProductCode()).thenReturn("oooooo"); +// when(cp.getCircuitPackMode()).thenReturn("inServiceMode"); +// +// ParentCircuitPack parentCp = mock(ParentCircuitPack.class); +// when(parentCp.getCircuitPackName()).thenReturn("1/0"); +// when(parentCp.getCpSlotName()).thenReturn("Slot1"); +// cp1 = mock(CircuitPacks.class); +// when(cp1.getCircuitPackName()).thenReturn("1/0 EThernet"); +// when(cp1.getVendor()).thenReturn("VendorA"); +// when(cp1.getModel()).thenReturn("Model1678"); +// when(cp1.getSerialId()).thenReturn("4627dgs7sgh6"); +// when(cp1.getClei()).thenReturn("1362d68785"); +// when(cp1.getHardwareVersion()).thenReturn("0.1"); +// when(cp1.getType()).thenReturn("EthPlug"); +// when(cp1.getProductCode()).thenReturn("oooooo"); +// when(cp1.getCircuitPackMode()).thenReturn("inServiceMode"); +// when(cp1.getParentCircuitPack()).thenReturn(parentCp); +// +// cp2 = mock(CircuitPacks.class); +// when(cp2.getCircuitPackName()).thenReturn("2/0"); +// when(cp2.getVendor()).thenReturn("VendorA"); +// when(cp2.getModel()).thenReturn("Model1678"); +// when(cp2.getSerialId()).thenReturn("4sads7sgh6"); +// when(cp2.getClei()).thenReturn("1wew362d68785"); +// when(cp2.getHardwareVersion()).thenReturn("0.1"); +// when(cp2.getType()).thenReturn("WSS"); +// when(cp2.getProductCode()).thenReturn("osooooo"); +// when(cp2.getCircuitPackMode()).thenReturn("inServiceMode"); +// +// cp3 = mock(CircuitPacks.class); +// when(parentCp.getCircuitPackName()).thenReturn("2/0"); +// when(parentCp.getCpSlotName()).thenReturn("Slot1"); +// when(cp3.getCircuitPackName()).thenReturn("2/0 OCS"); +// when(cp3.getVendor()).thenReturn("VendorA"); +// when(cp3.getModel()).thenReturn("Model1678"); +// when(cp3.getSerialId()).thenReturn("dswsads7sgh6"); +// when(cp3.getClei()).thenReturn("1ew62d68785"); +// when(cp3.getHardwareVersion()).thenReturn("0.1"); +// when(cp3.getType()).thenReturn("OCS Plug"); +// when(cp3.getProductCode()).thenReturn("osooooo"); +// when(cp3.getCircuitPackMode()).thenReturn("inServiceMode"); +// when(cp3.getParentCircuitPack()).thenReturn(parentCp); +// @Nullable Map<CircuitPacksKey, CircuitPacks> cpList = new HashMap<>(); +// cpList.put(cp.key(),cp); +// cpList.put(cp1.key(),cp1); +// cpList.put(cp2.key(),cp2); +// cpList.put(cp3.key(),cp3); +// when(device.getCircuitPacks()).thenReturn(cpList); +// +// // Reading Interface Data +// when(interfaces.getName()).thenReturn("1GE-interface-1"); +// when(interfaces.getDescription()).thenReturn("Ethernet Interface"); +// when(interfaces.getSupportingCircuitPackName()).thenReturn("1/0 EThernet"); +// @Nullable Map<InterfaceKey, Interface> interfacesList = new HashMap<>(); +// interfacesList.put(interfaces.key(),interfaces); +// when(device.getInterface()).thenReturn(interfacesList); +// +// // Reading Xponder Data +// when(xpdr.getXpdrNumber()).thenReturn(Uint16.valueOf(1)); +// when(xpdr.getXpdrType()).thenReturn(XpdrNodeTypes.Mpdr); +// when(xpdr.getLifecycleState()).thenReturn(LifecycleState.Deployed); +// @Nullable Map<XponderKey, Xponder> xpnderList = new HashMap<>(); +// xpnderList.put(xpdr.key(), xpdr); +// when(device.getXponder()).thenReturn(xpnderList); +// +// // Read initial Alarm data +// final Class<ActiveAlarmList> classAlarm = ActiveAlarmList.class; +// InstanceIdentifier<ActiveAlarmList> alarmDataIid = InstanceIdentifier.builder(classAlarm).build(); +// when(accessor.getTransactionUtils().readData(accessor.getDataBroker(), LogicalDatastoreType.OPERATIONAL, +// alarmDataIid)).thenReturn(alarmList); +// when(activeAlarms.getId()).thenReturn("Alarm1"); +// when(activeAlarms.getCircuitId()).thenReturn("1/0"); +// when(activeAlarms.getRaiseTime()).thenReturn(new DateAndTime("2017-10-22T15:23:43Z")); +// when(activeAlarms.getSeverity()).thenReturn(Severity.Critical); +// when(activeAlarms.getProbableCause()) +// .thenReturn(new ProbableCauseBuilder().setCause(ProbableCauseEnum.AutomaticLaserShutdown).build()); +// when(activeAlarms.getAdditionalDetail()).thenReturn("LaserShutdown"); +// when(activeAlarms.getResource()).thenReturn(new ResourceBuilder() +// .setDevice(new DeviceBuilder().setNodeId(NodeIdType.getDefaultInstance("zNhe2i5")).build()).build()); +// @Nullable Map<ActiveAlarmsKey, ActiveAlarms> activeAlarmlist = new HashMap<>(); +// activeAlarmlist.put(activeAlarms.key(),activeAlarms); +// when(alarmList.getActiveAlarms()).thenReturn(activeAlarmlist); +// +// // Read PM Data +// final Class<HistoricalPmList> pmDataClass = HistoricalPmList.class; +// InstanceIdentifier<HistoricalPmList> pmDataIid = InstanceIdentifier.builder(pmDataClass).build(); +// when(accessor.getTransactionUtils().readData(accessor.getDataBroker(), LogicalDatastoreType.OPERATIONAL, +// pmDataIid)).thenReturn(pmDataList); +// +// Measurement measurement = mock(Measurement.class); +// PmDataType pmDataType = mock(PmDataType.class); +// when(pmDataType.getUint64()).thenReturn(Uint64.valueOf(2425425)); +// when(measurement.getBinNumber()).thenReturn(Uint16.valueOf(1452)); +// when(measurement.getCompletionTime()).thenReturn(new DateAndTime("2018-10-22T15:23:43Z")); +// when(measurement.getGranularity()).thenReturn(PmGranularity._24Hour); +// when(measurement.getPmParameterUnit()).thenReturn("6824545199534863756"); +// when(measurement.getPmParameterValue()).thenReturn(pmDataType); +// when(measurement.getValidity()).thenReturn(Validity.Partial); +// +// @Nullable Map<MeasurementKey, Measurement> measurementList = new HashMap<>(); +// measurementList.put(measurement.key(),measurement); +// when(historicalPm.getMeasurement()).thenReturn(measurementList); +// when(historicalPm.getType()).thenReturn(PmNamesEnum.DelayTCM1Down); +// when(historicalPm.getExtension()).thenReturn("OpticalPowerOutput"); +// @Nullable Map<HistoricalPmKey, HistoricalPm> historicalPmList = new HashMap<>(); +// historicalPmList.put(historicalPm.key(),historicalPm); +// HistoricalPmEntry histPmEntry = mock(HistoricalPmEntry.class); +// when(histPmEntry.getHistoricalPm()).thenReturn(historicalPmList); +// when(histPmEntry.getPmResourceType()).thenReturn(ResourceTypeEnum.CircuitPack); +// @Nullable Map<HistoricalPmEntryKey, HistoricalPmEntry> histPmList = new HashMap<>(); +// histPmList.put(histPmEntry.key(),histPmEntry); +// when(pmDataList.getHistoricalPmEntry()).thenReturn(histPmList); +// +// } +// +// +// +// @Test +// public void test() { +// OpenroadmNetworkElement optionalNe = new OpenroadmNetworkElement(accessor, serviceProvider); +// optionalNe.initialReadFromNetworkElement(); +// } +// +//} diff --git a/sdnr/wt/devicemanager-openroadm/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm/test/TestOpenRoadmNetworkElementFactory.java b/sdnr/wt/devicemanager-openroadm/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm/test/TestOpenRoadmNetworkElementFactory.java index 901a7b376..40a48c358 100644 --- a/sdnr/wt/devicemanager-openroadm/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm/test/TestOpenRoadmNetworkElementFactory.java +++ b/sdnr/wt/devicemanager-openroadm/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm/test/TestOpenRoadmNetworkElementFactory.java @@ -21,71 +21,76 @@ */ package org.onap.ccsdk.features.sdnr.wt.devicemanager.openroadm.test; +import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; import java.io.IOException; +import java.util.Optional; import org.junit.After; import org.junit.BeforeClass; import org.junit.Test; import org.onap.ccsdk.features.sdnr.wt.devicemanager.openroadm.impl.OpenroadmNetworkElementFactory; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.openroadm.test.mock.NetconfAccessorMock; 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.TransactionUtils; import org.opendaylight.mdsal.binding.api.DataBroker; import org.opendaylight.mdsal.common.api.LogicalDatastoreType; import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev191129.OrgOpenroadmDevice; import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import org.opendaylight.yangtools.yang.common.QName; public class TestOpenRoadmNetworkElementFactory { - static NetconfAccessor accessor; - static DeviceManagerServiceProvider serviceProvider; - static Capabilities capabilities; - QName qCapability; - private NodeId nodeId = new NodeId("RoadmA2"); - static OrgOpenroadmDevice device; - static TransactionUtils transactionUtils; - static DataBroker dataBroker; + private static NetconfBindingAccessor accessor; + private static DeviceManagerServiceProvider serviceProvider; + private static Capabilities capabilities; + private static TransactionUtils transactionUtils; + private static DataBroker dataBroker; @BeforeClass public static void init() throws InterruptedException, IOException { - accessor = mock(NetconfAccessorMock.class); + accessor = mock(NetconfBindingAccessor.class); capabilities = mock(Capabilities.class); dataBroker = mock(DataBroker.class); transactionUtils = mock(TransactionUtils.class); serviceProvider = mock(DeviceManagerServiceProvider.class); + when(accessor.getNodeId()).thenReturn(new NodeId("RoadmA2")); when(accessor.getCapabilites()).thenReturn(capabilities); when(accessor.getDataBroker()).thenReturn(dataBroker); when(accessor.getTransactionUtils()).thenReturn(transactionUtils); + when(accessor.getNetconfBindingAccessor()).thenReturn(Optional.of(accessor)); when(serviceProvider.getDataProvider()).thenReturn(null); - device = mock(OrgOpenroadmDevice.class); + final Class<OrgOpenroadmDevice> openRoadmDev = OrgOpenroadmDevice.class; InstanceIdentifier<OrgOpenroadmDevice> deviceId = InstanceIdentifier.builder(openRoadmDev).build(); when(accessor.getTransactionUtils().readData(accessor.getDataBroker(), LogicalDatastoreType.OPERATIONAL, - deviceId)).thenReturn(device); + deviceId)).thenReturn(mock(OrgOpenroadmDevice.class)); + + when(accessor.getTransactionUtils()).thenReturn(mock(TransactionUtils.class)); } @Test - public void testCapabilties() { - when(accessor.getNodeId()).thenReturn(nodeId); - when(accessor.getCapabilites().isSupportingNamespace(OrgOpenroadmDevice.QNAME)).thenReturn(true); + public void testCapabiltiesAvailable1() { + when(accessor.getCapabilites().isSupportingNamespaceAndRevision(OrgOpenroadmDevice.QNAME)).thenReturn(true); + OpenroadmNetworkElementFactory factory = new OpenroadmNetworkElementFactory(); + assertTrue((factory.create(accessor, serviceProvider)).isPresent()); + } - // when(accessor.getCapabilites().isSupportingNamespace(SimulatorStatus.QNAME)).thenReturn(false); + @Test + public void testCapabiltiesAvailable2() { + when(accessor.getCapabilites().isSupportingNamespaceAndRevision("http://org/openroadm/device", "2018-10-19")) + .thenReturn(true); OpenroadmNetworkElementFactory factory = new OpenroadmNetworkElementFactory(); assertTrue((factory.create(accessor, serviceProvider)).isPresent()); } @Test - public void testCreateNone() throws Exception { - when(accessor.getCapabilites().isSupportingNamespace(OrgOpenroadmDevice.QNAME)).thenReturn(false); - // when(accessor.getCapabilites().isSupportingNamespace(SimulatorStatus.QNAME)).thenReturn(false); + public void testCapabiltiesNotAvailable() throws Exception { + when(accessor.getCapabilites().isSupportingNamespaceAndRevision(OrgOpenroadmDevice.QNAME)).thenReturn(false); OpenroadmNetworkElementFactory factory = new OpenroadmNetworkElementFactory(); - assertTrue(!(factory.create(accessor, serviceProvider).isPresent())); + assertFalse(factory.create(accessor, serviceProvider).isPresent()); } @After @@ -93,5 +98,4 @@ public class TestOpenRoadmNetworkElementFactory { } - } diff --git a/sdnr/wt/devicemanager-openroadm/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm/test/mock/NetconfAccessorMock.java b/sdnr/wt/devicemanager-openroadm/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm/test/mock/NetconfAccessorMock.java deleted file mode 100644 index d225a1ecc..000000000 --- a/sdnr/wt/devicemanager-openroadm/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm/test/mock/NetconfAccessorMock.java +++ /dev/null @@ -1,112 +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.openroadm.test.mock; - -import com.google.common.util.concurrent.ListenableFuture; -import java.util.List; -import org.eclipse.jdt.annotation.NonNull; -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.TransactionUtils; -import org.opendaylight.mdsal.binding.api.DataBroker; -import org.opendaylight.mdsal.binding.api.MountPoint; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netconf.notification._1._0.rev080714.CreateSubscriptionOutput; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netmod.notification.rev080714.netconf.streams.Stream; -import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.NetconfNode; -import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId; -import org.opendaylight.yangtools.concepts.ListenerRegistration; -import org.opendaylight.yangtools.yang.binding.NotificationListener; -import org.opendaylight.yangtools.yang.common.RpcResult; - -/** - */ -public class NetconfAccessorMock implements NetconfAccessor { - - private final NodeId nNodeId; - private final NetconfNode netconfNode; - private final MountPoint mountpoint; - private final DataBroker netconfNodeDataBroker; - - public NetconfAccessorMock(NodeId nNodeId, NetconfNode netconfNode, MountPoint mountpoint, - DataBroker netconfNodeDataBroker) { - this.nNodeId = nNodeId; - this.netconfNode = netconfNode; - this.mountpoint = mountpoint; - this.netconfNodeDataBroker = netconfNodeDataBroker; - } - - @Override - public NodeId getNodeId() { - return nNodeId; - } - - @Override - public NetconfNode getNetconfNode() { - return netconfNode; - } - - @Override - public Capabilities getCapabilites() { - return null; - } - - @Override - public DataBroker getDataBroker() { - return netconfNodeDataBroker; - } - - @Override - public MountPoint getMountpoint() { - return mountpoint; - } - - @Override - public TransactionUtils getTransactionUtils() { - return null; - } - - @Override - public <T extends NotificationListener> ListenerRegistration<NotificationListener> doRegisterNotificationListener( - @NonNull T listener) { - return null; - } - - @Override - public ListenableFuture<RpcResult<CreateSubscriptionOutput>> registerNotificationsStream(String streamName) { - return null; - } - - @Override - public void registerNotificationsStream(List<Stream> streamList) { - } - - @Override - public boolean isNCNotificationsSupported() { - return false; - } - - @Override - public List<Stream> getNotificationStreams() { - return null; - } - -} diff --git a/sdnr/wt/devicemanager-openroadm/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm/test/mock/TransactionUtilsMock.java b/sdnr/wt/devicemanager-openroadm/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm/test/mock/TransactionUtilsMock.java deleted file mode 100644 index 68383e68f..000000000 --- a/sdnr/wt/devicemanager-openroadm/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm/test/mock/TransactionUtilsMock.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * ONAP : ccsdk features - * ================================================================================ - * Copyright (C) 2020 highstreet technologies GmbH Intellectual Property. - * All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - * - */ -package org.onap.ccsdk.features.sdnr.wt.devicemanager.openroadm.test.mock; - -import java.util.concurrent.atomic.AtomicBoolean; -import java.util.concurrent.atomic.AtomicReference; -import org.eclipse.jdt.annotation.Nullable; -import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.TransactionUtils; -import org.opendaylight.mdsal.binding.api.DataBroker; -import org.opendaylight.mdsal.common.api.LogicalDatastoreType; -import org.opendaylight.yangtools.yang.binding.DataObject; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; - -public class TransactionUtilsMock implements TransactionUtils { - - @Override - public <T extends DataObject> @Nullable T readData(DataBroker dataBroker, LogicalDatastoreType dataStoreType, - InstanceIdentifier<T> iid) { - // TODO Auto-generated method stub - return null; - } - - @Override - public <T extends DataObject> @Nullable T readDataOptionalWithStatus(DataBroker dataBroker, - LogicalDatastoreType dataStoreType, InstanceIdentifier<T> iid, AtomicBoolean noErrorIndication, - AtomicReference<String> statusIndicator) { - // TODO Auto-generated method stub - return null; - } - -} |