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