f01f9c83d733c2632cbe3029fd3c2398de6161ea
[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.base.onfcore.wrapperc;
19
20
21
22 import java.lang.reflect.Constructor;
23 import java.lang.reflect.InvocationTargetException;
24 import java.util.ArrayList;
25 import java.util.List;
26
27 import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.NetworkElementCoreData;
28 import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.onfcore.container.ExtendedAirInterfaceHistoricalPerformanceType1211;
29 import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.onfcore.container.ONFLayerProtocolName;
30 import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.util.InternalDateAndTime;
31 import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.util.InternalSeverity;
32 import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.xml.AttributeValueChangedNotificationXml;
33 import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.xml.ObjectCreationNotificationXml;
34 import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.xml.ObjectDeletionNotificationXml;
35 import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.xml.ProblemNotificationXml;
36 import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.INetconfAcessor;
37 import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.TransactionUtils;
38 import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
39 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.UniversalId;
40 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.logical.termination.point.g.Lp;
41 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.g._874._1.model.rev170320.OtnHistoryDataG;
42 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.AirInterfaceCurrentProblemTypeG;
43 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.AirInterfaceDiversityCurrentProblemTypeG;
44 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.AirInterfaceHistoricalPerformanceTypeG;
45 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.AttributeValueChangedNotification;
46 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.ContainerCurrentProblemTypeG;
47 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.ContainerHistoricalPerformanceTypeG;
48 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.MicrowaveModelListener;
49 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.MwAirInterfaceDiversityPac;
50 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.MwAirInterfaceDiversityPacKey;
51 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.MwAirInterfacePac;
52 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.MwAirInterfacePacKey;
53 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.MwEthernetContainerPac;
54 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.MwEthernetContainerPacKey;
55 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.MwHybridMwStructurePac;
56 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.MwHybridMwStructurePacKey;
57 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.MwPureEthernetStructurePac;
58 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.MwPureEthernetStructurePacKey;
59 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.MwTdmContainerPac;
60 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.MwTdmContainerPacKey;
61 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.ObjectCreationNotification;
62 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.ObjectDeletionNotification;
63 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.ProblemNotification;
64 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.StructureCurrentProblemTypeG;
65 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.mw.air._interface.diversity.pac.AirInterfaceDiversityCurrentProblems;
66 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.mw.air._interface.pac.AirInterfaceConfiguration;
67 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.mw.air._interface.pac.AirInterfaceCurrentProblems;
68 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.mw.air._interface.pac.AirInterfaceHistoricalPerformances;
69 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.mw.ethernet.container.pac.EthernetContainerCurrentProblems;
70 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.mw.ethernet.container.pac.EthernetContainerHistoricalPerformances;
71 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.mw.hybrid.mw.structure.pac.HybridMwStructureCurrentProblems;
72 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.mw.pure.ethernet.structure.pac.PureEthernetStructureCurrentProblems;
73 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.mw.tdm.container.pac.TdmContainerCurrentProblems;
74 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
75 import org.opendaylight.yangtools.yang.binding.NotificationListener;
76 import org.opendaylight.yangtools.yang.common.QName;
77 import org.slf4j.Logger;
78 import org.slf4j.LoggerFactory;
79
80
81 public class WrapperMicrowaveModelRev180907 implements OnfMicrowaveModel, MicrowaveModelListener {
82
83     private static final Logger LOG = LoggerFactory.getLogger(WrapperMicrowaveModelRev180907.class);
84
85     public static final QName QNAME = MwAirInterfacePac.QNAME;
86
87
88     private NetworkElementCoreData coreData;
89
90     private OnfMicrowaveModelNotification microwaveModelListener;
91
92     private final TransactionUtils genericTransactionUtil;
93
94
95     /*-----------------------------------------------------------------------------
96      * Setter/Getter
97      */
98
99     /**
100      * @param acessor
101      */
102     public WrapperMicrowaveModelRev180907(INetconfAcessor acessor) {
103         genericTransactionUtil = acessor.getTransactionUtils();
104     }
105
106     @Override
107     public void setCoreData(NetworkElementCoreData coreData) {
108         this.coreData = coreData;
109     }
110
111     public NetworkElementCoreData getCoreData() {
112         return coreData;
113     }
114
115     @Override
116     public void setOnfMicrowaveModelListener(OnfMicrowaveModelNotification microwaveModelListener) {
117         this.microwaveModelListener = microwaveModelListener;
118     }
119
120     @SuppressWarnings("unchecked")
121     @Override
122     public <T extends NotificationListener> T getNotificationListener() {
123         return (T) this;
124     }
125
126     /*-----------------------------------------------------------------------------
127      * Interfacefunctions
128      */
129
130     @Override
131     public void readTheFaultsOfMicrowaveModel(ONFLayerProtocolName lpName, Class<?> lpClass, UniversalId uuid,
132             List<ProblemNotificationXml> 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 List<? extends OtnHistoryDataG> readTheHistoricalPerformanceData(ONFLayerProtocolName lpName, Lp lp) {
172         switch (lpName) {
173         case MWAirInterface:
174             return readTheHistoricalPerformanceDataOfMwAirInterfacePac(lp);
175
176         case EthernetContainer12:
177             return readTheHistoricalPerformanceDataOfEthernetContainer(lp);
178
179         case EthernetContainer10:
180         case EthernetPhysical:
181         case Ethernet:
182         case TDMContainer:
183         case Structure:
184         case Unknown:
185             LOG.debug("Do not read HistoricalPM data for {} {}", lpName, lp.getUuid().getValue());
186             break;
187         }
188         return new ArrayList<>();
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     /*-----------------------------------------------------------------------------
212      * Reading problems for specific interface pacs
213      */
214
215     /**
216      * Read problems of specific interfaces
217      *
218      * @param uuId Universal Id String of the interface
219      * @return number of alarms
220      */
221     private List<ProblemNotificationXml> readTheFaultsOfMwAirInterfacePac(UniversalId interfacePacUuid,
222             List<ProblemNotificationXml> resultList) {
223
224         final Class<MwAirInterfacePac> clazzPac = MwAirInterfacePac.class;
225         // final Class<MwAirInterfacePacKey> clazzPacKey = MwAirInterfacePacKey.class;
226         // final Class<AirInterfaceCurrentProblems> clazzProblems =
227         // AirInterfaceCurrentProblems.class;
228         // final Class<AirInterfaceCurrentProblemTypeG> clazzProblem =
229         // AirInterfaceCurrentProblemTypeG.class;
230
231         LOG.info("DBRead Get problems for class {} from mountpoint {} for uuid {}", clazzPac.getSimpleName(),
232                 coreData.getMountpoint(), interfacePacUuid.getValue());
233
234         // Step 2.2: construct data and the relative iid
235         InstanceIdentifier<AirInterfaceCurrentProblems> mwAirInterfaceIID = InstanceIdentifier
236                 .builder(MwAirInterfacePac.class, new MwAirInterfacePacKey(interfacePacUuid))
237                 .child(AirInterfaceCurrentProblems.class).build();
238
239         // Step 2.3: read to the config data store
240         AirInterfaceCurrentProblems problems = genericTransactionUtil.readData(coreData.getDataBroker(),
241                 LogicalDatastoreType.OPERATIONAL, mwAirInterfaceIID);
242
243         if (problems == null) {
244             LOG.debug("DBRead Id {} no AirInterfaceCurrentProblems", interfacePacUuid);
245         } else if (problems.getCurrentProblemList() == null) {
246             LOG.debug("DBRead Id {} empty CurrentProblemList", interfacePacUuid);
247         } else {
248             for (AirInterfaceCurrentProblemTypeG problem : problems.getCurrentProblemList()) {
249                 resultList.add(new ProblemNotificationXml(coreData.getMountpoint(), interfacePacUuid.getValue(),
250                         problem.getProblemName(), InternalSeverity.valueOf(problem.getProblemSeverity()),
251                         problem.getSequenceNumber(), InternalDateAndTime.valueOf(problem.getTimeStamp())));
252             }
253         }
254         return resultList;
255     }
256
257     /**
258      * Read problems of specific interfaces
259      *
260      * @param uuId Universal index of Interfacepac
261      * @return number of alarms
262      */
263     private List<ProblemNotificationXml> readTheFaultsOfMwEthernetContainerPac(UniversalId interfacePacUuid,
264             List<ProblemNotificationXml> resultList) {
265
266         final Class<MwEthernetContainerPac> clazzPac = MwEthernetContainerPac.class;
267         // final Class<MwEthernetContainerPacKey> clazzPacKey =
268         // MwEthernetContainerPacKey.class;
269         // final Class<EthernetContainerCurrentProblems> clazzProblems =
270         // EthernetContainerCurrentProblems.class;
271         // final Class<ContainerCurrentProblemTypeG> clazzProblem =
272         // ContainerCurrentProblemTypeG.class;
273
274         LOG.info("DBRead Get problems for class {} from mountpoint {} for uuid {}", clazzPac.getSimpleName(),
275                 coreData.getMountpoint(), interfacePacUuid.getValue());
276
277         InstanceIdentifier<EthernetContainerCurrentProblems> mwEthInterfaceIID = InstanceIdentifier
278                 .builder(MwEthernetContainerPac.class, new MwEthernetContainerPacKey(interfacePacUuid))
279                 .child(EthernetContainerCurrentProblems.class).build();
280
281         EthernetContainerCurrentProblems problems = genericTransactionUtil.readData(coreData.getDataBroker(),
282                 LogicalDatastoreType.OPERATIONAL, mwEthInterfaceIID);
283         if (problems == null) {
284             LOG.debug("DBRead Id {} no EthernetContainerCurrentProblems", interfacePacUuid);
285         } else if (problems.getCurrentProblemList() == null) {
286             LOG.debug("DBRead Id {} empty CurrentProblemsList", interfacePacUuid);
287         } else {
288             for (ContainerCurrentProblemTypeG problem : problems.getCurrentProblemList()) {
289                 resultList.add(new ProblemNotificationXml(coreData.getMountpoint(), interfacePacUuid.getValue(),
290                         problem.getProblemName(), InternalSeverity.valueOf(problem.getProblemSeverity()),
291                         problem.getSequenceNumber(), InternalDateAndTime.valueOf(problem.getTimeStamp())));
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 List<ProblemNotificationXml> readTheFaultsOfMwAirInterfaceDiversityPac(UniversalId interfacePacUuid,
304             List<ProblemNotificationXml> resultList) {
305
306         final Class<MwAirInterfaceDiversityPac> clazzPac = MwAirInterfaceDiversityPac.class;
307         // final Class<MwAirInterfaceDiversityPacKey> clazzPacKey =
308         // MwAirInterfaceDiversityPacKey.class;
309         final Class<AirInterfaceDiversityCurrentProblems> clazzProblems = AirInterfaceDiversityCurrentProblems.class;
310         // final Class<AirInterfaceDiversityCurrentProblemTypeG> clazzProblem =
311         // AirInterfaceDiversityCurrentProblemTypeG.class;
312
313         LOG.info("DBRead Get problems for class {} from mountpoint {} for uuid {}", clazzPac.getSimpleName(),
314                 coreData.getMountpoint(), interfacePacUuid.getValue());
315
316         InstanceIdentifier<AirInterfaceDiversityCurrentProblems> mwEthInterfaceIID = InstanceIdentifier
317                 .builder(clazzPac, new MwAirInterfaceDiversityPacKey(interfacePacUuid)).child(clazzProblems).build();
318
319         AirInterfaceDiversityCurrentProblems problems = genericTransactionUtil.readData(coreData.getDataBroker(),
320                 LogicalDatastoreType.OPERATIONAL, mwEthInterfaceIID);
321         if (problems == null) {
322             LOG.debug("DBRead Id {} no AirInterfaceDiversityCurrentProblems", interfacePacUuid);
323         } else if (problems.getCurrentProblemList() == null) {
324             LOG.debug("DBRead Id {} empty CurrentProblemList", interfacePacUuid);
325         } else {
326             for (AirInterfaceDiversityCurrentProblemTypeG problem : problems.getCurrentProblemList()) {
327                 resultList.add(new ProblemNotificationXml(coreData.getMountpoint(), interfacePacUuid.getValue(),
328                         problem.getProblemName(), InternalSeverity.valueOf(problem.getProblemSeverity()),
329                         problem.getSequenceNumber(), InternalDateAndTime.valueOf(problem.getTimeStamp())));
330             }
331         }
332         return resultList;
333     }
334
335     /**
336      * Read problems of specific interfaces
337      *
338      * @param uuId Universal index of Interfacepac
339      * @return number of alarms
340      */
341     private List<ProblemNotificationXml> readTheFaultsOfMwPureEthernetStructurePac(UniversalId interfacePacUuid,
342             List<ProblemNotificationXml> resultList) {
343
344         final Class<MwPureEthernetStructurePac> clazzPac = MwPureEthernetStructurePac.class;
345         // final Class<MwPureEthernetStructurePacKey> clazzPacKey =
346         // MwPureEthernetStructurePacKey.class;
347         final Class<PureEthernetStructureCurrentProblems> clazzProblems = PureEthernetStructureCurrentProblems.class;
348         // final Class<StructureCurrentProblemTypeG> clazzProblem =
349         // StructureCurrentProblemTypeG.class;
350
351         LOG.info("DBRead Get problems for class {} from mountpoint {} for uuid {}", clazzPac.getSimpleName(),
352                 coreData.getMountpoint(), interfacePacUuid.getValue());
353
354         InstanceIdentifier<PureEthernetStructureCurrentProblems> mwEthInterfaceIID = InstanceIdentifier
355                 .builder(clazzPac, new MwPureEthernetStructurePacKey(interfacePacUuid)).child(clazzProblems).build();
356
357         PureEthernetStructureCurrentProblems problems = genericTransactionUtil.readData(coreData.getDataBroker(),
358                 LogicalDatastoreType.OPERATIONAL, mwEthInterfaceIID);
359         if (problems == null) {
360             LOG.debug("DBRead Id {} no PureEthernetStructureCurrentProblems", interfacePacUuid);
361         } else if (problems.getCurrentProblemList() == null) {
362             LOG.debug("DBRead Id {} empty CurrentProblemsList", interfacePacUuid);
363         } else {
364             for (StructureCurrentProblemTypeG problem : problems.getCurrentProblemList()) {
365                 resultList.add(new ProblemNotificationXml(coreData.getMountpoint(), interfacePacUuid.getValue(),
366                         problem.getProblemName(), InternalSeverity.valueOf(problem.getProblemSeverity()),
367                         problem.getSequenceNumber(), InternalDateAndTime.valueOf(problem.getTimeStamp())));
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 List<ProblemNotificationXml> readTheFaultsOfMwHybridMwStructurePac(UniversalId interfacePacUuid,
380             List<ProblemNotificationXml> resultList) {
381
382         final Class<MwHybridMwStructurePac> clazzPac = MwHybridMwStructurePac.class;
383         // final Class<MwHybridMwStructurePacKey> clazzPacKey =
384         // MwHybridMwStructurePacKey.class;
385         final Class<HybridMwStructureCurrentProblems> clazzProblems = HybridMwStructureCurrentProblems.class;
386         // final Class<HybridMwStructureCurrentProblemsG> clazzProblem =
387         // HybridMwStructureCurrentProblemsG.class;
388
389         LOG.info("DBRead Get problems for class {} from mountpoint {} for uuid {}", clazzPac.getSimpleName(),
390                 coreData.getMountpoint(), interfacePacUuid.getValue());
391
392         InstanceIdentifier<HybridMwStructureCurrentProblems> mwEthInterfaceIID = InstanceIdentifier
393                 .builder(clazzPac, new MwHybridMwStructurePacKey(interfacePacUuid)).child(clazzProblems).build();
394
395         HybridMwStructureCurrentProblems problems = genericTransactionUtil.readData(coreData.getDataBroker(),
396                 LogicalDatastoreType.OPERATIONAL, mwEthInterfaceIID);
397         if (problems == null) {
398             LOG.debug("DBRead Id {} no HybridMwStructureCurrentProblems", interfacePacUuid);
399         } else if (problems.getCurrentProblemList() == null) {
400             LOG.debug("DBRead Id {} empty CurrentProblemsList", interfacePacUuid);
401         } else {
402             for (StructureCurrentProblemTypeG problem : problems.getCurrentProblemList()) {
403                 resultList.add(new ProblemNotificationXml(coreData.getMountpoint(), interfacePacUuid.getValue(),
404                         problem.getProblemName(), InternalSeverity.valueOf(problem.getProblemSeverity()),
405                         problem.getSequenceNumber(), InternalDateAndTime.valueOf(problem.getTimeStamp())));
406             }
407         }
408         return resultList;
409     }
410
411     /**
412      * Read problems of specific interfaces. TODO Goal for future implementation
413      * without usage of explicit new. Key is generated by newInstance() function
414      * here to verify this approach.
415      *
416      * @param uuId Universal index of Interfacepac
417      * @return number of alarms
418      * @throws SecurityException
419      * @throws NoSuchMethodException
420      * @throws InvocationTargetException
421      * @throws IllegalArgumentException
422      * @throws IllegalAccessException
423      * @throws InstantiationException
424      */
425     private List<ProblemNotificationXml> readTheFaultsOfMwTdmContainerPac(UniversalId interfacePacUuid,
426             List<ProblemNotificationXml> resultList) {
427
428         final Class<MwTdmContainerPac> clazzPac = MwTdmContainerPac.class;
429         final Class<MwTdmContainerPacKey> clazzPacKey = MwTdmContainerPacKey.class;
430         final Class<TdmContainerCurrentProblems> clazzProblems = TdmContainerCurrentProblems.class;
431         // final Class<ContainerCurrentProblemTypeG> clazzProblem =
432         // ContainerCurrentProblemTypeG.class;
433
434         LOG.info("DBRead Get problems for class {} from mountpoint {} for uuid {}", clazzPac.getSimpleName(),
435                 coreData.getMountpoint(), interfacePacUuid.getValue());
436
437         try {
438             // -- Specific part 1
439             Constructor<MwTdmContainerPacKey> cons = clazzPacKey.getConstructor(UniversalId.class); // Avoid new()
440             InstanceIdentifier<TdmContainerCurrentProblems> mwEthInterfaceIID = InstanceIdentifier
441                     .builder(clazzPac, cons.newInstance(interfacePacUuid)).child(clazzProblems).build();
442
443             // -- Specific part 2
444             TdmContainerCurrentProblems problems = genericTransactionUtil.readData(coreData.getDataBroker(),
445                     LogicalDatastoreType.OPERATIONAL, mwEthInterfaceIID);
446             if (problems == null) {
447                 LOG.debug("DBRead Id {} no TdmContainerCurrentProblems", interfacePacUuid);
448             } else if (problems.getCurrentProblemList() == null) {
449                 LOG.debug("DBRead Id {} empty CurrentProblemsList", interfacePacUuid);
450             } else {
451                 // -- Specific part 3
452                 for (ContainerCurrentProblemTypeG problem : problems.getCurrentProblemList()) {
453                     resultList.add(new ProblemNotificationXml(coreData.getMountpoint(), interfacePacUuid.getValue(),
454                             problem.getProblemName(), InternalSeverity.valueOf(problem.getProblemSeverity()),
455                             problem.getSequenceNumber(),
456                             InternalDateAndTime.valueOf(problem.getTimeStamp())));
457                 }
458             }
459         } catch (NoSuchMethodException | SecurityException | InstantiationException | IllegalAccessException
460                 | IllegalArgumentException | InvocationTargetException e) {
461             LOG.warn("Could not reade instance of MwTdmContainerPacKey: ", e);
462         }
463         return resultList;
464     }
465
466     /*-----------------------------------------------------------------------------
467      * Performance related data
468      */
469
470     /**
471      * PM MwAirInterfacePac
472      *
473      * @param lp
474      * @return
475      */
476     private List<ExtendedAirInterfaceHistoricalPerformanceType1211> readTheHistoricalPerformanceDataOfMwAirInterfacePac(
477             Lp lp) {
478
479         String uuId = lp.getUuid().getValue();
480
481         List<ExtendedAirInterfaceHistoricalPerformanceType1211> resultList = new ArrayList<>();
482         LOG.debug("DBRead Get {} MWAirInterfacePac: {}", coreData.getMountpoint(), uuId);
483         // ----
484         UniversalId mwAirInterfacePacuuId = new UniversalId(uuId);
485         // Step 2.1: construct data and the relative iid
486         InstanceIdentifier<AirInterfaceConfiguration> mwAirInterfaceConfigurationIID = InstanceIdentifier
487                 .builder(MwAirInterfacePac.class, new MwAirInterfacePacKey(mwAirInterfacePacuuId))
488                 .child(AirInterfaceConfiguration.class).build();
489         AirInterfaceConfiguration airConfiguration = genericTransactionUtil.readData(coreData.getDataBroker(),
490                 LogicalDatastoreType.OPERATIONAL, mwAirInterfaceConfigurationIID);
491
492         if (airConfiguration == null) {
493             LOG.debug("DBRead MWAirInterfacePac Id {} no AirInterfaceConfiguration", mwAirInterfacePacuuId);
494
495         } else {
496             // Step 2.2: construct data and the relative iid
497             InstanceIdentifier<AirInterfaceHistoricalPerformances> mwAirInterfaceHistoricalPerformanceIID = InstanceIdentifier
498                     .builder(MwAirInterfacePac.class, new MwAirInterfacePacKey(mwAirInterfacePacuuId))
499                     .child(AirInterfaceHistoricalPerformances.class).build();
500
501             // Step 2.3: read to the config data store
502             AirInterfaceHistoricalPerformances airHistoricalPerformanceData = genericTransactionUtil.readData(
503                     coreData.getDataBroker(), LogicalDatastoreType.OPERATIONAL, mwAirInterfaceHistoricalPerformanceIID);
504
505             if (airHistoricalPerformanceData == null) {
506                 LOG.debug("DBRead MWAirInterfacePac Id {} no AirInterfaceHistoricalPerformances",
507                         mwAirInterfacePacuuId);
508             } else {
509                 // org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170320.air._interface.historical.performances.g.HistoricalPerformanceDataList
510                 List<org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.air._interface.historical.performances.g.HistoricalPerformanceDataList> airHistPMList = airHistoricalPerformanceData
511                         .getHistoricalPerformanceDataList();
512                 LOG.debug("DBRead MWAirInterfacePac Id {} Records intermediate: {}", mwAirInterfacePacuuId,
513                         airHistPMList.size());
514                 if (airHistPMList != null) {
515                     for (AirInterfaceHistoricalPerformanceTypeG pmRecord : airHistoricalPerformanceData
516                             .getHistoricalPerformanceDataList()) {
517                         resultList.add(new ExtendedAirInterfaceHistoricalPerformanceType1211(pmRecord, airConfiguration));
518                     }
519                 }
520             }
521         }
522         LOG.debug("DBRead MWAirInterfacePac Id {} Records result: {}", mwAirInterfacePacuuId, resultList.size());
523         return resultList;
524     }
525
526     private List<ContainerHistoricalPerformanceTypeG> readTheHistoricalPerformanceDataOfEthernetContainer(Lp lp) {
527
528         final String myName = "MWEthernetContainerPac";
529         String uuId = lp.getUuid().getValue();
530
531         List<ContainerHistoricalPerformanceTypeG> resultList = new ArrayList<>();
532         LOG.debug("DBRead Get {} : {}", coreData.getMountpoint(), myName, uuId);
533         // ----
534         UniversalId ethContainerPacuuId = new UniversalId(uuId);
535         // Step 2.2: construct data and the relative iid
536         InstanceIdentifier<EthernetContainerHistoricalPerformances> ethContainerIID = InstanceIdentifier
537                 .builder(MwEthernetContainerPac.class, new MwEthernetContainerPacKey(ethContainerPacuuId))
538                 .child(EthernetContainerHistoricalPerformances.class).build();
539
540         // Step 2.3: read to the config data store
541         EthernetContainerHistoricalPerformances ethContainerHistoricalPerformanceData = genericTransactionUtil
542                 .readData(coreData.getDataBroker(), LogicalDatastoreType.OPERATIONAL, ethContainerIID);
543
544         if (ethContainerHistoricalPerformanceData == null) {
545             LOG.debug("DBRead {} Id {} no HistoricalPerformances", myName, ethContainerPacuuId);
546         } else {
547             // import
548             // org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170320.ethernet.container.historical.performances.g.HistoricalPerformanceDataList
549              List<org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.ethernet.container.historical.performances.g.HistoricalPerformanceDataList> airHistPMList = ethContainerHistoricalPerformanceData
550                     .getHistoricalPerformanceDataList();
551             LOG.debug("DBRead {} Id {} Records intermediate: {}", myName, ethContainerPacuuId, airHistPMList.size());
552             if (airHistPMList != null) {
553                 for (ContainerHistoricalPerformanceTypeG pmRecord : airHistPMList) {
554                     resultList.add(pmRecord);
555                 }
556             }
557         }
558         LOG.debug("DBRead {} Id {} Records result: {}", myName, ethContainerPacuuId, resultList.size());
559         return resultList;
560     }
561
562     @Override
563     public void onObjectCreationNotification(ObjectCreationNotification notification) {
564         LOG.debug("Got event of type :: {}", ObjectCreationNotification.class.getSimpleName());
565
566         ObjectCreationNotificationXml notificationXml = new ObjectCreationNotificationXml(coreData.getMountpoint(),
567                 notification.getCounter(),
568                 InternalDateAndTime.valueOf(notification.getTimeStamp()),
569                 notification.getObjectIdRef().getValue());
570         microwaveModelListener.onObjectCreationNotification(notificationXml);
571     }
572
573     @Override
574     public void onObjectDeletionNotification(ObjectDeletionNotification notification) {
575         LOG.debug("Got event of type :: {}", ObjectDeletionNotification.class.getSimpleName());
576
577         ObjectDeletionNotificationXml notificationXml = new ObjectDeletionNotificationXml(coreData.getMountpoint(),
578                 notification.getCounter(),
579                 InternalDateAndTime.valueOf(notification.getTimeStamp()),
580                 notification.getObjectIdRef().getValue()
581                 );
582         microwaveModelListener.onObjectDeletionNotification(notificationXml);
583     }
584
585     @Override
586     public void onProblemNotification(ProblemNotification notification) {
587
588         LOG.debug("Got event of type :: {}", ProblemNotification.class.getSimpleName());
589
590         ProblemNotificationXml notificationXml = new ProblemNotificationXml(coreData.getMountpoint(), notification.getObjectIdRef().getValue(),
591                 notification.getProblem(), InternalSeverity.valueOf(notification.getSeverity()),
592                 notification.getCounter(), InternalDateAndTime.valueOf(notification.getTimeStamp()));
593
594         microwaveModelListener.onProblemNotification(notificationXml);
595     }
596
597     @Override
598     public void onAttributeValueChangedNotification(AttributeValueChangedNotification notification) {
599         LOG.debug("Got event of type :: {}", AttributeValueChangedNotification.class.getSimpleName());
600
601         AttributeValueChangedNotificationXml notificationXml = new AttributeValueChangedNotificationXml(coreData.getMountpoint(),
602                 notification.getCounter(), InternalDateAndTime.valueOf(notification.getTimeStamp()),
603                 notification.getObjectIdRef().getValue(), notification.getAttributeName(), notification.getNewValue());
604
605         microwaveModelListener.onAttributeValueChangedNotification(notificationXml);
606     }
607
608 }