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