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