1 /*******************************************************************************
 
   2  * ============LICENSE_START========================================================================
 
   3  * ONAP : ccsdk feature sdnr wt
 
   4  * =================================================================================================
 
   5  * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. All rights reserved.
 
   6  * =================================================================================================
 
   7  * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
 
   8  * in compliance with the License. You may obtain a copy of the License at
 
  10  * http://www.apache.org/licenses/LICENSE-2.0
 
  12  * Unless required by applicable law or agreed to in writing, software distributed under the License
 
  13  * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
 
  14  * or implied. See the License for the specific language governing permissions and limitations under
 
  16  * ============LICENSE_END==========================================================================
 
  17  ******************************************************************************/
 
  18 package org.onap.ccsdk.features.sdnr.wt.devicemanager.onf.ifpac.microwave;
 
  22 import java.lang.reflect.Constructor;
 
  23 import java.lang.reflect.InvocationTargetException;
 
  24 import java.util.List;
 
  25 import java.util.Optional;
 
  26 import org.eclipse.jdt.annotation.NonNull;
 
  27 import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf.ifpac.microwave.pm.PerformanceDataAirInterface181010Builder;
 
  28 import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf.notifications.NotificationWorker;
 
  29 import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf.util.ONFLayerProtocolName;
 
  30 import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.DeviceManagerServiceProvider;
 
  31 import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.FaultService;
 
  32 import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.NotificationService;
 
  33 import org.onap.ccsdk.features.sdnr.wt.devicemanager.types.FaultData;
 
  34 import org.onap.ccsdk.features.sdnr.wt.devicemanager.types.PerformanceDataLtp;
 
  35 import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfAccessor;
 
  36 import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.TransactionUtils;
 
  37 import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
 
  38 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.UniversalId;
 
  39 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.logical.termination.point.g.Lp;
 
  40 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.SeverityType;
 
  41 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.AirInterfaceCurrentProblemTypeG;
 
  42 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.AirInterfaceDiversityCurrentProblemTypeG;
 
  43 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.AirInterfaceHistoricalPerformanceTypeG;
 
  44 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.AttributeValueChangedNotification;
 
  45 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.ContainerCurrentProblemTypeG;
 
  46 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.ContainerHistoricalPerformanceTypeG;
 
  47 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.MicrowaveModelListener;
 
  48 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.MwAirInterfaceDiversityPac;
 
  49 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.MwAirInterfaceDiversityPacKey;
 
  50 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.MwAirInterfacePac;
 
  51 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.MwAirInterfacePacKey;
 
  52 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.MwEthernetContainerPac;
 
  53 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.MwEthernetContainerPacKey;
 
  54 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.MwHybridMwStructurePac;
 
  55 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.MwHybridMwStructurePacKey;
 
  56 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.MwPureEthernetStructurePac;
 
  57 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.MwPureEthernetStructurePacKey;
 
  58 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.MwTdmContainerPac;
 
  59 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.MwTdmContainerPacKey;
 
  60 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.ObjectCreationNotification;
 
  61 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.ObjectDeletionNotification;
 
  62 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.ProblemNotification;
 
  63 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.StructureCurrentProblemTypeG;
 
  64 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.mw.air._interface.diversity.pac.AirInterfaceDiversityCurrentProblems;
 
  65 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.mw.air._interface.pac.AirInterfaceConfiguration;
 
  66 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.mw.air._interface.pac.AirInterfaceCurrentProblems;
 
  67 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.mw.air._interface.pac.AirInterfaceHistoricalPerformances;
 
  68 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.mw.ethernet.container.pac.EthernetContainerCurrentProblems;
 
  69 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.mw.ethernet.container.pac.EthernetContainerHistoricalPerformances;
 
  70 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.mw.hybrid.mw.structure.pac.HybridMwStructureCurrentProblems;
 
  71 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.mw.pure.ethernet.structure.pac.PureEthernetStructureCurrentProblems;
 
  72 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.mw.tdm.container.pac.TdmContainerCurrentProblems;
 
  73 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.EventlogBuilder;
 
  74 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.EventlogEntity;
 
  75 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 
  76 import org.opendaylight.yangtools.yang.binding.NotificationListener;
 
  77 import org.opendaylight.yangtools.yang.common.QName;
 
  78 import org.slf4j.Logger;
 
  79 import org.slf4j.LoggerFactory;
 
  82 public class WrapperMicrowaveModelRev181010 implements OnfMicrowaveModel, MicrowaveModelListener {
 
  84     private static final Logger LOG = LoggerFactory.getLogger(WrapperMicrowaveModelRev181010.class);
 
  86     public static final QName QNAME = MwAirInterfacePac.QNAME;
 
  89     private final NetconfAccessor acessor;
 
  90     private final NotificationService microwaveModelListener;
 
  91     private final TransactionUtils genericTransactionUtils;
 
  92     private final String mountpointId;
 
  93     private final @NonNull FaultService faultService;
 
  95     private Optional<NotificationWorker<EventlogEntity>> notificationQueue;
 
  98      * Handle specific version of microwave model
 
  99      * @param acessor to access device
 
 100      * @param serviceProvider for devicemanager services
 
 102     public WrapperMicrowaveModelRev181010(@NonNull NetconfAccessor acessor, @NonNull DeviceManagerServiceProvider serviceProvider) {
 
 103         this.acessor = acessor;
 
 104         this.genericTransactionUtils = acessor.getTransactionUtils();
 
 105         this.mountpointId = acessor.getNodeId().getValue();
 
 106         this.microwaveModelListener = serviceProvider.getNotificationService();
 
 107         this.faultService = serviceProvider.getFaultService();
 
 108         this.notificationQueue = Optional.empty();
 
 111     /*-----------------------------------------------------------------------------
 
 115     @SuppressWarnings("unchecked")
 
 117     public <T extends NotificationListener> T getNotificationListener() {
 
 122     public void setNotificationQueue(NotificationWorker<EventlogEntity> notificationQueue) {
 
 123         this.notificationQueue = Optional.of(notificationQueue);
 
 126     /*-----------------------------------------------------------------------------
 
 131     public void readTheFaultsOfMicrowaveModel(ONFLayerProtocolName lpName, Class<?> lpClass, UniversalId uuid,
 
 132             FaultData resultList) {
 
 136             readTheFaultsOfMwAirInterfacePac(uuid, resultList);
 
 139         case EthernetContainer12:
 
 140             readTheFaultsOfMwEthernetContainerPac(uuid, resultList);
 
 144             readTheFaultsOfMwTdmContainerPac(uuid, resultList);
 
 148             if (lpClass == MwHybridMwStructurePac.class) {
 
 149                 readTheFaultsOfMwHybridMwStructurePac(uuid, resultList);
 
 151             } else if (lpClass == MwAirInterfaceDiversityPac.class) {
 
 152                 readTheFaultsOfMwAirInterfaceDiversityPac(uuid, resultList);
 
 154             } else if (lpClass == MwPureEthernetStructurePac.class) {
 
 155                 readTheFaultsOfMwPureEthernetStructurePac(uuid, resultList);
 
 158                 LOG.warn("Unassigned lp model {} class {}", lpName, lpClass);
 
 162             // No alarms supported
 
 164         case EthernetContainer10:
 
 166             LOG.warn("Unassigned or not expected lp in model {}", lpName);
 
 171     public @NonNull PerformanceDataLtp getLtpHistoricalPerformanceData(@NonNull ONFLayerProtocolName lpName, @NonNull Lp lp) {
 
 172         PerformanceDataLtp res = new PerformanceDataLtp();
 
 175             return readAirInterfacePerformanceData(lp, res);
 
 177         case EthernetContainer12:
 
 178             return readEthernetContainerPerformanceData(lp, res);
 
 180         case EthernetContainer10:
 
 181         case EthernetPhysical:
 
 186             LOG.debug("Do not read HistoricalPM data for {} {}", lpName, Helper.nnGetUniversalId(lp.getUuid()).getValue());
 
 192     public Class<?> getClassForLtpExtension(QName qName) {
 
 194         if (qName.equals(MwAirInterfacePac.QNAME)) {
 
 195             res = MwAirInterfacePac.class;
 
 196         } else if (qName.equals(MwAirInterfaceDiversityPac.QNAME)) {
 
 197             res = MwAirInterfaceDiversityPac.class;
 
 198         } else if (qName.equals(MwPureEthernetStructurePac.QNAME)) {
 
 199             res = MwPureEthernetStructurePac.class;
 
 200         } else if (qName.equals(MwHybridMwStructurePac.QNAME)) {
 
 201             res = MwHybridMwStructurePac.class;
 
 202         } else if (qName.equals(MwEthernetContainerPac.QNAME)) {
 
 203             res = MwEthernetContainerPac.class;
 
 204         } else if (qName.equals(MwTdmContainerPac.QNAME)) {
 
 205             res = MwTdmContainerPac.class;
 
 207         LOG.info("Found QName {} mapped to {}", String.valueOf(qName), String.valueOf(res));
 
 212     public void onObjectCreationNotification(ObjectCreationNotification notification) {
 
 213         LOG.debug("Got event of type :: {}", ObjectCreationNotification.class.getSimpleName());
 
 214         if (notification != null) {
 
 215             microwaveModelListener.creationNotification(acessor.getNodeId(), notification.getCounter(),
 
 216                     notification.getTimeStamp(), Helper.nnGetUniversalId(notification.getObjectIdRef()).getValue());
 
 221     public void onObjectDeletionNotification( ObjectDeletionNotification notification) {
 
 222         LOG.debug("Got event of type :: {}", ObjectDeletionNotification.class.getSimpleName());
 
 223         if (notification != null) {
 
 224             microwaveModelListener.deletionNotification(acessor.getNodeId(), notification.getCounter(),
 
 225                     notification.getTimeStamp(), Helper.nnGetUniversalId(notification.getObjectIdRef()).getValue());
 
 230     public void onAttributeValueChangedNotification(AttributeValueChangedNotification notification) {
 
 231         LOG.debug("Got event of type :: {}", AttributeValueChangedNotification.class.getSimpleName());
 
 232         EventlogEntity beventlogEntity = new EventlogBuilder().setNodeId(acessor.getNodeId().getValue())
 
 233                 .setCounter(notification.getCounter()).setTimestamp(notification.getTimeStamp())
 
 234                 .setObjectId(Helper.nnGetUniversalId(notification.getObjectIdRef()).getValue())
 
 235                 .setAttributeName(notification.getAttributeName()).setNewValue(notification.getNewValue()).build();
 
 236         microwaveModelListener.eventNotification(beventlogEntity);
 
 237         if (notificationQueue.isPresent()) {
 
 238             notificationQueue.get().put(beventlogEntity);
 
 243     public void onProblemNotification(ProblemNotification notification) {
 
 245         LOG.debug("Got event of type :: {}", ProblemNotification.class.getSimpleName());
 
 247         faultService.faultNotification(acessor.getNodeId(), notification.getCounter(),
 
 248                 notification.getTimeStamp(), Helper.nnGetUniversalId(notification.getObjectIdRef()).getValue(),
 
 249                 notification.getProblem(), mapSeverity(notification.getSeverity()));
 
 252     /*-----------------------------------------------------------------------------
 
 253      * Reading problems for specific interface pacs
 
 257      * Read problems of specific interfaces
 
 259      * @param uuId Universal Id String of the interface
 
 260      * @return number of alarms
 
 262     private FaultData readTheFaultsOfMwAirInterfacePac(UniversalId interfacePacUuid,
 
 263             FaultData resultList) {
 
 265         final Class<MwAirInterfacePac> clazzPac = MwAirInterfacePac.class;
 
 266         // final Class<MwAirInterfacePacKey> clazzPacKey = MwAirInterfacePacKey.class;
 
 267         // final Class<AirInterfaceCurrentProblems> clazzProblems =
 
 268         // AirInterfaceCurrentProblems.class;
 
 269         // final Class<AirInterfaceCurrentProblemTypeG> clazzProblem =
 
 270         // AirInterfaceCurrentProblemTypeG.class;
 
 272         LOG.info("DBRead Get problems for class {} from mountpoint {} for uuid {}", clazzPac.getSimpleName(),
 
 273                 mountpointId, interfacePacUuid.getValue());
 
 275         // Step 2.2: construct data and the relative iid
 
 276         InstanceIdentifier<AirInterfaceCurrentProblems> mwAirInterfaceIID = InstanceIdentifier
 
 277                 .builder(MwAirInterfacePac.class, new MwAirInterfacePacKey(interfacePacUuid))
 
 278                 .child(AirInterfaceCurrentProblems.class).build();
 
 280         // Step 2.3: read to the config data store
 
 281         AirInterfaceCurrentProblems problems = genericTransactionUtils.readData(acessor.getDataBroker(),
 
 282                 LogicalDatastoreType.OPERATIONAL, mwAirInterfaceIID);
 
 284         if (problems == null) {
 
 285             LOG.debug("DBRead Id {} no AirInterfaceCurrentProblems", interfacePacUuid);
 
 286         } else if (problems.getCurrentProblemList() == null) {
 
 287             LOG.debug("DBRead Id {} empty CurrentProblemList", interfacePacUuid);
 
 289             for (AirInterfaceCurrentProblemTypeG problem : problems.nonnullCurrentProblemList()) {
 
 290                 resultList.add(acessor.getNodeId(), problem.getSequenceNumber(), problem.getTimeStamp(),
 
 291                         interfacePacUuid.getValue(), problem.getProblemName(), mapSeverity(problem.getProblemSeverity()));
 
 298      * Read problems of specific interfaces
 
 300      * @param uuId Universal index of Interfacepac
 
 301      * @return number of alarms
 
 303     private FaultData readTheFaultsOfMwEthernetContainerPac(UniversalId interfacePacUuid,
 
 304             FaultData resultList) {
 
 306         final Class<MwEthernetContainerPac> clazzPac = MwEthernetContainerPac.class;
 
 307         // final Class<MwEthernetContainerPacKey> clazzPacKey =
 
 308         // MwEthernetContainerPacKey.class;
 
 309         // final Class<EthernetContainerCurrentProblems> clazzProblems =
 
 310         // EthernetContainerCurrentProblems.class;
 
 311         // final Class<ContainerCurrentProblemTypeG> clazzProblem =
 
 312         // ContainerCurrentProblemTypeG.class;
 
 314         LOG.info("DBRead Get problems for class {} from mountpoint {} for uuid {}", clazzPac.getSimpleName(),
 
 315                 mountpointId, interfacePacUuid.getValue());
 
 317         InstanceIdentifier<EthernetContainerCurrentProblems> mwEthInterfaceIID = InstanceIdentifier
 
 318                 .builder(MwEthernetContainerPac.class, new MwEthernetContainerPacKey(interfacePacUuid))
 
 319                 .child(EthernetContainerCurrentProblems.class).build();
 
 321         EthernetContainerCurrentProblems problems = genericTransactionUtils.readData(acessor.getDataBroker(),
 
 322                 LogicalDatastoreType.OPERATIONAL, mwEthInterfaceIID);
 
 323         if (problems == null) {
 
 324             LOG.debug("DBRead Id {} no EthernetContainerCurrentProblems", interfacePacUuid);
 
 325         } else if (problems.getCurrentProblemList() == null) {
 
 326             LOG.debug("DBRead Id {} empty CurrentProblemsList", interfacePacUuid);
 
 328             for (ContainerCurrentProblemTypeG problem : problems.nonnullCurrentProblemList()) {
 
 329                 resultList.add(acessor.getNodeId(), problem.getSequenceNumber(), problem.getTimeStamp(),
 
 330                         interfacePacUuid.getValue(), problem.getProblemName(), mapSeverity(problem.getProblemSeverity()));
 
 337      * Read problems of specific interfaces
 
 339      * @param uuId Universal index of Interfacepac
 
 340      * @return number of alarms
 
 342     private FaultData readTheFaultsOfMwAirInterfaceDiversityPac(UniversalId interfacePacUuid,
 
 343             FaultData resultList) {
 
 345         final Class<MwAirInterfaceDiversityPac> clazzPac = MwAirInterfaceDiversityPac.class;
 
 346         // final Class<MwAirInterfaceDiversityPacKey> clazzPacKey =
 
 347         // MwAirInterfaceDiversityPacKey.class;
 
 348         final Class<AirInterfaceDiversityCurrentProblems> clazzProblems = AirInterfaceDiversityCurrentProblems.class;
 
 349         // final Class<AirInterfaceDiversityCurrentProblemTypeG> clazzProblem =
 
 350         // AirInterfaceDiversityCurrentProblemTypeG.class;
 
 352         LOG.info("DBRead Get problems for class {} from mountpoint {} for uuid {}", clazzPac.getSimpleName(),
 
 353                 mountpointId, interfacePacUuid.getValue());
 
 355         InstanceIdentifier<AirInterfaceDiversityCurrentProblems> mwEthInterfaceIID = InstanceIdentifier
 
 356                 .builder(clazzPac, new MwAirInterfaceDiversityPacKey(interfacePacUuid)).child(clazzProblems).build();
 
 358         AirInterfaceDiversityCurrentProblems problems = genericTransactionUtils.readData(acessor.getDataBroker(),
 
 359                 LogicalDatastoreType.OPERATIONAL, mwEthInterfaceIID);
 
 360         if (problems == null) {
 
 361             LOG.debug("DBRead Id {} no AirInterfaceDiversityCurrentProblems", interfacePacUuid);
 
 362         } else if (problems.getCurrentProblemList() == null) {
 
 363             LOG.debug("DBRead Id {} empty CurrentProblemList", interfacePacUuid);
 
 365             for (AirInterfaceDiversityCurrentProblemTypeG problem : problems.nonnullCurrentProblemList()) {
 
 366                 resultList.add(acessor.getNodeId(), problem.getSequenceNumber(), problem.getTimeStamp(),
 
 367                         interfacePacUuid.getValue(), problem.getProblemName(), mapSeverity(problem.getProblemSeverity()));
 
 374      * Read problems of specific interfaces
 
 376      * @param uuId Universal index of Interfacepac
 
 377      * @return number of alarms
 
 379     private FaultData readTheFaultsOfMwPureEthernetStructurePac(UniversalId interfacePacUuid,
 
 380             FaultData resultList) {
 
 382         final Class<MwPureEthernetStructurePac> clazzPac = MwPureEthernetStructurePac.class;
 
 383         // final Class<MwPureEthernetStructurePacKey> clazzPacKey =
 
 384         // MwPureEthernetStructurePacKey.class;
 
 385         final Class<PureEthernetStructureCurrentProblems> clazzProblems = PureEthernetStructureCurrentProblems.class;
 
 386         // final Class<StructureCurrentProblemTypeG> clazzProblem =
 
 387         // StructureCurrentProblemTypeG.class;
 
 389         LOG.info("DBRead Get problems for class {} from mountpoint {} for uuid {}", clazzPac.getSimpleName(),
 
 390                 mountpointId, interfacePacUuid.getValue());
 
 392         InstanceIdentifier<PureEthernetStructureCurrentProblems> mwEthInterfaceIID = InstanceIdentifier
 
 393                 .builder(clazzPac, new MwPureEthernetStructurePacKey(interfacePacUuid)).child(clazzProblems).build();
 
 395         PureEthernetStructureCurrentProblems problems = genericTransactionUtils.readData(acessor.getDataBroker(),
 
 396                 LogicalDatastoreType.OPERATIONAL, mwEthInterfaceIID);
 
 397         if (problems == null) {
 
 398             LOG.debug("DBRead Id {} no PureEthernetStructureCurrentProblems", interfacePacUuid);
 
 399         } else if (problems.getCurrentProblemList() == null) {
 
 400             LOG.debug("DBRead Id {} empty CurrentProblemsList", interfacePacUuid);
 
 402             for (StructureCurrentProblemTypeG problem : problems.nonnullCurrentProblemList()) {
 
 403                 resultList.add(acessor.getNodeId(), problem.getSequenceNumber(), problem.getTimeStamp(),
 
 404                         interfacePacUuid.getValue(), problem.getProblemName(), mapSeverity(problem.getProblemSeverity()));
 
 411      * Read problems of specific interfaces
 
 413      * @param uuId Universal index of Interfacepac
 
 414      * @return number of alarms
 
 416     private FaultData readTheFaultsOfMwHybridMwStructurePac(UniversalId interfacePacUuid,
 
 417             FaultData resultList) {
 
 419         final Class<MwHybridMwStructurePac> clazzPac = MwHybridMwStructurePac.class;
 
 420         // final Class<MwHybridMwStructurePacKey> clazzPacKey =
 
 421         // MwHybridMwStructurePacKey.class;
 
 422         final Class<HybridMwStructureCurrentProblems> clazzProblems = HybridMwStructureCurrentProblems.class;
 
 423         // final Class<HybridMwStructureCurrentProblemsG> clazzProblem =
 
 424         // HybridMwStructureCurrentProblemsG.class;
 
 426         LOG.info("DBRead Get problems for class {} from mountpoint {} for uuid {}", clazzPac.getSimpleName(),
 
 427                 mountpointId, interfacePacUuid.getValue());
 
 429         InstanceIdentifier<HybridMwStructureCurrentProblems> mwEthInterfaceIID = InstanceIdentifier
 
 430                 .builder(clazzPac, new MwHybridMwStructurePacKey(interfacePacUuid)).child(clazzProblems).build();
 
 432         HybridMwStructureCurrentProblems problems = genericTransactionUtils.readData(acessor.getDataBroker(),
 
 433                 LogicalDatastoreType.OPERATIONAL, mwEthInterfaceIID);
 
 434         if (problems == null) {
 
 435             LOG.debug("DBRead Id {} no HybridMwStructureCurrentProblems", interfacePacUuid);
 
 436         } else if (problems.getCurrentProblemList() == null) {
 
 437             LOG.debug("DBRead Id {} empty CurrentProblemsList", interfacePacUuid);
 
 439             for (StructureCurrentProblemTypeG problem : problems.nonnullCurrentProblemList()) {
 
 440                 resultList.add(acessor.getNodeId(), problem.getSequenceNumber(), problem.getTimeStamp(),
 
 441                         interfacePacUuid.getValue(), problem.getProblemName(), mapSeverity(problem.getProblemSeverity()));
 
 448      * Read problems of specific interfaces. TODO Goal for future implementation
 
 449      * without usage of explicit new. Key is generated by newInstance() function
 
 450      * here to verify this approach.
 
 452      * @param uuId Universal index of Interfacepac
 
 453      * @return number of alarms
 
 454      * @throws SecurityException
 
 455      * @throws NoSuchMethodException
 
 456      * @throws InvocationTargetException
 
 457      * @throws IllegalArgumentException
 
 458      * @throws IllegalAccessException
 
 459      * @throws InstantiationException
 
 461     private FaultData readTheFaultsOfMwTdmContainerPac(UniversalId interfacePacUuid,
 
 462             FaultData resultList) {
 
 464         final Class<MwTdmContainerPac> clazzPac = MwTdmContainerPac.class;
 
 465         final Class<MwTdmContainerPacKey> clazzPacKey = MwTdmContainerPacKey.class;
 
 466         final Class<TdmContainerCurrentProblems> clazzProblems = TdmContainerCurrentProblems.class;
 
 467         // final Class<ContainerCurrentProblemTypeG> clazzProblem =
 
 468         // ContainerCurrentProblemTypeG.class;
 
 470         LOG.info("DBRead Get problems for class {} from mountpoint {} for uuid {}", clazzPac.getSimpleName(),
 
 471                 mountpointId, interfacePacUuid.getValue());
 
 474             // -- Specific part 1
 
 475             Constructor<MwTdmContainerPacKey> cons = clazzPacKey.getConstructor(UniversalId.class); // Avoid new()
 
 476             InstanceIdentifier<TdmContainerCurrentProblems> mwEthInterfaceIID = InstanceIdentifier
 
 477                     .builder(clazzPac, cons.newInstance(interfacePacUuid)).child(clazzProblems).build();
 
 479             // -- Specific part 2
 
 480             TdmContainerCurrentProblems problems = genericTransactionUtils.readData(acessor.getDataBroker(),
 
 481                     LogicalDatastoreType.OPERATIONAL, mwEthInterfaceIID);
 
 482             if (problems == null) {
 
 483                 LOG.debug("DBRead Id {} no TdmContainerCurrentProblems", interfacePacUuid);
 
 485                 // -- Specific part 3
 
 486                 for (ContainerCurrentProblemTypeG problem : problems.nonnullCurrentProblemList()) {
 
 487                     resultList.add(acessor.getNodeId(), problem.getSequenceNumber(), problem.getTimeStamp(),
 
 488                             interfacePacUuid.getValue(), problem.getProblemName(), mapSeverity(problem.getProblemSeverity()));
 
 491         } catch (NoSuchMethodException | SecurityException | InstantiationException | IllegalAccessException
 
 492                 | IllegalArgumentException | InvocationTargetException e) {
 
 493             LOG.warn("Could not reade instance of MwTdmContainerPacKey: ", e);
 
 498     /*-----------------------------------------------------------------------------
 
 499      * Performance related data
 
 503      * Read and add performance data
 
 504      * @param lp to read from
 
 505      * @param result Object to be filled with data
 
 508     private @NonNull PerformanceDataLtp readAirInterfacePerformanceData(Lp lp, PerformanceDataLtp result) {
 
 510         LOG.debug("DBRead Get {} MWAirInterfacePac: {}", acessor.getNodeId(), lp.getUuid());
 
 512         UniversalId mwAirInterfacePacuuId = lp.getUuid();
 
 513         // Step 2.1: construct data and the relative iid
 
 514         InstanceIdentifier<AirInterfaceConfiguration> mwAirInterfaceConfigurationIID = InstanceIdentifier
 
 515                 .builder(MwAirInterfacePac.class, new MwAirInterfacePacKey(mwAirInterfacePacuuId))
 
 516                 .child(AirInterfaceConfiguration.class).build();
 
 517         AirInterfaceConfiguration airConfiguration = acessor.getTransactionUtils().readData(acessor.getDataBroker(),
 
 518                 LogicalDatastoreType.OPERATIONAL, mwAirInterfaceConfigurationIID);
 
 520         if (airConfiguration == null) {
 
 521             LOG.debug("DBRead MWAirInterfacePac Id {} no AirInterfaceConfiguration", mwAirInterfacePacuuId);
 
 524             // Step 2.2: construct data and the relative iid
 
 525             InstanceIdentifier<AirInterfaceHistoricalPerformances> mwAirInterfaceHistoricalPerformanceIID = InstanceIdentifier
 
 526                     .builder(MwAirInterfacePac.class, new MwAirInterfacePacKey(mwAirInterfacePacuuId))
 
 527                     .child(AirInterfaceHistoricalPerformances.class).build();
 
 529             // Step 2.3: read to the config data store
 
 530             AirInterfaceHistoricalPerformances airHistoricalPerformanceData = genericTransactionUtils.readData(
 
 531                     acessor.getDataBroker(), LogicalDatastoreType.OPERATIONAL, mwAirInterfaceHistoricalPerformanceIID);
 
 533             if (airHistoricalPerformanceData == null) {
 
 534                 LOG.debug("DBRead MWAirInterfacePac Id {} no AirInterfaceHistoricalPerformances",
 
 535                         mwAirInterfacePacuuId);
 
 537                 // org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170320.air._interface.historical.performances.g.HistoricalPerformanceDataList
 
 538                 List<org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.air._interface.historical.performances.g.HistoricalPerformanceDataList> airHistPMList = airHistoricalPerformanceData
 
 539                         .nonnullHistoricalPerformanceDataList();
 
 540                 LOG.debug("DBRead MWAirInterfacePac Id {} Records intermediate: {}", mwAirInterfacePacuuId,
 
 541                         airHistPMList.size());
 
 542                 for (AirInterfaceHistoricalPerformanceTypeG pmRecord : airHistoricalPerformanceData
 
 543                         .nonnullHistoricalPerformanceDataList()) {
 
 544                     result.add(new PerformanceDataAirInterface181010Builder(acessor.getNodeId(), lp, pmRecord, airConfiguration));
 
 548         LOG.debug("DBRead MWAirInterfacePac Id {} Records result: {}", mwAirInterfacePacuuId, result.size());
 
 552     private @NonNull PerformanceDataLtp readEthernetContainerPerformanceData(Lp lp, PerformanceDataLtp result) {
 
 553         final String myName = "MWEthernetContainerPac";
 
 555         LOG.debug("DBRead Get {} : {}", mountpointId, myName, lp.getUuid());
 
 557         UniversalId ethContainerPacuuId = lp.getUuid();
 
 558         // Step 2.2: construct data and the relative iid
 
 559         InstanceIdentifier<EthernetContainerHistoricalPerformances> ethContainerIID = InstanceIdentifier
 
 560                 .builder(MwEthernetContainerPac.class, new MwEthernetContainerPacKey(ethContainerPacuuId))
 
 561                 .child(EthernetContainerHistoricalPerformances.class).build();
 
 563         // Step 2.3: read to the config data store
 
 564         EthernetContainerHistoricalPerformances ethContainerHistoricalPerformanceData = acessor.getTransactionUtils()
 
 565                 .readData(acessor.getDataBroker(), LogicalDatastoreType.OPERATIONAL, ethContainerIID);
 
 567         if (ethContainerHistoricalPerformanceData == null) {
 
 568             LOG.debug("DBRead {} Id {} no HistoricalPerformances", myName, ethContainerPacuuId);
 
 570             List<org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.ethernet.container.historical.performances.g.HistoricalPerformanceDataList> airHistPMList = ethContainerHistoricalPerformanceData
 
 571                     .nonnullHistoricalPerformanceDataList();
 
 572             LOG.debug("DBRead {} Id {} Records intermediate: {}", myName, ethContainerPacuuId, airHistPMList.size());
 
 573             for (ContainerHistoricalPerformanceTypeG pmRecord : airHistPMList) {
 
 574                 result.add(new PerformanceDataAirInterface181010Builder(acessor.getNodeId(), lp, pmRecord));
 
 577         LOG.debug("DBRead {} Id {} Records result: {}", myName, ethContainerPacuuId, result.size());
 
 581     public static org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.SeverityType mapSeverity( SeverityType severity) {
 
 583         Optional<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.SeverityType> res =
 
 584                 org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.SeverityType.forName(severity.name());
 
 585         return res.orElse(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.SeverityType.NonAlarmed);