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