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