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