891aa3d6d6c71ca04fd1068814edfed1c663673d
[ccsdk/features.git] / sdnr / wt / devicemanager-onf / provider / src / main / java / org / onap / ccsdk / features / sdnr / wt / devicemanager / onf / ifpac / microwave / WrapperMicrowaveModelRev170324.java
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
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
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
15  * the License.
16  * ============LICENSE_END==========================================================================
17  */
18 package org.onap.ccsdk.features.sdnr.wt.devicemanager.onf.ifpac.microwave;
19
20
21
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.PerformanceDataAirInterface170324Builder;
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.rev170324.AirInterfaceCurrentProblemTypeG;
41 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.AirInterfaceDiversityCurrentProblemTypeG;
42 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.AirInterfaceHistoricalPerformanceTypeG;
43 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.AttributeValueChangedNotification;
44 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.ContainerCurrentProblemTypeG;
45 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.ContainerHistoricalPerformanceTypeG;
46 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.MicrowaveModelListener;
47 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.MwAirInterfaceDiversityPac;
48 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.MwAirInterfaceDiversityPacKey;
49 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.MwAirInterfacePac;
50 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.MwAirInterfacePacKey;
51 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.MwEthernetContainerPac;
52 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.MwEthernetContainerPacKey;
53 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.MwHybridMwStructurePac;
54 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.MwHybridMwStructurePacKey;
55 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.MwPureEthernetStructurePac;
56 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.MwPureEthernetStructurePacKey;
57 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.MwTdmContainerPac;
58 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.MwTdmContainerPacKey;
59 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.ObjectCreationNotification;
60 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.ObjectDeletionNotification;
61 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.ProblemNotification;
62 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.SeverityType;
63 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.StructureCurrentProblemTypeG;
64 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.mw.air._interface.diversity.pac.AirInterfaceDiversityCurrentProblems;
65 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.mw.air._interface.pac.AirInterfaceConfiguration;
66 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.mw.air._interface.pac.AirInterfaceCurrentProblems;
67 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.mw.air._interface.pac.AirInterfaceHistoricalPerformances;
68 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.mw.ethernet.container.pac.EthernetContainerCurrentProblems;
69 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.mw.ethernet.container.pac.EthernetContainerHistoricalPerformances;
70 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.mw.hybrid.mw.structure.pac.HybridMwStructureCurrentProblems;
71 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.mw.pure.ethernet.structure.pac.PureEthernetStructureCurrentProblems;
72 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.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;
80
81
82 public class WrapperMicrowaveModelRev170324 implements OnfMicrowaveModel, MicrowaveModelListener {
83
84     private static final Logger LOG = LoggerFactory.getLogger(WrapperMicrowaveModelRev170324.class);
85
86     public static final QName QNAME = MwAirInterfacePac.QNAME;
87
88
89     private final NotificationService microwaveModelListener;
90     private final NetconfAccessor acessor;
91     private final TransactionUtils genericTransactionUtils;
92     private final FaultService faultService;
93
94     private Optional<NotificationWorker<EventlogEntity>> notificationQueue;
95
96     /**
97      * @param acessor to access device
98      */
99     public WrapperMicrowaveModelRev170324(@NonNull NetconfAccessor acessor,
100             @NonNull DeviceManagerServiceProvider serviceProvider) {
101         this.acessor = acessor;
102         this.genericTransactionUtils = acessor.getTransactionUtils();
103         this.microwaveModelListener = serviceProvider.getNotificationService();
104         this.faultService = serviceProvider.getFaultService();
105         this.notificationQueue = Optional.empty();
106     }
107
108     /*-----------------------------------------------------------------------------
109      * Setter/Getter
110      */
111
112     @SuppressWarnings("unchecked")
113     @Override
114     public <T extends NotificationListener> T getNotificationListener() {
115         return (T) this;
116     }
117
118     @Override
119     public void setNotificationQueue(NotificationWorker<EventlogEntity> notificationQueue) {
120         this.notificationQueue = Optional.of(notificationQueue);
121     }
122
123     /*-----------------------------------------------------------------------------
124      * Interface functions
125      */
126
127     @Override
128     public void readTheFaultsOfMicrowaveModel(ONFLayerProtocolName lpName, Class<?> lpClass, UniversalId uuid,
129             FaultData resultList) {
130
131         switch (lpName) {
132             case MWAIRINTERFACE:
133                 readTheFaultsOfMwAirInterfacePac(uuid, resultList);
134                 break;
135
136             case ETHERNETCONTAINER12:
137                 readTheFaultsOfMwEthernetContainerPac(uuid, resultList);
138                 break;
139
140             case TDMCONTAINER:
141                 readTheFaultsOfMwTdmContainerPac(uuid, resultList);
142                 break;
143
144             case STRUCTURE:
145                 if (lpClass == MwHybridMwStructurePac.class) {
146                     readTheFaultsOfMwHybridMwStructurePac(uuid, resultList);
147
148                 } else if (lpClass == MwAirInterfaceDiversityPac.class) {
149                     readTheFaultsOfMwAirInterfaceDiversityPac(uuid, resultList);
150
151                 } else if (lpClass == MwPureEthernetStructurePac.class) {
152                     readTheFaultsOfMwPureEthernetStructurePac(uuid, resultList);
153
154                 } else {
155                     LOG.warn("Unassigned lp model {} class {}", lpName, lpClass);
156                 }
157                 break;
158             case ETHERNET:
159                 // No alarms supported
160                 break;
161             case ETHERNETCONTAINER10:
162             default:
163                 LOG.warn("Unassigned or not expected lp in model {}", lpName);
164         }
165     }
166
167     @Override
168     public @NonNull PerformanceDataLtp getLtpHistoricalPerformanceData(@NonNull ONFLayerProtocolName lpName,
169             @NonNull Lp lp) {
170         PerformanceDataLtp res = new PerformanceDataLtp();
171         readAirInterfacePerformanceData(lp, res);
172         readEthernetContainerPerformanceData(lp, res);
173         return res;
174     }
175
176
177     @Override
178     public Class<?> getClassForLtpExtension(QName qName) {
179         Class<?> res = null;
180         if (qName.equals(MwAirInterfacePac.QNAME)) {
181             res = MwAirInterfacePac.class;
182         } else if (qName.equals(MwAirInterfaceDiversityPac.QNAME)) {
183             res = MwAirInterfaceDiversityPac.class;
184         } else if (qName.equals(MwPureEthernetStructurePac.QNAME)) {
185             res = MwPureEthernetStructurePac.class;
186         } else if (qName.equals(MwHybridMwStructurePac.QNAME)) {
187             res = MwHybridMwStructurePac.class;
188         } else if (qName.equals(MwEthernetContainerPac.QNAME)) {
189             res = MwEthernetContainerPac.class;
190         } else if (qName.equals(MwTdmContainerPac.QNAME)) {
191             res = MwTdmContainerPac.class;
192         }
193         LOG.info("Found QName {} mapped to {}", String.valueOf(qName), String.valueOf(res));
194         return res;
195     }
196
197     @Override
198     public void onObjectCreationNotification(ObjectCreationNotification notification) {
199         LOG.debug("Got event of type :: {}", ObjectCreationNotification.class.getSimpleName());
200         if (notification != null) {
201             microwaveModelListener.creationNotification(acessor.getNodeId(), notification.getCounter(),
202                     notification.getTimeStamp(), Helper.nnGetUniversalId(notification.getObjectIdRef()).getValue());
203         }
204     }
205
206     @Override
207     public void onObjectDeletionNotification(ObjectDeletionNotification notification) {
208         LOG.debug("Got event of type :: {}", ObjectDeletionNotification.class.getSimpleName());
209         if (notification != null) {
210             microwaveModelListener.deletionNotification(acessor.getNodeId(), notification.getCounter(),
211                     notification.getTimeStamp(), Helper.nnGetUniversalId(notification.getObjectIdRef()).getValue());
212         }
213     }
214
215     @Override
216     public void onAttributeValueChangedNotification(AttributeValueChangedNotification notification) {
217         LOG.debug("Got event of type :: {}", AttributeValueChangedNotification.class.getSimpleName());
218         EventlogEntity beventlogEntity = new EventlogBuilder().setNodeId(acessor.getNodeId().getValue())
219                 .setCounter(notification.getCounter()).setTimestamp(notification.getTimeStamp())
220                 .setObjectId(Helper.nnGetUniversalId(notification.getObjectIdRef()).getValue())
221                 .setAttributeName(notification.getAttributeName()).setNewValue(notification.getNewValue()).build();
222         microwaveModelListener.eventNotification(beventlogEntity);
223         if (notificationQueue.isPresent()) {
224             notificationQueue.get().put(beventlogEntity);
225         }
226     }
227
228     @Override
229     public void onProblemNotification(ProblemNotification notification) {
230
231         LOG.debug("Got event of type :: {}", ProblemNotification.class.getSimpleName());
232
233         faultService.faultNotification(acessor.getNodeId(), notification.getCounter(), notification.getTimeStamp(),
234                 Helper.nnGetUniversalId(notification.getObjectIdRef()).getValue(), notification.getProblem(),
235                 mapSeverity(notification.getSeverity()));
236     }
237
238     /*-----------------------------------------------------------------------------
239      * Reading problems for specific interface pacs
240      */
241
242     /**
243      * Read problems of specific interfaces
244      *
245      * @param uuId Universal Id String of the interface
246      * @return number of alarms
247      */
248     private FaultData readTheFaultsOfMwAirInterfacePac(UniversalId interfacePacUuid, FaultData resultList) {
249
250         final Class<MwAirInterfacePac> clazzPac = MwAirInterfacePac.class;
251
252         String mountpointId = acessor.getNodeId().getValue();
253         LOG.info("DBRead Get problems for class {} from mountpoint {} for uuid {}", clazzPac.getSimpleName(),
254                 mountpointId, interfacePacUuid.getValue());
255
256         // Step 2.2: construct data and the relative iid
257         InstanceIdentifier<AirInterfaceCurrentProblems> mwAirInterfaceIID =
258                 InstanceIdentifier.builder(MwAirInterfacePac.class, new MwAirInterfacePacKey(interfacePacUuid))
259                         .child(AirInterfaceCurrentProblems.class).build();
260
261         // Step 2.3: read to the config data store
262         AirInterfaceCurrentProblems problems = genericTransactionUtils.readData(acessor.getDataBroker(),
263                 LogicalDatastoreType.OPERATIONAL, mwAirInterfaceIID);
264
265         if (problems == null) {
266             LOG.debug("DBRead Id {} no AirInterfaceCurrentProblems", interfacePacUuid);
267         } else {
268             for (AirInterfaceCurrentProblemTypeG problem : problems.nonnullCurrentProblemList()) {
269                 resultList.add(acessor.getNodeId(), problem.getSequenceNumber(), problem.getTimeStamp(),
270                         interfacePacUuid.getValue(), problem.getProblemName(),
271                         mapSeverity(problem.getProblemSeverity()));
272             }
273         }
274         return resultList;
275     }
276
277
278     /**
279      * Read problems of specific interfaces
280      *
281      * @param uuId Universal index of Interfacepac
282      * @return number of alarms
283      */
284     private FaultData readTheFaultsOfMwEthernetContainerPac(UniversalId interfacePacUuid, FaultData resultList) {
285
286         final Class<MwEthernetContainerPac> clazzPac = MwEthernetContainerPac.class;
287
288         String mountpointId = acessor.getNodeId().getValue();
289         LOG.info("DBRead Get problems for class {} from mountpoint {} for uuid {}", clazzPac.getSimpleName(),
290                 mountpointId, interfacePacUuid.getValue());
291
292         InstanceIdentifier<EthernetContainerCurrentProblems> mwEthInterfaceIID = InstanceIdentifier
293                 .builder(MwEthernetContainerPac.class, new MwEthernetContainerPacKey(interfacePacUuid))
294                 .child(EthernetContainerCurrentProblems.class).build();
295
296         EthernetContainerCurrentProblems problems = genericTransactionUtils.readData(acessor.getDataBroker(),
297                 LogicalDatastoreType.OPERATIONAL, mwEthInterfaceIID);
298         if (problems == null) {
299             LOG.debug("DBRead Id {} no EthernetContainerCurrentProblems", interfacePacUuid);
300         } else {
301             for (ContainerCurrentProblemTypeG problem : problems.nonnullCurrentProblemList()) {
302                 resultList.add(acessor.getNodeId(), problem.getSequenceNumber(), problem.getTimeStamp(),
303                         interfacePacUuid.getValue(), problem.getProblemName(),
304                         mapSeverity(problem.getProblemSeverity()));
305             }
306         }
307         return resultList;
308     }
309
310     /**
311      * Read problems of specific interfaces
312      *
313      * @param uuId Universal index of Interfacepac
314      * @return number of alarms
315      */
316     private FaultData readTheFaultsOfMwAirInterfaceDiversityPac(UniversalId interfacePacUuid, FaultData resultList) {
317
318         final Class<MwAirInterfaceDiversityPac> clazzPac = MwAirInterfaceDiversityPac.class;
319         final Class<AirInterfaceDiversityCurrentProblems> clazzProblems = AirInterfaceDiversityCurrentProblems.class;
320
321         String mountpointId = acessor.getNodeId().getValue();
322         LOG.info("DBRead Get problems for class {} from mountpoint {} for uuid {}", clazzPac.getSimpleName(),
323                 mountpointId, interfacePacUuid.getValue());
324
325         InstanceIdentifier<AirInterfaceDiversityCurrentProblems> mwEthInterfaceIID = InstanceIdentifier
326                 .builder(clazzPac, new MwAirInterfaceDiversityPacKey(interfacePacUuid)).child(clazzProblems).build();
327
328         AirInterfaceDiversityCurrentProblems problems = genericTransactionUtils.readData(acessor.getDataBroker(),
329                 LogicalDatastoreType.OPERATIONAL, mwEthInterfaceIID);
330         if (problems == null) {
331             LOG.debug("DBRead Id {} no AirInterfaceDiversityCurrentProblems", interfacePacUuid);
332         } else {
333             for (AirInterfaceDiversityCurrentProblemTypeG problem : problems.nonnullCurrentProblemList()) {
334                 resultList.add(acessor.getNodeId(), problem.getSequenceNumber(), problem.getTimeStamp(),
335                         interfacePacUuid.getValue(), problem.getProblemName(),
336                         mapSeverity(problem.getProblemSeverity()));
337             }
338         }
339         return resultList;
340     }
341
342     /**
343      * Read problems of specific interfaces
344      *
345      * @param uuId Universal index of Interfacepac
346      * @return number of alarms
347      */
348     private FaultData readTheFaultsOfMwPureEthernetStructurePac(UniversalId interfacePacUuid, FaultData resultList) {
349
350         final Class<MwPureEthernetStructurePac> clazzPac = MwPureEthernetStructurePac.class;
351         final Class<PureEthernetStructureCurrentProblems> clazzProblems = PureEthernetStructureCurrentProblems.class;
352
353         String mountpointId = acessor.getNodeId().getValue();
354         LOG.info("DBRead Get problems for class {} from mountpoint {} for uuid {}", clazzPac.getSimpleName(),
355                 mountpointId, interfacePacUuid.getValue());
356
357         InstanceIdentifier<PureEthernetStructureCurrentProblems> mwEthInterfaceIID = InstanceIdentifier
358                 .builder(clazzPac, new MwPureEthernetStructurePacKey(interfacePacUuid)).child(clazzProblems).build();
359
360         PureEthernetStructureCurrentProblems problems = genericTransactionUtils.readData(acessor.getDataBroker(),
361                 LogicalDatastoreType.OPERATIONAL, mwEthInterfaceIID);
362         if (problems == null) {
363             LOG.debug("DBRead Id {} no PureEthernetStructureCurrentProblems", interfacePacUuid);
364         } else {
365             for (StructureCurrentProblemTypeG problem : problems.nonnullCurrentProblemList()) {
366                 resultList.add(acessor.getNodeId(), problem.getSequenceNumber(), problem.getTimeStamp(),
367                         interfacePacUuid.getValue(), problem.getProblemName(),
368                         mapSeverity(problem.getProblemSeverity()));
369             }
370         }
371         return resultList;
372     }
373
374     /**
375      * Read problems of specific interfaces
376      *
377      * @param uuId Universal index of Interfacepac
378      * @return number of alarms
379      */
380     private FaultData readTheFaultsOfMwHybridMwStructurePac(UniversalId interfacePacUuid, FaultData resultList) {
381
382         final Class<MwHybridMwStructurePac> clazzPac = MwHybridMwStructurePac.class;
383         final Class<HybridMwStructureCurrentProblems> clazzProblems = HybridMwStructureCurrentProblems.class;
384
385         String mountpointId = acessor.getNodeId().getValue();
386         LOG.info("DBRead Get problems for class {} from mountpoint {} for uuid {}", clazzPac.getSimpleName(),
387                 mountpointId, interfacePacUuid.getValue());
388
389         InstanceIdentifier<HybridMwStructureCurrentProblems> mwEthInterfaceIID = InstanceIdentifier
390                 .builder(clazzPac, new MwHybridMwStructurePacKey(interfacePacUuid)).child(clazzProblems).build();
391
392         HybridMwStructureCurrentProblems problems = genericTransactionUtils.readData(acessor.getDataBroker(),
393                 LogicalDatastoreType.OPERATIONAL, mwEthInterfaceIID);
394         if (problems == null) {
395             LOG.debug("DBRead Id {} no HybridMwStructureCurrentProblems", interfacePacUuid);
396         } else {
397             for (StructureCurrentProblemTypeG problem : problems.nonnullCurrentProblemList()) {
398                 resultList.add(acessor.getNodeId(), problem.getSequenceNumber(), problem.getTimeStamp(),
399                         interfacePacUuid.getValue(), problem.getProblemName(),
400                         mapSeverity(problem.getProblemSeverity()));
401             }
402         }
403         return resultList;
404     }
405
406     /**
407      * Read problems of specific interfaces. TODO Goal for future implementation without usage of explicit new. Key is
408      * generated by newInstance() function here to verify this approach.
409      *
410      * @param uuId Universal index of Interfacepac
411      * @return number of alarms
412      * @throws SecurityException
413      * @throws NoSuchMethodException
414      * @throws InvocationTargetException
415      * @throws IllegalArgumentException
416      * @throws IllegalAccessException
417      * @throws InstantiationException
418      */
419     private FaultData readTheFaultsOfMwTdmContainerPac(UniversalId interfacePacUuid, FaultData resultList) {
420
421         final Class<MwTdmContainerPac> clazzPac = MwTdmContainerPac.class;
422         final Class<MwTdmContainerPacKey> clazzPacKey = MwTdmContainerPacKey.class;
423         final Class<TdmContainerCurrentProblems> clazzProblems = TdmContainerCurrentProblems.class;
424
425         String mountpointId = acessor.getNodeId().getValue();
426         LOG.info("DBRead Get problems for class {} from mountpoint {} for uuid {}", clazzPac.getSimpleName(),
427                 mountpointId, interfacePacUuid.getValue());
428
429         try {
430             // -- Specific part 1
431             Constructor<MwTdmContainerPacKey> cons = clazzPacKey.getConstructor(UniversalId.class); // Avoid new()
432             InstanceIdentifier<TdmContainerCurrentProblems> mwEthInterfaceIID = InstanceIdentifier
433                     .builder(clazzPac, cons.newInstance(interfacePacUuid)).child(clazzProblems).build();
434
435             // -- Specific part 2
436             TdmContainerCurrentProblems problems = genericTransactionUtils.readData(acessor.getDataBroker(),
437                     LogicalDatastoreType.OPERATIONAL, mwEthInterfaceIID);
438             if (problems == null) {
439                 LOG.debug("DBRead Id {} no TdmContainerCurrentProblems", interfacePacUuid);
440             } else {
441                 // -- Specific part 3
442                 for (ContainerCurrentProblemTypeG problem : problems.nonnullCurrentProblemList()) {
443                     resultList.add(acessor.getNodeId(), problem.getSequenceNumber(), problem.getTimeStamp(),
444                             interfacePacUuid.getValue(), problem.getProblemName(),
445                             mapSeverity(problem.getProblemSeverity()));
446                 }
447             }
448         } catch (NoSuchMethodException | SecurityException | InstantiationException | IllegalAccessException
449                 | IllegalArgumentException | InvocationTargetException e) {
450             LOG.warn("Could not reade instance of MwTdmContainerPacKey: ", e);
451         }
452         return resultList;
453     }
454
455     /**
456      * Read and add performance data
457      * 
458      * @param lp to read from
459      * @param result Object to be filled with data
460      * @return result
461      */
462     private @NonNull PerformanceDataLtp readAirInterfacePerformanceData(Lp lp, PerformanceDataLtp result) {
463
464         LOG.debug("DBRead Get {} MWAirInterfacePac: {}", acessor.getNodeId(), lp.getUuid());
465         // ----
466         UniversalId mwAirInterfacePacuuId = lp.getUuid();
467         // Step 2.1: construct data and the relative iid
468         InstanceIdentifier<AirInterfaceConfiguration> mwAirInterfaceConfigurationIID =
469                 InstanceIdentifier.builder(MwAirInterfacePac.class, new MwAirInterfacePacKey(mwAirInterfacePacuuId))
470                         .child(AirInterfaceConfiguration.class).build();
471         AirInterfaceConfiguration airConfiguration = acessor.getTransactionUtils().readData(acessor.getDataBroker(),
472                 LogicalDatastoreType.OPERATIONAL, mwAirInterfaceConfigurationIID);
473
474         if (airConfiguration == null) {
475             LOG.debug("DBRead MWAirInterfacePac Id {} no AirInterfaceConfiguration", mwAirInterfacePacuuId);
476
477         } else {
478             // Step 2.2: construct data and the relative iid
479             InstanceIdentifier<AirInterfaceHistoricalPerformances> mwAirInterfaceHistoricalPerformanceIID =
480                     InstanceIdentifier.builder(MwAirInterfacePac.class, new MwAirInterfacePacKey(mwAirInterfacePacuuId))
481                             .child(AirInterfaceHistoricalPerformances.class).build();
482
483             // Step 2.3: read to the config data store
484             AirInterfaceHistoricalPerformances airHistoricalPerformanceData = genericTransactionUtils.readData(
485                     acessor.getDataBroker(), LogicalDatastoreType.OPERATIONAL, mwAirInterfaceHistoricalPerformanceIID);
486
487             if (airHistoricalPerformanceData == null) {
488                 LOG.debug("DBRead MWAirInterfacePac Id {} no AirInterfaceHistoricalPerformances",
489                         mwAirInterfacePacuuId);
490             } else {
491                 // org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170320.air._interface.historical.performances.g.HistoricalPerformanceDataList
492                 List<org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.air._interface.historical.performances.g.HistoricalPerformanceDataList> airHistPMList =
493                         airHistoricalPerformanceData.nonnullHistoricalPerformanceDataList();
494                 LOG.debug("DBRead MWAirInterfacePac Id {} Records intermediate: {}", mwAirInterfacePacuuId,
495                         airHistPMList.size());
496                 for (AirInterfaceHistoricalPerformanceTypeG pmRecord : airHistoricalPerformanceData
497                         .nonnullHistoricalPerformanceDataList()) {
498                     result.add(new PerformanceDataAirInterface170324Builder(acessor.getNodeId(), lp, pmRecord,
499                             airConfiguration));
500                 }
501             }
502         }
503         LOG.debug("DBRead MWAirInterfacePac Id {} Records result: {}", mwAirInterfacePacuuId, result.size());
504         return result;
505     }
506
507
508     private @NonNull PerformanceDataLtp readEthernetContainerPerformanceData(Lp lp, PerformanceDataLtp result) {
509         final String myName = "MWEthernetContainerPac";
510
511         String mountpointId = acessor.getNodeId().getValue();
512
513         LOG.debug("DBRead Get {} : {}", mountpointId, myName, lp.getUuid());
514         // ----
515         UniversalId ethContainerPacuuId = lp.getUuid();
516         // Step 2.2: construct data and the relative iid
517         InstanceIdentifier<EthernetContainerHistoricalPerformances> ethContainerIID = InstanceIdentifier
518                 .builder(MwEthernetContainerPac.class, new MwEthernetContainerPacKey(ethContainerPacuuId))
519                 .child(EthernetContainerHistoricalPerformances.class).build();
520
521         // Step 2.3: read to the config data store
522         EthernetContainerHistoricalPerformances ethContainerHistoricalPerformanceData = acessor.getTransactionUtils()
523                 .readData(acessor.getDataBroker(), LogicalDatastoreType.OPERATIONAL, ethContainerIID);
524
525         if (ethContainerHistoricalPerformanceData == null) {
526             LOG.debug("DBRead {} Id {} no HistoricalPerformances", myName, ethContainerPacuuId);
527         } else {
528             List<org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.ethernet.container.historical.performances.g.HistoricalPerformanceDataList> airHistPMList =
529                     ethContainerHistoricalPerformanceData.nonnullHistoricalPerformanceDataList();
530             LOG.debug("DBRead {} Id {} Records intermediate: {}", myName, ethContainerPacuuId, airHistPMList.size());
531             for (ContainerHistoricalPerformanceTypeG pmRecord : airHistPMList) {
532                 result.add(new PerformanceDataAirInterface170324Builder(acessor.getNodeId(), lp, pmRecord));
533             }
534         }
535         LOG.debug("DBRead {} Id {} Records result: {}", myName, ethContainerPacuuId, result.size());
536         return result;
537     }
538
539     private org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.SeverityType mapSeverity(
540             SeverityType severity) {
541
542         Optional<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.SeverityType> res =
543                 org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.SeverityType
544                         .forName(severity.name());
545         return res.orElse(
546                 org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.SeverityType.NonAlarmed);
547     }
548
549 }