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