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