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