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