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