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