f0f5bf117753f96dcbba1a4aa466616a98420e14
[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.PerformanceDataAirInterface181010Builder;
28 import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf.notifications.NotificationWorker;
29 import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf.util.ONFLayerProtocolName;
30 import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.DeviceManagerServiceProvider;
31 import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.FaultService;
32 import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.NotificationService;
33 import org.onap.ccsdk.features.sdnr.wt.devicemanager.types.FaultData;
34 import org.onap.ccsdk.features.sdnr.wt.devicemanager.types.PerformanceDataLtp;
35 import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfAccessor;
36 import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.TransactionUtils;
37 import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
38 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.UniversalId;
39 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.logical.termination.point.g.Lp;
40 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.SeverityType;
41 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.AirInterfaceCurrentProblemTypeG;
42 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.AirInterfaceDiversityCurrentProblemTypeG;
43 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.AirInterfaceHistoricalPerformanceTypeG;
44 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.AttributeValueChangedNotification;
45 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.ContainerCurrentProblemTypeG;
46 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.ContainerHistoricalPerformanceTypeG;
47 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.MicrowaveModelListener;
48 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.MwAirInterfaceDiversityPac;
49 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.MwAirInterfaceDiversityPacKey;
50 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.MwAirInterfacePac;
51 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.MwAirInterfacePacKey;
52 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.MwEthernetContainerPac;
53 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.MwEthernetContainerPacKey;
54 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.MwHybridMwStructurePac;
55 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.MwHybridMwStructurePacKey;
56 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.MwPureEthernetStructurePac;
57 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.MwPureEthernetStructurePacKey;
58 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.MwTdmContainerPac;
59 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.MwTdmContainerPacKey;
60 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.ObjectCreationNotification;
61 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.ObjectDeletionNotification;
62 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.ProblemNotification;
63 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.StructureCurrentProblemTypeG;
64 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.mw.air._interface.diversity.pac.AirInterfaceDiversityCurrentProblems;
65 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.mw.air._interface.pac.AirInterfaceConfiguration;
66 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.mw.air._interface.pac.AirInterfaceCurrentProblems;
67 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.mw.air._interface.pac.AirInterfaceHistoricalPerformances;
68 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.mw.ethernet.container.pac.EthernetContainerCurrentProblems;
69 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.mw.ethernet.container.pac.EthernetContainerHistoricalPerformances;
70 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.mw.hybrid.mw.structure.pac.HybridMwStructureCurrentProblems;
71 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.mw.pure.ethernet.structure.pac.PureEthernetStructureCurrentProblems;
72 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.mw.tdm.container.pac.TdmContainerCurrentProblems;
73 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.EventlogBuilder;
74 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.EventlogEntity;
75 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
76 import org.opendaylight.yangtools.yang.binding.NotificationListener;
77 import org.opendaylight.yangtools.yang.common.QName;
78 import org.slf4j.Logger;
79 import org.slf4j.LoggerFactory;
80
81
82 public class WrapperMicrowaveModelRev181010 implements OnfMicrowaveModel, MicrowaveModelListener {
83
84     private static final Logger LOG = LoggerFactory.getLogger(WrapperMicrowaveModelRev181010.class);
85
86     public static final QName QNAME = MwAirInterfacePac.QNAME;
87
88
89     private final NetconfAccessor acessor;
90     private final NotificationService microwaveModelListener;
91     private final TransactionUtils genericTransactionUtils;
92     private final String mountpointId;
93     private final @NonNull FaultService faultService;
94
95     private Optional<NotificationWorker<EventlogEntity>> notificationQueue;
96
97     /**
98      * Handle specific version of microwave model
99      * 
100      * @param acessor to access device
101      * @param serviceProvider for devicemanager services
102      */
103     public WrapperMicrowaveModelRev181010(@NonNull NetconfAccessor acessor,
104             @NonNull DeviceManagerServiceProvider serviceProvider) {
105         this.acessor = acessor;
106         this.genericTransactionUtils = acessor.getTransactionUtils();
107         this.mountpointId = acessor.getNodeId().getValue();
108         this.microwaveModelListener = serviceProvider.getNotificationService();
109         this.faultService = serviceProvider.getFaultService();
110         this.notificationQueue = Optional.empty();
111     }
112
113     /*-----------------------------------------------------------------------------
114      * Setter/Getter
115      */
116
117     @SuppressWarnings("unchecked")
118     @Override
119     public <T extends NotificationListener> T getNotificationListener() {
120         return (T) this;
121     }
122
123     @Override
124     public void setNotificationQueue(NotificationWorker<EventlogEntity> notificationQueue) {
125         this.notificationQueue = Optional.of(notificationQueue);
126     }
127
128     /*-----------------------------------------------------------------------------
129      * Interfacefunctions
130      */
131
132     @Override
133     public void readTheFaultsOfMicrowaveModel(ONFLayerProtocolName lpName, Class<?> lpClass, UniversalId uuid,
134             FaultData resultList) {
135
136         switch (lpName) {
137             case MWAIRINTERFACE:
138                 readTheFaultsOfMwAirInterfacePac(uuid, resultList);
139                 break;
140
141             case ETHERNETCONTAINER12:
142                 readTheFaultsOfMwEthernetContainerPac(uuid, resultList);
143                 break;
144
145             case TDMCONTAINER:
146                 readTheFaultsOfMwTdmContainerPac(uuid, resultList);
147                 break;
148
149             case STRUCTURE:
150                 if (lpClass == MwHybridMwStructurePac.class) {
151                     readTheFaultsOfMwHybridMwStructurePac(uuid, resultList);
152
153                 } else if (lpClass == MwAirInterfaceDiversityPac.class) {
154                     readTheFaultsOfMwAirInterfaceDiversityPac(uuid, resultList);
155
156                 } else if (lpClass == MwPureEthernetStructurePac.class) {
157                     readTheFaultsOfMwPureEthernetStructurePac(uuid, resultList);
158
159                 } else {
160                     LOG.warn("Unassigned lp model {} class {}", lpName, lpClass);
161                 }
162                 break;
163             case ETHERNET:
164                 // No alarms supported
165                 break;
166             case ETHERNETCONTAINER10:
167             default:
168                 LOG.warn("Unassigned or not expected lp in model {}", lpName);
169         }
170     }
171
172     @Override
173     public @NonNull PerformanceDataLtp getLtpHistoricalPerformanceData(@NonNull ONFLayerProtocolName lpName,
174             @NonNull Lp lp) {
175         PerformanceDataLtp res = new PerformanceDataLtp();
176         switch (lpName) {
177             case MWAIRINTERFACE:
178                 return readAirInterfacePerformanceData(lp, res);
179
180             case ETHERNETCONTAINER12:
181                 return readEthernetContainerPerformanceData(lp, res);
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,
190                         Helper.nnGetUniversalId(lp.getUuid()).getValue());
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(), notification.getTimeStamp(),
252                 Helper.nnGetUniversalId(notification.getObjectIdRef()).getValue(), notification.getProblem(),
253                 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, FaultData resultList) {
267
268         final Class<MwAirInterfacePac> clazzPac = MwAirInterfacePac.class;
269
270         LOG.info("DBRead Get problems for class {} from mountpoint {} for uuid {}", clazzPac.getSimpleName(),
271                 mountpointId, interfacePacUuid.getValue());
272
273         // Step 2.2: construct data and the relative iid
274         InstanceIdentifier<AirInterfaceCurrentProblems> mwAirInterfaceIID =
275                 InstanceIdentifier.builder(MwAirInterfacePac.class, new MwAirInterfacePacKey(interfacePacUuid))
276                         .child(AirInterfaceCurrentProblems.class).build();
277
278         // Step 2.3: read to the config data store
279         AirInterfaceCurrentProblems problems = genericTransactionUtils.readData(acessor.getDataBroker(),
280                 LogicalDatastoreType.OPERATIONAL, mwAirInterfaceIID);
281
282         if (problems == null) {
283             LOG.debug("DBRead Id {} no AirInterfaceCurrentProblems", interfacePacUuid);
284         } else if (problems.getCurrentProblemList() == null) {
285             LOG.debug("DBRead Id {} empty CurrentProblemList", interfacePacUuid);
286         } else {
287             for (AirInterfaceCurrentProblemTypeG problem : problems.nonnullCurrentProblemList()) {
288                 resultList.add(acessor.getNodeId(), problem.getSequenceNumber(), problem.getTimeStamp(),
289                         interfacePacUuid.getValue(), problem.getProblemName(),
290                         mapSeverity(problem.getProblemSeverity()));
291             }
292         }
293         return resultList;
294     }
295
296     /**
297      * Read problems of specific interfaces
298      *
299      * @param uuId Universal index of Interfacepac
300      * @return number of alarms
301      */
302     private FaultData readTheFaultsOfMwEthernetContainerPac(UniversalId interfacePacUuid, FaultData resultList) {
303
304         final Class<MwEthernetContainerPac> clazzPac = MwEthernetContainerPac.class;
305
306         LOG.info("DBRead Get problems for class {} from mountpoint {} for uuid {}", clazzPac.getSimpleName(),
307                 mountpointId, interfacePacUuid.getValue());
308
309         InstanceIdentifier<EthernetContainerCurrentProblems> mwEthInterfaceIID = InstanceIdentifier
310                 .builder(MwEthernetContainerPac.class, new MwEthernetContainerPacKey(interfacePacUuid))
311                 .child(EthernetContainerCurrentProblems.class).build();
312
313         EthernetContainerCurrentProblems problems = genericTransactionUtils.readData(acessor.getDataBroker(),
314                 LogicalDatastoreType.OPERATIONAL, mwEthInterfaceIID);
315         if (problems == null) {
316             LOG.debug("DBRead Id {} no EthernetContainerCurrentProblems", interfacePacUuid);
317         } else if (problems.getCurrentProblemList() == null) {
318             LOG.debug("DBRead Id {} empty CurrentProblemsList", 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 = genericTransactionUtils.readData(acessor.getDataBroker(),
347                 LogicalDatastoreType.OPERATIONAL, mwEthInterfaceIID);
348         if (problems == null) {
349             LOG.debug("DBRead Id {} no AirInterfaceDiversityCurrentProblems", interfacePacUuid);
350         } else if (problems.getCurrentProblemList() == null) {
351             LOG.debug("DBRead Id {} empty CurrentProblemList", interfacePacUuid);
352         } else {
353             for (AirInterfaceDiversityCurrentProblemTypeG problem : problems.nonnullCurrentProblemList()) {
354                 resultList.add(acessor.getNodeId(), problem.getSequenceNumber(), problem.getTimeStamp(),
355                         interfacePacUuid.getValue(), problem.getProblemName(),
356                         mapSeverity(problem.getProblemSeverity()));
357             }
358         }
359         return resultList;
360     }
361
362     /**
363      * Read problems of specific interfaces
364      *
365      * @param uuId Universal index of Interfacepac
366      * @return number of alarms
367      */
368     private FaultData readTheFaultsOfMwPureEthernetStructurePac(UniversalId interfacePacUuid, FaultData resultList) {
369
370         final Class<MwPureEthernetStructurePac> clazzPac = MwPureEthernetStructurePac.class;
371         final Class<PureEthernetStructureCurrentProblems> clazzProblems = PureEthernetStructureCurrentProblems.class;
372
373         LOG.info("DBRead Get problems for class {} from mountpoint {} for uuid {}", clazzPac.getSimpleName(),
374                 mountpointId, interfacePacUuid.getValue());
375
376         InstanceIdentifier<PureEthernetStructureCurrentProblems> mwEthInterfaceIID = InstanceIdentifier
377                 .builder(clazzPac, new MwPureEthernetStructurePacKey(interfacePacUuid)).child(clazzProblems).build();
378
379         PureEthernetStructureCurrentProblems problems = genericTransactionUtils.readData(acessor.getDataBroker(),
380                 LogicalDatastoreType.OPERATIONAL, mwEthInterfaceIID);
381         if (problems == null) {
382             LOG.debug("DBRead Id {} no PureEthernetStructureCurrentProblems", interfacePacUuid);
383         } else if (problems.getCurrentProblemList() == null) {
384             LOG.debug("DBRead Id {} empty CurrentProblemsList", interfacePacUuid);
385         } else {
386             for (StructureCurrentProblemTypeG problem : problems.nonnullCurrentProblemList()) {
387                 resultList.add(acessor.getNodeId(), problem.getSequenceNumber(), problem.getTimeStamp(),
388                         interfacePacUuid.getValue(), problem.getProblemName(),
389                         mapSeverity(problem.getProblemSeverity()));
390             }
391         }
392         return resultList;
393     }
394
395     /**
396      * Read problems of specific interfaces
397      *
398      * @param uuId Universal index of Interfacepac
399      * @return number of alarms
400      */
401     private FaultData readTheFaultsOfMwHybridMwStructurePac(UniversalId interfacePacUuid, FaultData resultList) {
402
403         final Class<MwHybridMwStructurePac> clazzPac = MwHybridMwStructurePac.class;
404         final Class<HybridMwStructureCurrentProblems> clazzProblems = HybridMwStructureCurrentProblems.class;
405
406         LOG.info("DBRead Get problems for class {} from mountpoint {} for uuid {}", clazzPac.getSimpleName(),
407                 mountpointId, interfacePacUuid.getValue());
408
409         InstanceIdentifier<HybridMwStructureCurrentProblems> mwEthInterfaceIID = InstanceIdentifier
410                 .builder(clazzPac, new MwHybridMwStructurePacKey(interfacePacUuid)).child(clazzProblems).build();
411
412         HybridMwStructureCurrentProblems problems = genericTransactionUtils.readData(acessor.getDataBroker(),
413                 LogicalDatastoreType.OPERATIONAL, mwEthInterfaceIID);
414         if (problems == null) {
415             LOG.debug("DBRead Id {} no HybridMwStructureCurrentProblems", interfacePacUuid);
416         } else if (problems.getCurrentProblemList() == null) {
417             LOG.debug("DBRead Id {} empty CurrentProblemsList", interfacePacUuid);
418         } else {
419             for (StructureCurrentProblemTypeG problem : problems.nonnullCurrentProblemList()) {
420                 resultList.add(acessor.getNodeId(), problem.getSequenceNumber(), problem.getTimeStamp(),
421                         interfacePacUuid.getValue(), problem.getProblemName(),
422                         mapSeverity(problem.getProblemSeverity()));
423             }
424         }
425         return resultList;
426     }
427
428     /**
429      * Read problems of specific interfaces. TODO Goal for future implementation without usage of explicit new. Key is
430      * generated by newInstance() function here to verify this approach.
431      *
432      * @param uuId Universal index of Interfacepac
433      * @return number of alarms
434      * @throws SecurityException
435      * @throws NoSuchMethodException
436      * @throws InvocationTargetException
437      * @throws IllegalArgumentException
438      * @throws IllegalAccessException
439      * @throws InstantiationException
440      */
441     private FaultData readTheFaultsOfMwTdmContainerPac(UniversalId interfacePacUuid, FaultData resultList) {
442
443         final Class<MwTdmContainerPac> clazzPac = MwTdmContainerPac.class;
444         final Class<MwTdmContainerPacKey> clazzPacKey = MwTdmContainerPacKey.class;
445         final Class<TdmContainerCurrentProblems> clazzProblems = TdmContainerCurrentProblems.class;
446
447         LOG.info("DBRead Get problems for class {} from mountpoint {} for uuid {}", clazzPac.getSimpleName(),
448                 mountpointId, interfacePacUuid.getValue());
449
450         try {
451             // -- Specific part 1
452             Constructor<MwTdmContainerPacKey> cons = clazzPacKey.getConstructor(UniversalId.class); // Avoid new()
453             InstanceIdentifier<TdmContainerCurrentProblems> mwEthInterfaceIID = InstanceIdentifier
454                     .builder(clazzPac, cons.newInstance(interfacePacUuid)).child(clazzProblems).build();
455
456             // -- Specific part 2
457             TdmContainerCurrentProblems problems = genericTransactionUtils.readData(acessor.getDataBroker(),
458                     LogicalDatastoreType.OPERATIONAL, mwEthInterfaceIID);
459             if (problems == null) {
460                 LOG.debug("DBRead Id {} no TdmContainerCurrentProblems", interfacePacUuid);
461             } else {
462                 // -- Specific part 3
463                 for (ContainerCurrentProblemTypeG problem : problems.nonnullCurrentProblemList()) {
464                     resultList.add(acessor.getNodeId(), problem.getSequenceNumber(), problem.getTimeStamp(),
465                             interfacePacUuid.getValue(), problem.getProblemName(),
466                             mapSeverity(problem.getProblemSeverity()));
467                 }
468             }
469         } catch (NoSuchMethodException | SecurityException | InstantiationException | IllegalAccessException
470                 | IllegalArgumentException | InvocationTargetException e) {
471             LOG.warn("Could not reade instance of MwTdmContainerPacKey: ", e);
472         }
473         return resultList;
474     }
475
476     /*-----------------------------------------------------------------------------
477      * Performance related data
478      */
479
480     /**
481      * Read and add performance data
482      * 
483      * @param lp to read from
484      * @param result Object to be filled with data
485      * @return result
486      */
487     private @NonNull PerformanceDataLtp readAirInterfacePerformanceData(Lp lp, PerformanceDataLtp result) {
488
489         LOG.debug("DBRead Get {} MWAirInterfacePac: {}", acessor.getNodeId(), lp.getUuid());
490         // ----
491         UniversalId mwAirInterfacePacuuId = lp.getUuid();
492         // Step 2.1: construct data and the relative iid
493         InstanceIdentifier<AirInterfaceConfiguration> mwAirInterfaceConfigurationIID =
494                 InstanceIdentifier.builder(MwAirInterfacePac.class, new MwAirInterfacePacKey(mwAirInterfacePacuuId))
495                         .child(AirInterfaceConfiguration.class).build();
496         AirInterfaceConfiguration airConfiguration = acessor.getTransactionUtils().readData(acessor.getDataBroker(),
497                 LogicalDatastoreType.OPERATIONAL, mwAirInterfaceConfigurationIID);
498
499         if (airConfiguration == null) {
500             LOG.debug("DBRead MWAirInterfacePac Id {} no AirInterfaceConfiguration", mwAirInterfacePacuuId);
501
502         } else {
503             // Step 2.2: construct data and the relative iid
504             InstanceIdentifier<AirInterfaceHistoricalPerformances> mwAirInterfaceHistoricalPerformanceIID =
505                     InstanceIdentifier.builder(MwAirInterfacePac.class, new MwAirInterfacePacKey(mwAirInterfacePacuuId))
506                             .child(AirInterfaceHistoricalPerformances.class).build();
507
508             // Step 2.3: read to the config data store
509             AirInterfaceHistoricalPerformances airHistoricalPerformanceData = genericTransactionUtils.readData(
510                     acessor.getDataBroker(), LogicalDatastoreType.OPERATIONAL, mwAirInterfaceHistoricalPerformanceIID);
511
512             if (airHistoricalPerformanceData == null) {
513                 LOG.debug("DBRead MWAirInterfacePac Id {} no AirInterfaceHistoricalPerformances",
514                         mwAirInterfacePacuuId);
515             } else {
516                 // org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170320.air._interface.historical.performances.g.HistoricalPerformanceDataList
517                 List<org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.air._interface.historical.performances.g.HistoricalPerformanceDataList> airHistPMList =
518                         airHistoricalPerformanceData.nonnullHistoricalPerformanceDataList();
519                 LOG.debug("DBRead MWAirInterfacePac Id {} Records intermediate: {}", mwAirInterfacePacuuId,
520                         airHistPMList.size());
521                 for (AirInterfaceHistoricalPerformanceTypeG pmRecord : airHistoricalPerformanceData
522                         .nonnullHistoricalPerformanceDataList()) {
523                     result.add(new PerformanceDataAirInterface181010Builder(acessor.getNodeId(), lp, pmRecord,
524                             airConfiguration));
525                 }
526             }
527         }
528         LOG.debug("DBRead MWAirInterfacePac Id {} Records result: {}", mwAirInterfacePacuuId, result.size());
529         return result;
530     }
531
532     private @NonNull PerformanceDataLtp readEthernetContainerPerformanceData(Lp lp, PerformanceDataLtp result) {
533         final String myName = "MWEthernetContainerPac";
534
535         LOG.debug("DBRead Get {} : {}", mountpointId, myName, lp.getUuid());
536         // ----
537         UniversalId ethContainerPacuuId = lp.getUuid();
538         // Step 2.2: construct data and the relative iid
539         InstanceIdentifier<EthernetContainerHistoricalPerformances> ethContainerIID = InstanceIdentifier
540                 .builder(MwEthernetContainerPac.class, new MwEthernetContainerPacKey(ethContainerPacuuId))
541                 .child(EthernetContainerHistoricalPerformances.class).build();
542
543         // Step 2.3: read to the config data store
544         EthernetContainerHistoricalPerformances ethContainerHistoricalPerformanceData = acessor.getTransactionUtils()
545                 .readData(acessor.getDataBroker(), LogicalDatastoreType.OPERATIONAL, ethContainerIID);
546
547         if (ethContainerHistoricalPerformanceData == null) {
548             LOG.debug("DBRead {} Id {} no HistoricalPerformances", myName, ethContainerPacuuId);
549         } else {
550             List<org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.ethernet.container.historical.performances.g.HistoricalPerformanceDataList> airHistPMList =
551                     ethContainerHistoricalPerformanceData.nonnullHistoricalPerformanceDataList();
552             LOG.debug("DBRead {} Id {} Records intermediate: {}", myName, ethContainerPacuuId, airHistPMList.size());
553             for (ContainerHistoricalPerformanceTypeG pmRecord : airHistPMList) {
554                 result.add(new PerformanceDataAirInterface181010Builder(acessor.getNodeId(), lp, pmRecord));
555             }
556         }
557         LOG.debug("DBRead {} Id {} Records result: {}", myName, ethContainerPacuuId, result.size());
558         return result;
559     }
560
561     public static org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.SeverityType mapSeverity(
562             SeverityType severity) {
563
564         Optional<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.SeverityType> res =
565                 org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.SeverityType
566                         .forName(severity.name());
567         return res.orElse(
568                 org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.SeverityType.NonAlarmed);
569     }
570
571
572
573 }