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