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